babylon.module.d.ts 6.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707
  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. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. 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>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @returns a file request object
  1453. */
  1454. 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;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. 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;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. import { WebRequest } from "babylonjs/Misc/webRequest";
  1476. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1477. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1478. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1479. /** @hidden */
  1480. export class ShaderProcessor {
  1481. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1482. private static _ProcessPrecision;
  1483. private static _ExtractOperation;
  1484. private static _BuildSubExpression;
  1485. private static _BuildExpression;
  1486. private static _MoveCursorWithinIf;
  1487. private static _MoveCursor;
  1488. private static _EvaluatePreProcessors;
  1489. private static _PreparePreProcessors;
  1490. private static _ProcessShaderConversion;
  1491. private static _ProcessIncludes;
  1492. /**
  1493. * Loads a file from a url
  1494. * @param url url to load
  1495. * @param onSuccess callback called when the file successfully loads
  1496. * @param onProgress callback called while file is loading (if the server supports this mode)
  1497. * @param offlineProvider defines the offline provider for caching
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @returns a file request object
  1501. * @hidden
  1502. */
  1503. 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;
  1504. }
  1505. }
  1506. declare module "babylonjs/Maths/math.like" {
  1507. import { float, int, DeepImmutable } from "babylonjs/types";
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IColor4Like {
  1512. r: float;
  1513. g: float;
  1514. b: float;
  1515. a: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IColor3Like {
  1521. r: float;
  1522. g: float;
  1523. b: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IVector4Like {
  1529. x: float;
  1530. y: float;
  1531. z: float;
  1532. w: float;
  1533. }
  1534. /**
  1535. * @hidden
  1536. */
  1537. export interface IVector3Like {
  1538. x: float;
  1539. y: float;
  1540. z: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IVector2Like {
  1546. x: float;
  1547. y: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IMatrixLike {
  1553. toArray(): DeepImmutable<Float32Array>;
  1554. updateFlag: int;
  1555. }
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IViewportLike {
  1560. x: float;
  1561. y: float;
  1562. width: float;
  1563. height: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IPlaneLike {
  1569. normal: IVector3Like;
  1570. d: float;
  1571. normalize(): void;
  1572. }
  1573. }
  1574. declare module "babylonjs/Materials/iEffectFallbacks" {
  1575. import { Effect } from "babylonjs/Materials/effect";
  1576. /**
  1577. * Interface used to define common properties for effect fallbacks
  1578. */
  1579. export interface IEffectFallbacks {
  1580. /**
  1581. * Removes the defines that should be removed when falling back.
  1582. * @param currentDefines defines the current define statements for the shader.
  1583. * @param effect defines the current effect we try to compile
  1584. * @returns The resulting defines with defines of the current rank removed.
  1585. */
  1586. reduce(currentDefines: string, effect: Effect): string;
  1587. /**
  1588. * Removes the fallback from the bound mesh.
  1589. */
  1590. unBindMesh(): void;
  1591. /**
  1592. * Checks to see if more fallbacks are still availible.
  1593. */
  1594. hasMoreFallbacks: boolean;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1598. /**
  1599. * Class used to evalaute queries containing `and` and `or` operators
  1600. */
  1601. export class AndOrNotEvaluator {
  1602. /**
  1603. * Evaluate a query
  1604. * @param query defines the query to evaluate
  1605. * @param evaluateCallback defines the callback used to filter result
  1606. * @returns true if the query matches
  1607. */
  1608. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1609. private static _HandleParenthesisContent;
  1610. private static _SimplifyNegation;
  1611. }
  1612. }
  1613. declare module "babylonjs/Misc/tags" {
  1614. /**
  1615. * Class used to store custom tags
  1616. */
  1617. export class Tags {
  1618. /**
  1619. * Adds support for tags on the given object
  1620. * @param obj defines the object to use
  1621. */
  1622. static EnableFor(obj: any): void;
  1623. /**
  1624. * Removes tags support
  1625. * @param obj defines the object to use
  1626. */
  1627. static DisableFor(obj: any): void;
  1628. /**
  1629. * Gets a boolean indicating if the given object has tags
  1630. * @param obj defines the object to use
  1631. * @returns a boolean
  1632. */
  1633. static HasTags(obj: any): boolean;
  1634. /**
  1635. * Gets the tags available on a given object
  1636. * @param obj defines the object to use
  1637. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1638. * @returns the tags
  1639. */
  1640. static GetTags(obj: any, asString?: boolean): any;
  1641. /**
  1642. * Adds tags to an object
  1643. * @param obj defines the object to use
  1644. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1645. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1646. */
  1647. static AddTagsTo(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _AddTagTo(obj: any, tag: string): void;
  1652. /**
  1653. * Removes specific tags from a specific object
  1654. * @param obj defines the object to use
  1655. * @param tagsString defines the tags to remove
  1656. */
  1657. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1658. /**
  1659. * @hidden
  1660. */
  1661. static _RemoveTagFrom(obj: any, tag: string): void;
  1662. /**
  1663. * Defines if tags hosted on an object match a given query
  1664. * @param obj defines the object to use
  1665. * @param tagsQuery defines the tag query
  1666. * @returns a boolean
  1667. */
  1668. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1669. }
  1670. }
  1671. declare module "babylonjs/Maths/math.scalar" {
  1672. /**
  1673. * Scalar computation library
  1674. */
  1675. export class Scalar {
  1676. /**
  1677. * Two pi constants convenient for computation.
  1678. */
  1679. static TwoPi: number;
  1680. /**
  1681. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1682. * @param a number
  1683. * @param b number
  1684. * @param epsilon (default = 1.401298E-45)
  1685. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1686. */
  1687. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1688. /**
  1689. * Returns a string : the upper case translation of the number i to hexadecimal.
  1690. * @param i number
  1691. * @returns the upper case translation of the number i to hexadecimal.
  1692. */
  1693. static ToHex(i: number): string;
  1694. /**
  1695. * Returns -1 if value is negative and +1 is value is positive.
  1696. * @param value the value
  1697. * @returns the value itself if it's equal to zero.
  1698. */
  1699. static Sign(value: number): number;
  1700. /**
  1701. * Returns the value itself if it's between min and max.
  1702. * Returns min if the value is lower than min.
  1703. * Returns max if the value is greater than max.
  1704. * @param value the value to clmap
  1705. * @param min the min value to clamp to (default: 0)
  1706. * @param max the max value to clamp to (default: 1)
  1707. * @returns the clamped value
  1708. */
  1709. static Clamp(value: number, min?: number, max?: number): number;
  1710. /**
  1711. * the log2 of value.
  1712. * @param value the value to compute log2 of
  1713. * @returns the log2 of value.
  1714. */
  1715. static Log2(value: number): number;
  1716. /**
  1717. * Loops the value, so that it is never larger than length and never smaller than 0.
  1718. *
  1719. * This is similar to the modulo operator but it works with floating point numbers.
  1720. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1721. * With t = 5 and length = 2.5, the result would be 0.0.
  1722. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1723. * @param value the value
  1724. * @param length the length
  1725. * @returns the looped value
  1726. */
  1727. static Repeat(value: number, length: number): number;
  1728. /**
  1729. * Normalize the value between 0.0 and 1.0 using min and max values
  1730. * @param value value to normalize
  1731. * @param min max to normalize between
  1732. * @param max min to normalize between
  1733. * @returns the normalized value
  1734. */
  1735. static Normalize(value: number, min: number, max: number): number;
  1736. /**
  1737. * Denormalize the value from 0.0 and 1.0 using min and max values
  1738. * @param normalized value to denormalize
  1739. * @param min max to denormalize between
  1740. * @param max min to denormalize between
  1741. * @returns the denormalized value
  1742. */
  1743. static Denormalize(normalized: number, min: number, max: number): number;
  1744. /**
  1745. * Calculates the shortest difference between two given angles given in degrees.
  1746. * @param current current angle in degrees
  1747. * @param target target angle in degrees
  1748. * @returns the delta
  1749. */
  1750. static DeltaAngle(current: number, target: number): number;
  1751. /**
  1752. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1753. * @param tx value
  1754. * @param length length
  1755. * @returns The returned value will move back and forth between 0 and length
  1756. */
  1757. static PingPong(tx: number, length: number): number;
  1758. /**
  1759. * Interpolates between min and max with smoothing at the limits.
  1760. *
  1761. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1762. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1763. * @param from from
  1764. * @param to to
  1765. * @param tx value
  1766. * @returns the smooth stepped value
  1767. */
  1768. static SmoothStep(from: number, to: number, tx: number): number;
  1769. /**
  1770. * Moves a value current towards target.
  1771. *
  1772. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1773. * Negative values of maxDelta pushes the value away from target.
  1774. * @param current current value
  1775. * @param target target value
  1776. * @param maxDelta max distance to move
  1777. * @returns resulting value
  1778. */
  1779. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1780. /**
  1781. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. *
  1783. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1784. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1785. * @param current current value
  1786. * @param target target value
  1787. * @param maxDelta max distance to move
  1788. * @returns resulting angle
  1789. */
  1790. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1791. /**
  1792. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1793. * @param start start value
  1794. * @param end target value
  1795. * @param amount amount to lerp between
  1796. * @returns the lerped value
  1797. */
  1798. static Lerp(start: number, end: number, amount: number): number;
  1799. /**
  1800. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1801. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1802. * @param start start value
  1803. * @param end target value
  1804. * @param amount amount to lerp between
  1805. * @returns the lerped value
  1806. */
  1807. static LerpAngle(start: number, end: number, amount: number): number;
  1808. /**
  1809. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1810. * @param a start value
  1811. * @param b target value
  1812. * @param value value between a and b
  1813. * @returns the inverseLerp value
  1814. */
  1815. static InverseLerp(a: number, b: number, value: number): number;
  1816. /**
  1817. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1818. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1819. * @param value1 spline value
  1820. * @param tangent1 spline value
  1821. * @param value2 spline value
  1822. * @param tangent2 spline value
  1823. * @param amount input value
  1824. * @returns hermite result
  1825. */
  1826. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1827. /**
  1828. * Returns a random float number between and min and max values
  1829. * @param min min value of random
  1830. * @param max max value of random
  1831. * @returns random value
  1832. */
  1833. static RandomRange(min: number, max: number): number;
  1834. /**
  1835. * This function returns percentage of a number in a given range.
  1836. *
  1837. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1838. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1839. * @param number to convert to percentage
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the percentage
  1843. */
  1844. static RangeToPercent(number: number, min: number, max: number): number;
  1845. /**
  1846. * This function returns number that corresponds to the percentage in a given range.
  1847. *
  1848. * PercentToRange(0.34,0,100) will return 34.
  1849. * @param percent to convert to number
  1850. * @param min min range
  1851. * @param max max range
  1852. * @returns the number
  1853. */
  1854. static PercentToRange(percent: number, min: number, max: number): number;
  1855. /**
  1856. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1857. * @param angle The angle to normalize in radian.
  1858. * @return The converted angle.
  1859. */
  1860. static NormalizeRadians(angle: number): number;
  1861. }
  1862. }
  1863. declare module "babylonjs/Maths/math.constants" {
  1864. /**
  1865. * Constant used to convert a value to gamma space
  1866. * @ignorenaming
  1867. */
  1868. export const ToGammaSpace: number;
  1869. /**
  1870. * Constant used to convert a value to linear space
  1871. * @ignorenaming
  1872. */
  1873. export const ToLinearSpace = 2.2;
  1874. /**
  1875. * Constant used to define the minimal number value in Babylon.js
  1876. * @ignorenaming
  1877. */
  1878. let Epsilon: number;
  1879. export { Epsilon };
  1880. }
  1881. declare module "babylonjs/Maths/math.viewport" {
  1882. /**
  1883. * Class used to represent a viewport on screen
  1884. */
  1885. export class Viewport {
  1886. /** viewport left coordinate */
  1887. x: number;
  1888. /** viewport top coordinate */
  1889. y: number;
  1890. /**viewport width */
  1891. width: number;
  1892. /** viewport height */
  1893. height: number;
  1894. /**
  1895. * Creates a Viewport object located at (x, y) and sized (width, height)
  1896. * @param x defines viewport left coordinate
  1897. * @param y defines viewport top coordinate
  1898. * @param width defines the viewport width
  1899. * @param height defines the viewport height
  1900. */
  1901. constructor(
  1902. /** viewport left coordinate */
  1903. x: number,
  1904. /** viewport top coordinate */
  1905. y: number,
  1906. /**viewport width */
  1907. width: number,
  1908. /** viewport height */
  1909. height: number);
  1910. /**
  1911. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1912. * @param renderWidth defines the rendering width
  1913. * @param renderHeight defines the rendering height
  1914. * @returns a new Viewport
  1915. */
  1916. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1917. /**
  1918. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1919. * @param renderWidth defines the rendering width
  1920. * @param renderHeight defines the rendering height
  1921. * @param ref defines the target viewport
  1922. * @returns the current viewport
  1923. */
  1924. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1925. /**
  1926. * Returns a new Viewport copied from the current one
  1927. * @returns a new Viewport
  1928. */
  1929. clone(): Viewport;
  1930. }
  1931. }
  1932. declare module "babylonjs/Misc/arrayTools" {
  1933. /**
  1934. * Class containing a set of static utilities functions for arrays.
  1935. */
  1936. export class ArrayTools {
  1937. /**
  1938. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1939. * @param size the number of element to construct and put in the array
  1940. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1941. * @returns a new array filled with new objects
  1942. */
  1943. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1944. }
  1945. }
  1946. declare module "babylonjs/Maths/math.vector" {
  1947. import { Viewport } from "babylonjs/Maths/math.viewport";
  1948. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1949. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1950. /**
  1951. * Class representing a vector containing 2 coordinates
  1952. */
  1953. export class Vector2 {
  1954. /** defines the first coordinate */
  1955. x: number;
  1956. /** defines the second coordinate */
  1957. y: number;
  1958. /**
  1959. * Creates a new Vector2 from the given x and y coordinates
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. */
  1963. constructor(
  1964. /** defines the first coordinate */
  1965. x?: number,
  1966. /** defines the second coordinate */
  1967. y?: number);
  1968. /**
  1969. * Gets a string with the Vector2 coordinates
  1970. * @returns a string with the Vector2 coordinates
  1971. */
  1972. toString(): string;
  1973. /**
  1974. * Gets class name
  1975. * @returns the string "Vector2"
  1976. */
  1977. getClassName(): string;
  1978. /**
  1979. * Gets current vector hash code
  1980. * @returns the Vector2 hash code as a number
  1981. */
  1982. getHashCode(): number;
  1983. /**
  1984. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1985. * @param array defines the source array
  1986. * @param index defines the offset in source array
  1987. * @returns the current Vector2
  1988. */
  1989. toArray(array: FloatArray, index?: number): Vector2;
  1990. /**
  1991. * Copy the current vector to an array
  1992. * @returns a new array with 2 elements: the Vector2 coordinates.
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1997. * @param source defines the source Vector2
  1998. * @returns the current updated Vector2
  1999. */
  2000. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2001. /**
  2002. * Sets the Vector2 coordinates with the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns the current updated Vector2
  2006. */
  2007. copyFromFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Sets the Vector2 coordinates with the given floats
  2010. * @param x defines the first coordinate
  2011. * @param y defines the second coordinate
  2012. * @returns the current updated Vector2
  2013. */
  2014. set(x: number, y: number): Vector2;
  2015. /**
  2016. * Add another vector with the current one
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2019. */
  2020. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2021. /**
  2022. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2023. * @param otherVector defines the other vector
  2024. * @param result defines the target vector
  2025. * @returns the unmodified current Vector2
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2028. /**
  2029. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2030. * @param otherVector defines the other vector
  2031. * @returns the current updated Vector2
  2032. */
  2033. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2034. /**
  2035. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns a new Vector2
  2038. */
  2039. addVector3(otherVector: Vector3): Vector2;
  2040. /**
  2041. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. subtract(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Multiplies in place the current Vector2 coordinates by the given ones
  2061. * @param otherVector defines the other vector
  2062. * @returns the current updated Vector2
  2063. */
  2064. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2065. /**
  2066. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2067. * @param otherVector defines the other vector
  2068. * @returns a new Vector2
  2069. */
  2070. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2071. /**
  2072. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2073. * @param otherVector defines the other vector
  2074. * @param result defines the target vector
  2075. * @returns the unmodified current Vector2
  2076. */
  2077. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2078. /**
  2079. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2080. * @param x defines the first coordinate
  2081. * @param y defines the second coordinate
  2082. * @returns a new Vector2
  2083. */
  2084. multiplyByFloats(x: number, y: number): Vector2;
  2085. /**
  2086. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2087. * @param otherVector defines the other vector
  2088. * @returns a new Vector2
  2089. */
  2090. divide(otherVector: Vector2): Vector2;
  2091. /**
  2092. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2093. * @param otherVector defines the other vector
  2094. * @param result defines the target vector
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2098. /**
  2099. * Divides the current Vector2 coordinates by the given ones
  2100. * @param otherVector defines the other vector
  2101. * @returns the current updated Vector2
  2102. */
  2103. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2104. /**
  2105. * Gets a new Vector2 with current Vector2 negated coordinates
  2106. * @returns a new Vector2
  2107. */
  2108. negate(): Vector2;
  2109. /**
  2110. * Multiply the Vector2 coordinates by scale
  2111. * @param scale defines the scaling factor
  2112. * @returns the current updated Vector2
  2113. */
  2114. scaleInPlace(scale: number): Vector2;
  2115. /**
  2116. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2117. * @param scale defines the scaling factor
  2118. * @returns a new Vector2
  2119. */
  2120. scale(scale: number): Vector2;
  2121. /**
  2122. * Scale the current Vector2 values by a factor to a given Vector2
  2123. * @param scale defines the scale factor
  2124. * @param result defines the Vector2 object where to store the result
  2125. * @returns the unmodified current Vector2
  2126. */
  2127. scaleToRef(scale: number, result: Vector2): Vector2;
  2128. /**
  2129. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2130. * @param scale defines the scale factor
  2131. * @param result defines the Vector2 object where to store the result
  2132. * @returns the unmodified current Vector2
  2133. */
  2134. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2135. /**
  2136. * Gets a boolean if two vectors are equals
  2137. * @param otherVector defines the other vector
  2138. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2139. */
  2140. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2141. /**
  2142. * Gets a boolean if two vectors are equals (using an epsilon value)
  2143. * @param otherVector defines the other vector
  2144. * @param epsilon defines the minimal distance to consider equality
  2145. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2146. */
  2147. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2148. /**
  2149. * Gets a new Vector2 from current Vector2 floored values
  2150. * @returns a new Vector2
  2151. */
  2152. floor(): Vector2;
  2153. /**
  2154. * Gets a new Vector2 from current Vector2 floored values
  2155. * @returns a new Vector2
  2156. */
  2157. fract(): Vector2;
  2158. /**
  2159. * Gets the length of the vector
  2160. * @returns the vector length (float)
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Gets the vector squared length
  2165. * @returns the vector squared length (float)
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalize the vector
  2170. * @returns the current updated Vector2
  2171. */
  2172. normalize(): Vector2;
  2173. /**
  2174. * Gets a new Vector2 copied from the Vector2
  2175. * @returns a new Vector2
  2176. */
  2177. clone(): Vector2;
  2178. /**
  2179. * Gets a new Vector2(0, 0)
  2180. * @returns a new Vector2
  2181. */
  2182. static Zero(): Vector2;
  2183. /**
  2184. * Gets a new Vector2(1, 1)
  2185. * @returns a new Vector2
  2186. */
  2187. static One(): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set from the given index element of the given array
  2190. * @param array defines the data source
  2191. * @param offset defines the offset in the data source
  2192. * @returns a new Vector2
  2193. */
  2194. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2195. /**
  2196. * Sets "result" from the given index element of the given array
  2197. * @param array defines the data source
  2198. * @param offset defines the offset in the data source
  2199. * @param result defines the target vector
  2200. */
  2201. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2202. /**
  2203. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2204. * @param value1 defines 1st point of control
  2205. * @param value2 defines 2nd point of control
  2206. * @param value3 defines 3rd point of control
  2207. * @param value4 defines 4th point of control
  2208. * @param amount defines the interpolation factor
  2209. * @returns a new Vector2
  2210. */
  2211. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2212. /**
  2213. * 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".
  2214. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2215. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2216. * @param value defines the value to clamp
  2217. * @param min defines the lower limit
  2218. * @param max defines the upper limit
  2219. * @returns a new Vector2
  2220. */
  2221. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2222. /**
  2223. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2224. * @param value1 defines the 1st control point
  2225. * @param tangent1 defines the outgoing tangent
  2226. * @param value2 defines the 2nd control point
  2227. * @param tangent2 defines the incoming tangent
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2234. * @param start defines the start vector
  2235. * @param end defines the end vector
  2236. * @param amount defines the interpolation factor
  2237. * @returns a new Vector2
  2238. */
  2239. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2240. /**
  2241. * Gets the dot product of the vector "left" and the vector "right"
  2242. * @param left defines first vector
  2243. * @param right defines second vector
  2244. * @returns the dot product (float)
  2245. */
  2246. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2247. /**
  2248. * Returns a new Vector2 equal to the normalized given vector
  2249. * @param vector defines the vector to normalize
  2250. * @returns a new Vector2
  2251. */
  2252. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2253. /**
  2254. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2255. * @param left defines 1st vector
  2256. * @param right defines 2nd vector
  2257. * @returns a new Vector2
  2258. */
  2259. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2260. /**
  2261. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2262. * @param left defines 1st vector
  2263. * @param right defines 2nd vector
  2264. * @returns a new Vector2
  2265. */
  2266. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2267. /**
  2268. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2269. * @param vector defines the vector to transform
  2270. * @param transformation defines the matrix to apply
  2271. * @returns a new Vector2
  2272. */
  2273. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2274. /**
  2275. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2276. * @param vector defines the vector to transform
  2277. * @param transformation defines the matrix to apply
  2278. * @param result defines the target vector
  2279. */
  2280. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2281. /**
  2282. * Determines if a given vector is included in a triangle
  2283. * @param p defines the vector to test
  2284. * @param p0 defines 1st triangle point
  2285. * @param p1 defines 2nd triangle point
  2286. * @param p2 defines 3rd triangle point
  2287. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2288. */
  2289. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2290. /**
  2291. * Gets the distance between the vectors "value1" and "value2"
  2292. * @param value1 defines first vector
  2293. * @param value2 defines second vector
  2294. * @returns the distance between vectors
  2295. */
  2296. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2297. /**
  2298. * Returns the squared distance between the vectors "value1" and "value2"
  2299. * @param value1 defines first vector
  2300. * @param value2 defines second vector
  2301. * @returns the squared distance between vectors
  2302. */
  2303. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2304. /**
  2305. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2306. * @param value1 defines first vector
  2307. * @param value2 defines second vector
  2308. * @returns a new Vector2
  2309. */
  2310. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2311. /**
  2312. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2313. * @param p defines the middle point
  2314. * @param segA defines one point of the segment
  2315. * @param segB defines the other point of the segment
  2316. * @returns the shortest distance
  2317. */
  2318. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2319. }
  2320. /**
  2321. * Class used to store (x,y,z) vector representation
  2322. * A Vector3 is the main object used in 3D geometry
  2323. * It can represent etiher the coordinates of a point the space, either a direction
  2324. * Reminder: js uses a left handed forward facing system
  2325. */
  2326. export class Vector3 {
  2327. /**
  2328. * Defines the first coordinates (on X axis)
  2329. */
  2330. x: number;
  2331. /**
  2332. * Defines the second coordinates (on Y axis)
  2333. */
  2334. y: number;
  2335. /**
  2336. * Defines the third coordinates (on Z axis)
  2337. */
  2338. z: number;
  2339. private static _UpReadOnly;
  2340. private static _ZeroReadOnly;
  2341. /**
  2342. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2343. * @param x defines the first coordinates (on X axis)
  2344. * @param y defines the second coordinates (on Y axis)
  2345. * @param z defines the third coordinates (on Z axis)
  2346. */
  2347. constructor(
  2348. /**
  2349. * Defines the first coordinates (on X axis)
  2350. */
  2351. x?: number,
  2352. /**
  2353. * Defines the second coordinates (on Y axis)
  2354. */
  2355. y?: number,
  2356. /**
  2357. * Defines the third coordinates (on Z axis)
  2358. */
  2359. z?: number);
  2360. /**
  2361. * Creates a string representation of the Vector3
  2362. * @returns a string with the Vector3 coordinates.
  2363. */
  2364. toString(): string;
  2365. /**
  2366. * Gets the class name
  2367. * @returns the string "Vector3"
  2368. */
  2369. getClassName(): string;
  2370. /**
  2371. * Creates the Vector3 hash code
  2372. * @returns a number which tends to be unique between Vector3 instances
  2373. */
  2374. getHashCode(): number;
  2375. /**
  2376. * Creates an array containing three elements : the coordinates of the Vector3
  2377. * @returns a new array of numbers
  2378. */
  2379. asArray(): number[];
  2380. /**
  2381. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2382. * @param array defines the destination array
  2383. * @param index defines the offset in the destination array
  2384. * @returns the current Vector3
  2385. */
  2386. toArray(array: FloatArray, index?: number): Vector3;
  2387. /**
  2388. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2389. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2390. */
  2391. toQuaternion(): Quaternion;
  2392. /**
  2393. * Adds the given vector to the current Vector3
  2394. * @param otherVector defines the second operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2398. /**
  2399. * Adds the given coordinates to the current Vector3
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2406. /**
  2407. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Subtract the given vector from the current Vector3
  2421. * @param otherVector defines the second operand
  2422. * @returns the current updated Vector3
  2423. */
  2424. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2425. /**
  2426. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2427. * @param otherVector defines the second operand
  2428. * @returns the resulting Vector3
  2429. */
  2430. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2431. /**
  2432. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2433. * @param otherVector defines the second operand
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the current Vector3
  2436. */
  2437. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2438. /**
  2439. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  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. * @returns the resulting Vector3
  2444. */
  2445. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2446. /**
  2447. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @param result defines the Vector3 object where to store the result
  2452. * @returns the current Vector3
  2453. */
  2454. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2455. /**
  2456. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2457. * @returns a new Vector3
  2458. */
  2459. negate(): Vector3;
  2460. /**
  2461. * Negate this vector in place
  2462. * @returns this
  2463. */
  2464. negateInPlace(): Vector3;
  2465. /**
  2466. * Multiplies the Vector3 coordinates by the float "scale"
  2467. * @param scale defines the multiplier factor
  2468. * @returns the current updated Vector3
  2469. */
  2470. scaleInPlace(scale: number): Vector3;
  2471. /**
  2472. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2473. * @param scale defines the multiplier factor
  2474. * @returns a new Vector3
  2475. */
  2476. scale(scale: number): Vector3;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2479. * @param scale defines the multiplier factor
  2480. * @param result defines the Vector3 object where to store the result
  2481. * @returns the current Vector3
  2482. */
  2483. scaleToRef(scale: number, result: Vector3): Vector3;
  2484. /**
  2485. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2486. * @param scale defines the scale factor
  2487. * @param result defines the Vector3 object where to store the result
  2488. * @returns the unmodified current Vector3
  2489. */
  2490. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2491. /**
  2492. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2493. * @param otherVector defines the second operand
  2494. * @returns true if both vectors are equals
  2495. */
  2496. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2497. /**
  2498. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2499. * @param otherVector defines the second operand
  2500. * @param epsilon defines the minimal distance to define values as equals
  2501. * @returns true if both vectors are distant less than epsilon
  2502. */
  2503. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2504. /**
  2505. * Returns true if the current Vector3 coordinates equals the given floats
  2506. * @param x defines the x coordinate of the operand
  2507. * @param y defines the y coordinate of the operand
  2508. * @param z defines the z coordinate of the operand
  2509. * @returns true if both vectors are equals
  2510. */
  2511. equalsToFloats(x: number, y: number, z: number): boolean;
  2512. /**
  2513. * Multiplies the current Vector3 coordinates by the given ones
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the new Vector3
  2522. */
  2523. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2533. * @param x defines the x coordinate of the operand
  2534. * @param y defines the y coordinate of the operand
  2535. * @param z defines the z coordinate of the operand
  2536. * @returns the new Vector3
  2537. */
  2538. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2539. /**
  2540. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2541. * @param otherVector defines the second operand
  2542. * @returns the new Vector3
  2543. */
  2544. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2547. * @param otherVector defines the second operand
  2548. * @param result defines the Vector3 object where to store the result
  2549. * @returns the current Vector3
  2550. */
  2551. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2552. /**
  2553. * Divides the current Vector3 coordinates by the given ones.
  2554. * @param otherVector defines the second operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. divideInPlace(otherVector: Vector3): Vector3;
  2558. /**
  2559. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2560. * @param other defines the second operand
  2561. * @returns the current updated Vector3
  2562. */
  2563. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2564. /**
  2565. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2566. * @param other defines the second operand
  2567. * @returns the current updated Vector3
  2568. */
  2569. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2570. /**
  2571. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2572. * @param x defines the x coordinate of the operand
  2573. * @param y defines the y coordinate of the operand
  2574. * @param z defines the z coordinate of the operand
  2575. * @returns the current updated Vector3
  2576. */
  2577. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2578. /**
  2579. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2580. * @param x defines the x coordinate of the operand
  2581. * @param y defines the y coordinate of the operand
  2582. * @param z defines the z coordinate of the operand
  2583. * @returns the current updated Vector3
  2584. */
  2585. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2586. /**
  2587. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2588. * Check if is non uniform within a certain amount of decimal places to account for this
  2589. * @param epsilon the amount the values can differ
  2590. * @returns if the the vector is non uniform to a certain number of decimal places
  2591. */
  2592. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2593. /**
  2594. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2595. */
  2596. get isNonUniform(): boolean;
  2597. /**
  2598. * Gets a new Vector3 from current Vector3 floored values
  2599. * @returns a new Vector3
  2600. */
  2601. floor(): Vector3;
  2602. /**
  2603. * Gets a new Vector3 from current Vector3 floored values
  2604. * @returns a new Vector3
  2605. */
  2606. fract(): Vector3;
  2607. /**
  2608. * Gets the length of the Vector3
  2609. * @returns the length of the Vector3
  2610. */
  2611. length(): number;
  2612. /**
  2613. * Gets the squared length of the Vector3
  2614. * @returns squared length of the Vector3
  2615. */
  2616. lengthSquared(): number;
  2617. /**
  2618. * Normalize the current Vector3.
  2619. * Please note that this is an in place operation.
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalize(): Vector3;
  2623. /**
  2624. * Reorders the x y z properties of the vector in place
  2625. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2626. * @returns the current updated vector
  2627. */
  2628. reorderInPlace(order: string): this;
  2629. /**
  2630. * Rotates the vector around 0,0,0 by a quaternion
  2631. * @param quaternion the rotation quaternion
  2632. * @param result vector to store the result
  2633. * @returns the resulting vector
  2634. */
  2635. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2636. /**
  2637. * Rotates a vector around a given point
  2638. * @param quaternion the rotation quaternion
  2639. * @param point the point to rotate around
  2640. * @param result vector to store the result
  2641. * @returns the resulting vector
  2642. */
  2643. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2644. /**
  2645. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2646. * The cross product is then orthogonal to both current and "other"
  2647. * @param other defines the right operand
  2648. * @returns the cross product
  2649. */
  2650. cross(other: Vector3): Vector3;
  2651. /**
  2652. * Normalize the current Vector3 with the given input length.
  2653. * Please note that this is an in place operation.
  2654. * @param len the length of the vector
  2655. * @returns the current updated Vector3
  2656. */
  2657. normalizeFromLength(len: number): Vector3;
  2658. /**
  2659. * Normalize the current Vector3 to a new vector
  2660. * @returns the new Vector3
  2661. */
  2662. normalizeToNew(): Vector3;
  2663. /**
  2664. * Normalize the current Vector3 to the reference
  2665. * @param reference define the Vector3 to update
  2666. * @returns the updated Vector3
  2667. */
  2668. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2669. /**
  2670. * Creates a new Vector3 copied from the current Vector3
  2671. * @returns the new Vector3
  2672. */
  2673. clone(): Vector3;
  2674. /**
  2675. * Copies the given vector coordinates to the current Vector3 ones
  2676. * @param source defines the source Vector3
  2677. * @returns the current updated Vector3
  2678. */
  2679. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2680. /**
  2681. * Copies the given floats to the current Vector3 coordinates
  2682. * @param x defines the x coordinate of the operand
  2683. * @param y defines the y coordinate of the operand
  2684. * @param z defines the z coordinate of the operand
  2685. * @returns the current updated Vector3
  2686. */
  2687. copyFromFloats(x: number, y: number, z: number): Vector3;
  2688. /**
  2689. * Copies the given floats to the current Vector3 coordinates
  2690. * @param x defines the x coordinate of the operand
  2691. * @param y defines the y coordinate of the operand
  2692. * @param z defines the z coordinate of the operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. set(x: number, y: number, z: number): Vector3;
  2696. /**
  2697. * Copies the given float to the current Vector3 coordinates
  2698. * @param v defines the x, y and z coordinates of the operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. setAll(v: number): Vector3;
  2702. /**
  2703. * Get the clip factor between two vectors
  2704. * @param vector0 defines the first operand
  2705. * @param vector1 defines the second operand
  2706. * @param axis defines the axis to use
  2707. * @param size defines the size along the axis
  2708. * @returns the clip factor
  2709. */
  2710. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2711. /**
  2712. * Get angle between two vectors
  2713. * @param vector0 angle between vector0 and vector1
  2714. * @param vector1 angle between vector0 and vector1
  2715. * @param normal direction of the normal
  2716. * @return the angle between vector0 and vector1
  2717. */
  2718. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2719. /**
  2720. * Returns a new Vector3 set from the index "offset" of the given array
  2721. * @param array defines the source array
  2722. * @param offset defines the offset in the source array
  2723. * @returns the new Vector3
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2726. /**
  2727. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2728. * @param array defines the source array
  2729. * @param offset defines the offset in the source array
  2730. * @returns the new Vector3
  2731. * @deprecated Please use FromArray instead.
  2732. */
  2733. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2734. /**
  2735. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2736. * @param array defines the source array
  2737. * @param offset defines the offset in the source array
  2738. * @param result defines the Vector3 where to store the result
  2739. */
  2740. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2741. /**
  2742. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2743. * @param array defines the source array
  2744. * @param offset defines the offset in the source array
  2745. * @param result defines the Vector3 where to store the result
  2746. * @deprecated Please use FromArrayToRef instead.
  2747. */
  2748. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2749. /**
  2750. * Sets the given vector "result" with the given floats.
  2751. * @param x defines the x coordinate of the source
  2752. * @param y defines the y coordinate of the source
  2753. * @param z defines the z coordinate of the source
  2754. * @param result defines the Vector3 where to store the result
  2755. */
  2756. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2759. * @returns a new empty Vector3
  2760. */
  2761. static Zero(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2764. * @returns a new unit Vector3
  2765. */
  2766. static One(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2769. * @returns a new up Vector3
  2770. */
  2771. static Up(): Vector3;
  2772. /**
  2773. * Gets a up Vector3 that must not be updated
  2774. */
  2775. static get UpReadOnly(): DeepImmutable<Vector3>;
  2776. /**
  2777. * Gets a zero Vector3 that must not be updated
  2778. */
  2779. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2780. /**
  2781. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2782. * @returns a new down Vector3
  2783. */
  2784. static Down(): Vector3;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2787. * @returns a new forward Vector3
  2788. */
  2789. static Forward(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2792. * @returns a new forward Vector3
  2793. */
  2794. static Backward(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2797. * @returns a new right Vector3
  2798. */
  2799. static Right(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2802. * @returns a new left Vector3
  2803. */
  2804. static Left(): Vector3;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2807. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the transformed Vector3
  2811. */
  2812. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2815. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2823. * This method computes tranformed coordinates only, not transformed direction vectors
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2833. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2834. * @param vector defines the Vector3 to transform
  2835. * @param transformation defines the transformation matrix
  2836. * @returns the new Vector3
  2837. */
  2838. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2839. /**
  2840. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2841. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2842. * @param vector defines the Vector3 to transform
  2843. * @param transformation defines the transformation matrix
  2844. * @param result defines the Vector3 where to store the result
  2845. */
  2846. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2847. /**
  2848. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2849. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2850. * @param x define the x coordinate of the source vector
  2851. * @param y define the y coordinate of the source vector
  2852. * @param z define the z coordinate of the source vector
  2853. * @param transformation defines the transformation matrix
  2854. * @param result defines the Vector3 where to store the result
  2855. */
  2856. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2857. /**
  2858. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2859. * @param value1 defines the first control point
  2860. * @param value2 defines the second control point
  2861. * @param value3 defines the third control point
  2862. * @param value4 defines the fourth control point
  2863. * @param amount defines the amount on the spline to use
  2864. * @returns the new Vector3
  2865. */
  2866. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2867. /**
  2868. * 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"
  2869. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2870. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2871. * @param value defines the current value
  2872. * @param min defines the lower range value
  2873. * @param max defines the upper range value
  2874. * @returns the new Vector3
  2875. */
  2876. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * 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"
  2879. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2880. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2881. * @param value defines the current value
  2882. * @param min defines the lower range value
  2883. * @param max defines the upper range value
  2884. * @param result defines the Vector3 where to store the result
  2885. */
  2886. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2887. /**
  2888. * Checks if a given vector is inside a specific range
  2889. * @param v defines the vector to test
  2890. * @param min defines the minimum range
  2891. * @param max defines the maximum range
  2892. */
  2893. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2894. /**
  2895. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2896. * @param value1 defines the first control point
  2897. * @param tangent1 defines the first tangent vector
  2898. * @param value2 defines the second control point
  2899. * @param tangent2 defines the second tangent vector
  2900. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2901. * @returns the new Vector3
  2902. */
  2903. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2904. /**
  2905. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2906. * @param start defines the start value
  2907. * @param end defines the end value
  2908. * @param amount max defines amount between both (between 0 and 1)
  2909. * @returns the new Vector3
  2910. */
  2911. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2912. /**
  2913. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2914. * @param start defines the start value
  2915. * @param end defines the end value
  2916. * @param amount max defines amount between both (between 0 and 1)
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2920. /**
  2921. * Returns the dot product (float) between the vectors "left" and "right"
  2922. * @param left defines the left operand
  2923. * @param right defines the right operand
  2924. * @returns the dot product
  2925. */
  2926. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2927. /**
  2928. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2929. * The cross product is then orthogonal to both "left" and "right"
  2930. * @param left defines the left operand
  2931. * @param right defines the right operand
  2932. * @returns the cross product
  2933. */
  2934. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2935. /**
  2936. * Sets the given vector "result" with the cross product of "left" and "right"
  2937. * The cross product is then orthogonal to both "left" and "right"
  2938. * @param left defines the left operand
  2939. * @param right defines the right operand
  2940. * @param result defines the Vector3 where to store the result
  2941. */
  2942. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2943. /**
  2944. * Returns a new Vector3 as the normalization of the given vector
  2945. * @param vector defines the Vector3 to normalize
  2946. * @returns the new Vector3
  2947. */
  2948. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2949. /**
  2950. * Sets the given vector "result" with the normalization of the given first vector
  2951. * @param vector defines the Vector3 to normalize
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2955. /**
  2956. * Project a Vector3 onto screen space
  2957. * @param vector defines the Vector3 to project
  2958. * @param world defines the world matrix to use
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @param viewport defines the screen viewport to use
  2961. * @returns the new Vector3
  2962. */
  2963. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2964. /** @hidden */
  2965. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Unproject from screen space to object space
  2968. * @param source defines the screen space Vector3 to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param transform defines the transform (view x projection) matrix to use
  2973. * @returns the new Vector3
  2974. */
  2975. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2976. /**
  2977. * Unproject from screen space to object space
  2978. * @param source defines the screen space Vector3 to use
  2979. * @param viewportWidth defines the current width of the viewport
  2980. * @param viewportHeight defines the current height of the viewport
  2981. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2982. * @param view defines the view matrix to use
  2983. * @param projection defines the projection matrix to use
  2984. * @returns the new Vector3
  2985. */
  2986. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2987. /**
  2988. * Unproject from screen space to object space
  2989. * @param source defines the screen space Vector3 to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Unproject from screen space to object space
  3000. * @param sourceX defines the screen space x coordinate to use
  3001. * @param sourceY defines the screen space y coordinate to use
  3002. * @param sourceZ defines the screen space z coordinate to use
  3003. * @param viewportWidth defines the current width of the viewport
  3004. * @param viewportHeight defines the current height of the viewport
  3005. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3006. * @param view defines the view matrix to use
  3007. * @param projection defines the projection matrix to use
  3008. * @param result defines the Vector3 where to store the result
  3009. */
  3010. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3011. /**
  3012. * Gets the minimal coordinate values between two Vector3
  3013. * @param left defines the first operand
  3014. * @param right defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Gets the maximal coordinate values between two Vector3
  3020. * @param left defines the first operand
  3021. * @param right defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Returns the distance between the vectors "value1" and "value2"
  3027. * @param value1 defines the first operand
  3028. * @param value2 defines the second operand
  3029. * @returns the distance
  3030. */
  3031. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3032. /**
  3033. * Returns the squared distance between the vectors "value1" and "value2"
  3034. * @param value1 defines the first operand
  3035. * @param value2 defines the second operand
  3036. * @returns the squared distance
  3037. */
  3038. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3039. /**
  3040. * Returns a new Vector3 located at the center between "value1" and "value2"
  3041. * @param value1 defines the first operand
  3042. * @param value2 defines the second operand
  3043. * @returns the new Vector3
  3044. */
  3045. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3046. /**
  3047. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3048. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3049. * to something in order to rotate it from its local system to the given target system
  3050. * Note: axis1, axis2 and axis3 are normalized during this operation
  3051. * @param axis1 defines the first axis
  3052. * @param axis2 defines the second axis
  3053. * @param axis3 defines the third axis
  3054. * @returns a new Vector3
  3055. */
  3056. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3057. /**
  3058. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3059. * @param axis1 defines the first axis
  3060. * @param axis2 defines the second axis
  3061. * @param axis3 defines the third axis
  3062. * @param ref defines the Vector3 where to store the result
  3063. */
  3064. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3065. }
  3066. /**
  3067. * Vector4 class created for EulerAngle class conversion to Quaternion
  3068. */
  3069. export class Vector4 {
  3070. /** x value of the vector */
  3071. x: number;
  3072. /** y value of the vector */
  3073. y: number;
  3074. /** z value of the vector */
  3075. z: number;
  3076. /** w value of the vector */
  3077. w: number;
  3078. /**
  3079. * Creates a Vector4 object from the given floats.
  3080. * @param x x value of the vector
  3081. * @param y y value of the vector
  3082. * @param z z value of the vector
  3083. * @param w w value of the vector
  3084. */
  3085. constructor(
  3086. /** x value of the vector */
  3087. x: number,
  3088. /** y value of the vector */
  3089. y: number,
  3090. /** z value of the vector */
  3091. z: number,
  3092. /** w value of the vector */
  3093. w: number);
  3094. /**
  3095. * Returns the string with the Vector4 coordinates.
  3096. * @returns a string containing all the vector values
  3097. */
  3098. toString(): string;
  3099. /**
  3100. * Returns the string "Vector4".
  3101. * @returns "Vector4"
  3102. */
  3103. getClassName(): string;
  3104. /**
  3105. * Returns the Vector4 hash code.
  3106. * @returns a unique hash code
  3107. */
  3108. getHashCode(): number;
  3109. /**
  3110. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3111. * @returns the resulting array
  3112. */
  3113. asArray(): number[];
  3114. /**
  3115. * Populates the given array from the given index with the Vector4 coordinates.
  3116. * @param array array to populate
  3117. * @param index index of the array to start at (default: 0)
  3118. * @returns the Vector4.
  3119. */
  3120. toArray(array: FloatArray, index?: number): Vector4;
  3121. /**
  3122. * Adds the given vector to the current Vector4.
  3123. * @param otherVector the vector to add
  3124. * @returns the updated Vector4.
  3125. */
  3126. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3127. /**
  3128. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3129. * @param otherVector the vector to add
  3130. * @returns the resulting vector
  3131. */
  3132. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3135. * @param otherVector the vector to add
  3136. * @param result the vector to store the result
  3137. * @returns the current Vector4.
  3138. */
  3139. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3140. /**
  3141. * Subtract in place the given vector from the current Vector4.
  3142. * @param otherVector the vector to subtract
  3143. * @returns the updated Vector4.
  3144. */
  3145. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3146. /**
  3147. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3148. * @param otherVector the vector to add
  3149. * @returns the new vector with the result
  3150. */
  3151. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3152. /**
  3153. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3154. * @param otherVector the vector to subtract
  3155. * @param result the vector to store the result
  3156. * @returns the current Vector4.
  3157. */
  3158. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3159. /**
  3160. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3161. */
  3162. /**
  3163. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3164. * @param x value to subtract
  3165. * @param y value to subtract
  3166. * @param z value to subtract
  3167. * @param w value to subtract
  3168. * @returns new vector containing the result
  3169. */
  3170. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3171. /**
  3172. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3173. * @param x value to subtract
  3174. * @param y value to subtract
  3175. * @param z value to subtract
  3176. * @param w value to subtract
  3177. * @param result the vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3181. /**
  3182. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3183. * @returns a new vector with the negated values
  3184. */
  3185. negate(): Vector4;
  3186. /**
  3187. * Multiplies the current Vector4 coordinates by scale (float).
  3188. * @param scale the number to scale with
  3189. * @returns the updated Vector4.
  3190. */
  3191. scaleInPlace(scale: number): Vector4;
  3192. /**
  3193. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3194. * @param scale the number to scale with
  3195. * @returns a new vector with the result
  3196. */
  3197. scale(scale: number): Vector4;
  3198. /**
  3199. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3200. * @param scale the number to scale with
  3201. * @param result a vector to store the result in
  3202. * @returns the current Vector4.
  3203. */
  3204. scaleToRef(scale: number, result: Vector4): Vector4;
  3205. /**
  3206. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3207. * @param scale defines the scale factor
  3208. * @param result defines the Vector4 object where to store the result
  3209. * @returns the unmodified current Vector4
  3210. */
  3211. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3212. /**
  3213. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3214. * @param otherVector the vector to compare against
  3215. * @returns true if they are equal
  3216. */
  3217. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3218. /**
  3219. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3220. * @param otherVector vector to compare against
  3221. * @param epsilon (Default: very small number)
  3222. * @returns true if they are equal
  3223. */
  3224. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3225. /**
  3226. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3227. * @param x x value to compare against
  3228. * @param y y value to compare against
  3229. * @param z z value to compare against
  3230. * @param w w value to compare against
  3231. * @returns true if equal
  3232. */
  3233. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3234. /**
  3235. * Multiplies in place the current Vector4 by the given one.
  3236. * @param otherVector vector to multiple with
  3237. * @returns the updated Vector4.
  3238. */
  3239. multiplyInPlace(otherVector: Vector4): Vector4;
  3240. /**
  3241. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3242. * @param otherVector vector to multiple with
  3243. * @returns resulting new vector
  3244. */
  3245. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3246. /**
  3247. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3248. * @param otherVector vector to multiple with
  3249. * @param result vector to store the result
  3250. * @returns the current Vector4.
  3251. */
  3252. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3253. /**
  3254. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3255. * @param x x value multiply with
  3256. * @param y y value multiply with
  3257. * @param z z value multiply with
  3258. * @param w w value multiply with
  3259. * @returns resulting new vector
  3260. */
  3261. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3264. * @param otherVector vector to devide with
  3265. * @returns resulting new vector
  3266. */
  3267. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3270. * @param otherVector vector to devide with
  3271. * @param result vector to store the result
  3272. * @returns the current Vector4.
  3273. */
  3274. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3275. /**
  3276. * Divides the current Vector3 coordinates by the given ones.
  3277. * @param otherVector vector to devide with
  3278. * @returns the updated Vector3.
  3279. */
  3280. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3283. * @param other defines the second operand
  3284. * @returns the current updated Vector4
  3285. */
  3286. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3287. /**
  3288. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3289. * @param other defines the second operand
  3290. * @returns the current updated Vector4
  3291. */
  3292. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3293. /**
  3294. * Gets a new Vector4 from current Vector4 floored values
  3295. * @returns a new Vector4
  3296. */
  3297. floor(): Vector4;
  3298. /**
  3299. * Gets a new Vector4 from current Vector3 floored values
  3300. * @returns a new Vector4
  3301. */
  3302. fract(): Vector4;
  3303. /**
  3304. * Returns the Vector4 length (float).
  3305. * @returns the length
  3306. */
  3307. length(): number;
  3308. /**
  3309. * Returns the Vector4 squared length (float).
  3310. * @returns the length squared
  3311. */
  3312. lengthSquared(): number;
  3313. /**
  3314. * Normalizes in place the Vector4.
  3315. * @returns the updated Vector4.
  3316. */
  3317. normalize(): Vector4;
  3318. /**
  3319. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3320. * @returns this converted to a new vector3
  3321. */
  3322. toVector3(): Vector3;
  3323. /**
  3324. * Returns a new Vector4 copied from the current one.
  3325. * @returns the new cloned vector
  3326. */
  3327. clone(): Vector4;
  3328. /**
  3329. * Updates the current Vector4 with the given one coordinates.
  3330. * @param source the source vector to copy from
  3331. * @returns the updated Vector4.
  3332. */
  3333. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Updates the current Vector4 coordinates with the given floats.
  3336. * @param x float to copy from
  3337. * @param y float to copy from
  3338. * @param z float to copy from
  3339. * @param w float to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to set from
  3346. * @param y float to set from
  3347. * @param z float to set from
  3348. * @param w float to set from
  3349. * @returns the updated Vector4.
  3350. */
  3351. set(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Copies the given float to the current Vector3 coordinates
  3354. * @param v defines the x, y, z and w coordinates of the operand
  3355. * @returns the current updated Vector3
  3356. */
  3357. setAll(v: number): Vector4;
  3358. /**
  3359. * Returns a new Vector4 set from the starting index of the given array.
  3360. * @param array the array to pull values from
  3361. * @param offset the offset into the array to start at
  3362. * @returns the new vector
  3363. */
  3364. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3365. /**
  3366. * Updates the given vector "result" from the starting index of the given array.
  3367. * @param array the array to pull values from
  3368. * @param offset the offset into the array to start at
  3369. * @param result the vector to store the result in
  3370. */
  3371. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3372. /**
  3373. * Updates the given vector "result" from the starting index of the given Float32Array.
  3374. * @param array the array to pull values from
  3375. * @param offset the offset into the array to start at
  3376. * @param result the vector to store the result in
  3377. */
  3378. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3379. /**
  3380. * Updates the given vector "result" coordinates from the given floats.
  3381. * @param x float to set from
  3382. * @param y float to set from
  3383. * @param z float to set from
  3384. * @param w float to set from
  3385. * @param result the vector to the floats in
  3386. */
  3387. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3388. /**
  3389. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3390. * @returns the new vector
  3391. */
  3392. static Zero(): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3395. * @returns the new vector
  3396. */
  3397. static One(): Vector4;
  3398. /**
  3399. * Returns a new normalized Vector4 from the given one.
  3400. * @param vector the vector to normalize
  3401. * @returns the vector
  3402. */
  3403. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the given vector "result" from the normalization of the given one.
  3406. * @param vector the vector to normalize
  3407. * @param result the vector to store the result in
  3408. */
  3409. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3410. /**
  3411. * Returns a vector with the minimum values from the left and right vectors
  3412. * @param left left vector to minimize
  3413. * @param right right vector to minimize
  3414. * @returns a new vector with the minimum of the left and right vector values
  3415. */
  3416. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a vector with the maximum values from the left and right vectors
  3419. * @param left left vector to maximize
  3420. * @param right right vector to maximize
  3421. * @returns a new vector with the maximum of the left and right vector values
  3422. */
  3423. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Returns the distance (float) between the vectors "value1" and "value2".
  3426. * @param value1 value to calulate the distance between
  3427. * @param value2 value to calulate the distance between
  3428. * @return the distance between the two vectors
  3429. */
  3430. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3431. /**
  3432. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3433. * @param value1 value to calulate the distance between
  3434. * @param value2 value to calulate the distance between
  3435. * @return the distance between the two vectors squared
  3436. */
  3437. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3438. /**
  3439. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3440. * @param value1 value to calulate the center between
  3441. * @param value2 value to calulate the center between
  3442. * @return the center between the two vectors
  3443. */
  3444. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3447. * This methods computes transformed normalized direction vectors only.
  3448. * @param vector the vector to transform
  3449. * @param transformation the transformation matrix to apply
  3450. * @returns the new vector
  3451. */
  3452. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3453. /**
  3454. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3455. * This methods computes transformed normalized direction vectors only.
  3456. * @param vector the vector to transform
  3457. * @param transformation the transformation matrix to apply
  3458. * @param result the vector to store the result in
  3459. */
  3460. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3461. /**
  3462. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3463. * This methods computes transformed normalized direction vectors only.
  3464. * @param x value to transform
  3465. * @param y value to transform
  3466. * @param z value to transform
  3467. * @param w value to transform
  3468. * @param transformation the transformation matrix to apply
  3469. * @param result the vector to store the results in
  3470. */
  3471. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3472. /**
  3473. * Creates a new Vector4 from a Vector3
  3474. * @param source defines the source data
  3475. * @param w defines the 4th component (default is 0)
  3476. * @returns a new Vector4
  3477. */
  3478. static FromVector3(source: Vector3, w?: number): Vector4;
  3479. }
  3480. /**
  3481. * Class used to store quaternion data
  3482. * @see https://en.wikipedia.org/wiki/Quaternion
  3483. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3484. */
  3485. export class Quaternion {
  3486. /** defines the first component (0 by default) */
  3487. x: number;
  3488. /** defines the second component (0 by default) */
  3489. y: number;
  3490. /** defines the third component (0 by default) */
  3491. z: number;
  3492. /** defines the fourth component (1.0 by default) */
  3493. w: number;
  3494. /**
  3495. * Creates a new Quaternion from the given floats
  3496. * @param x defines the first component (0 by default)
  3497. * @param y defines the second component (0 by default)
  3498. * @param z defines the third component (0 by default)
  3499. * @param w defines the fourth component (1.0 by default)
  3500. */
  3501. constructor(
  3502. /** defines the first component (0 by default) */
  3503. x?: number,
  3504. /** defines the second component (0 by default) */
  3505. y?: number,
  3506. /** defines the third component (0 by default) */
  3507. z?: number,
  3508. /** defines the fourth component (1.0 by default) */
  3509. w?: number);
  3510. /**
  3511. * Gets a string representation for the current quaternion
  3512. * @returns a string with the Quaternion coordinates
  3513. */
  3514. toString(): string;
  3515. /**
  3516. * Gets the class name of the quaternion
  3517. * @returns the string "Quaternion"
  3518. */
  3519. getClassName(): string;
  3520. /**
  3521. * Gets a hash code for this quaternion
  3522. * @returns the quaternion hash code
  3523. */
  3524. getHashCode(): number;
  3525. /**
  3526. * Copy the quaternion to an array
  3527. * @returns a new array populated with 4 elements from the quaternion coordinates
  3528. */
  3529. asArray(): number[];
  3530. /**
  3531. * Check if two quaternions are equals
  3532. * @param otherQuaternion defines the second operand
  3533. * @return true if the current quaternion and the given one coordinates are strictly equals
  3534. */
  3535. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3536. /**
  3537. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3538. * @param otherQuaternion defines the other quaternion
  3539. * @param epsilon defines the minimal distance to consider equality
  3540. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3541. */
  3542. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3543. /**
  3544. * Clone the current quaternion
  3545. * @returns a new quaternion copied from the current one
  3546. */
  3547. clone(): Quaternion;
  3548. /**
  3549. * Copy a quaternion to the current one
  3550. * @param other defines the other quaternion
  3551. * @returns the updated current quaternion
  3552. */
  3553. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Updates the current quaternion with the given float coordinates
  3556. * @param x defines the x coordinate
  3557. * @param y defines the y coordinate
  3558. * @param z defines the z coordinate
  3559. * @param w defines the w coordinate
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3563. /**
  3564. * Updates the current quaternion from 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. set(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Adds two quaternions
  3574. * @param other defines the second operand
  3575. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3576. */
  3577. add(other: DeepImmutable<Quaternion>): Quaternion;
  3578. /**
  3579. * Add a quaternion to the current one
  3580. * @param other defines the quaternion to add
  3581. * @returns the current quaternion
  3582. */
  3583. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3584. /**
  3585. * Subtract two quaternions
  3586. * @param other defines the second operand
  3587. * @returns a new quaternion as the subtraction result of the given one from the current one
  3588. */
  3589. subtract(other: Quaternion): Quaternion;
  3590. /**
  3591. * Multiplies the current quaternion by a scale factor
  3592. * @param value defines the scale factor
  3593. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3594. */
  3595. scale(value: number): Quaternion;
  3596. /**
  3597. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3598. * @param scale defines the scale factor
  3599. * @param result defines the Quaternion object where to store the result
  3600. * @returns the unmodified current quaternion
  3601. */
  3602. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3603. /**
  3604. * Multiplies in place the current quaternion by a scale factor
  3605. * @param value defines the scale factor
  3606. * @returns the current modified quaternion
  3607. */
  3608. scaleInPlace(value: number): Quaternion;
  3609. /**
  3610. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3611. * @param scale defines the scale factor
  3612. * @param result defines the Quaternion object where to store the result
  3613. * @returns the unmodified current quaternion
  3614. */
  3615. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3616. /**
  3617. * Multiplies two quaternions
  3618. * @param q1 defines the second operand
  3619. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3620. */
  3621. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3622. /**
  3623. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3624. * @param q1 defines the second operand
  3625. * @param result defines the target quaternion
  3626. * @returns the current quaternion
  3627. */
  3628. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3629. /**
  3630. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3631. * @param q1 defines the second operand
  3632. * @returns the currentupdated quaternion
  3633. */
  3634. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3635. /**
  3636. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3637. * @param ref defines the target quaternion
  3638. * @returns the current quaternion
  3639. */
  3640. conjugateToRef(ref: Quaternion): Quaternion;
  3641. /**
  3642. * Conjugates in place (1-q) the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. conjugateInPlace(): Quaternion;
  3646. /**
  3647. * Conjugates in place (1-q) the current quaternion
  3648. * @returns a new quaternion
  3649. */
  3650. conjugate(): Quaternion;
  3651. /**
  3652. * Gets length of current quaternion
  3653. * @returns the quaternion length (float)
  3654. */
  3655. length(): number;
  3656. /**
  3657. * Normalize in place the current quaternion
  3658. * @returns the current updated quaternion
  3659. */
  3660. normalize(): Quaternion;
  3661. /**
  3662. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3663. * @param order is a reserved parameter and is ignore for now
  3664. * @returns a new Vector3 containing the Euler angles
  3665. */
  3666. toEulerAngles(order?: string): Vector3;
  3667. /**
  3668. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3669. * @param result defines the vector which will be filled with the Euler angles
  3670. * @param order is a reserved parameter and is ignore for now
  3671. * @returns the current unchanged quaternion
  3672. */
  3673. toEulerAnglesToRef(result: Vector3): Quaternion;
  3674. /**
  3675. * Updates the given rotation matrix with the current quaternion values
  3676. * @param result defines the target matrix
  3677. * @returns the current unchanged quaternion
  3678. */
  3679. toRotationMatrix(result: Matrix): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given rotation matrix values
  3682. * @param matrix defines the source matrix
  3683. * @returns the current updated quaternion
  3684. */
  3685. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3686. /**
  3687. * Creates a new quaternion from a rotation matrix
  3688. * @param matrix defines the source matrix
  3689. * @returns a new quaternion created from the given rotation matrix values
  3690. */
  3691. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3692. /**
  3693. * Updates the given quaternion with the given rotation matrix values
  3694. * @param matrix defines the source matrix
  3695. * @param result defines the target quaternion
  3696. */
  3697. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3698. /**
  3699. * Returns the dot product (float) between the quaternions "left" and "right"
  3700. * @param left defines the left operand
  3701. * @param right defines the right operand
  3702. * @returns the dot product
  3703. */
  3704. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3705. /**
  3706. * Checks if the two quaternions are close to each other
  3707. * @param quat0 defines the first quaternion to check
  3708. * @param quat1 defines the second quaternion to check
  3709. * @returns true if the two quaternions are close to each other
  3710. */
  3711. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3712. /**
  3713. * Creates an empty quaternion
  3714. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3715. */
  3716. static Zero(): Quaternion;
  3717. /**
  3718. * Inverse a given quaternion
  3719. * @param q defines the source quaternion
  3720. * @returns a new quaternion as the inverted current quaternion
  3721. */
  3722. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Inverse a given quaternion
  3725. * @param q defines the source quaternion
  3726. * @param result the quaternion the result will be stored in
  3727. * @returns the result quaternion
  3728. */
  3729. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3730. /**
  3731. * Creates an identity quaternion
  3732. * @returns the identity quaternion
  3733. */
  3734. static Identity(): Quaternion;
  3735. /**
  3736. * Gets a boolean indicating if the given quaternion is identity
  3737. * @param quaternion defines the quaternion to check
  3738. * @returns true if the quaternion is identity
  3739. */
  3740. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Creates a quaternion from a rotation around an axis
  3743. * @param axis defines the axis to use
  3744. * @param angle defines the angle to use
  3745. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3746. */
  3747. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3748. /**
  3749. * Creates a rotation around an axis and stores it into the given quaternion
  3750. * @param axis defines the axis to use
  3751. * @param angle defines the angle to use
  3752. * @param result defines the target quaternion
  3753. * @returns the target quaternion
  3754. */
  3755. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Creates a new quaternion from data stored into an array
  3758. * @param array defines the data source
  3759. * @param offset defines the offset in the source array where the data starts
  3760. * @returns a new quaternion
  3761. */
  3762. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @returns the new Quaternion
  3769. */
  3770. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3771. /**
  3772. * Updates a quaternion from Euler rotation angles
  3773. * @param x Pitch
  3774. * @param y Yaw
  3775. * @param z Roll
  3776. * @param result the quaternion to store the result
  3777. * @returns the updated quaternion
  3778. */
  3779. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3780. /**
  3781. * Create a quaternion from Euler rotation vector
  3782. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3783. * @returns the new Quaternion
  3784. */
  3785. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3786. /**
  3787. * Updates a quaternion from Euler rotation vector
  3788. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3789. * @param result the quaternion to store the result
  3790. * @returns the updated quaternion
  3791. */
  3792. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3793. /**
  3794. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @returns the new quaternion
  3799. */
  3800. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3801. /**
  3802. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3803. * @param yaw defines the rotation around Y axis
  3804. * @param pitch defines the rotation around X axis
  3805. * @param roll defines the rotation around Z axis
  3806. * @param result defines the target quaternion
  3807. */
  3808. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3817. /**
  3818. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3819. * @param alpha defines the rotation around first axis
  3820. * @param beta defines the rotation around second axis
  3821. * @param gamma defines the rotation around third axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3825. /**
  3826. * 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)
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3833. /**
  3834. * 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
  3835. * @param axis1 defines the first axis
  3836. * @param axis2 defines the second axis
  3837. * @param axis3 defines the third axis
  3838. * @param ref defines the target quaternion
  3839. */
  3840. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3841. /**
  3842. * Interpolates between two quaternions
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @returns the new interpolated quaternion
  3847. */
  3848. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3849. /**
  3850. * Interpolates between two quaternions and stores it into a target quaternion
  3851. * @param left defines first quaternion
  3852. * @param right defines second quaternion
  3853. * @param amount defines the gradient to use
  3854. * @param result defines the target quaternion
  3855. */
  3856. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3857. /**
  3858. * Interpolate between two quaternions using Hermite interpolation
  3859. * @param value1 defines first quaternion
  3860. * @param tangent1 defines the incoming tangent
  3861. * @param value2 defines second quaternion
  3862. * @param tangent2 defines the outgoing tangent
  3863. * @param amount defines the target quaternion
  3864. * @returns the new interpolated quaternion
  3865. */
  3866. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3867. }
  3868. /**
  3869. * Class used to store matrix data (4x4)
  3870. */
  3871. export class Matrix {
  3872. private static _updateFlagSeed;
  3873. private static _identityReadOnly;
  3874. private _isIdentity;
  3875. private _isIdentityDirty;
  3876. private _isIdentity3x2;
  3877. private _isIdentity3x2Dirty;
  3878. /**
  3879. * Gets the update flag of the matrix which is an unique number for the matrix.
  3880. * It will be incremented every time the matrix data change.
  3881. * You can use it to speed the comparison between two versions of the same matrix.
  3882. */
  3883. updateFlag: number;
  3884. private readonly _m;
  3885. /**
  3886. * Gets the internal data of the matrix
  3887. */
  3888. get m(): DeepImmutable<Float32Array>;
  3889. /** @hidden */
  3890. _markAsUpdated(): void;
  3891. /** @hidden */
  3892. private _updateIdentityStatus;
  3893. /**
  3894. * Creates an empty matrix (filled with zeros)
  3895. */
  3896. constructor();
  3897. /**
  3898. * Check if the current matrix is identity
  3899. * @returns true is the matrix is the identity matrix
  3900. */
  3901. isIdentity(): boolean;
  3902. /**
  3903. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3904. * @returns true is the matrix is the identity matrix
  3905. */
  3906. isIdentityAs3x2(): boolean;
  3907. /**
  3908. * Gets the determinant of the matrix
  3909. * @returns the matrix determinant
  3910. */
  3911. determinant(): number;
  3912. /**
  3913. * Returns the matrix as a Float32Array
  3914. * @returns the matrix underlying array
  3915. */
  3916. toArray(): DeepImmutable<Float32Array>;
  3917. /**
  3918. * Returns the matrix as a Float32Array
  3919. * @returns the matrix underlying array.
  3920. */
  3921. asArray(): DeepImmutable<Float32Array>;
  3922. /**
  3923. * Inverts the current matrix in place
  3924. * @returns the current inverted matrix
  3925. */
  3926. invert(): Matrix;
  3927. /**
  3928. * Sets all the matrix elements to zero
  3929. * @returns the current matrix
  3930. */
  3931. reset(): Matrix;
  3932. /**
  3933. * Adds the current matrix with a second one
  3934. * @param other defines the matrix to add
  3935. * @returns a new matrix as the addition of the current matrix and the given one
  3936. */
  3937. add(other: DeepImmutable<Matrix>): Matrix;
  3938. /**
  3939. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3940. * @param other defines the matrix to add
  3941. * @param result defines the target matrix
  3942. * @returns the current matrix
  3943. */
  3944. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3945. /**
  3946. * Adds in place the given matrix to the current matrix
  3947. * @param other defines the second operand
  3948. * @returns the current updated matrix
  3949. */
  3950. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3951. /**
  3952. * Sets the given matrix to the current inverted Matrix
  3953. * @param other defines the target matrix
  3954. * @returns the unmodified current matrix
  3955. */
  3956. invertToRef(other: Matrix): Matrix;
  3957. /**
  3958. * add a value at the specified position in the current Matrix
  3959. * @param index the index of the value within the matrix. between 0 and 15.
  3960. * @param value the value to be added
  3961. * @returns the current updated matrix
  3962. */
  3963. addAtIndex(index: number, value: number): Matrix;
  3964. /**
  3965. * mutiply the specified position in the current Matrix by a value
  3966. * @param index the index of the value within the matrix. between 0 and 15.
  3967. * @param value the value to be added
  3968. * @returns the current updated matrix
  3969. */
  3970. multiplyAtIndex(index: number, value: number): Matrix;
  3971. /**
  3972. * Inserts the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Adds the translation vector (using 3 floats) in the current matrix
  3981. * @param x defines the 1st component of the translation
  3982. * @param y defines the 2nd component of the translation
  3983. * @param z defines the 3rd component of the translation
  3984. * @returns the current updated matrix
  3985. */
  3986. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector in the current matrix
  3989. * @param vector3 defines the translation to insert
  3990. * @returns the current updated matrix
  3991. */
  3992. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3993. /**
  3994. * Gets the translation value of the current matrix
  3995. * @returns a new Vector3 as the extracted translation from the matrix
  3996. */
  3997. getTranslation(): Vector3;
  3998. /**
  3999. * Fill a Vector3 with the extracted translation from the matrix
  4000. * @param result defines the Vector3 where to store the translation
  4001. * @returns the current matrix
  4002. */
  4003. getTranslationToRef(result: Vector3): Matrix;
  4004. /**
  4005. * Remove rotation and scaling part from the matrix
  4006. * @returns the updated matrix
  4007. */
  4008. removeRotationAndScaling(): Matrix;
  4009. /**
  4010. * Multiply two matrices
  4011. * @param other defines the second operand
  4012. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4013. */
  4014. multiply(other: DeepImmutable<Matrix>): Matrix;
  4015. /**
  4016. * Copy the current matrix from the given one
  4017. * @param other defines the source matrix
  4018. * @returns the current updated matrix
  4019. */
  4020. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4021. /**
  4022. * Populates the given array from the starting index with the current matrix values
  4023. * @param array defines the target array
  4024. * @param offset defines the offset in the target array where to start storing values
  4025. * @returns the current matrix
  4026. */
  4027. copyToArray(array: Float32Array, offset?: number): Matrix;
  4028. /**
  4029. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4030. * @param other defines the second operand
  4031. * @param result defines the matrix where to store the multiplication
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4035. /**
  4036. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4037. * @param other defines the second operand
  4038. * @param result defines the array where to store the multiplication
  4039. * @param offset defines the offset in the target array where to start storing values
  4040. * @returns the current matrix
  4041. */
  4042. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4043. /**
  4044. * Check equality between this matrix and a second one
  4045. * @param value defines the second matrix to compare
  4046. * @returns true is the current matrix and the given one values are strictly equal
  4047. */
  4048. equals(value: DeepImmutable<Matrix>): boolean;
  4049. /**
  4050. * Clone the current matrix
  4051. * @returns a new matrix from the current matrix
  4052. */
  4053. clone(): Matrix;
  4054. /**
  4055. * Returns the name of the current matrix class
  4056. * @returns the string "Matrix"
  4057. */
  4058. getClassName(): string;
  4059. /**
  4060. * Gets the hash code of the current matrix
  4061. * @returns the hash code
  4062. */
  4063. getHashCode(): number;
  4064. /**
  4065. * Decomposes the current Matrix into a translation, rotation and scaling components
  4066. * @param scale defines the scale vector3 given as a reference to update
  4067. * @param rotation defines the rotation quaternion given as a reference to update
  4068. * @param translation defines the translation vector3 given as a reference to update
  4069. * @returns true if operation was successful
  4070. */
  4071. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4072. /**
  4073. * Gets specific row of the matrix
  4074. * @param index defines the number of the row to get
  4075. * @returns the index-th row of the current matrix as a new Vector4
  4076. */
  4077. getRow(index: number): Nullable<Vector4>;
  4078. /**
  4079. * Sets the index-th row of the current matrix to the vector4 values
  4080. * @param index defines the number of the row to set
  4081. * @param row defines the target vector4
  4082. * @returns the updated current matrix
  4083. */
  4084. setRow(index: number, row: Vector4): Matrix;
  4085. /**
  4086. * Compute the transpose of the matrix
  4087. * @returns the new transposed matrix
  4088. */
  4089. transpose(): Matrix;
  4090. /**
  4091. * Compute the transpose of the matrix and store it in a given matrix
  4092. * @param result defines the target matrix
  4093. * @returns the current matrix
  4094. */
  4095. transposeToRef(result: Matrix): Matrix;
  4096. /**
  4097. * Sets the index-th row of the current matrix with the given 4 x float values
  4098. * @param index defines the row index
  4099. * @param x defines the x component to set
  4100. * @param y defines the y component to set
  4101. * @param z defines the z component to set
  4102. * @param w defines the w component to set
  4103. * @returns the updated current matrix
  4104. */
  4105. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4106. /**
  4107. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4108. * @param scale defines the scale factor
  4109. * @returns a new matrix
  4110. */
  4111. scale(scale: number): Matrix;
  4112. /**
  4113. * Scale the current matrix values by a factor to a given result matrix
  4114. * @param scale defines the scale factor
  4115. * @param result defines the matrix to store the result
  4116. * @returns the current matrix
  4117. */
  4118. scaleToRef(scale: number, result: Matrix): Matrix;
  4119. /**
  4120. * Scale the current matrix values by a factor and add the result to a given matrix
  4121. * @param scale defines the scale factor
  4122. * @param result defines the Matrix to store the result
  4123. * @returns the current matrix
  4124. */
  4125. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4126. /**
  4127. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4128. * @param ref matrix to store the result
  4129. */
  4130. toNormalMatrix(ref: Matrix): void;
  4131. /**
  4132. * Gets only rotation part of the current matrix
  4133. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4134. */
  4135. getRotationMatrix(): Matrix;
  4136. /**
  4137. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4138. * @param result defines the target matrix to store data to
  4139. * @returns the current matrix
  4140. */
  4141. getRotationMatrixToRef(result: Matrix): Matrix;
  4142. /**
  4143. * Toggles model matrix from being right handed to left handed in place and vice versa
  4144. */
  4145. toggleModelMatrixHandInPlace(): void;
  4146. /**
  4147. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4148. */
  4149. toggleProjectionMatrixHandInPlace(): void;
  4150. /**
  4151. * Creates a matrix from an array
  4152. * @param array defines the source array
  4153. * @param offset defines an offset in the source array
  4154. * @returns a new Matrix set from the starting index of the given array
  4155. */
  4156. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4157. /**
  4158. * Copy the content of an array into a given matrix
  4159. * @param array defines the source array
  4160. * @param offset defines an offset in the source array
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4164. /**
  4165. * Stores an array into a matrix after having multiplied each component by a given factor
  4166. * @param array defines the source array
  4167. * @param offset defines the offset in the source array
  4168. * @param scale defines the scaling factor
  4169. * @param result defines the target matrix
  4170. */
  4171. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4172. /**
  4173. * Gets an identity matrix that must not be updated
  4174. */
  4175. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4176. /**
  4177. * Stores a list of values (16) inside a given matrix
  4178. * @param initialM11 defines 1st value of 1st row
  4179. * @param initialM12 defines 2nd value of 1st row
  4180. * @param initialM13 defines 3rd value of 1st row
  4181. * @param initialM14 defines 4th value of 1st row
  4182. * @param initialM21 defines 1st value of 2nd row
  4183. * @param initialM22 defines 2nd value of 2nd row
  4184. * @param initialM23 defines 3rd value of 2nd row
  4185. * @param initialM24 defines 4th value of 2nd row
  4186. * @param initialM31 defines 1st value of 3rd row
  4187. * @param initialM32 defines 2nd value of 3rd row
  4188. * @param initialM33 defines 3rd value of 3rd row
  4189. * @param initialM34 defines 4th value of 3rd row
  4190. * @param initialM41 defines 1st value of 4th row
  4191. * @param initialM42 defines 2nd value of 4th row
  4192. * @param initialM43 defines 3rd value of 4th row
  4193. * @param initialM44 defines 4th value of 4th row
  4194. * @param result defines the target matrix
  4195. */
  4196. 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;
  4197. /**
  4198. * Creates new matrix from a list of values (16)
  4199. * @param initialM11 defines 1st value of 1st row
  4200. * @param initialM12 defines 2nd value of 1st row
  4201. * @param initialM13 defines 3rd value of 1st row
  4202. * @param initialM14 defines 4th value of 1st row
  4203. * @param initialM21 defines 1st value of 2nd row
  4204. * @param initialM22 defines 2nd value of 2nd row
  4205. * @param initialM23 defines 3rd value of 2nd row
  4206. * @param initialM24 defines 4th value of 2nd row
  4207. * @param initialM31 defines 1st value of 3rd row
  4208. * @param initialM32 defines 2nd value of 3rd row
  4209. * @param initialM33 defines 3rd value of 3rd row
  4210. * @param initialM34 defines 4th value of 3rd row
  4211. * @param initialM41 defines 1st value of 4th row
  4212. * @param initialM42 defines 2nd value of 4th row
  4213. * @param initialM43 defines 3rd value of 4th row
  4214. * @param initialM44 defines 4th value of 4th row
  4215. * @returns the new matrix
  4216. */
  4217. 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;
  4218. /**
  4219. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @returns a new matrix
  4224. */
  4225. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4226. /**
  4227. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4228. * @param scale defines the scale vector3
  4229. * @param rotation defines the rotation quaternion
  4230. * @param translation defines the translation vector3
  4231. * @param result defines the target matrix
  4232. */
  4233. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4234. /**
  4235. * Creates a new identity matrix
  4236. * @returns a new identity matrix
  4237. */
  4238. static Identity(): Matrix;
  4239. /**
  4240. * Creates a new identity matrix and stores the result in a given matrix
  4241. * @param result defines the target matrix
  4242. */
  4243. static IdentityToRef(result: Matrix): void;
  4244. /**
  4245. * Creates a new zero matrix
  4246. * @returns a new zero matrix
  4247. */
  4248. static Zero(): Matrix;
  4249. /**
  4250. * Creates a new rotation matrix for "angle" radians around the X axis
  4251. * @param angle defines the angle (in radians) to use
  4252. * @return the new matrix
  4253. */
  4254. static RotationX(angle: number): Matrix;
  4255. /**
  4256. * Creates a new matrix as the invert of a given matrix
  4257. * @param source defines the source matrix
  4258. * @returns the new matrix
  4259. */
  4260. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4263. * @param angle defines the angle (in radians) to use
  4264. * @param result defines the target matrix
  4265. */
  4266. static RotationXToRef(angle: number, result: Matrix): void;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Y axis
  4269. * @param angle defines the angle (in radians) to use
  4270. * @return the new matrix
  4271. */
  4272. static RotationY(angle: number): Matrix;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4275. * @param angle defines the angle (in radians) to use
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationYToRef(angle: number, result: Matrix): void;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the Z axis
  4281. * @param angle defines the angle (in radians) to use
  4282. * @return the new matrix
  4283. */
  4284. static RotationZ(angle: number): Matrix;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4287. * @param angle defines the angle (in radians) to use
  4288. * @param result defines the target matrix
  4289. */
  4290. static RotationZToRef(angle: number, result: Matrix): void;
  4291. /**
  4292. * Creates a new rotation matrix for "angle" radians around the given axis
  4293. * @param axis defines the axis to use
  4294. * @param angle defines the angle (in radians) to use
  4295. * @return the new matrix
  4296. */
  4297. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4298. /**
  4299. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4300. * @param axis defines the axis to use
  4301. * @param angle defines the angle (in radians) to use
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4305. /**
  4306. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4307. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4308. * @param from defines the vector to align
  4309. * @param to defines the vector to align to
  4310. * @param result defines the target matrix
  4311. */
  4312. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4313. /**
  4314. * Creates a rotation matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @returns the new rotation matrix
  4319. */
  4320. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4321. /**
  4322. * Creates a rotation matrix and stores it in a given matrix
  4323. * @param yaw defines the yaw angle in radians (Y axis)
  4324. * @param pitch defines the pitch angle in radians (X axis)
  4325. * @param roll defines the roll angle in radians (X axis)
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4329. /**
  4330. * Creates a scaling matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @returns the new matrix
  4335. */
  4336. static Scaling(x: number, y: number, z: number): Matrix;
  4337. /**
  4338. * Creates a scaling matrix and stores it in a given matrix
  4339. * @param x defines the scale factor on X axis
  4340. * @param y defines the scale factor on Y axis
  4341. * @param z defines the scale factor on Z axis
  4342. * @param result defines the target matrix
  4343. */
  4344. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4345. /**
  4346. * Creates a translation matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Translation(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a translation matrix and stores it in a given matrix
  4355. * @param x defines the translation on X axis
  4356. * @param y defines the translation on Y axis
  4357. * @param z defines the translationon Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @returns the new matrix
  4367. */
  4368. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4369. /**
  4370. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4371. * @param startValue defines the start value
  4372. * @param endValue defines the end value
  4373. * @param gradient defines the gradient factor
  4374. * @param result defines the Matrix object where to store data
  4375. */
  4376. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4377. /**
  4378. * Builds a new matrix whose values are computed by:
  4379. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4380. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4381. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4382. * @param startValue defines the first matrix
  4383. * @param endValue defines the second matrix
  4384. * @param gradient defines the gradient between the two matrices
  4385. * @returns the new matrix
  4386. */
  4387. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4388. /**
  4389. * Update a matrix to values which are computed by:
  4390. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4391. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4392. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4393. * @param startValue defines the first matrix
  4394. * @param endValue defines the second matrix
  4395. * @param gradient defines the gradient between the two matrices
  4396. * @param result defines the target matrix
  4397. */
  4398. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4399. /**
  4400. * 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"
  4401. * This function works in left handed mode
  4402. * @param eye defines the final position of the entity
  4403. * @param target defines where the entity should look at
  4404. * @param up defines the up vector for the entity
  4405. * @returns the new matrix
  4406. */
  4407. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4408. /**
  4409. * 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".
  4410. * This function works in left handed mode
  4411. * @param eye defines the final position of the entity
  4412. * @param target defines where the entity should look at
  4413. * @param up defines the up vector for the entity
  4414. * @param result defines the target matrix
  4415. */
  4416. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4417. /**
  4418. * 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"
  4419. * This function works in right handed mode
  4420. * @param eye defines the final position of the entity
  4421. * @param target defines where the entity should look at
  4422. * @param up defines the up vector for the entity
  4423. * @returns the new matrix
  4424. */
  4425. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4426. /**
  4427. * 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".
  4428. * This function works in right handed mode
  4429. * @param eye defines the final position of the entity
  4430. * @param target defines where the entity should look at
  4431. * @param up defines the up vector for the entity
  4432. * @param result defines the target matrix
  4433. */
  4434. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4435. /**
  4436. * Create a left-handed orthographic projection matrix
  4437. * @param width defines the viewport width
  4438. * @param height defines the viewport height
  4439. * @param znear defines the near clip plane
  4440. * @param zfar defines the far clip plane
  4441. * @returns a new matrix as a left-handed orthographic projection matrix
  4442. */
  4443. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4444. /**
  4445. * Store a left-handed orthographic projection to a given matrix
  4446. * @param width defines the viewport width
  4447. * @param height defines the viewport height
  4448. * @param znear defines the near clip plane
  4449. * @param zfar defines the far clip plane
  4450. * @param result defines the target matrix
  4451. */
  4452. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4453. /**
  4454. * Create a left-handed orthographic projection matrix
  4455. * @param left defines the viewport left coordinate
  4456. * @param right defines the viewport right coordinate
  4457. * @param bottom defines the viewport bottom coordinate
  4458. * @param top defines the viewport top coordinate
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @returns a new matrix as a left-handed orthographic projection matrix
  4462. */
  4463. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4464. /**
  4465. * Stores a left-handed orthographic projection into a given matrix
  4466. * @param left defines the viewport left coordinate
  4467. * @param right defines the viewport right coordinate
  4468. * @param bottom defines the viewport bottom coordinate
  4469. * @param top defines the viewport top coordinate
  4470. * @param znear defines the near clip plane
  4471. * @param zfar defines the far clip plane
  4472. * @param result defines the target matrix
  4473. */
  4474. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4475. /**
  4476. * Creates a right-handed orthographic projection matrix
  4477. * @param left defines the viewport left coordinate
  4478. * @param right defines the viewport right coordinate
  4479. * @param bottom defines the viewport bottom coordinate
  4480. * @param top defines the viewport top coordinate
  4481. * @param znear defines the near clip plane
  4482. * @param zfar defines the far clip plane
  4483. * @returns a new matrix as a right-handed orthographic projection matrix
  4484. */
  4485. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4486. /**
  4487. * Stores a right-handed orthographic projection into a given matrix
  4488. * @param left defines the viewport left coordinate
  4489. * @param right defines the viewport right coordinate
  4490. * @param bottom defines the viewport bottom coordinate
  4491. * @param top defines the viewport top coordinate
  4492. * @param znear defines the near clip plane
  4493. * @param zfar defines the far clip plane
  4494. * @param result defines the target matrix
  4495. */
  4496. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4497. /**
  4498. * Creates a left-handed perspective projection matrix
  4499. * @param width defines the viewport width
  4500. * @param height defines the viewport height
  4501. * @param znear defines the near clip plane
  4502. * @param zfar defines the far clip plane
  4503. * @returns a new matrix as a left-handed perspective projection matrix
  4504. */
  4505. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4506. /**
  4507. * Creates a left-handed perspective projection matrix
  4508. * @param fov defines the horizontal field of view
  4509. * @param aspect defines the aspect ratio
  4510. * @param znear defines the near clip plane
  4511. * @param zfar defines the far clip plane
  4512. * @returns a new matrix as a left-handed perspective projection matrix
  4513. */
  4514. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4515. /**
  4516. * Stores a left-handed perspective projection into a given matrix
  4517. * @param fov defines the horizontal field of view
  4518. * @param aspect defines the aspect ratio
  4519. * @param znear defines the near clip plane
  4520. * @param zfar defines the far clip plane
  4521. * @param result defines the target matrix
  4522. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4523. */
  4524. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4525. /**
  4526. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4527. * @param fov defines the horizontal field of view
  4528. * @param aspect defines the aspect ratio
  4529. * @param znear defines the near clip plane
  4530. * @param zfar not used as infinity is used as far clip
  4531. * @param result defines the target matrix
  4532. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4533. */
  4534. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4535. /**
  4536. * Creates a right-handed perspective projection matrix
  4537. * @param fov defines the horizontal field of view
  4538. * @param aspect defines the aspect ratio
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @returns a new matrix as a right-handed perspective projection matrix
  4542. */
  4543. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4544. /**
  4545. * Stores a right-handed perspective projection into a given matrix
  4546. * @param fov defines the horizontal field of view
  4547. * @param aspect defines the aspect ratio
  4548. * @param znear defines the near clip plane
  4549. * @param zfar defines the far clip plane
  4550. * @param result defines the target matrix
  4551. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4552. */
  4553. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4554. /**
  4555. * Stores a right-handed perspective projection into a given matrix
  4556. * @param fov defines the horizontal field of view
  4557. * @param aspect defines the aspect ratio
  4558. * @param znear defines the near clip plane
  4559. * @param zfar not used as infinity is used as far clip
  4560. * @param result defines the target matrix
  4561. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4562. */
  4563. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4564. /**
  4565. * Stores a perspective projection for WebVR info a given matrix
  4566. * @param fov defines the field of view
  4567. * @param znear defines the near clip plane
  4568. * @param zfar defines the far clip plane
  4569. * @param result defines the target matrix
  4570. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4571. */
  4572. static PerspectiveFovWebVRToRef(fov: {
  4573. upDegrees: number;
  4574. downDegrees: number;
  4575. leftDegrees: number;
  4576. rightDegrees: number;
  4577. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4578. /**
  4579. * Computes a complete transformation matrix
  4580. * @param viewport defines the viewport to use
  4581. * @param world defines the world matrix
  4582. * @param view defines the view matrix
  4583. * @param projection defines the projection matrix
  4584. * @param zmin defines the near clip plane
  4585. * @param zmax defines the far clip plane
  4586. * @returns the transformation matrix
  4587. */
  4588. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4589. /**
  4590. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4591. * @param matrix defines the matrix to use
  4592. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4593. */
  4594. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4595. /**
  4596. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4597. * @param matrix defines the matrix to use
  4598. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4599. */
  4600. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4601. /**
  4602. * Compute the transpose of a given matrix
  4603. * @param matrix defines the matrix to transpose
  4604. * @returns the new matrix
  4605. */
  4606. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4607. /**
  4608. * Compute the transpose of a matrix and store it in a target matrix
  4609. * @param matrix defines the matrix to transpose
  4610. * @param result defines the target matrix
  4611. */
  4612. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4613. /**
  4614. * Computes a reflection matrix from a plane
  4615. * @param plane defines the reflection plane
  4616. * @returns a new matrix
  4617. */
  4618. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4619. /**
  4620. * Computes a reflection matrix from a plane
  4621. * @param plane defines the reflection plane
  4622. * @param result defines the target matrix
  4623. */
  4624. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4625. /**
  4626. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4627. * @param xaxis defines the value of the 1st axis
  4628. * @param yaxis defines the value of the 2nd axis
  4629. * @param zaxis defines the value of the 3rd axis
  4630. * @param result defines the target matrix
  4631. */
  4632. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4635. * @param quat defines the quaternion to use
  4636. * @param result defines the target matrix
  4637. */
  4638. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4639. }
  4640. /**
  4641. * @hidden
  4642. */
  4643. export class TmpVectors {
  4644. static Vector2: Vector2[];
  4645. static Vector3: Vector3[];
  4646. static Vector4: Vector4[];
  4647. static Quaternion: Quaternion[];
  4648. static Matrix: Matrix[];
  4649. }
  4650. }
  4651. declare module "babylonjs/Maths/math.path" {
  4652. import { DeepImmutable, Nullable } from "babylonjs/types";
  4653. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4654. /**
  4655. * Defines potential orientation for back face culling
  4656. */
  4657. export enum Orientation {
  4658. /**
  4659. * Clockwise
  4660. */
  4661. CW = 0,
  4662. /** Counter clockwise */
  4663. CCW = 1
  4664. }
  4665. /** Class used to represent a Bezier curve */
  4666. export class BezierCurve {
  4667. /**
  4668. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4669. * @param t defines the time
  4670. * @param x1 defines the left coordinate on X axis
  4671. * @param y1 defines the left coordinate on Y axis
  4672. * @param x2 defines the right coordinate on X axis
  4673. * @param y2 defines the right coordinate on Y axis
  4674. * @returns the interpolated value
  4675. */
  4676. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4677. }
  4678. /**
  4679. * Defines angle representation
  4680. */
  4681. export class Angle {
  4682. private _radians;
  4683. /**
  4684. * Creates an Angle object of "radians" radians (float).
  4685. * @param radians the angle in radians
  4686. */
  4687. constructor(radians: number);
  4688. /**
  4689. * Get value in degrees
  4690. * @returns the Angle value in degrees (float)
  4691. */
  4692. degrees(): number;
  4693. /**
  4694. * Get value in radians
  4695. * @returns the Angle value in radians (float)
  4696. */
  4697. radians(): number;
  4698. /**
  4699. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4700. * @param a defines first vector
  4701. * @param b defines second vector
  4702. * @returns a new Angle
  4703. */
  4704. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4705. /**
  4706. * Gets a new Angle object from the given float in radians
  4707. * @param radians defines the angle value in radians
  4708. * @returns a new Angle
  4709. */
  4710. static FromRadians(radians: number): Angle;
  4711. /**
  4712. * Gets a new Angle object from the given float in degrees
  4713. * @param degrees defines the angle value in degrees
  4714. * @returns a new Angle
  4715. */
  4716. static FromDegrees(degrees: number): Angle;
  4717. }
  4718. /**
  4719. * This represents an arc in a 2d space.
  4720. */
  4721. export class Arc2 {
  4722. /** Defines the start point of the arc */
  4723. startPoint: Vector2;
  4724. /** Defines the mid point of the arc */
  4725. midPoint: Vector2;
  4726. /** Defines the end point of the arc */
  4727. endPoint: Vector2;
  4728. /**
  4729. * Defines the center point of the arc.
  4730. */
  4731. centerPoint: Vector2;
  4732. /**
  4733. * Defines the radius of the arc.
  4734. */
  4735. radius: number;
  4736. /**
  4737. * Defines the angle of the arc (from mid point to end point).
  4738. */
  4739. angle: Angle;
  4740. /**
  4741. * Defines the start angle of the arc (from start point to middle point).
  4742. */
  4743. startAngle: Angle;
  4744. /**
  4745. * Defines the orientation of the arc (clock wise/counter clock wise).
  4746. */
  4747. orientation: Orientation;
  4748. /**
  4749. * Creates an Arc object from the three given points : start, middle and end.
  4750. * @param startPoint Defines the start point of the arc
  4751. * @param midPoint Defines the midlle point of the arc
  4752. * @param endPoint Defines the end point of the arc
  4753. */
  4754. constructor(
  4755. /** Defines the start point of the arc */
  4756. startPoint: Vector2,
  4757. /** Defines the mid point of the arc */
  4758. midPoint: Vector2,
  4759. /** Defines the end point of the arc */
  4760. endPoint: Vector2);
  4761. }
  4762. /**
  4763. * Represents a 2D path made up of multiple 2D points
  4764. */
  4765. export class Path2 {
  4766. private _points;
  4767. private _length;
  4768. /**
  4769. * If the path start and end point are the same
  4770. */
  4771. closed: boolean;
  4772. /**
  4773. * Creates a Path2 object from the starting 2D coordinates x and y.
  4774. * @param x the starting points x value
  4775. * @param y the starting points y value
  4776. */
  4777. constructor(x: number, y: number);
  4778. /**
  4779. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4780. * @param x the added points x value
  4781. * @param y the added points y value
  4782. * @returns the updated Path2.
  4783. */
  4784. addLineTo(x: number, y: number): Path2;
  4785. /**
  4786. * 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.
  4787. * @param midX middle point x value
  4788. * @param midY middle point y value
  4789. * @param endX end point x value
  4790. * @param endY end point y value
  4791. * @param numberOfSegments (default: 36)
  4792. * @returns the updated Path2.
  4793. */
  4794. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4795. /**
  4796. * Closes the Path2.
  4797. * @returns the Path2.
  4798. */
  4799. close(): Path2;
  4800. /**
  4801. * Gets the sum of the distance between each sequential point in the path
  4802. * @returns the Path2 total length (float).
  4803. */
  4804. length(): number;
  4805. /**
  4806. * Gets the points which construct the path
  4807. * @returns the Path2 internal array of points.
  4808. */
  4809. getPoints(): Vector2[];
  4810. /**
  4811. * Retreives the point at the distance aways from the starting point
  4812. * @param normalizedLengthPosition the length along the path to retreive the point from
  4813. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4814. */
  4815. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4816. /**
  4817. * Creates a new path starting from an x and y position
  4818. * @param x starting x value
  4819. * @param y starting y value
  4820. * @returns a new Path2 starting at the coordinates (x, y).
  4821. */
  4822. static StartingAt(x: number, y: number): Path2;
  4823. }
  4824. /**
  4825. * Represents a 3D path made up of multiple 3D points
  4826. */
  4827. export class Path3D {
  4828. /**
  4829. * an array of Vector3, the curve axis of the Path3D
  4830. */
  4831. path: Vector3[];
  4832. private _curve;
  4833. private _distances;
  4834. private _tangents;
  4835. private _normals;
  4836. private _binormals;
  4837. private _raw;
  4838. private _alignTangentsWithPath;
  4839. private readonly _pointAtData;
  4840. /**
  4841. * new Path3D(path, normal, raw)
  4842. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4843. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4844. * @param path an array of Vector3, the curve axis of the Path3D
  4845. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4846. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4847. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4848. */
  4849. constructor(
  4850. /**
  4851. * an array of Vector3, the curve axis of the Path3D
  4852. */
  4853. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4854. /**
  4855. * Returns the Path3D array of successive Vector3 designing its curve.
  4856. * @returns the Path3D array of successive Vector3 designing its curve.
  4857. */
  4858. getCurve(): Vector3[];
  4859. /**
  4860. * Returns the Path3D array of successive Vector3 designing its curve.
  4861. * @returns the Path3D array of successive Vector3 designing its curve.
  4862. */
  4863. getPoints(): Vector3[];
  4864. /**
  4865. * @returns the computed length (float) of the path.
  4866. */
  4867. length(): number;
  4868. /**
  4869. * Returns an array populated with tangent vectors on each Path3D curve point.
  4870. * @returns an array populated with tangent vectors on each Path3D curve point.
  4871. */
  4872. getTangents(): Vector3[];
  4873. /**
  4874. * Returns an array populated with normal vectors on each Path3D curve point.
  4875. * @returns an array populated with normal vectors on each Path3D curve point.
  4876. */
  4877. getNormals(): Vector3[];
  4878. /**
  4879. * Returns an array populated with binormal vectors on each Path3D curve point.
  4880. * @returns an array populated with binormal vectors on each Path3D curve point.
  4881. */
  4882. getBinormals(): Vector3[];
  4883. /**
  4884. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4885. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4886. */
  4887. getDistances(): number[];
  4888. /**
  4889. * Returns an interpolated point along this path
  4890. * @param position the position of the point along this path, from 0.0 to 1.0
  4891. * @returns a new Vector3 as the point
  4892. */
  4893. getPointAt(position: number): Vector3;
  4894. /**
  4895. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4896. * @param position the position of the point along this path, from 0.0 to 1.0
  4897. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4898. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4899. */
  4900. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4901. /**
  4902. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4903. * @param position the position of the point along this path, from 0.0 to 1.0
  4904. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4905. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4906. */
  4907. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4908. /**
  4909. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4910. * @param position the position of the point along this path, from 0.0 to 1.0
  4911. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4912. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4913. */
  4914. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4915. /**
  4916. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4917. * @param position the position of the point along this path, from 0.0 to 1.0
  4918. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4919. */
  4920. getDistanceAt(position: number): number;
  4921. /**
  4922. * Returns the array index of the previous point of an interpolated point along this path
  4923. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4924. * @returns the array index
  4925. */
  4926. getPreviousPointIndexAt(position: number): number;
  4927. /**
  4928. * 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)
  4929. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4930. * @returns the sub position
  4931. */
  4932. getSubPositionAt(position: number): number;
  4933. /**
  4934. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4935. * @param target the vector of which to get the closest position to
  4936. * @returns the position of the closest virtual point on this path to the target vector
  4937. */
  4938. getClosestPositionTo(target: Vector3): number;
  4939. /**
  4940. * Returns a sub path (slice) of this path
  4941. * @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
  4942. * @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
  4943. * @returns a sub path (slice) of this path
  4944. */
  4945. slice(start?: number, end?: number): Path3D;
  4946. /**
  4947. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4948. * @param path path which all values are copied into the curves points
  4949. * @param firstNormal which should be projected onto the curve
  4950. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4951. * @returns the same object updated.
  4952. */
  4953. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4954. private _compute;
  4955. private _getFirstNonNullVector;
  4956. private _getLastNonNullVector;
  4957. private _normalVector;
  4958. /**
  4959. * Updates the point at data for an interpolated point along this curve
  4960. * @param position the position of the point along this curve, from 0.0 to 1.0
  4961. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4962. * @returns the (updated) point at data
  4963. */
  4964. private _updatePointAtData;
  4965. /**
  4966. * Updates the point at data from the specified parameters
  4967. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4968. * @param point the interpolated point
  4969. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4970. */
  4971. private _setPointAtData;
  4972. /**
  4973. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4974. */
  4975. private _updateInterpolationMatrix;
  4976. }
  4977. /**
  4978. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4979. * A Curve3 is designed from a series of successive Vector3.
  4980. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4981. */
  4982. export class Curve3 {
  4983. private _points;
  4984. private _length;
  4985. /**
  4986. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4987. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4988. * @param v1 (Vector3) the control point
  4989. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4996. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4997. * @param v1 (Vector3) the first control point
  4998. * @param v2 (Vector3) the second control point
  4999. * @param v3 (Vector3) the end point of the Cubic Bezier
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5006. * @param p1 (Vector3) the origin point of the Hermite Spline
  5007. * @param t1 (Vector3) the tangent vector at the origin point
  5008. * @param p2 (Vector3) the end point of the Hermite Spline
  5009. * @param t2 (Vector3) the tangent vector at the end point
  5010. * @param nbPoints (integer) the wanted number of points in the curve
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5014. /**
  5015. * Returns a Curve3 object along a CatmullRom Spline curve :
  5016. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5017. * @param nbPoints (integer) the wanted number of points between each curve control points
  5018. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5019. * @returns the created Curve3
  5020. */
  5021. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5022. /**
  5023. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5024. * A Curve3 is designed from a series of successive Vector3.
  5025. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5026. * @param points points which make up the curve
  5027. */
  5028. constructor(points: Vector3[]);
  5029. /**
  5030. * @returns the Curve3 stored array of successive Vector3
  5031. */
  5032. getPoints(): Vector3[];
  5033. /**
  5034. * @returns the computed length (float) of the curve.
  5035. */
  5036. length(): number;
  5037. /**
  5038. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5039. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5040. * curveA and curveB keep unchanged.
  5041. * @param curve the curve to continue from this curve
  5042. * @returns the newly constructed curve
  5043. */
  5044. continue(curve: DeepImmutable<Curve3>): Curve3;
  5045. private _computeLength;
  5046. }
  5047. }
  5048. declare module "babylonjs/Animations/easing" {
  5049. /**
  5050. * This represents the main contract an easing function should follow.
  5051. * Easing functions are used throughout the animation system.
  5052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5053. */
  5054. export interface IEasingFunction {
  5055. /**
  5056. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5057. * of the easing function.
  5058. * The link below provides some of the most common examples of easing functions.
  5059. * @see https://easings.net/
  5060. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5061. * @returns the corresponding value on the curve defined by the easing function
  5062. */
  5063. ease(gradient: number): number;
  5064. }
  5065. /**
  5066. * Base class used for every default easing function.
  5067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5068. */
  5069. export class EasingFunction implements IEasingFunction {
  5070. /**
  5071. * Interpolation follows the mathematical formula associated with the easing function.
  5072. */
  5073. static readonly EASINGMODE_EASEIN: number;
  5074. /**
  5075. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5076. */
  5077. static readonly EASINGMODE_EASEOUT: number;
  5078. /**
  5079. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5080. */
  5081. static readonly EASINGMODE_EASEINOUT: number;
  5082. private _easingMode;
  5083. /**
  5084. * Sets the easing mode of the current function.
  5085. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5086. */
  5087. setEasingMode(easingMode: number): void;
  5088. /**
  5089. * Gets the current easing mode.
  5090. * @returns the easing mode
  5091. */
  5092. getEasingMode(): number;
  5093. /**
  5094. * @hidden
  5095. */
  5096. easeInCore(gradient: number): number;
  5097. /**
  5098. * Given an input gradient between 0 and 1, this returns the corresponding value
  5099. * of the easing function.
  5100. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5101. * @returns the corresponding value on the curve defined by the easing function
  5102. */
  5103. ease(gradient: number): number;
  5104. }
  5105. /**
  5106. * Easing function with a circle shape (see link below).
  5107. * @see https://easings.net/#easeInCirc
  5108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5109. */
  5110. export class CircleEase extends EasingFunction implements IEasingFunction {
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a ease back shape (see link below).
  5116. * @see https://easings.net/#easeInBack
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BackEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the amplitude of the function */
  5121. amplitude: number;
  5122. /**
  5123. * Instantiates a back ease easing
  5124. * @see https://easings.net/#easeInBack
  5125. * @param amplitude Defines the amplitude of the function
  5126. */
  5127. constructor(
  5128. /** Defines the amplitude of the function */
  5129. amplitude?: number);
  5130. /** @hidden */
  5131. easeInCore(gradient: number): number;
  5132. }
  5133. /**
  5134. * Easing function with a bouncing shape (see link below).
  5135. * @see https://easings.net/#easeInBounce
  5136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5137. */
  5138. export class BounceEase extends EasingFunction implements IEasingFunction {
  5139. /** Defines the number of bounces */
  5140. bounces: number;
  5141. /** Defines the amplitude of the bounce */
  5142. bounciness: number;
  5143. /**
  5144. * Instantiates a bounce easing
  5145. * @see https://easings.net/#easeInBounce
  5146. * @param bounces Defines the number of bounces
  5147. * @param bounciness Defines the amplitude of the bounce
  5148. */
  5149. constructor(
  5150. /** Defines the number of bounces */
  5151. bounces?: number,
  5152. /** Defines the amplitude of the bounce */
  5153. bounciness?: number);
  5154. /** @hidden */
  5155. easeInCore(gradient: number): number;
  5156. }
  5157. /**
  5158. * Easing function with a power of 3 shape (see link below).
  5159. * @see https://easings.net/#easeInCubic
  5160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5161. */
  5162. export class CubicEase extends EasingFunction implements IEasingFunction {
  5163. /** @hidden */
  5164. easeInCore(gradient: number): number;
  5165. }
  5166. /**
  5167. * Easing function with an elastic shape (see link below).
  5168. * @see https://easings.net/#easeInElastic
  5169. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5170. */
  5171. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5172. /** Defines the number of oscillations*/
  5173. oscillations: number;
  5174. /** Defines the amplitude of the oscillations*/
  5175. springiness: number;
  5176. /**
  5177. * Instantiates an elastic easing function
  5178. * @see https://easings.net/#easeInElastic
  5179. * @param oscillations Defines the number of oscillations
  5180. * @param springiness Defines the amplitude of the oscillations
  5181. */
  5182. constructor(
  5183. /** Defines the number of oscillations*/
  5184. oscillations?: number,
  5185. /** Defines the amplitude of the oscillations*/
  5186. springiness?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with an exponential shape (see link below).
  5192. * @see https://easings.net/#easeInExpo
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the exponent of the function */
  5197. exponent: number;
  5198. /**
  5199. * Instantiates an exponential easing function
  5200. * @see https://easings.net/#easeInExpo
  5201. * @param exponent Defines the exponent of the function
  5202. */
  5203. constructor(
  5204. /** Defines the exponent of the function */
  5205. exponent?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class PowerEase extends EasingFunction implements IEasingFunction {
  5215. /** Defines the power of the function */
  5216. power: number;
  5217. /**
  5218. * Instantiates an power base easing function
  5219. * @see https://easings.net/#easeInQuad
  5220. * @param power Defines the power of the function
  5221. */
  5222. constructor(
  5223. /** Defines the power of the function */
  5224. power?: number);
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a power of 2 shape (see link below).
  5230. * @see https://easings.net/#easeInQuad
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5234. /** @hidden */
  5235. easeInCore(gradient: number): number;
  5236. }
  5237. /**
  5238. * Easing function with a power of 4 shape (see link below).
  5239. * @see https://easings.net/#easeInQuart
  5240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5241. */
  5242. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5243. /** @hidden */
  5244. easeInCore(gradient: number): number;
  5245. }
  5246. /**
  5247. * Easing function with a power of 5 shape (see link below).
  5248. * @see https://easings.net/#easeInQuint
  5249. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5250. */
  5251. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a sin shape (see link below).
  5257. * @see https://easings.net/#easeInSine
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class SineEase extends EasingFunction implements IEasingFunction {
  5261. /** @hidden */
  5262. easeInCore(gradient: number): number;
  5263. }
  5264. /**
  5265. * Easing function with a bezier shape (see link below).
  5266. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5270. /** Defines the x component of the start tangent in the bezier curve */
  5271. x1: number;
  5272. /** Defines the y component of the start tangent in the bezier curve */
  5273. y1: number;
  5274. /** Defines the x component of the end tangent in the bezier curve */
  5275. x2: number;
  5276. /** Defines the y component of the end tangent in the bezier curve */
  5277. y2: number;
  5278. /**
  5279. * Instantiates a bezier function
  5280. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5281. * @param x1 Defines the x component of the start tangent in the bezier curve
  5282. * @param y1 Defines the y component of the start tangent in the bezier curve
  5283. * @param x2 Defines the x component of the end tangent in the bezier curve
  5284. * @param y2 Defines the y component of the end tangent in the bezier curve
  5285. */
  5286. constructor(
  5287. /** Defines the x component of the start tangent in the bezier curve */
  5288. x1?: number,
  5289. /** Defines the y component of the start tangent in the bezier curve */
  5290. y1?: number,
  5291. /** Defines the x component of the end tangent in the bezier curve */
  5292. x2?: number,
  5293. /** Defines the y component of the end tangent in the bezier curve */
  5294. y2?: number);
  5295. /** @hidden */
  5296. easeInCore(gradient: number): number;
  5297. }
  5298. }
  5299. declare module "babylonjs/Maths/math.color" {
  5300. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5301. /**
  5302. * Class used to hold a RBG color
  5303. */
  5304. export class Color3 {
  5305. /**
  5306. * Defines the red component (between 0 and 1, default is 0)
  5307. */
  5308. r: number;
  5309. /**
  5310. * Defines the green component (between 0 and 1, default is 0)
  5311. */
  5312. g: number;
  5313. /**
  5314. * Defines the blue component (between 0 and 1, default is 0)
  5315. */
  5316. b: number;
  5317. /**
  5318. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5319. * @param r defines the red component (between 0 and 1, default is 0)
  5320. * @param g defines the green component (between 0 and 1, default is 0)
  5321. * @param b defines the blue component (between 0 and 1, default is 0)
  5322. */
  5323. constructor(
  5324. /**
  5325. * Defines the red component (between 0 and 1, default is 0)
  5326. */
  5327. r?: number,
  5328. /**
  5329. * Defines the green component (between 0 and 1, default is 0)
  5330. */
  5331. g?: number,
  5332. /**
  5333. * Defines the blue component (between 0 and 1, default is 0)
  5334. */
  5335. b?: number);
  5336. /**
  5337. * Creates a string with the Color3 current values
  5338. * @returns the string representation of the Color3 object
  5339. */
  5340. toString(): string;
  5341. /**
  5342. * Returns the string "Color3"
  5343. * @returns "Color3"
  5344. */
  5345. getClassName(): string;
  5346. /**
  5347. * Compute the Color3 hash code
  5348. * @returns an unique number that can be used to hash Color3 objects
  5349. */
  5350. getHashCode(): number;
  5351. /**
  5352. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5353. * @param array defines the array where to store the r,g,b components
  5354. * @param index defines an optional index in the target array to define where to start storing values
  5355. * @returns the current Color3 object
  5356. */
  5357. toArray(array: FloatArray, index?: number): Color3;
  5358. /**
  5359. * Returns a new Color4 object from the current Color3 and the given alpha
  5360. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5361. * @returns a new Color4 object
  5362. */
  5363. toColor4(alpha?: number): Color4;
  5364. /**
  5365. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5366. * @returns the new array
  5367. */
  5368. asArray(): number[];
  5369. /**
  5370. * Returns the luminance value
  5371. * @returns a float value
  5372. */
  5373. toLuminance(): number;
  5374. /**
  5375. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3 object
  5378. */
  5379. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines the Color3 object where to store the result
  5384. * @returns the current Color3
  5385. */
  5386. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Determines equality between Color3 objects
  5389. * @param otherColor defines the second operand
  5390. * @returns true if the rgb values are equal to the given ones
  5391. */
  5392. equals(otherColor: DeepImmutable<Color3>): boolean;
  5393. /**
  5394. * Determines equality between the current Color3 object and a set of r,b,g values
  5395. * @param r defines the red component to check
  5396. * @param g defines the green component to check
  5397. * @param b defines the blue component to check
  5398. * @returns true if the rgb values are equal to the given ones
  5399. */
  5400. equalsFloats(r: number, g: number, b: number): boolean;
  5401. /**
  5402. * Multiplies in place each rgb value by scale
  5403. * @param scale defines the scaling factor
  5404. * @returns the updated Color3
  5405. */
  5406. scale(scale: number): Color3;
  5407. /**
  5408. * Multiplies the rgb values by scale and stores the result into "result"
  5409. * @param scale defines the scaling factor
  5410. * @param result defines the Color3 object where to store the result
  5411. * @returns the unmodified current Color3
  5412. */
  5413. scaleToRef(scale: number, result: Color3): Color3;
  5414. /**
  5415. * Scale the current Color3 values by a factor and add the result to a given Color3
  5416. * @param scale defines the scale factor
  5417. * @param result defines color to store the result into
  5418. * @returns the unmodified current Color3
  5419. */
  5420. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5421. /**
  5422. * Clamps the rgb values by the min and max values and stores the result into "result"
  5423. * @param min defines minimum clamping value (default is 0)
  5424. * @param max defines maximum clamping value (default is 1)
  5425. * @param result defines color to store the result into
  5426. * @returns the original Color3
  5427. */
  5428. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5429. /**
  5430. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5431. * @param otherColor defines the second operand
  5432. * @returns the new Color3
  5433. */
  5434. add(otherColor: DeepImmutable<Color3>): Color3;
  5435. /**
  5436. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5437. * @param otherColor defines the second operand
  5438. * @param result defines Color3 object to store the result into
  5439. * @returns the unmodified current Color3
  5440. */
  5441. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5442. /**
  5443. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5444. * @param otherColor defines the second operand
  5445. * @returns the new Color3
  5446. */
  5447. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5448. /**
  5449. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5450. * @param otherColor defines the second operand
  5451. * @param result defines Color3 object to store the result into
  5452. * @returns the unmodified current Color3
  5453. */
  5454. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5455. /**
  5456. * Copy the current object
  5457. * @returns a new Color3 copied the current one
  5458. */
  5459. clone(): Color3;
  5460. /**
  5461. * Copies the rgb values from the source in the current Color3
  5462. * @param source defines the source Color3 object
  5463. * @returns the updated Color3 object
  5464. */
  5465. copyFrom(source: DeepImmutable<Color3>): Color3;
  5466. /**
  5467. * Updates the Color3 rgb values from the given floats
  5468. * @param r defines the red component to read from
  5469. * @param g defines the green component to read from
  5470. * @param b defines the blue component to read from
  5471. * @returns the current Color3 object
  5472. */
  5473. copyFromFloats(r: number, g: number, b: number): Color3;
  5474. /**
  5475. * Updates the Color3 rgb values from the given floats
  5476. * @param r defines the red component to read from
  5477. * @param g defines the green component to read from
  5478. * @param b defines the blue component to read from
  5479. * @returns the current Color3 object
  5480. */
  5481. set(r: number, g: number, b: number): Color3;
  5482. /**
  5483. * Compute the Color3 hexadecimal code as a string
  5484. * @returns a string containing the hexadecimal representation of the Color3 object
  5485. */
  5486. toHexString(): string;
  5487. /**
  5488. * Computes a new Color3 converted from the current one to linear space
  5489. * @returns a new Color3 object
  5490. */
  5491. toLinearSpace(): Color3;
  5492. /**
  5493. * Converts current color in rgb space to HSV values
  5494. * @returns a new color3 representing the HSV values
  5495. */
  5496. toHSV(): Color3;
  5497. /**
  5498. * Converts current color in rgb space to HSV values
  5499. * @param result defines the Color3 where to store the HSV values
  5500. */
  5501. toHSVToRef(result: Color3): void;
  5502. /**
  5503. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the linear space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5508. /**
  5509. * Computes a new Color3 converted from the current one to gamma space
  5510. * @returns a new Color3 object
  5511. */
  5512. toGammaSpace(): Color3;
  5513. /**
  5514. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5515. * @param convertedColor defines the Color3 object where to store the gamma space version
  5516. * @returns the unmodified Color3
  5517. */
  5518. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5519. private static _BlackReadOnly;
  5520. /**
  5521. * Convert Hue, saturation and value to a Color3 (RGB)
  5522. * @param hue defines the hue
  5523. * @param saturation defines the saturation
  5524. * @param value defines the value
  5525. * @param result defines the Color3 where to store the RGB values
  5526. */
  5527. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5528. /**
  5529. * Creates a new Color3 from the string containing valid hexadecimal values
  5530. * @param hex defines a string containing valid hexadecimal values
  5531. * @returns a new Color3 object
  5532. */
  5533. static FromHexString(hex: string): Color3;
  5534. /**
  5535. * Creates a new Color3 from the starting index of the given array
  5536. * @param array defines the source array
  5537. * @param offset defines an offset in the source array
  5538. * @returns a new Color3 object
  5539. */
  5540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5541. /**
  5542. * Creates a new Color3 from integer values (< 256)
  5543. * @param r defines the red component to read from (value between 0 and 255)
  5544. * @param g defines the green component to read from (value between 0 and 255)
  5545. * @param b defines the blue component to read from (value between 0 and 255)
  5546. * @returns a new Color3 object
  5547. */
  5548. static FromInts(r: number, g: number, b: number): Color3;
  5549. /**
  5550. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5551. * @param start defines the start Color3 value
  5552. * @param end defines the end Color3 value
  5553. * @param amount defines the gradient value between start and end
  5554. * @returns a new Color3 object
  5555. */
  5556. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5557. /**
  5558. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5559. * @param left defines the start value
  5560. * @param right defines the end value
  5561. * @param amount defines the gradient factor
  5562. * @param result defines the Color3 object where to store the result
  5563. */
  5564. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5565. /**
  5566. * Returns a Color3 value containing a red color
  5567. * @returns a new Color3 object
  5568. */
  5569. static Red(): Color3;
  5570. /**
  5571. * Returns a Color3 value containing a green color
  5572. * @returns a new Color3 object
  5573. */
  5574. static Green(): Color3;
  5575. /**
  5576. * Returns a Color3 value containing a blue color
  5577. * @returns a new Color3 object
  5578. */
  5579. static Blue(): Color3;
  5580. /**
  5581. * Returns a Color3 value containing a black color
  5582. * @returns a new Color3 object
  5583. */
  5584. static Black(): Color3;
  5585. /**
  5586. * Gets a Color3 value containing a black color that must not be updated
  5587. */
  5588. static get BlackReadOnly(): DeepImmutable<Color3>;
  5589. /**
  5590. * Returns a Color3 value containing a white color
  5591. * @returns a new Color3 object
  5592. */
  5593. static White(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a purple color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Purple(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a magenta color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Magenta(): Color3;
  5604. /**
  5605. * Returns a Color3 value containing a yellow color
  5606. * @returns a new Color3 object
  5607. */
  5608. static Yellow(): Color3;
  5609. /**
  5610. * Returns a Color3 value containing a gray color
  5611. * @returns a new Color3 object
  5612. */
  5613. static Gray(): Color3;
  5614. /**
  5615. * Returns a Color3 value containing a teal color
  5616. * @returns a new Color3 object
  5617. */
  5618. static Teal(): Color3;
  5619. /**
  5620. * Returns a Color3 value containing a random color
  5621. * @returns a new Color3 object
  5622. */
  5623. static Random(): Color3;
  5624. }
  5625. /**
  5626. * Class used to hold a RBGA color
  5627. */
  5628. export class Color4 {
  5629. /**
  5630. * Defines the red component (between 0 and 1, default is 0)
  5631. */
  5632. r: number;
  5633. /**
  5634. * Defines the green component (between 0 and 1, default is 0)
  5635. */
  5636. g: number;
  5637. /**
  5638. * Defines the blue component (between 0 and 1, default is 0)
  5639. */
  5640. b: number;
  5641. /**
  5642. * Defines the alpha component (between 0 and 1, default is 1)
  5643. */
  5644. a: number;
  5645. /**
  5646. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5647. * @param r defines the red component (between 0 and 1, default is 0)
  5648. * @param g defines the green component (between 0 and 1, default is 0)
  5649. * @param b defines the blue component (between 0 and 1, default is 0)
  5650. * @param a defines the alpha component (between 0 and 1, default is 1)
  5651. */
  5652. constructor(
  5653. /**
  5654. * Defines the red component (between 0 and 1, default is 0)
  5655. */
  5656. r?: number,
  5657. /**
  5658. * Defines the green component (between 0 and 1, default is 0)
  5659. */
  5660. g?: number,
  5661. /**
  5662. * Defines the blue component (between 0 and 1, default is 0)
  5663. */
  5664. b?: number,
  5665. /**
  5666. * Defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. a?: number);
  5669. /**
  5670. * Adds in place the given Color4 values to the current Color4 object
  5671. * @param right defines the second operand
  5672. * @returns the current updated Color4 object
  5673. */
  5674. addInPlace(right: DeepImmutable<Color4>): Color4;
  5675. /**
  5676. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5677. * @returns the new array
  5678. */
  5679. asArray(): number[];
  5680. /**
  5681. * Stores from the starting index in the given array the Color4 successive values
  5682. * @param array defines the array where to store the r,g,b components
  5683. * @param index defines an optional index in the target array to define where to start storing values
  5684. * @returns the current Color4 object
  5685. */
  5686. toArray(array: number[], index?: number): Color4;
  5687. /**
  5688. * Determines equality between Color4 objects
  5689. * @param otherColor defines the second operand
  5690. * @returns true if the rgba values are equal to the given ones
  5691. */
  5692. equals(otherColor: DeepImmutable<Color4>): boolean;
  5693. /**
  5694. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5695. * @param right defines the second operand
  5696. * @returns a new Color4 object
  5697. */
  5698. add(right: DeepImmutable<Color4>): Color4;
  5699. /**
  5700. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5701. * @param right defines the second operand
  5702. * @returns a new Color4 object
  5703. */
  5704. subtract(right: DeepImmutable<Color4>): Color4;
  5705. /**
  5706. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5707. * @param right defines the second operand
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the current Color4 object
  5710. */
  5711. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5712. /**
  5713. * Creates a new Color4 with the current Color4 values multiplied by scale
  5714. * @param scale defines the scaling factor to apply
  5715. * @returns a new Color4 object
  5716. */
  5717. scale(scale: number): Color4;
  5718. /**
  5719. * Multiplies the current Color4 values by scale and stores the result in "result"
  5720. * @param scale defines the scaling factor to apply
  5721. * @param result defines the Color4 object where to store the result
  5722. * @returns the current unmodified Color4
  5723. */
  5724. scaleToRef(scale: number, result: Color4): Color4;
  5725. /**
  5726. * Scale the current Color4 values by a factor and add the result to a given Color4
  5727. * @param scale defines the scale factor
  5728. * @param result defines the Color4 object where to store the result
  5729. * @returns the unmodified current Color4
  5730. */
  5731. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5732. /**
  5733. * Clamps the rgb values by the min and max values and stores the result into "result"
  5734. * @param min defines minimum clamping value (default is 0)
  5735. * @param max defines maximum clamping value (default is 1)
  5736. * @param result defines color to store the result into.
  5737. * @returns the cuurent Color4
  5738. */
  5739. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5740. /**
  5741. * Multipy an Color4 value by another and return a new Color4 object
  5742. * @param color defines the Color4 value to multiply by
  5743. * @returns a new Color4 object
  5744. */
  5745. multiply(color: Color4): Color4;
  5746. /**
  5747. * Multipy a Color4 value by another and push the result in a reference value
  5748. * @param color defines the Color4 value to multiply by
  5749. * @param result defines the Color4 to fill the result in
  5750. * @returns the result Color4
  5751. */
  5752. multiplyToRef(color: Color4, result: Color4): Color4;
  5753. /**
  5754. * Creates a string with the Color4 current values
  5755. * @returns the string representation of the Color4 object
  5756. */
  5757. toString(): string;
  5758. /**
  5759. * Returns the string "Color4"
  5760. * @returns "Color4"
  5761. */
  5762. getClassName(): string;
  5763. /**
  5764. * Compute the Color4 hash code
  5765. * @returns an unique number that can be used to hash Color4 objects
  5766. */
  5767. getHashCode(): number;
  5768. /**
  5769. * Creates a new Color4 copied from the current one
  5770. * @returns a new Color4 object
  5771. */
  5772. clone(): Color4;
  5773. /**
  5774. * Copies the given Color4 values into the current one
  5775. * @param source defines the source Color4 object
  5776. * @returns the current updated Color4 object
  5777. */
  5778. copyFrom(source: Color4): Color4;
  5779. /**
  5780. * Copies the given float values into the current one
  5781. * @param r defines the red component to read from
  5782. * @param g defines the green component to read from
  5783. * @param b defines the blue component to read from
  5784. * @param a defines the alpha component to read from
  5785. * @returns the current updated Color4 object
  5786. */
  5787. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5788. /**
  5789. * Copies the given float values into the current one
  5790. * @param r defines the red component to read from
  5791. * @param g defines the green component to read from
  5792. * @param b defines the blue component to read from
  5793. * @param a defines the alpha component to read from
  5794. * @returns the current updated Color4 object
  5795. */
  5796. set(r: number, g: number, b: number, a: number): Color4;
  5797. /**
  5798. * Compute the Color4 hexadecimal code as a string
  5799. * @returns a string containing the hexadecimal representation of the Color4 object
  5800. */
  5801. toHexString(): string;
  5802. /**
  5803. * Computes a new Color4 converted from the current one to linear space
  5804. * @returns a new Color4 object
  5805. */
  5806. toLinearSpace(): Color4;
  5807. /**
  5808. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5809. * @param convertedColor defines the Color4 object where to store the linear space version
  5810. * @returns the unmodified Color4
  5811. */
  5812. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5813. /**
  5814. * Computes a new Color4 converted from the current one to gamma space
  5815. * @returns a new Color4 object
  5816. */
  5817. toGammaSpace(): Color4;
  5818. /**
  5819. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5820. * @param convertedColor defines the Color4 object where to store the gamma space version
  5821. * @returns the unmodified Color4
  5822. */
  5823. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5824. /**
  5825. * Creates a new Color4 from the string containing valid hexadecimal values
  5826. * @param hex defines a string containing valid hexadecimal values
  5827. * @returns a new Color4 object
  5828. */
  5829. static FromHexString(hex: string): Color4;
  5830. /**
  5831. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5832. * @param left defines the start value
  5833. * @param right defines the end value
  5834. * @param amount defines the gradient factor
  5835. * @returns a new Color4 object
  5836. */
  5837. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5838. /**
  5839. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5840. * @param left defines the start value
  5841. * @param right defines the end value
  5842. * @param amount defines the gradient factor
  5843. * @param result defines the Color4 object where to store data
  5844. */
  5845. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5846. /**
  5847. * Creates a new Color4 from a Color3 and an alpha value
  5848. * @param color3 defines the source Color3 to read from
  5849. * @param alpha defines the alpha component (1.0 by default)
  5850. * @returns a new Color4 object
  5851. */
  5852. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5853. /**
  5854. * Creates a new Color4 from the starting index element of the given array
  5855. * @param array defines the source array to read from
  5856. * @param offset defines the offset in the source array
  5857. * @returns a new Color4 object
  5858. */
  5859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5860. /**
  5861. * Creates a new Color3 from integer values (< 256)
  5862. * @param r defines the red component to read from (value between 0 and 255)
  5863. * @param g defines the green component to read from (value between 0 and 255)
  5864. * @param b defines the blue component to read from (value between 0 and 255)
  5865. * @param a defines the alpha component to read from (value between 0 and 255)
  5866. * @returns a new Color3 object
  5867. */
  5868. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5869. /**
  5870. * Check the content of a given array and convert it to an array containing RGBA data
  5871. * If the original array was already containing count * 4 values then it is returned directly
  5872. * @param colors defines the array to check
  5873. * @param count defines the number of RGBA data to expect
  5874. * @returns an array containing count * 4 values (RGBA)
  5875. */
  5876. static CheckColors4(colors: number[], count: number): number[];
  5877. }
  5878. /**
  5879. * @hidden
  5880. */
  5881. export class TmpColors {
  5882. static Color3: Color3[];
  5883. static Color4: Color4[];
  5884. }
  5885. }
  5886. declare module "babylonjs/Animations/animationKey" {
  5887. /**
  5888. * Defines an interface which represents an animation key frame
  5889. */
  5890. export interface IAnimationKey {
  5891. /**
  5892. * Frame of the key frame
  5893. */
  5894. frame: number;
  5895. /**
  5896. * Value at the specifies key frame
  5897. */
  5898. value: any;
  5899. /**
  5900. * The input tangent for the cubic hermite spline
  5901. */
  5902. inTangent?: any;
  5903. /**
  5904. * The output tangent for the cubic hermite spline
  5905. */
  5906. outTangent?: any;
  5907. /**
  5908. * The animation interpolation type
  5909. */
  5910. interpolation?: AnimationKeyInterpolation;
  5911. }
  5912. /**
  5913. * Enum for the animation key frame interpolation type
  5914. */
  5915. export enum AnimationKeyInterpolation {
  5916. /**
  5917. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5918. */
  5919. STEP = 1
  5920. }
  5921. }
  5922. declare module "babylonjs/Animations/animationRange" {
  5923. /**
  5924. * Represents the range of an animation
  5925. */
  5926. export class AnimationRange {
  5927. /**The name of the animation range**/
  5928. name: string;
  5929. /**The starting frame of the animation */
  5930. from: number;
  5931. /**The ending frame of the animation*/
  5932. to: number;
  5933. /**
  5934. * Initializes the range of an animation
  5935. * @param name The name of the animation range
  5936. * @param from The starting frame of the animation
  5937. * @param to The ending frame of the animation
  5938. */
  5939. constructor(
  5940. /**The name of the animation range**/
  5941. name: string,
  5942. /**The starting frame of the animation */
  5943. from: number,
  5944. /**The ending frame of the animation*/
  5945. to: number);
  5946. /**
  5947. * Makes a copy of the animation range
  5948. * @returns A copy of the animation range
  5949. */
  5950. clone(): AnimationRange;
  5951. }
  5952. }
  5953. declare module "babylonjs/Animations/animationEvent" {
  5954. /**
  5955. * Composed of a frame, and an action function
  5956. */
  5957. export class AnimationEvent {
  5958. /** The frame for which the event is triggered **/
  5959. frame: number;
  5960. /** The event to perform when triggered **/
  5961. action: (currentFrame: number) => void;
  5962. /** Specifies if the event should be triggered only once**/
  5963. onlyOnce?: boolean | undefined;
  5964. /**
  5965. * Specifies if the animation event is done
  5966. */
  5967. isDone: boolean;
  5968. /**
  5969. * Initializes the animation event
  5970. * @param frame The frame for which the event is triggered
  5971. * @param action The event to perform when triggered
  5972. * @param onlyOnce Specifies if the event should be triggered only once
  5973. */
  5974. constructor(
  5975. /** The frame for which the event is triggered **/
  5976. frame: number,
  5977. /** The event to perform when triggered **/
  5978. action: (currentFrame: number) => void,
  5979. /** Specifies if the event should be triggered only once**/
  5980. onlyOnce?: boolean | undefined);
  5981. /** @hidden */
  5982. _clone(): AnimationEvent;
  5983. }
  5984. }
  5985. declare module "babylonjs/Behaviors/behavior" {
  5986. import { Nullable } from "babylonjs/types";
  5987. /**
  5988. * Interface used to define a behavior
  5989. */
  5990. export interface Behavior<T> {
  5991. /** gets or sets behavior's name */
  5992. name: string;
  5993. /**
  5994. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5995. */
  5996. init(): void;
  5997. /**
  5998. * Called when the behavior is attached to a target
  5999. * @param target defines the target where the behavior is attached to
  6000. */
  6001. attach(target: T): void;
  6002. /**
  6003. * Called when the behavior is detached from its target
  6004. */
  6005. detach(): void;
  6006. }
  6007. /**
  6008. * Interface implemented by classes supporting behaviors
  6009. */
  6010. export interface IBehaviorAware<T> {
  6011. /**
  6012. * Attach a behavior
  6013. * @param behavior defines the behavior to attach
  6014. * @returns the current host
  6015. */
  6016. addBehavior(behavior: Behavior<T>): T;
  6017. /**
  6018. * Remove a behavior from the current object
  6019. * @param behavior defines the behavior to detach
  6020. * @returns the current host
  6021. */
  6022. removeBehavior(behavior: Behavior<T>): T;
  6023. /**
  6024. * Gets a behavior using its name to search
  6025. * @param name defines the name to search
  6026. * @returns the behavior or null if not found
  6027. */
  6028. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6029. }
  6030. }
  6031. declare module "babylonjs/Misc/smartArray" {
  6032. /**
  6033. * Defines an array and its length.
  6034. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6035. */
  6036. export interface ISmartArrayLike<T> {
  6037. /**
  6038. * The data of the array.
  6039. */
  6040. data: Array<T>;
  6041. /**
  6042. * The active length of the array.
  6043. */
  6044. length: number;
  6045. }
  6046. /**
  6047. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6048. */
  6049. export class SmartArray<T> implements ISmartArrayLike<T> {
  6050. /**
  6051. * The full set of data from the array.
  6052. */
  6053. data: Array<T>;
  6054. /**
  6055. * The active length of the array.
  6056. */
  6057. length: number;
  6058. protected _id: number;
  6059. /**
  6060. * Instantiates a Smart Array.
  6061. * @param capacity defines the default capacity of the array.
  6062. */
  6063. constructor(capacity: number);
  6064. /**
  6065. * Pushes a value at the end of the active data.
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Iterates over the active data and apply the lambda to them.
  6071. * @param func defines the action to apply on each value.
  6072. */
  6073. forEach(func: (content: T) => void): void;
  6074. /**
  6075. * Sorts the full sets of data.
  6076. * @param compareFn defines the comparison function to apply.
  6077. */
  6078. sort(compareFn: (a: T, b: T) => number): void;
  6079. /**
  6080. * Resets the active data to an empty array.
  6081. */
  6082. reset(): void;
  6083. /**
  6084. * Releases all the data from the array as well as the array.
  6085. */
  6086. dispose(): void;
  6087. /**
  6088. * Concats the active data with a given array.
  6089. * @param array defines the data to concatenate with.
  6090. */
  6091. concat(array: any): void;
  6092. /**
  6093. * Returns the position of a value in the active data.
  6094. * @param value defines the value to find the index for
  6095. * @returns the index if found in the active data otherwise -1
  6096. */
  6097. indexOf(value: T): number;
  6098. /**
  6099. * Returns whether an element is part of the active data.
  6100. * @param value defines the value to look for
  6101. * @returns true if found in the active data otherwise false
  6102. */
  6103. contains(value: T): boolean;
  6104. private static _GlobalId;
  6105. }
  6106. /**
  6107. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6108. * The data in this array can only be present once
  6109. */
  6110. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6111. private _duplicateId;
  6112. /**
  6113. * Pushes a value at the end of the active data.
  6114. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6115. * @param value defines the object to push in the array.
  6116. */
  6117. push(value: T): void;
  6118. /**
  6119. * Pushes a value at the end of the active data.
  6120. * If the data is already present, it won t be added again
  6121. * @param value defines the object to push in the array.
  6122. * @returns true if added false if it was already present
  6123. */
  6124. pushNoDuplicate(value: T): boolean;
  6125. /**
  6126. * Resets the active data to an empty array.
  6127. */
  6128. reset(): void;
  6129. /**
  6130. * Concats the active data with a given array.
  6131. * This ensures no dupplicate will be present in the result.
  6132. * @param array defines the data to concatenate with.
  6133. */
  6134. concatWithNoDuplicate(array: any): void;
  6135. }
  6136. }
  6137. declare module "babylonjs/Cameras/cameraInputsManager" {
  6138. import { Nullable } from "babylonjs/types";
  6139. import { Camera } from "babylonjs/Cameras/camera";
  6140. /**
  6141. * @ignore
  6142. * This is a list of all the different input types that are available in the application.
  6143. * Fo instance: ArcRotateCameraGamepadInput...
  6144. */
  6145. export var CameraInputTypes: {};
  6146. /**
  6147. * This is the contract to implement in order to create a new input class.
  6148. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6149. */
  6150. export interface ICameraInput<TCamera extends Camera> {
  6151. /**
  6152. * Defines the camera the input is attached to.
  6153. */
  6154. camera: Nullable<TCamera>;
  6155. /**
  6156. * Gets the class name of the current intput.
  6157. * @returns the class name
  6158. */
  6159. getClassName(): string;
  6160. /**
  6161. * Get the friendly name associated with the input class.
  6162. * @returns the input friendly name
  6163. */
  6164. getSimpleName(): string;
  6165. /**
  6166. * Attach the input controls to a specific dom element to get the input from.
  6167. * @param element Defines the element the controls should be listened from
  6168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6169. */
  6170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6171. /**
  6172. * Detach the current controls from the specified dom element.
  6173. * @param element Defines the element to stop listening the inputs from
  6174. */
  6175. detachControl(element: Nullable<HTMLElement>): void;
  6176. /**
  6177. * Update the current camera state depending on the inputs that have been used this frame.
  6178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6179. */
  6180. checkInputs?: () => void;
  6181. }
  6182. /**
  6183. * Represents a map of input types to input instance or input index to input instance.
  6184. */
  6185. export interface CameraInputsMap<TCamera extends Camera> {
  6186. /**
  6187. * Accessor to the input by input type.
  6188. */
  6189. [name: string]: ICameraInput<TCamera>;
  6190. /**
  6191. * Accessor to the input by input index.
  6192. */
  6193. [idx: number]: ICameraInput<TCamera>;
  6194. }
  6195. /**
  6196. * This represents the input manager used within a camera.
  6197. * It helps dealing with all the different kind of input attached to a camera.
  6198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6199. */
  6200. export class CameraInputsManager<TCamera extends Camera> {
  6201. /**
  6202. * Defines the list of inputs attahed to the camera.
  6203. */
  6204. attached: CameraInputsMap<TCamera>;
  6205. /**
  6206. * Defines the dom element the camera is collecting inputs from.
  6207. * This is null if the controls have not been attached.
  6208. */
  6209. attachedElement: Nullable<HTMLElement>;
  6210. /**
  6211. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6212. */
  6213. noPreventDefault: boolean;
  6214. /**
  6215. * Defined the camera the input manager belongs to.
  6216. */
  6217. camera: TCamera;
  6218. /**
  6219. * Update the current camera state depending on the inputs that have been used this frame.
  6220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6221. */
  6222. checkInputs: () => void;
  6223. /**
  6224. * Instantiate a new Camera Input Manager.
  6225. * @param camera Defines the camera the input manager blongs to
  6226. */
  6227. constructor(camera: TCamera);
  6228. /**
  6229. * Add an input method to a camera
  6230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6231. * @param input camera input method
  6232. */
  6233. add(input: ICameraInput<TCamera>): void;
  6234. /**
  6235. * Remove a specific input method from a camera
  6236. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6237. * @param inputToRemove camera input method
  6238. */
  6239. remove(inputToRemove: ICameraInput<TCamera>): void;
  6240. /**
  6241. * Remove a specific input type from a camera
  6242. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6243. * @param inputType the type of the input to remove
  6244. */
  6245. removeByType(inputType: string): void;
  6246. private _addCheckInputs;
  6247. /**
  6248. * Attach the input controls to the currently attached dom element to listen the events from.
  6249. * @param input Defines the input to attach
  6250. */
  6251. attachInput(input: ICameraInput<TCamera>): void;
  6252. /**
  6253. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6254. * @param element Defines the dom element to collect the events from
  6255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6256. */
  6257. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6258. /**
  6259. * Detach the current manager inputs controls from a specific dom element.
  6260. * @param element Defines the dom element to collect the events from
  6261. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6262. */
  6263. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6264. /**
  6265. * Rebuild the dynamic inputCheck function from the current list of
  6266. * defined inputs in the manager.
  6267. */
  6268. rebuildInputCheck(): void;
  6269. /**
  6270. * Remove all attached input methods from a camera
  6271. */
  6272. clear(): void;
  6273. /**
  6274. * Serialize the current input manager attached to a camera.
  6275. * This ensures than once parsed,
  6276. * the input associated to the camera will be identical to the current ones
  6277. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6278. */
  6279. serialize(serializedCamera: any): void;
  6280. /**
  6281. * Parses an input manager serialized JSON to restore the previous list of inputs
  6282. * and states associated to a camera.
  6283. * @param parsedCamera Defines the JSON to parse
  6284. */
  6285. parse(parsedCamera: any): void;
  6286. }
  6287. }
  6288. declare module "babylonjs/Meshes/buffer" {
  6289. import { Nullable, DataArray } from "babylonjs/types";
  6290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6291. /**
  6292. * Class used to store data that will be store in GPU memory
  6293. */
  6294. export class Buffer {
  6295. private _engine;
  6296. private _buffer;
  6297. /** @hidden */
  6298. _data: Nullable<DataArray>;
  6299. private _updatable;
  6300. private _instanced;
  6301. private _divisor;
  6302. /**
  6303. * Gets the byte stride.
  6304. */
  6305. readonly byteStride: number;
  6306. /**
  6307. * Constructor
  6308. * @param engine the engine
  6309. * @param data the data to use for this buffer
  6310. * @param updatable whether the data is updatable
  6311. * @param stride the stride (optional)
  6312. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6313. * @param instanced whether the buffer is instanced (optional)
  6314. * @param useBytes set to true if the stride in in bytes (optional)
  6315. * @param divisor sets an optional divisor for instances (1 by default)
  6316. */
  6317. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6318. /**
  6319. * Create a new VertexBuffer based on the current buffer
  6320. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6321. * @param offset defines offset in the buffer (0 by default)
  6322. * @param size defines the size in floats of attributes (position is 3 for instance)
  6323. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6324. * @param instanced defines if the vertex buffer contains indexed data
  6325. * @param useBytes defines if the offset and stride are in bytes *
  6326. * @param divisor sets an optional divisor for instances (1 by default)
  6327. * @returns the new vertex buffer
  6328. */
  6329. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6330. /**
  6331. * Gets a boolean indicating if the Buffer is updatable?
  6332. * @returns true if the buffer is updatable
  6333. */
  6334. isUpdatable(): boolean;
  6335. /**
  6336. * Gets current buffer's data
  6337. * @returns a DataArray or null
  6338. */
  6339. getData(): Nullable<DataArray>;
  6340. /**
  6341. * Gets underlying native buffer
  6342. * @returns underlying native buffer
  6343. */
  6344. getBuffer(): Nullable<DataBuffer>;
  6345. /**
  6346. * Gets the stride in float32 units (i.e. byte stride / 4).
  6347. * May not be an integer if the byte stride is not divisible by 4.
  6348. * @returns the stride in float32 units
  6349. * @deprecated Please use byteStride instead.
  6350. */
  6351. getStrideSize(): number;
  6352. /**
  6353. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6354. * @param data defines the data to store
  6355. */
  6356. create(data?: Nullable<DataArray>): void;
  6357. /** @hidden */
  6358. _rebuild(): void;
  6359. /**
  6360. * Update current buffer data
  6361. * @param data defines the data to store
  6362. */
  6363. update(data: DataArray): void;
  6364. /**
  6365. * Updates the data directly.
  6366. * @param data the new data
  6367. * @param offset the new offset
  6368. * @param vertexCount the vertex count (optional)
  6369. * @param useBytes set to true if the offset is in bytes
  6370. */
  6371. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6372. /**
  6373. * Release all resources
  6374. */
  6375. dispose(): void;
  6376. }
  6377. /**
  6378. * Specialized buffer used to store vertex data
  6379. */
  6380. export class VertexBuffer {
  6381. /** @hidden */
  6382. _buffer: Buffer;
  6383. private _kind;
  6384. private _size;
  6385. private _ownsBuffer;
  6386. private _instanced;
  6387. private _instanceDivisor;
  6388. /**
  6389. * The byte type.
  6390. */
  6391. static readonly BYTE: number;
  6392. /**
  6393. * The unsigned byte type.
  6394. */
  6395. static readonly UNSIGNED_BYTE: number;
  6396. /**
  6397. * The short type.
  6398. */
  6399. static readonly SHORT: number;
  6400. /**
  6401. * The unsigned short type.
  6402. */
  6403. static readonly UNSIGNED_SHORT: number;
  6404. /**
  6405. * The integer type.
  6406. */
  6407. static readonly INT: number;
  6408. /**
  6409. * The unsigned integer type.
  6410. */
  6411. static readonly UNSIGNED_INT: number;
  6412. /**
  6413. * The float type.
  6414. */
  6415. static readonly FLOAT: number;
  6416. /**
  6417. * Gets or sets the instance divisor when in instanced mode
  6418. */
  6419. get instanceDivisor(): number;
  6420. set instanceDivisor(value: number);
  6421. /**
  6422. * Gets the byte stride.
  6423. */
  6424. readonly byteStride: number;
  6425. /**
  6426. * Gets the byte offset.
  6427. */
  6428. readonly byteOffset: number;
  6429. /**
  6430. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6431. */
  6432. readonly normalized: boolean;
  6433. /**
  6434. * Gets the data type of each component in the array.
  6435. */
  6436. readonly type: number;
  6437. /**
  6438. * Constructor
  6439. * @param engine the engine
  6440. * @param data the data to use for this vertex buffer
  6441. * @param kind the vertex buffer kind
  6442. * @param updatable whether the data is updatable
  6443. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6444. * @param stride the stride (optional)
  6445. * @param instanced whether the buffer is instanced (optional)
  6446. * @param offset the offset of the data (optional)
  6447. * @param size the number of components (optional)
  6448. * @param type the type of the component (optional)
  6449. * @param normalized whether the data contains normalized data (optional)
  6450. * @param useBytes set to true if stride and offset are in bytes (optional)
  6451. * @param divisor defines the instance divisor to use (1 by default)
  6452. */
  6453. 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);
  6454. /** @hidden */
  6455. _rebuild(): void;
  6456. /**
  6457. * Returns the kind of the VertexBuffer (string)
  6458. * @returns a string
  6459. */
  6460. getKind(): string;
  6461. /**
  6462. * Gets a boolean indicating if the VertexBuffer is updatable?
  6463. * @returns true if the buffer is updatable
  6464. */
  6465. isUpdatable(): boolean;
  6466. /**
  6467. * Gets current buffer's data
  6468. * @returns a DataArray or null
  6469. */
  6470. getData(): Nullable<DataArray>;
  6471. /**
  6472. * Gets underlying native buffer
  6473. * @returns underlying native buffer
  6474. */
  6475. getBuffer(): Nullable<DataBuffer>;
  6476. /**
  6477. * Gets the stride in float32 units (i.e. byte stride / 4).
  6478. * May not be an integer if the byte stride is not divisible by 4.
  6479. * @returns the stride in float32 units
  6480. * @deprecated Please use byteStride instead.
  6481. */
  6482. getStrideSize(): number;
  6483. /**
  6484. * Returns the offset as a multiple of the type byte length.
  6485. * @returns the offset in bytes
  6486. * @deprecated Please use byteOffset instead.
  6487. */
  6488. getOffset(): number;
  6489. /**
  6490. * Returns the number of components per vertex attribute (integer)
  6491. * @returns the size in float
  6492. */
  6493. getSize(): number;
  6494. /**
  6495. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6496. * @returns true if this buffer is instanced
  6497. */
  6498. getIsInstanced(): boolean;
  6499. /**
  6500. * Returns the instancing divisor, zero for non-instanced (integer).
  6501. * @returns a number
  6502. */
  6503. getInstanceDivisor(): number;
  6504. /**
  6505. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6506. * @param data defines the data to store
  6507. */
  6508. create(data?: DataArray): void;
  6509. /**
  6510. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6511. * This function will create a new buffer if the current one is not updatable
  6512. * @param data defines the data to store
  6513. */
  6514. update(data: DataArray): void;
  6515. /**
  6516. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6517. * Returns the directly updated WebGLBuffer.
  6518. * @param data the new data
  6519. * @param offset the new offset
  6520. * @param useBytes set to true if the offset is in bytes
  6521. */
  6522. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6523. /**
  6524. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6525. */
  6526. dispose(): void;
  6527. /**
  6528. * Enumerates each value of this vertex buffer as numbers.
  6529. * @param count the number of values to enumerate
  6530. * @param callback the callback function called for each value
  6531. */
  6532. forEach(count: number, callback: (value: number, index: number) => void): void;
  6533. /**
  6534. * Positions
  6535. */
  6536. static readonly PositionKind: string;
  6537. /**
  6538. * Normals
  6539. */
  6540. static readonly NormalKind: string;
  6541. /**
  6542. * Tangents
  6543. */
  6544. static readonly TangentKind: string;
  6545. /**
  6546. * Texture coordinates
  6547. */
  6548. static readonly UVKind: string;
  6549. /**
  6550. * Texture coordinates 2
  6551. */
  6552. static readonly UV2Kind: string;
  6553. /**
  6554. * Texture coordinates 3
  6555. */
  6556. static readonly UV3Kind: string;
  6557. /**
  6558. * Texture coordinates 4
  6559. */
  6560. static readonly UV4Kind: string;
  6561. /**
  6562. * Texture coordinates 5
  6563. */
  6564. static readonly UV5Kind: string;
  6565. /**
  6566. * Texture coordinates 6
  6567. */
  6568. static readonly UV6Kind: string;
  6569. /**
  6570. * Colors
  6571. */
  6572. static readonly ColorKind: string;
  6573. /**
  6574. * Matrix indices (for bones)
  6575. */
  6576. static readonly MatricesIndicesKind: string;
  6577. /**
  6578. * Matrix weights (for bones)
  6579. */
  6580. static readonly MatricesWeightsKind: string;
  6581. /**
  6582. * Additional matrix indices (for bones)
  6583. */
  6584. static readonly MatricesIndicesExtraKind: string;
  6585. /**
  6586. * Additional matrix weights (for bones)
  6587. */
  6588. static readonly MatricesWeightsExtraKind: string;
  6589. /**
  6590. * Deduces the stride given a kind.
  6591. * @param kind The kind string to deduce
  6592. * @returns The deduced stride
  6593. */
  6594. static DeduceStride(kind: string): number;
  6595. /**
  6596. * Gets the byte length of the given type.
  6597. * @param type the type
  6598. * @returns the number of bytes
  6599. */
  6600. static GetTypeByteLength(type: number): number;
  6601. /**
  6602. * Enumerates each value of the given parameters as numbers.
  6603. * @param data the data to enumerate
  6604. * @param byteOffset the byte offset of the data
  6605. * @param byteStride the byte stride of the data
  6606. * @param componentCount the number of components per element
  6607. * @param componentType the type of the component
  6608. * @param count the number of values to enumerate
  6609. * @param normalized whether the data is normalized
  6610. * @param callback the callback function called for each value
  6611. */
  6612. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6613. private static _GetFloatValue;
  6614. }
  6615. }
  6616. declare module "babylonjs/Collisions/intersectionInfo" {
  6617. import { Nullable } from "babylonjs/types";
  6618. /**
  6619. * @hidden
  6620. */
  6621. export class IntersectionInfo {
  6622. bu: Nullable<number>;
  6623. bv: Nullable<number>;
  6624. distance: number;
  6625. faceId: number;
  6626. subMeshId: number;
  6627. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6628. }
  6629. }
  6630. declare module "babylonjs/Maths/math.plane" {
  6631. import { DeepImmutable } from "babylonjs/types";
  6632. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6633. /**
  6634. * Represens a plane by the equation ax + by + cz + d = 0
  6635. */
  6636. export class Plane {
  6637. private static _TmpMatrix;
  6638. /**
  6639. * Normal of the plane (a,b,c)
  6640. */
  6641. normal: Vector3;
  6642. /**
  6643. * d component of the plane
  6644. */
  6645. d: number;
  6646. /**
  6647. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6648. * @param a a component of the plane
  6649. * @param b b component of the plane
  6650. * @param c c component of the plane
  6651. * @param d d component of the plane
  6652. */
  6653. constructor(a: number, b: number, c: number, d: number);
  6654. /**
  6655. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6656. */
  6657. asArray(): number[];
  6658. /**
  6659. * @returns a new plane copied from the current Plane.
  6660. */
  6661. clone(): Plane;
  6662. /**
  6663. * @returns the string "Plane".
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * @returns the Plane hash code.
  6668. */
  6669. getHashCode(): number;
  6670. /**
  6671. * Normalize the current Plane in place.
  6672. * @returns the updated Plane.
  6673. */
  6674. normalize(): Plane;
  6675. /**
  6676. * Applies a transformation the plane and returns the result
  6677. * @param transformation the transformation matrix to be applied to the plane
  6678. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6679. */
  6680. transform(transformation: DeepImmutable<Matrix>): Plane;
  6681. /**
  6682. * Calcualtte the dot product between the point and the plane normal
  6683. * @param point point to calculate the dot product with
  6684. * @returns the dot product (float) of the point coordinates and the plane normal.
  6685. */
  6686. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6687. /**
  6688. * Updates the current Plane from the plane defined by the three given points.
  6689. * @param point1 one of the points used to contruct the plane
  6690. * @param point2 one of the points used to contruct the plane
  6691. * @param point3 one of the points used to contruct the plane
  6692. * @returns the updated Plane.
  6693. */
  6694. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Checks if the plane is facing a given direction
  6697. * @param direction the direction to check if the plane is facing
  6698. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6699. * @returns True is the vector "direction" is the same side than the plane normal.
  6700. */
  6701. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6702. /**
  6703. * Calculates the distance to a point
  6704. * @param point point to calculate distance to
  6705. * @returns the signed distance (float) from the given point to the Plane.
  6706. */
  6707. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6708. /**
  6709. * Creates a plane from an array
  6710. * @param array the array to create a plane from
  6711. * @returns a new Plane from the given array.
  6712. */
  6713. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6714. /**
  6715. * Creates a plane from three points
  6716. * @param point1 point used to create the plane
  6717. * @param point2 point used to create the plane
  6718. * @param point3 point used to create the plane
  6719. * @returns a new Plane defined by the three given points.
  6720. */
  6721. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6722. /**
  6723. * Creates a plane from an origin point and a normal
  6724. * @param origin origin of the plane to be constructed
  6725. * @param normal normal of the plane to be constructed
  6726. * @returns a new Plane the normal vector to this plane at the given origin point.
  6727. * Note : the vector "normal" is updated because normalized.
  6728. */
  6729. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6730. /**
  6731. * Calculates the distance from a plane and a point
  6732. * @param origin origin of the plane to be constructed
  6733. * @param normal normal of the plane to be constructed
  6734. * @param point point to calculate distance to
  6735. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6736. */
  6737. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6738. }
  6739. }
  6740. declare module "babylonjs/Culling/boundingSphere" {
  6741. import { DeepImmutable } from "babylonjs/types";
  6742. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6743. import { Plane } from "babylonjs/Maths/math.plane";
  6744. /**
  6745. * Class used to store bounding sphere information
  6746. */
  6747. export class BoundingSphere {
  6748. /**
  6749. * Gets the center of the bounding sphere in local space
  6750. */
  6751. readonly center: Vector3;
  6752. /**
  6753. * Radius of the bounding sphere in local space
  6754. */
  6755. radius: number;
  6756. /**
  6757. * Gets the center of the bounding sphere in world space
  6758. */
  6759. readonly centerWorld: Vector3;
  6760. /**
  6761. * Radius of the bounding sphere in world space
  6762. */
  6763. radiusWorld: number;
  6764. /**
  6765. * Gets the minimum vector in local space
  6766. */
  6767. readonly minimum: Vector3;
  6768. /**
  6769. * Gets the maximum vector in local space
  6770. */
  6771. readonly maximum: Vector3;
  6772. private _worldMatrix;
  6773. private static readonly TmpVector3;
  6774. /**
  6775. * Creates a new bounding sphere
  6776. * @param min defines the minimum vector (in local space)
  6777. * @param max defines the maximum vector (in local space)
  6778. * @param worldMatrix defines the new world matrix
  6779. */
  6780. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6781. /**
  6782. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6783. * @param min defines the new minimum vector (in local space)
  6784. * @param max defines the new maximum vector (in local space)
  6785. * @param worldMatrix defines the new world matrix
  6786. */
  6787. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6788. /**
  6789. * Scale the current bounding sphere by applying a scale factor
  6790. * @param factor defines the scale factor to apply
  6791. * @returns the current bounding box
  6792. */
  6793. scale(factor: number): BoundingSphere;
  6794. /**
  6795. * Gets the world matrix of the bounding box
  6796. * @returns a matrix
  6797. */
  6798. getWorldMatrix(): DeepImmutable<Matrix>;
  6799. /** @hidden */
  6800. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6801. /**
  6802. * Tests if the bounding sphere is intersecting the frustum planes
  6803. * @param frustumPlanes defines the frustum planes to test
  6804. * @returns true if there is an intersection
  6805. */
  6806. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6807. /**
  6808. * Tests if the bounding sphere center is in between the frustum planes.
  6809. * Used for optimistic fast inclusion.
  6810. * @param frustumPlanes defines the frustum planes to test
  6811. * @returns true if the sphere center is in between the frustum planes
  6812. */
  6813. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6814. /**
  6815. * Tests if a point is inside the bounding sphere
  6816. * @param point defines the point to test
  6817. * @returns true if the point is inside the bounding sphere
  6818. */
  6819. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6820. /**
  6821. * Checks if two sphere intersct
  6822. * @param sphere0 sphere 0
  6823. * @param sphere1 sphere 1
  6824. * @returns true if the speres intersect
  6825. */
  6826. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6827. }
  6828. }
  6829. declare module "babylonjs/Culling/boundingBox" {
  6830. import { DeepImmutable } from "babylonjs/types";
  6831. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6832. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6833. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6834. import { Plane } from "babylonjs/Maths/math.plane";
  6835. /**
  6836. * Class used to store bounding box information
  6837. */
  6838. export class BoundingBox implements ICullable {
  6839. /**
  6840. * Gets the 8 vectors representing the bounding box in local space
  6841. */
  6842. readonly vectors: Vector3[];
  6843. /**
  6844. * Gets the center of the bounding box in local space
  6845. */
  6846. readonly center: Vector3;
  6847. /**
  6848. * Gets the center of the bounding box in world space
  6849. */
  6850. readonly centerWorld: Vector3;
  6851. /**
  6852. * Gets the extend size in local space
  6853. */
  6854. readonly extendSize: Vector3;
  6855. /**
  6856. * Gets the extend size in world space
  6857. */
  6858. readonly extendSizeWorld: Vector3;
  6859. /**
  6860. * Gets the OBB (object bounding box) directions
  6861. */
  6862. readonly directions: Vector3[];
  6863. /**
  6864. * Gets the 8 vectors representing the bounding box in world space
  6865. */
  6866. readonly vectorsWorld: Vector3[];
  6867. /**
  6868. * Gets the minimum vector in world space
  6869. */
  6870. readonly minimumWorld: Vector3;
  6871. /**
  6872. * Gets the maximum vector in world space
  6873. */
  6874. readonly maximumWorld: Vector3;
  6875. /**
  6876. * Gets the minimum vector in local space
  6877. */
  6878. readonly minimum: Vector3;
  6879. /**
  6880. * Gets the maximum vector in local space
  6881. */
  6882. readonly maximum: Vector3;
  6883. private _worldMatrix;
  6884. private static readonly TmpVector3;
  6885. /**
  6886. * @hidden
  6887. */
  6888. _tag: number;
  6889. /**
  6890. * Creates a new bounding box
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding box by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingBox;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(world: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding box is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding box is entirely inside the frustum planes
  6924. * @param frustumPlanes defines the frustum planes to test
  6925. * @returns true if there is an inclusion
  6926. */
  6927. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6928. /**
  6929. * Tests if a point is inside the bounding box
  6930. * @param point defines the point to test
  6931. * @returns true if the point is inside the bounding box
  6932. */
  6933. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6934. /**
  6935. * Tests if the bounding box intersects with a bounding sphere
  6936. * @param sphere defines the sphere to test
  6937. * @returns true if there is an intersection
  6938. */
  6939. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6940. /**
  6941. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6942. * @param min defines the min vector to use
  6943. * @param max defines the max vector to use
  6944. * @returns true if there is an intersection
  6945. */
  6946. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Tests if two bounding boxes are intersections
  6949. * @param box0 defines the first box to test
  6950. * @param box1 defines the second box to test
  6951. * @returns true if there is an intersection
  6952. */
  6953. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6954. /**
  6955. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6956. * @param minPoint defines the minimum vector of the bounding box
  6957. * @param maxPoint defines the maximum vector of the bounding box
  6958. * @param sphereCenter defines the sphere center
  6959. * @param sphereRadius defines the sphere radius
  6960. * @returns true if there is an intersection
  6961. */
  6962. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6963. /**
  6964. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6965. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @return true if there is an inclusion
  6968. */
  6969. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6972. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6973. * @param frustumPlanes defines the frustum planes to test
  6974. * @return true if there is an intersection
  6975. */
  6976. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6977. }
  6978. }
  6979. declare module "babylonjs/Collisions/collider" {
  6980. import { Nullable, IndicesArray } from "babylonjs/types";
  6981. import { Vector3 } from "babylonjs/Maths/math.vector";
  6982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6983. import { Plane } from "babylonjs/Maths/math.plane";
  6984. /** @hidden */
  6985. export class Collider {
  6986. /** Define if a collision was found */
  6987. collisionFound: boolean;
  6988. /**
  6989. * Define last intersection point in local space
  6990. */
  6991. intersectionPoint: Vector3;
  6992. /**
  6993. * Define last collided mesh
  6994. */
  6995. collidedMesh: Nullable<AbstractMesh>;
  6996. private _collisionPoint;
  6997. private _planeIntersectionPoint;
  6998. private _tempVector;
  6999. private _tempVector2;
  7000. private _tempVector3;
  7001. private _tempVector4;
  7002. private _edge;
  7003. private _baseToVertex;
  7004. private _destinationPoint;
  7005. private _slidePlaneNormal;
  7006. private _displacementVector;
  7007. /** @hidden */
  7008. _radius: Vector3;
  7009. /** @hidden */
  7010. _retry: number;
  7011. private _velocity;
  7012. private _basePoint;
  7013. private _epsilon;
  7014. /** @hidden */
  7015. _velocityWorldLength: number;
  7016. /** @hidden */
  7017. _basePointWorld: Vector3;
  7018. private _velocityWorld;
  7019. private _normalizedVelocity;
  7020. /** @hidden */
  7021. _initialVelocity: Vector3;
  7022. /** @hidden */
  7023. _initialPosition: Vector3;
  7024. private _nearestDistance;
  7025. private _collisionMask;
  7026. get collisionMask(): number;
  7027. set collisionMask(mask: number);
  7028. /**
  7029. * Gets the plane normal used to compute the sliding response (in local space)
  7030. */
  7031. get slidePlaneNormal(): Vector3;
  7032. /** @hidden */
  7033. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7034. /** @hidden */
  7035. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7036. /** @hidden */
  7037. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7038. /** @hidden */
  7039. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7042. /** @hidden */
  7043. _getResponse(pos: Vector3, vel: Vector3): void;
  7044. }
  7045. }
  7046. declare module "babylonjs/Culling/boundingInfo" {
  7047. import { DeepImmutable } from "babylonjs/types";
  7048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7050. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7051. import { Plane } from "babylonjs/Maths/math.plane";
  7052. import { Collider } from "babylonjs/Collisions/collider";
  7053. /**
  7054. * Interface for cullable objects
  7055. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7056. */
  7057. export interface ICullable {
  7058. /**
  7059. * Checks if the object or part of the object is in the frustum
  7060. * @param frustumPlanes Camera near/planes
  7061. * @returns true if the object is in frustum otherwise false
  7062. */
  7063. isInFrustum(frustumPlanes: Plane[]): boolean;
  7064. /**
  7065. * Checks if a cullable object (mesh...) is in the camera frustum
  7066. * Unlike isInFrustum this cheks the full bounding box
  7067. * @param frustumPlanes Camera near/planes
  7068. * @returns true if the object is in frustum otherwise false
  7069. */
  7070. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7071. }
  7072. /**
  7073. * Info for a bounding data of a mesh
  7074. */
  7075. export class BoundingInfo implements ICullable {
  7076. /**
  7077. * Bounding box for the mesh
  7078. */
  7079. readonly boundingBox: BoundingBox;
  7080. /**
  7081. * Bounding sphere for the mesh
  7082. */
  7083. readonly boundingSphere: BoundingSphere;
  7084. private _isLocked;
  7085. private static readonly TmpVector3;
  7086. /**
  7087. * Constructs bounding info
  7088. * @param minimum min vector of the bounding box/sphere
  7089. * @param maximum max vector of the bounding box/sphere
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * min vector of the bounding box/sphere
  7102. */
  7103. get minimum(): Vector3;
  7104. /**
  7105. * max vector of the bounding box/sphere
  7106. */
  7107. get maximum(): Vector3;
  7108. /**
  7109. * If the info is locked and won't be updated to avoid perf overhead
  7110. */
  7111. get isLocked(): boolean;
  7112. set isLocked(value: boolean);
  7113. /**
  7114. * Updates the bounding sphere and box
  7115. * @param world world matrix to be used to update
  7116. */
  7117. update(world: DeepImmutable<Matrix>): void;
  7118. /**
  7119. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7120. * @param center New center of the bounding info
  7121. * @param extend New extend of the bounding info
  7122. * @returns the current bounding info
  7123. */
  7124. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7125. /**
  7126. * Scale the current bounding info by applying a scale factor
  7127. * @param factor defines the scale factor to apply
  7128. * @returns the current bounding info
  7129. */
  7130. scale(factor: number): BoundingInfo;
  7131. /**
  7132. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7133. * @param frustumPlanes defines the frustum to test
  7134. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7135. * @returns true if the bounding info is in the frustum planes
  7136. */
  7137. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7138. /**
  7139. * Gets the world distance between the min and max points of the bounding box
  7140. */
  7141. get diagonalLength(): number;
  7142. /**
  7143. * Checks if a cullable object (mesh...) is in the camera frustum
  7144. * Unlike isInFrustum this cheks the full bounding box
  7145. * @param frustumPlanes Camera near/planes
  7146. * @returns true if the object is in frustum otherwise false
  7147. */
  7148. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7149. /** @hidden */
  7150. _checkCollision(collider: Collider): boolean;
  7151. /**
  7152. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7153. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7154. * @param point the point to check intersection with
  7155. * @returns if the point intersects
  7156. */
  7157. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7158. /**
  7159. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7160. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7161. * @param boundingInfo the bounding info to check intersection with
  7162. * @param precise if the intersection should be done using OBB
  7163. * @returns if the bounding info intersects
  7164. */
  7165. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7166. }
  7167. }
  7168. declare module "babylonjs/Maths/math.functions" {
  7169. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7170. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7171. /**
  7172. * Extracts minimum and maximum values from a list of indexed positions
  7173. * @param positions defines the positions to use
  7174. * @param indices defines the indices to the positions
  7175. * @param indexStart defines the start index
  7176. * @param indexCount defines the end index
  7177. * @param bias defines bias value to add to the result
  7178. * @return minimum and maximum values
  7179. */
  7180. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7181. minimum: Vector3;
  7182. maximum: Vector3;
  7183. };
  7184. /**
  7185. * Extracts minimum and maximum values from a list of positions
  7186. * @param positions defines the positions to use
  7187. * @param start defines the start index in the positions array
  7188. * @param count defines the number of positions to handle
  7189. * @param bias defines bias value to add to the result
  7190. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7191. * @return minimum and maximum values
  7192. */
  7193. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7194. minimum: Vector3;
  7195. maximum: Vector3;
  7196. };
  7197. }
  7198. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7199. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7200. /** @hidden */
  7201. export class WebGLDataBuffer extends DataBuffer {
  7202. private _buffer;
  7203. constructor(resource: WebGLBuffer);
  7204. get underlyingResource(): any;
  7205. }
  7206. }
  7207. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7208. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7209. import { Nullable } from "babylonjs/types";
  7210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7211. /** @hidden */
  7212. export class WebGLPipelineContext implements IPipelineContext {
  7213. engine: ThinEngine;
  7214. program: Nullable<WebGLProgram>;
  7215. context?: WebGLRenderingContext;
  7216. vertexShader?: WebGLShader;
  7217. fragmentShader?: WebGLShader;
  7218. isParallelCompiled: boolean;
  7219. onCompiled?: () => void;
  7220. transformFeedback?: WebGLTransformFeedback | null;
  7221. vertexCompilationError: Nullable<string>;
  7222. fragmentCompilationError: Nullable<string>;
  7223. programLinkError: Nullable<string>;
  7224. programValidationError: Nullable<string>;
  7225. get isAsync(): boolean;
  7226. get isReady(): boolean;
  7227. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7228. }
  7229. }
  7230. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7231. import { FloatArray, Nullable } from "babylonjs/types";
  7232. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7233. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7234. module "babylonjs/Engines/thinEngine" {
  7235. interface ThinEngine {
  7236. /**
  7237. * Create an uniform buffer
  7238. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7239. * @param elements defines the content of the uniform buffer
  7240. * @returns the webGL uniform buffer
  7241. */
  7242. createUniformBuffer(elements: FloatArray): DataBuffer;
  7243. /**
  7244. * Create a dynamic uniform buffer
  7245. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7246. * @param elements defines the content of the uniform buffer
  7247. * @returns the webGL uniform buffer
  7248. */
  7249. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7250. /**
  7251. * Update an existing uniform buffer
  7252. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7253. * @param uniformBuffer defines the target uniform buffer
  7254. * @param elements defines the content to update
  7255. * @param offset defines the offset in the uniform buffer where update should start
  7256. * @param count defines the size of the data to update
  7257. */
  7258. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7259. /**
  7260. * Bind an uniform buffer to the current webGL context
  7261. * @param buffer defines the buffer to bind
  7262. */
  7263. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7264. /**
  7265. * Bind a buffer to the current webGL context at a given location
  7266. * @param buffer defines the buffer to bind
  7267. * @param location defines the index where to bind the buffer
  7268. */
  7269. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7270. /**
  7271. * Bind a specific block at a given index in a specific shader program
  7272. * @param pipelineContext defines the pipeline context to use
  7273. * @param blockName defines the block name
  7274. * @param index defines the index where to bind the block
  7275. */
  7276. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7277. }
  7278. }
  7279. }
  7280. declare module "babylonjs/Materials/uniformBuffer" {
  7281. import { Nullable, FloatArray } from "babylonjs/types";
  7282. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7283. import { Engine } from "babylonjs/Engines/engine";
  7284. import { Effect } from "babylonjs/Materials/effect";
  7285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7286. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7287. import { Color3 } from "babylonjs/Maths/math.color";
  7288. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7289. /**
  7290. * Uniform buffer objects.
  7291. *
  7292. * Handles blocks of uniform on the GPU.
  7293. *
  7294. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7295. *
  7296. * For more information, please refer to :
  7297. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7298. */
  7299. export class UniformBuffer {
  7300. private _engine;
  7301. private _buffer;
  7302. private _data;
  7303. private _bufferData;
  7304. private _dynamic?;
  7305. private _uniformLocations;
  7306. private _uniformSizes;
  7307. private _uniformLocationPointer;
  7308. private _needSync;
  7309. private _noUBO;
  7310. private _currentEffect;
  7311. /** @hidden */
  7312. _alreadyBound: boolean;
  7313. private static _MAX_UNIFORM_SIZE;
  7314. private static _tempBuffer;
  7315. /**
  7316. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7321. /**
  7322. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7327. /**
  7328. * Lambda to Update a single float in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateFloat: (name: string, x: number) => void;
  7333. /**
  7334. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7339. /**
  7340. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update a vec4 of 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7351. /**
  7352. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7357. /**
  7358. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7363. /**
  7364. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7369. /**
  7370. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7375. /**
  7376. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7381. /**
  7382. * Instantiates a new Uniform buffer objects.
  7383. *
  7384. * Handles blocks of uniform on the GPU.
  7385. *
  7386. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7387. *
  7388. * For more information, please refer to :
  7389. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7390. * @param engine Define the engine the buffer is associated with
  7391. * @param data Define the data contained in the buffer
  7392. * @param dynamic Define if the buffer is updatable
  7393. */
  7394. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7395. /**
  7396. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7397. * or just falling back on setUniformXXX calls.
  7398. */
  7399. get useUbo(): boolean;
  7400. /**
  7401. * Indicates if the WebGL underlying uniform buffer is in sync
  7402. * with the javascript cache data.
  7403. */
  7404. get isSync(): boolean;
  7405. /**
  7406. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7407. * Also, a dynamic UniformBuffer will disable cache verification and always
  7408. * update the underlying WebGL uniform buffer to the GPU.
  7409. * @returns if Dynamic, otherwise false
  7410. */
  7411. isDynamic(): boolean;
  7412. /**
  7413. * The data cache on JS side.
  7414. * @returns the underlying data as a float array
  7415. */
  7416. getData(): Float32Array;
  7417. /**
  7418. * The underlying WebGL Uniform buffer.
  7419. * @returns the webgl buffer
  7420. */
  7421. getBuffer(): Nullable<DataBuffer>;
  7422. /**
  7423. * std140 layout specifies how to align data within an UBO structure.
  7424. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7425. * for specs.
  7426. */
  7427. private _fillAlignment;
  7428. /**
  7429. * Adds an uniform in the buffer.
  7430. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7431. * for the layout to be correct !
  7432. * @param name Name of the uniform, as used in the uniform block in the shader.
  7433. * @param size Data size, or data directly.
  7434. */
  7435. addUniform(name: string, size: number | number[]): void;
  7436. /**
  7437. * Adds a Matrix 4x4 to the uniform buffer.
  7438. * @param name Name of the uniform, as used in the uniform block in the shader.
  7439. * @param mat A 4x4 matrix.
  7440. */
  7441. addMatrix(name: string, mat: Matrix): void;
  7442. /**
  7443. * Adds a vec2 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param x Define the x component value of the vec2
  7446. * @param y Define the y component value of the vec2
  7447. */
  7448. addFloat2(name: string, x: number, y: number): void;
  7449. /**
  7450. * Adds a vec3 to the uniform buffer.
  7451. * @param name Name of the uniform, as used in the uniform block in the shader.
  7452. * @param x Define the x component value of the vec3
  7453. * @param y Define the y component value of the vec3
  7454. * @param z Define the z component value of the vec3
  7455. */
  7456. addFloat3(name: string, x: number, y: number, z: number): void;
  7457. /**
  7458. * Adds a vec3 to the uniform buffer.
  7459. * @param name Name of the uniform, as used in the uniform block in the shader.
  7460. * @param color Define the vec3 from a Color
  7461. */
  7462. addColor3(name: string, color: Color3): void;
  7463. /**
  7464. * Adds a vec4 to the uniform buffer.
  7465. * @param name Name of the uniform, as used in the uniform block in the shader.
  7466. * @param color Define the rgb components from a Color
  7467. * @param alpha Define the a component of the vec4
  7468. */
  7469. addColor4(name: string, color: Color3, alpha: number): void;
  7470. /**
  7471. * Adds a vec3 to the uniform buffer.
  7472. * @param name Name of the uniform, as used in the uniform block in the shader.
  7473. * @param vector Define the vec3 components from a Vector
  7474. */
  7475. addVector3(name: string, vector: Vector3): void;
  7476. /**
  7477. * Adds a Matrix 3x3 to the uniform buffer.
  7478. * @param name Name of the uniform, as used in the uniform block in the shader.
  7479. */
  7480. addMatrix3x3(name: string): void;
  7481. /**
  7482. * Adds a Matrix 2x2 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. */
  7485. addMatrix2x2(name: string): void;
  7486. /**
  7487. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7488. */
  7489. create(): void;
  7490. /** @hidden */
  7491. _rebuild(): void;
  7492. /**
  7493. * Updates the WebGL Uniform Buffer on the GPU.
  7494. * If the `dynamic` flag is set to true, no cache comparison is done.
  7495. * Otherwise, the buffer will be updated only if the cache differs.
  7496. */
  7497. update(): void;
  7498. /**
  7499. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. * @param size Define the size of the data.
  7503. */
  7504. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7505. private _valueCache;
  7506. private _cacheMatrix;
  7507. private _updateMatrix3x3ForUniform;
  7508. private _updateMatrix3x3ForEffect;
  7509. private _updateMatrix2x2ForEffect;
  7510. private _updateMatrix2x2ForUniform;
  7511. private _updateFloatForEffect;
  7512. private _updateFloatForUniform;
  7513. private _updateFloat2ForEffect;
  7514. private _updateFloat2ForUniform;
  7515. private _updateFloat3ForEffect;
  7516. private _updateFloat3ForUniform;
  7517. private _updateFloat4ForEffect;
  7518. private _updateFloat4ForUniform;
  7519. private _updateMatrixForEffect;
  7520. private _updateMatrixForUniform;
  7521. private _updateVector3ForEffect;
  7522. private _updateVector3ForUniform;
  7523. private _updateVector4ForEffect;
  7524. private _updateVector4ForUniform;
  7525. private _updateColor3ForEffect;
  7526. private _updateColor3ForUniform;
  7527. private _updateColor4ForEffect;
  7528. private _updateColor4ForUniform;
  7529. /**
  7530. * Sets a sampler uniform on the effect.
  7531. * @param name Define the name of the sampler.
  7532. * @param texture Define the texture to set in the sampler
  7533. */
  7534. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7535. /**
  7536. * Directly updates the value of the uniform in the cache AND on the GPU.
  7537. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7538. * @param data Define the flattened data
  7539. */
  7540. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7541. /**
  7542. * Binds this uniform buffer to an effect.
  7543. * @param effect Define the effect to bind the buffer to
  7544. * @param name Name of the uniform block in the shader.
  7545. */
  7546. bindToEffect(effect: Effect, name: string): void;
  7547. /**
  7548. * Disposes the uniform buffer.
  7549. */
  7550. dispose(): void;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/iInspectable" {
  7554. /**
  7555. * Enum that determines the text-wrapping mode to use.
  7556. */
  7557. export enum InspectableType {
  7558. /**
  7559. * Checkbox for booleans
  7560. */
  7561. Checkbox = 0,
  7562. /**
  7563. * Sliders for numbers
  7564. */
  7565. Slider = 1,
  7566. /**
  7567. * Vector3
  7568. */
  7569. Vector3 = 2,
  7570. /**
  7571. * Quaternions
  7572. */
  7573. Quaternion = 3,
  7574. /**
  7575. * Color3
  7576. */
  7577. Color3 = 4,
  7578. /**
  7579. * String
  7580. */
  7581. String = 5
  7582. }
  7583. /**
  7584. * Interface used to define custom inspectable properties.
  7585. * This interface is used by the inspector to display custom property grids
  7586. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7587. */
  7588. export interface IInspectable {
  7589. /**
  7590. * Gets the label to display
  7591. */
  7592. label: string;
  7593. /**
  7594. * Gets the name of the property to edit
  7595. */
  7596. propertyName: string;
  7597. /**
  7598. * Gets the type of the editor to use
  7599. */
  7600. type: InspectableType;
  7601. /**
  7602. * Gets the minimum value of the property when using in "slider" mode
  7603. */
  7604. min?: number;
  7605. /**
  7606. * Gets the maximum value of the property when using in "slider" mode
  7607. */
  7608. max?: number;
  7609. /**
  7610. * Gets the setp to use when using in "slider" mode
  7611. */
  7612. step?: number;
  7613. }
  7614. }
  7615. declare module "babylonjs/Misc/timingTools" {
  7616. /**
  7617. * Class used to provide helper for timing
  7618. */
  7619. export class TimingTools {
  7620. /**
  7621. * Polyfill for setImmediate
  7622. * @param action defines the action to execute after the current execution block
  7623. */
  7624. static SetImmediate(action: () => void): void;
  7625. }
  7626. }
  7627. declare module "babylonjs/Misc/instantiationTools" {
  7628. /**
  7629. * Class used to enable instatition of objects by class name
  7630. */
  7631. export class InstantiationTools {
  7632. /**
  7633. * Use this object to register external classes like custom textures or material
  7634. * to allow the laoders to instantiate them
  7635. */
  7636. static RegisteredExternalClasses: {
  7637. [key: string]: Object;
  7638. };
  7639. /**
  7640. * Tries to instantiate a new object from a given class name
  7641. * @param className defines the class name to instantiate
  7642. * @returns the new object or null if the system was not able to do the instantiation
  7643. */
  7644. static Instantiate(className: string): any;
  7645. }
  7646. }
  7647. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7648. /**
  7649. * Define options used to create a depth texture
  7650. */
  7651. export class DepthTextureCreationOptions {
  7652. /** Specifies whether or not a stencil should be allocated in the texture */
  7653. generateStencil?: boolean;
  7654. /** Specifies whether or not bilinear filtering is enable on the texture */
  7655. bilinearFiltering?: boolean;
  7656. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7657. comparisonFunction?: number;
  7658. /** Specifies if the created texture is a cube texture */
  7659. isCube?: boolean;
  7660. }
  7661. }
  7662. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7664. import { Nullable } from "babylonjs/types";
  7665. import { Scene } from "babylonjs/scene";
  7666. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7667. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7668. module "babylonjs/Engines/thinEngine" {
  7669. interface ThinEngine {
  7670. /**
  7671. * Creates a depth stencil cube texture.
  7672. * This is only available in WebGL 2.
  7673. * @param size The size of face edge in the cube texture.
  7674. * @param options The options defining the cube texture.
  7675. * @returns The cube texture
  7676. */
  7677. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7678. /**
  7679. * Creates a cube texture
  7680. * @param rootUrl defines the url where the files to load is located
  7681. * @param scene defines the current scene
  7682. * @param files defines the list of files to load (1 per face)
  7683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7684. * @param onLoad defines an optional callback raised when the texture is loaded
  7685. * @param onError defines an optional callback raised if there is an issue to load the texture
  7686. * @param format defines the format of the data
  7687. * @param forcedExtension defines the extension to use to pick the right loader
  7688. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7689. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7690. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7691. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7692. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7693. * @returns the cube texture as an InternalTexture
  7694. */
  7695. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7696. /**
  7697. * Creates a cube texture
  7698. * @param rootUrl defines the url where the files to load is located
  7699. * @param scene defines the current scene
  7700. * @param files defines the list of files to load (1 per face)
  7701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7702. * @param onLoad defines an optional callback raised when the texture is loaded
  7703. * @param onError defines an optional callback raised if there is an issue to load the texture
  7704. * @param format defines the format of the data
  7705. * @param forcedExtension defines the extension to use to pick the right loader
  7706. * @returns the cube texture as an InternalTexture
  7707. */
  7708. 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;
  7709. /**
  7710. * Creates a cube texture
  7711. * @param rootUrl defines the url where the files to load is located
  7712. * @param scene defines the current scene
  7713. * @param files defines the list of files to load (1 per face)
  7714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7715. * @param onLoad defines an optional callback raised when the texture is loaded
  7716. * @param onError defines an optional callback raised if there is an issue to load the texture
  7717. * @param format defines the format of the data
  7718. * @param forcedExtension defines the extension to use to pick the right loader
  7719. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  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, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7725. /** @hidden */
  7726. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7727. /** @hidden */
  7728. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7729. /** @hidden */
  7730. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7731. /** @hidden */
  7732. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7733. /**
  7734. * @hidden
  7735. */
  7736. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7737. }
  7738. }
  7739. }
  7740. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7741. import { Nullable } from "babylonjs/types";
  7742. import { Scene } from "babylonjs/scene";
  7743. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7745. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7746. /**
  7747. * Class for creating a cube texture
  7748. */
  7749. export class CubeTexture extends BaseTexture {
  7750. private _delayedOnLoad;
  7751. /**
  7752. * The url of the texture
  7753. */
  7754. url: string;
  7755. /**
  7756. * Gets or sets the center of the bounding box associated with the cube texture.
  7757. * It must define where the camera used to render the texture was set
  7758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7759. */
  7760. boundingBoxPosition: Vector3;
  7761. private _boundingBoxSize;
  7762. /**
  7763. * Gets or sets the size of the bounding box associated with the cube texture
  7764. * When defined, the cubemap will switch to local mode
  7765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7766. * @example https://www.babylonjs-playground.com/#RNASML
  7767. */
  7768. set boundingBoxSize(value: Vector3);
  7769. /**
  7770. * Returns the bounding box size
  7771. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7772. */
  7773. get boundingBoxSize(): Vector3;
  7774. protected _rotationY: number;
  7775. /**
  7776. * Sets texture matrix rotation angle around Y axis in radians.
  7777. */
  7778. set rotationY(value: number);
  7779. /**
  7780. * Gets texture matrix rotation angle around Y axis radians.
  7781. */
  7782. get rotationY(): number;
  7783. /**
  7784. * Are mip maps generated for this texture or not.
  7785. */
  7786. get noMipmap(): boolean;
  7787. private _noMipmap;
  7788. private _files;
  7789. protected _forcedExtension: Nullable<string>;
  7790. private _extensions;
  7791. private _textureMatrix;
  7792. private _format;
  7793. private _createPolynomials;
  7794. /** @hidden */
  7795. _prefiltered: boolean;
  7796. /**
  7797. * Creates a cube texture from an array of image urls
  7798. * @param files defines an array of image urls
  7799. * @param scene defines the hosting scene
  7800. * @param noMipmap specifies if mip maps are not used
  7801. * @returns a cube texture
  7802. */
  7803. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7804. /**
  7805. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7806. * @param url defines the url of the prefiltered texture
  7807. * @param scene defines the scene the texture is attached to
  7808. * @param forcedExtension defines the extension of the file if different from the url
  7809. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7810. * @return the prefiltered texture
  7811. */
  7812. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7813. /**
  7814. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7815. * as prefiltered data.
  7816. * @param rootUrl defines the url of the texture or the root name of the six images
  7817. * @param scene defines the scene the texture is attached to
  7818. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7819. * @param noMipmap defines if mipmaps should be created or not
  7820. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7821. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7822. * @param onError defines a callback triggered in case of error during load
  7823. * @param format defines the internal format to use for the texture once loaded
  7824. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7825. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7826. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7827. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7828. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7829. * @return the cube texture
  7830. */
  7831. 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);
  7832. /**
  7833. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7834. */
  7835. get isPrefiltered(): boolean;
  7836. /**
  7837. * Get the current class name of the texture useful for serialization or dynamic coding.
  7838. * @returns "CubeTexture"
  7839. */
  7840. getClassName(): string;
  7841. /**
  7842. * Update the url (and optional buffer) of this texture if url was null during construction.
  7843. * @param url the url of the texture
  7844. * @param forcedExtension defines the extension to use
  7845. * @param onLoad callback called when the texture is loaded (defaults to null)
  7846. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7847. */
  7848. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7849. /**
  7850. * Delays loading of the cube texture
  7851. * @param forcedExtension defines the extension to use
  7852. */
  7853. delayLoad(forcedExtension?: string): void;
  7854. /**
  7855. * Returns the reflection texture matrix
  7856. * @returns the reflection texture matrix
  7857. */
  7858. getReflectionTextureMatrix(): Matrix;
  7859. /**
  7860. * Sets the reflection texture matrix
  7861. * @param value Reflection texture matrix
  7862. */
  7863. setReflectionTextureMatrix(value: Matrix): void;
  7864. /**
  7865. * Parses text to create a cube texture
  7866. * @param parsedTexture define the serialized text to read from
  7867. * @param scene defines the hosting scene
  7868. * @param rootUrl defines the root url of the cube texture
  7869. * @returns a cube texture
  7870. */
  7871. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7872. /**
  7873. * Makes a clone, or deep copy, of the cube texture
  7874. * @returns a new cube texture
  7875. */
  7876. clone(): CubeTexture;
  7877. }
  7878. }
  7879. declare module "babylonjs/Materials/materialDefines" {
  7880. /**
  7881. * Manages the defines for the Material
  7882. */
  7883. export class MaterialDefines {
  7884. /** @hidden */
  7885. protected _keys: string[];
  7886. private _isDirty;
  7887. /** @hidden */
  7888. _renderId: number;
  7889. /** @hidden */
  7890. _areLightsDirty: boolean;
  7891. /** @hidden */
  7892. _areLightsDisposed: boolean;
  7893. /** @hidden */
  7894. _areAttributesDirty: boolean;
  7895. /** @hidden */
  7896. _areTexturesDirty: boolean;
  7897. /** @hidden */
  7898. _areFresnelDirty: boolean;
  7899. /** @hidden */
  7900. _areMiscDirty: boolean;
  7901. /** @hidden */
  7902. _areImageProcessingDirty: boolean;
  7903. /** @hidden */
  7904. _normals: boolean;
  7905. /** @hidden */
  7906. _uvs: boolean;
  7907. /** @hidden */
  7908. _needNormals: boolean;
  7909. /** @hidden */
  7910. _needUVs: boolean;
  7911. [id: string]: any;
  7912. /**
  7913. * Specifies if the material needs to be re-calculated
  7914. */
  7915. get isDirty(): boolean;
  7916. /**
  7917. * Marks the material to indicate that it has been re-calculated
  7918. */
  7919. markAsProcessed(): void;
  7920. /**
  7921. * Marks the material to indicate that it needs to be re-calculated
  7922. */
  7923. markAsUnprocessed(): void;
  7924. /**
  7925. * Marks the material to indicate all of its defines need to be re-calculated
  7926. */
  7927. markAllAsDirty(): void;
  7928. /**
  7929. * Marks the material to indicate that image processing needs to be re-calculated
  7930. */
  7931. markAsImageProcessingDirty(): void;
  7932. /**
  7933. * Marks the material to indicate the lights need to be re-calculated
  7934. * @param disposed Defines whether the light is dirty due to dispose or not
  7935. */
  7936. markAsLightDirty(disposed?: boolean): void;
  7937. /**
  7938. * Marks the attribute state as changed
  7939. */
  7940. markAsAttributesDirty(): void;
  7941. /**
  7942. * Marks the texture state as changed
  7943. */
  7944. markAsTexturesDirty(): void;
  7945. /**
  7946. * Marks the fresnel state as changed
  7947. */
  7948. markAsFresnelDirty(): void;
  7949. /**
  7950. * Marks the misc state as changed
  7951. */
  7952. markAsMiscDirty(): void;
  7953. /**
  7954. * Rebuilds the material defines
  7955. */
  7956. rebuild(): void;
  7957. /**
  7958. * Specifies if two material defines are equal
  7959. * @param other - A material define instance to compare to
  7960. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7961. */
  7962. isEqual(other: MaterialDefines): boolean;
  7963. /**
  7964. * Clones this instance's defines to another instance
  7965. * @param other - material defines to clone values to
  7966. */
  7967. cloneTo(other: MaterialDefines): void;
  7968. /**
  7969. * Resets the material define values
  7970. */
  7971. reset(): void;
  7972. /**
  7973. * Converts the material define values to a string
  7974. * @returns - String of material define information
  7975. */
  7976. toString(): string;
  7977. }
  7978. }
  7979. declare module "babylonjs/Materials/colorCurves" {
  7980. import { Effect } from "babylonjs/Materials/effect";
  7981. /**
  7982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7984. * 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;
  7985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7986. */
  7987. export class ColorCurves {
  7988. private _dirty;
  7989. private _tempColor;
  7990. private _globalCurve;
  7991. private _highlightsCurve;
  7992. private _midtonesCurve;
  7993. private _shadowsCurve;
  7994. private _positiveCurve;
  7995. private _negativeCurve;
  7996. private _globalHue;
  7997. private _globalDensity;
  7998. private _globalSaturation;
  7999. private _globalExposure;
  8000. /**
  8001. * Gets the global Hue value.
  8002. * 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).
  8003. */
  8004. get globalHue(): number;
  8005. /**
  8006. * Sets the global Hue value.
  8007. * 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).
  8008. */
  8009. set globalHue(value: number);
  8010. /**
  8011. * Gets the global Density value.
  8012. * 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.
  8013. * Values less than zero provide a filter of opposite hue.
  8014. */
  8015. get globalDensity(): number;
  8016. /**
  8017. * Sets the global Density value.
  8018. * 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.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. set globalDensity(value: number);
  8022. /**
  8023. * Gets the global Saturation value.
  8024. * 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.
  8025. */
  8026. get globalSaturation(): number;
  8027. /**
  8028. * Sets the global Saturation value.
  8029. * 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.
  8030. */
  8031. set globalSaturation(value: number);
  8032. /**
  8033. * Gets the global Exposure value.
  8034. * 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.
  8035. */
  8036. get globalExposure(): number;
  8037. /**
  8038. * Sets the global Exposure value.
  8039. * 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.
  8040. */
  8041. set globalExposure(value: number);
  8042. private _highlightsHue;
  8043. private _highlightsDensity;
  8044. private _highlightsSaturation;
  8045. private _highlightsExposure;
  8046. /**
  8047. * Gets the highlights Hue value.
  8048. * 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).
  8049. */
  8050. get highlightsHue(): number;
  8051. /**
  8052. * Sets the highlights Hue value.
  8053. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8054. */
  8055. set highlightsHue(value: number);
  8056. /**
  8057. * Gets the highlights Density value.
  8058. * 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.
  8059. * Values less than zero provide a filter of opposite hue.
  8060. */
  8061. get highlightsDensity(): number;
  8062. /**
  8063. * Sets the highlights Density value.
  8064. * 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.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. set highlightsDensity(value: number);
  8068. /**
  8069. * Gets the highlights Saturation value.
  8070. * 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.
  8071. */
  8072. get highlightsSaturation(): number;
  8073. /**
  8074. * Sets the highlights Saturation value.
  8075. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8076. */
  8077. set highlightsSaturation(value: number);
  8078. /**
  8079. * Gets the highlights Exposure value.
  8080. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8081. */
  8082. get highlightsExposure(): number;
  8083. /**
  8084. * Sets the highlights Exposure value.
  8085. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8086. */
  8087. set highlightsExposure(value: number);
  8088. private _midtonesHue;
  8089. private _midtonesDensity;
  8090. private _midtonesSaturation;
  8091. private _midtonesExposure;
  8092. /**
  8093. * Gets the midtones Hue value.
  8094. * 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).
  8095. */
  8096. get midtonesHue(): number;
  8097. /**
  8098. * Sets the midtones Hue value.
  8099. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8100. */
  8101. set midtonesHue(value: number);
  8102. /**
  8103. * Gets the midtones Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. get midtonesDensity(): number;
  8108. /**
  8109. * Sets the midtones Density value.
  8110. * 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.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. set midtonesDensity(value: number);
  8114. /**
  8115. * Gets the midtones Saturation value.
  8116. * 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.
  8117. */
  8118. get midtonesSaturation(): number;
  8119. /**
  8120. * Sets the midtones Saturation value.
  8121. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8122. */
  8123. set midtonesSaturation(value: number);
  8124. /**
  8125. * Gets the midtones Exposure value.
  8126. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8127. */
  8128. get midtonesExposure(): number;
  8129. /**
  8130. * Sets the midtones Exposure value.
  8131. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8132. */
  8133. set midtonesExposure(value: number);
  8134. private _shadowsHue;
  8135. private _shadowsDensity;
  8136. private _shadowsSaturation;
  8137. private _shadowsExposure;
  8138. /**
  8139. * Gets the shadows Hue value.
  8140. * 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).
  8141. */
  8142. get shadowsHue(): number;
  8143. /**
  8144. * Sets the shadows Hue value.
  8145. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8146. */
  8147. set shadowsHue(value: number);
  8148. /**
  8149. * Gets the shadows Density value.
  8150. * 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.
  8151. * Values less than zero provide a filter of opposite hue.
  8152. */
  8153. get shadowsDensity(): number;
  8154. /**
  8155. * Sets the shadows Density value.
  8156. * 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.
  8157. * Values less than zero provide a filter of opposite hue.
  8158. */
  8159. set shadowsDensity(value: number);
  8160. /**
  8161. * Gets the shadows Saturation value.
  8162. * 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.
  8163. */
  8164. get shadowsSaturation(): number;
  8165. /**
  8166. * Sets the shadows Saturation value.
  8167. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8168. */
  8169. set shadowsSaturation(value: number);
  8170. /**
  8171. * Gets the shadows Exposure value.
  8172. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8173. */
  8174. get shadowsExposure(): number;
  8175. /**
  8176. * Sets the shadows Exposure value.
  8177. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8178. */
  8179. set shadowsExposure(value: number);
  8180. /**
  8181. * Returns the class name
  8182. * @returns The class name
  8183. */
  8184. getClassName(): string;
  8185. /**
  8186. * Binds the color curves to the shader.
  8187. * @param colorCurves The color curve to bind
  8188. * @param effect The effect to bind to
  8189. * @param positiveUniform The positive uniform shader parameter
  8190. * @param neutralUniform The neutral uniform shader parameter
  8191. * @param negativeUniform The negative uniform shader parameter
  8192. */
  8193. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8194. /**
  8195. * Prepare the list of uniforms associated with the ColorCurves effects.
  8196. * @param uniformsList The list of uniforms used in the effect
  8197. */
  8198. static PrepareUniforms(uniformsList: string[]): void;
  8199. /**
  8200. * Returns color grading data based on a hue, density, saturation and exposure value.
  8201. * @param filterHue The hue of the color filter.
  8202. * @param filterDensity The density of the color filter.
  8203. * @param saturation The saturation.
  8204. * @param exposure The exposure.
  8205. * @param result The result data container.
  8206. */
  8207. private getColorGradingDataToRef;
  8208. /**
  8209. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8210. * @param value The input slider value in range [-100,100].
  8211. * @returns Adjusted value.
  8212. */
  8213. private static applyColorGradingSliderNonlinear;
  8214. /**
  8215. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8216. * @param hue The hue (H) input.
  8217. * @param saturation The saturation (S) input.
  8218. * @param brightness The brightness (B) input.
  8219. * @result An RGBA color represented as Vector4.
  8220. */
  8221. private static fromHSBToRef;
  8222. /**
  8223. * Returns a value clamped between min and max
  8224. * @param value The value to clamp
  8225. * @param min The minimum of value
  8226. * @param max The maximum of value
  8227. * @returns The clamped value.
  8228. */
  8229. private static clamp;
  8230. /**
  8231. * Clones the current color curve instance.
  8232. * @return The cloned curves
  8233. */
  8234. clone(): ColorCurves;
  8235. /**
  8236. * Serializes the current color curve instance to a json representation.
  8237. * @return a JSON representation
  8238. */
  8239. serialize(): any;
  8240. /**
  8241. * Parses the color curve from a json representation.
  8242. * @param source the JSON source to parse
  8243. * @return The parsed curves
  8244. */
  8245. static Parse(source: any): ColorCurves;
  8246. }
  8247. }
  8248. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8249. import { Observable } from "babylonjs/Misc/observable";
  8250. import { Nullable } from "babylonjs/types";
  8251. import { Color4 } from "babylonjs/Maths/math.color";
  8252. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8253. import { Effect } from "babylonjs/Materials/effect";
  8254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8255. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8256. /**
  8257. * Interface to follow in your material defines to integrate easily the
  8258. * Image proccessing functions.
  8259. * @hidden
  8260. */
  8261. export interface IImageProcessingConfigurationDefines {
  8262. IMAGEPROCESSING: boolean;
  8263. VIGNETTE: boolean;
  8264. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8265. VIGNETTEBLENDMODEOPAQUE: boolean;
  8266. TONEMAPPING: boolean;
  8267. TONEMAPPING_ACES: boolean;
  8268. CONTRAST: boolean;
  8269. EXPOSURE: boolean;
  8270. COLORCURVES: boolean;
  8271. COLORGRADING: boolean;
  8272. COLORGRADING3D: boolean;
  8273. SAMPLER3DGREENDEPTH: boolean;
  8274. SAMPLER3DBGRMAP: boolean;
  8275. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8276. }
  8277. /**
  8278. * @hidden
  8279. */
  8280. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8281. IMAGEPROCESSING: boolean;
  8282. VIGNETTE: boolean;
  8283. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8284. VIGNETTEBLENDMODEOPAQUE: boolean;
  8285. TONEMAPPING: boolean;
  8286. TONEMAPPING_ACES: boolean;
  8287. CONTRAST: boolean;
  8288. COLORCURVES: boolean;
  8289. COLORGRADING: boolean;
  8290. COLORGRADING3D: boolean;
  8291. SAMPLER3DGREENDEPTH: boolean;
  8292. SAMPLER3DBGRMAP: boolean;
  8293. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8294. EXPOSURE: boolean;
  8295. constructor();
  8296. }
  8297. /**
  8298. * This groups together the common properties used for image processing either in direct forward pass
  8299. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8300. * or not.
  8301. */
  8302. export class ImageProcessingConfiguration {
  8303. /**
  8304. * Default tone mapping applied in BabylonJS.
  8305. */
  8306. static readonly TONEMAPPING_STANDARD: number;
  8307. /**
  8308. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8309. * to other engines rendering to increase portability.
  8310. */
  8311. static readonly TONEMAPPING_ACES: number;
  8312. /**
  8313. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8314. */
  8315. colorCurves: Nullable<ColorCurves>;
  8316. private _colorCurvesEnabled;
  8317. /**
  8318. * Gets wether the color curves effect is enabled.
  8319. */
  8320. get colorCurvesEnabled(): boolean;
  8321. /**
  8322. * Sets wether the color curves effect is enabled.
  8323. */
  8324. set colorCurvesEnabled(value: boolean);
  8325. private _colorGradingTexture;
  8326. /**
  8327. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8328. */
  8329. get colorGradingTexture(): Nullable<BaseTexture>;
  8330. /**
  8331. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8332. */
  8333. set colorGradingTexture(value: Nullable<BaseTexture>);
  8334. private _colorGradingEnabled;
  8335. /**
  8336. * Gets wether the color grading effect is enabled.
  8337. */
  8338. get colorGradingEnabled(): boolean;
  8339. /**
  8340. * Sets wether the color grading effect is enabled.
  8341. */
  8342. set colorGradingEnabled(value: boolean);
  8343. private _colorGradingWithGreenDepth;
  8344. /**
  8345. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8346. */
  8347. get colorGradingWithGreenDepth(): boolean;
  8348. /**
  8349. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8350. */
  8351. set colorGradingWithGreenDepth(value: boolean);
  8352. private _colorGradingBGR;
  8353. /**
  8354. * Gets wether the color grading texture contains BGR values.
  8355. */
  8356. get colorGradingBGR(): boolean;
  8357. /**
  8358. * Sets wether the color grading texture contains BGR values.
  8359. */
  8360. set colorGradingBGR(value: boolean);
  8361. /** @hidden */
  8362. _exposure: number;
  8363. /**
  8364. * Gets the Exposure used in the effect.
  8365. */
  8366. get exposure(): number;
  8367. /**
  8368. * Sets the Exposure used in the effect.
  8369. */
  8370. set exposure(value: number);
  8371. private _toneMappingEnabled;
  8372. /**
  8373. * Gets wether the tone mapping effect is enabled.
  8374. */
  8375. get toneMappingEnabled(): boolean;
  8376. /**
  8377. * Sets wether the tone mapping effect is enabled.
  8378. */
  8379. set toneMappingEnabled(value: boolean);
  8380. private _toneMappingType;
  8381. /**
  8382. * Gets the type of tone mapping effect.
  8383. */
  8384. get toneMappingType(): number;
  8385. /**
  8386. * Sets the type of tone mapping effect used in BabylonJS.
  8387. */
  8388. set toneMappingType(value: number);
  8389. protected _contrast: number;
  8390. /**
  8391. * Gets the contrast used in the effect.
  8392. */
  8393. get contrast(): number;
  8394. /**
  8395. * Sets the contrast used in the effect.
  8396. */
  8397. set contrast(value: number);
  8398. /**
  8399. * Vignette stretch size.
  8400. */
  8401. vignetteStretch: number;
  8402. /**
  8403. * Vignette centre X Offset.
  8404. */
  8405. vignetteCentreX: number;
  8406. /**
  8407. * Vignette centre Y Offset.
  8408. */
  8409. vignetteCentreY: number;
  8410. /**
  8411. * Vignette weight or intensity of the vignette effect.
  8412. */
  8413. vignetteWeight: number;
  8414. /**
  8415. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8416. * if vignetteEnabled is set to true.
  8417. */
  8418. vignetteColor: Color4;
  8419. /**
  8420. * Camera field of view used by the Vignette effect.
  8421. */
  8422. vignetteCameraFov: number;
  8423. private _vignetteBlendMode;
  8424. /**
  8425. * Gets the vignette blend mode allowing different kind of effect.
  8426. */
  8427. get vignetteBlendMode(): number;
  8428. /**
  8429. * Sets the vignette blend mode allowing different kind of effect.
  8430. */
  8431. set vignetteBlendMode(value: number);
  8432. private _vignetteEnabled;
  8433. /**
  8434. * Gets wether the vignette effect is enabled.
  8435. */
  8436. get vignetteEnabled(): boolean;
  8437. /**
  8438. * Sets wether the vignette effect is enabled.
  8439. */
  8440. set vignetteEnabled(value: boolean);
  8441. private _applyByPostProcess;
  8442. /**
  8443. * Gets wether the image processing is applied through a post process or not.
  8444. */
  8445. get applyByPostProcess(): boolean;
  8446. /**
  8447. * Sets wether the image processing is applied through a post process or not.
  8448. */
  8449. set applyByPostProcess(value: boolean);
  8450. private _isEnabled;
  8451. /**
  8452. * Gets wether the image processing is enabled or not.
  8453. */
  8454. get isEnabled(): boolean;
  8455. /**
  8456. * Sets wether the image processing is enabled or not.
  8457. */
  8458. set isEnabled(value: boolean);
  8459. /**
  8460. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8461. */
  8462. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8463. /**
  8464. * Method called each time the image processing information changes requires to recompile the effect.
  8465. */
  8466. protected _updateParameters(): void;
  8467. /**
  8468. * Gets the current class name.
  8469. * @return "ImageProcessingConfiguration"
  8470. */
  8471. getClassName(): string;
  8472. /**
  8473. * Prepare the list of uniforms associated with the Image Processing effects.
  8474. * @param uniforms The list of uniforms used in the effect
  8475. * @param defines the list of defines currently in use
  8476. */
  8477. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8478. /**
  8479. * Prepare the list of samplers associated with the Image Processing effects.
  8480. * @param samplersList The list of uniforms used in the effect
  8481. * @param defines the list of defines currently in use
  8482. */
  8483. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8484. /**
  8485. * Prepare the list of defines associated to the shader.
  8486. * @param defines the list of defines to complete
  8487. * @param forPostProcess Define if we are currently in post process mode or not
  8488. */
  8489. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8490. /**
  8491. * Returns true if all the image processing information are ready.
  8492. * @returns True if ready, otherwise, false
  8493. */
  8494. isReady(): boolean;
  8495. /**
  8496. * Binds the image processing to the shader.
  8497. * @param effect The effect to bind to
  8498. * @param overrideAspectRatio Override the aspect ratio of the effect
  8499. */
  8500. bind(effect: Effect, overrideAspectRatio?: number): void;
  8501. /**
  8502. * Clones the current image processing instance.
  8503. * @return The cloned image processing
  8504. */
  8505. clone(): ImageProcessingConfiguration;
  8506. /**
  8507. * Serializes the current image processing instance to a json representation.
  8508. * @return a JSON representation
  8509. */
  8510. serialize(): any;
  8511. /**
  8512. * Parses the image processing from a json representation.
  8513. * @param source the JSON source to parse
  8514. * @return The parsed image processing
  8515. */
  8516. static Parse(source: any): ImageProcessingConfiguration;
  8517. private static _VIGNETTEMODE_MULTIPLY;
  8518. private static _VIGNETTEMODE_OPAQUE;
  8519. /**
  8520. * Used to apply the vignette as a mix with the pixel color.
  8521. */
  8522. static get VIGNETTEMODE_MULTIPLY(): number;
  8523. /**
  8524. * Used to apply the vignette as a replacement of the pixel color.
  8525. */
  8526. static get VIGNETTEMODE_OPAQUE(): number;
  8527. }
  8528. }
  8529. declare module "babylonjs/Shaders/postprocess.vertex" {
  8530. /** @hidden */
  8531. export var postprocessVertexShader: {
  8532. name: string;
  8533. shader: string;
  8534. };
  8535. }
  8536. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8538. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8539. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8540. module "babylonjs/Engines/thinEngine" {
  8541. interface ThinEngine {
  8542. /**
  8543. * Creates a new render target texture
  8544. * @param size defines the size of the texture
  8545. * @param options defines the options used to create the texture
  8546. * @returns a new render target texture stored in an InternalTexture
  8547. */
  8548. createRenderTargetTexture(size: number | {
  8549. width: number;
  8550. height: number;
  8551. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8552. /**
  8553. * Creates a depth stencil texture.
  8554. * This is only available in WebGL 2 or with the depth texture extension available.
  8555. * @param size The size of face edge in the texture.
  8556. * @param options The options defining the texture.
  8557. * @returns The texture
  8558. */
  8559. createDepthStencilTexture(size: number | {
  8560. width: number;
  8561. height: number;
  8562. }, options: DepthTextureCreationOptions): InternalTexture;
  8563. /** @hidden */
  8564. _createDepthStencilTexture(size: number | {
  8565. width: number;
  8566. height: number;
  8567. }, options: DepthTextureCreationOptions): InternalTexture;
  8568. }
  8569. }
  8570. }
  8571. declare module "babylonjs/Maths/math.axis" {
  8572. import { Vector3 } from "babylonjs/Maths/math.vector";
  8573. /** Defines supported spaces */
  8574. export enum Space {
  8575. /** Local (object) space */
  8576. LOCAL = 0,
  8577. /** World space */
  8578. WORLD = 1,
  8579. /** Bone space */
  8580. BONE = 2
  8581. }
  8582. /** Defines the 3 main axes */
  8583. export class Axis {
  8584. /** X axis */
  8585. static X: Vector3;
  8586. /** Y axis */
  8587. static Y: Vector3;
  8588. /** Z axis */
  8589. static Z: Vector3;
  8590. }
  8591. }
  8592. declare module "babylonjs/Cameras/targetCamera" {
  8593. import { Nullable } from "babylonjs/types";
  8594. import { Camera } from "babylonjs/Cameras/camera";
  8595. import { Scene } from "babylonjs/scene";
  8596. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8597. /**
  8598. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8599. * This is the base of the follow, arc rotate cameras and Free camera
  8600. * @see http://doc.babylonjs.com/features/cameras
  8601. */
  8602. export class TargetCamera extends Camera {
  8603. private static _RigCamTransformMatrix;
  8604. private static _TargetTransformMatrix;
  8605. private static _TargetFocalPoint;
  8606. /**
  8607. * Define the current direction the camera is moving to
  8608. */
  8609. cameraDirection: Vector3;
  8610. /**
  8611. * Define the current rotation the camera is rotating to
  8612. */
  8613. cameraRotation: Vector2;
  8614. /**
  8615. * When set, the up vector of the camera will be updated by the rotation of the camera
  8616. */
  8617. updateUpVectorFromRotation: boolean;
  8618. private _tmpQuaternion;
  8619. /**
  8620. * Define the current rotation of the camera
  8621. */
  8622. rotation: Vector3;
  8623. /**
  8624. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8625. */
  8626. rotationQuaternion: Quaternion;
  8627. /**
  8628. * Define the current speed of the camera
  8629. */
  8630. speed: number;
  8631. /**
  8632. * Add constraint to the camera to prevent it to move freely in all directions and
  8633. * around all axis.
  8634. */
  8635. noRotationConstraint: boolean;
  8636. /**
  8637. * Define the current target of the camera as an object or a position.
  8638. */
  8639. lockedTarget: any;
  8640. /** @hidden */
  8641. _currentTarget: Vector3;
  8642. /** @hidden */
  8643. _initialFocalDistance: number;
  8644. /** @hidden */
  8645. _viewMatrix: Matrix;
  8646. /** @hidden */
  8647. _camMatrix: Matrix;
  8648. /** @hidden */
  8649. _cameraTransformMatrix: Matrix;
  8650. /** @hidden */
  8651. _cameraRotationMatrix: Matrix;
  8652. /** @hidden */
  8653. _referencePoint: Vector3;
  8654. /** @hidden */
  8655. _transformedReferencePoint: Vector3;
  8656. protected _globalCurrentTarget: Vector3;
  8657. protected _globalCurrentUpVector: Vector3;
  8658. /** @hidden */
  8659. _reset: () => void;
  8660. private _defaultUp;
  8661. /**
  8662. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8663. * This is the base of the follow, arc rotate cameras and Free camera
  8664. * @see http://doc.babylonjs.com/features/cameras
  8665. * @param name Defines the name of the camera in the scene
  8666. * @param position Defines the start position of the camera in the scene
  8667. * @param scene Defines the scene the camera belongs to
  8668. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8669. */
  8670. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8671. /**
  8672. * Gets the position in front of the camera at a given distance.
  8673. * @param distance The distance from the camera we want the position to be
  8674. * @returns the position
  8675. */
  8676. getFrontPosition(distance: number): Vector3;
  8677. /** @hidden */
  8678. _getLockedTargetPosition(): Nullable<Vector3>;
  8679. private _storedPosition;
  8680. private _storedRotation;
  8681. private _storedRotationQuaternion;
  8682. /**
  8683. * Store current camera state of the camera (fov, position, rotation, etc..)
  8684. * @returns the camera
  8685. */
  8686. storeState(): Camera;
  8687. /**
  8688. * Restored camera state. You must call storeState() first
  8689. * @returns whether it was successful or not
  8690. * @hidden
  8691. */
  8692. _restoreStateValues(): boolean;
  8693. /** @hidden */
  8694. _initCache(): void;
  8695. /** @hidden */
  8696. _updateCache(ignoreParentClass?: boolean): void;
  8697. /** @hidden */
  8698. _isSynchronizedViewMatrix(): boolean;
  8699. /** @hidden */
  8700. _computeLocalCameraSpeed(): number;
  8701. /**
  8702. * Defines the target the camera should look at.
  8703. * @param target Defines the new target as a Vector or a mesh
  8704. */
  8705. setTarget(target: Vector3): void;
  8706. /**
  8707. * Return the current target position of the camera. This value is expressed in local space.
  8708. * @returns the target position
  8709. */
  8710. getTarget(): Vector3;
  8711. /** @hidden */
  8712. _decideIfNeedsToMove(): boolean;
  8713. /** @hidden */
  8714. _updatePosition(): void;
  8715. /** @hidden */
  8716. _checkInputs(): void;
  8717. protected _updateCameraRotationMatrix(): void;
  8718. /**
  8719. * 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)
  8720. * @returns the current camera
  8721. */
  8722. private _rotateUpVectorWithCameraRotationMatrix;
  8723. private _cachedRotationZ;
  8724. private _cachedQuaternionRotationZ;
  8725. /** @hidden */
  8726. _getViewMatrix(): Matrix;
  8727. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8728. /**
  8729. * @hidden
  8730. */
  8731. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8732. /**
  8733. * @hidden
  8734. */
  8735. _updateRigCameras(): void;
  8736. private _getRigCamPositionAndTarget;
  8737. /**
  8738. * Gets the current object class name.
  8739. * @return the class name
  8740. */
  8741. getClassName(): string;
  8742. }
  8743. }
  8744. declare module "babylonjs/Events/keyboardEvents" {
  8745. /**
  8746. * Gather the list of keyboard event types as constants.
  8747. */
  8748. export class KeyboardEventTypes {
  8749. /**
  8750. * The keydown event is fired when a key becomes active (pressed).
  8751. */
  8752. static readonly KEYDOWN: number;
  8753. /**
  8754. * The keyup event is fired when a key has been released.
  8755. */
  8756. static readonly KEYUP: number;
  8757. }
  8758. /**
  8759. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8760. */
  8761. export class KeyboardInfo {
  8762. /**
  8763. * Defines the type of event (KeyboardEventTypes)
  8764. */
  8765. type: number;
  8766. /**
  8767. * Defines the related dom event
  8768. */
  8769. event: KeyboardEvent;
  8770. /**
  8771. * Instantiates a new keyboard info.
  8772. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8773. * @param type Defines the type of event (KeyboardEventTypes)
  8774. * @param event Defines the related dom event
  8775. */
  8776. constructor(
  8777. /**
  8778. * Defines the type of event (KeyboardEventTypes)
  8779. */
  8780. type: number,
  8781. /**
  8782. * Defines the related dom event
  8783. */
  8784. event: KeyboardEvent);
  8785. }
  8786. /**
  8787. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8788. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8789. */
  8790. export class KeyboardInfoPre extends KeyboardInfo {
  8791. /**
  8792. * Defines the type of event (KeyboardEventTypes)
  8793. */
  8794. type: number;
  8795. /**
  8796. * Defines the related dom event
  8797. */
  8798. event: KeyboardEvent;
  8799. /**
  8800. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8801. */
  8802. skipOnPointerObservable: boolean;
  8803. /**
  8804. * Instantiates a new keyboard pre info.
  8805. * This class is used to store keyboard related info for the onPreKeyboardObservable 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. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8821. import { Nullable } from "babylonjs/types";
  8822. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8823. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8824. /**
  8825. * Manage the keyboard inputs to control the movement of a free camera.
  8826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8827. */
  8828. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8829. /**
  8830. * Defines the camera the input is attached to.
  8831. */
  8832. camera: FreeCamera;
  8833. /**
  8834. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8835. */
  8836. keysUp: number[];
  8837. /**
  8838. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8839. */
  8840. keysDown: number[];
  8841. /**
  8842. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8843. */
  8844. keysLeft: number[];
  8845. /**
  8846. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8847. */
  8848. keysRight: number[];
  8849. private _keys;
  8850. private _onCanvasBlurObserver;
  8851. private _onKeyboardObserver;
  8852. private _engine;
  8853. private _scene;
  8854. /**
  8855. * Attach the input controls to a specific dom element to get the input from.
  8856. * @param element Defines the element the controls should be listened from
  8857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8858. */
  8859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8860. /**
  8861. * Detach the current controls from the specified dom element.
  8862. * @param element Defines the element to stop listening the inputs from
  8863. */
  8864. detachControl(element: Nullable<HTMLElement>): void;
  8865. /**
  8866. * Update the current camera state depending on the inputs that have been used this frame.
  8867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8868. */
  8869. checkInputs(): void;
  8870. /**
  8871. * Gets the class name of the current intput.
  8872. * @returns the class name
  8873. */
  8874. getClassName(): string;
  8875. /** @hidden */
  8876. _onLostFocus(): void;
  8877. /**
  8878. * Get the friendly name associated with the input class.
  8879. * @returns the input friendly name
  8880. */
  8881. getSimpleName(): string;
  8882. }
  8883. }
  8884. declare module "babylonjs/Lights/shadowLight" {
  8885. import { Camera } from "babylonjs/Cameras/camera";
  8886. import { Scene } from "babylonjs/scene";
  8887. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8889. import { Light } from "babylonjs/Lights/light";
  8890. /**
  8891. * Interface describing all the common properties and methods a shadow light needs to implement.
  8892. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8893. * as well as binding the different shadow properties to the effects.
  8894. */
  8895. export interface IShadowLight extends Light {
  8896. /**
  8897. * The light id in the scene (used in scene.findLighById for instance)
  8898. */
  8899. id: string;
  8900. /**
  8901. * The position the shdow will be casted from.
  8902. */
  8903. position: Vector3;
  8904. /**
  8905. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8906. */
  8907. direction: Vector3;
  8908. /**
  8909. * The transformed position. Position of the light in world space taking parenting in account.
  8910. */
  8911. transformedPosition: Vector3;
  8912. /**
  8913. * The transformed direction. Direction of the light in world space taking parenting in account.
  8914. */
  8915. transformedDirection: Vector3;
  8916. /**
  8917. * The friendly name of the light in the scene.
  8918. */
  8919. name: string;
  8920. /**
  8921. * Defines the shadow projection clipping minimum z value.
  8922. */
  8923. shadowMinZ: number;
  8924. /**
  8925. * Defines the shadow projection clipping maximum z value.
  8926. */
  8927. shadowMaxZ: number;
  8928. /**
  8929. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8930. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8931. */
  8932. computeTransformedInformation(): boolean;
  8933. /**
  8934. * Gets the scene the light belongs to.
  8935. * @returns The scene
  8936. */
  8937. getScene(): Scene;
  8938. /**
  8939. * Callback defining a custom Projection Matrix Builder.
  8940. * This can be used to override the default projection matrix computation.
  8941. */
  8942. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8943. /**
  8944. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8945. * @param matrix The materix to updated with the projection information
  8946. * @param viewMatrix The transform matrix of the light
  8947. * @param renderList The list of mesh to render in the map
  8948. * @returns The current light
  8949. */
  8950. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8951. /**
  8952. * Gets the current depth scale used in ESM.
  8953. * @returns The scale
  8954. */
  8955. getDepthScale(): number;
  8956. /**
  8957. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8958. * @returns true if a cube texture needs to be use
  8959. */
  8960. needCube(): boolean;
  8961. /**
  8962. * Detects if the projection matrix requires to be recomputed this frame.
  8963. * @returns true if it requires to be recomputed otherwise, false.
  8964. */
  8965. needProjectionMatrixCompute(): boolean;
  8966. /**
  8967. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8968. */
  8969. forceProjectionMatrixCompute(): void;
  8970. /**
  8971. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8972. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8973. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8974. */
  8975. getShadowDirection(faceIndex?: number): Vector3;
  8976. /**
  8977. * Gets the minZ used for shadow according to both the scene and the light.
  8978. * @param activeCamera The camera we are returning the min for
  8979. * @returns the depth min z
  8980. */
  8981. getDepthMinZ(activeCamera: Camera): number;
  8982. /**
  8983. * Gets the maxZ used for shadow according to both the scene and the light.
  8984. * @param activeCamera The camera we are returning the max for
  8985. * @returns the depth max z
  8986. */
  8987. getDepthMaxZ(activeCamera: Camera): number;
  8988. }
  8989. /**
  8990. * Base implementation IShadowLight
  8991. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8992. */
  8993. export abstract class ShadowLight extends Light implements IShadowLight {
  8994. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8995. protected _position: Vector3;
  8996. protected _setPosition(value: Vector3): void;
  8997. /**
  8998. * Sets the position the shadow will be casted from. Also use as the light position for both
  8999. * point and spot lights.
  9000. */
  9001. get position(): Vector3;
  9002. /**
  9003. * Sets the position the shadow will be casted from. Also use as the light position for both
  9004. * point and spot lights.
  9005. */
  9006. set position(value: Vector3);
  9007. protected _direction: Vector3;
  9008. protected _setDirection(value: Vector3): void;
  9009. /**
  9010. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9011. * Also use as the light direction on spot and directional lights.
  9012. */
  9013. get direction(): Vector3;
  9014. /**
  9015. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9016. * Also use as the light direction on spot and directional lights.
  9017. */
  9018. set direction(value: Vector3);
  9019. protected _shadowMinZ: number;
  9020. /**
  9021. * Gets the shadow projection clipping minimum z value.
  9022. */
  9023. get shadowMinZ(): number;
  9024. /**
  9025. * Sets the shadow projection clipping minimum z value.
  9026. */
  9027. set shadowMinZ(value: number);
  9028. protected _shadowMaxZ: number;
  9029. /**
  9030. * Sets the shadow projection clipping maximum z value.
  9031. */
  9032. get shadowMaxZ(): number;
  9033. /**
  9034. * Gets the shadow projection clipping maximum z value.
  9035. */
  9036. set shadowMaxZ(value: number);
  9037. /**
  9038. * Callback defining a custom Projection Matrix Builder.
  9039. * This can be used to override the default projection matrix computation.
  9040. */
  9041. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9042. /**
  9043. * The transformed position. Position of the light in world space taking parenting in account.
  9044. */
  9045. transformedPosition: Vector3;
  9046. /**
  9047. * The transformed direction. Direction of the light in world space taking parenting in account.
  9048. */
  9049. transformedDirection: Vector3;
  9050. private _needProjectionMatrixCompute;
  9051. /**
  9052. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9053. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9054. */
  9055. computeTransformedInformation(): boolean;
  9056. /**
  9057. * Return the depth scale used for the shadow map.
  9058. * @returns the depth scale.
  9059. */
  9060. getDepthScale(): number;
  9061. /**
  9062. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9063. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9064. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9065. */
  9066. getShadowDirection(faceIndex?: number): Vector3;
  9067. /**
  9068. * Returns the ShadowLight absolute position in the World.
  9069. * @returns the position vector in world space
  9070. */
  9071. getAbsolutePosition(): Vector3;
  9072. /**
  9073. * Sets the ShadowLight direction toward the passed target.
  9074. * @param target The point to target in local space
  9075. * @returns the updated ShadowLight direction
  9076. */
  9077. setDirectionToTarget(target: Vector3): Vector3;
  9078. /**
  9079. * Returns the light rotation in euler definition.
  9080. * @returns the x y z rotation in local space.
  9081. */
  9082. getRotation(): Vector3;
  9083. /**
  9084. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9085. * @returns true if a cube texture needs to be use
  9086. */
  9087. needCube(): boolean;
  9088. /**
  9089. * Detects if the projection matrix requires to be recomputed this frame.
  9090. * @returns true if it requires to be recomputed otherwise, false.
  9091. */
  9092. needProjectionMatrixCompute(): boolean;
  9093. /**
  9094. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9095. */
  9096. forceProjectionMatrixCompute(): void;
  9097. /** @hidden */
  9098. _initCache(): void;
  9099. /** @hidden */
  9100. _isSynchronized(): boolean;
  9101. /**
  9102. * Computes the world matrix of the node
  9103. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9104. * @returns the world matrix
  9105. */
  9106. computeWorldMatrix(force?: boolean): Matrix;
  9107. /**
  9108. * Gets the minZ used for shadow according to both the scene and the light.
  9109. * @param activeCamera The camera we are returning the min for
  9110. * @returns the depth min z
  9111. */
  9112. getDepthMinZ(activeCamera: Camera): number;
  9113. /**
  9114. * Gets the maxZ used for shadow according to both the scene and the light.
  9115. * @param activeCamera The camera we are returning the max for
  9116. * @returns the depth max z
  9117. */
  9118. getDepthMaxZ(activeCamera: Camera): number;
  9119. /**
  9120. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9121. * @param matrix The materix to updated with the projection information
  9122. * @param viewMatrix The transform matrix of the light
  9123. * @param renderList The list of mesh to render in the map
  9124. * @returns The current light
  9125. */
  9126. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9127. }
  9128. }
  9129. declare module "babylonjs/Materials/effectFallbacks" {
  9130. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9131. import { Effect } from "babylonjs/Materials/effect";
  9132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9133. /**
  9134. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9135. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9136. */
  9137. export class EffectFallbacks implements IEffectFallbacks {
  9138. private _defines;
  9139. private _currentRank;
  9140. private _maxRank;
  9141. private _mesh;
  9142. /**
  9143. * Removes the fallback from the bound mesh.
  9144. */
  9145. unBindMesh(): void;
  9146. /**
  9147. * Adds a fallback on the specified property.
  9148. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9149. * @param define The name of the define in the shader
  9150. */
  9151. addFallback(rank: number, define: string): void;
  9152. /**
  9153. * Sets the mesh to use CPU skinning when needing to fallback.
  9154. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9155. * @param mesh The mesh to use the fallbacks.
  9156. */
  9157. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9158. /**
  9159. * Checks to see if more fallbacks are still availible.
  9160. */
  9161. get hasMoreFallbacks(): boolean;
  9162. /**
  9163. * Removes the defines that should be removed when falling back.
  9164. * @param currentDefines defines the current define statements for the shader.
  9165. * @param effect defines the current effect we try to compile
  9166. * @returns The resulting defines with defines of the current rank removed.
  9167. */
  9168. reduce(currentDefines: string, effect: Effect): string;
  9169. }
  9170. }
  9171. declare module "babylonjs/Materials/materialHelper" {
  9172. import { Nullable } from "babylonjs/types";
  9173. import { Scene } from "babylonjs/scene";
  9174. import { Engine } from "babylonjs/Engines/engine";
  9175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9176. import { Light } from "babylonjs/Lights/light";
  9177. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9178. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9180. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9181. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9182. /**
  9183. * "Static Class" containing the most commonly used helper while dealing with material for
  9184. * rendering purpose.
  9185. *
  9186. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9187. *
  9188. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9189. */
  9190. export class MaterialHelper {
  9191. /**
  9192. * Bind the current view position to an effect.
  9193. * @param effect The effect to be bound
  9194. * @param scene The scene the eyes position is used from
  9195. */
  9196. static BindEyePosition(effect: Effect, scene: Scene): void;
  9197. /**
  9198. * Helps preparing the defines values about the UVs in used in the effect.
  9199. * UVs are shared as much as we can accross channels in the shaders.
  9200. * @param texture The texture we are preparing the UVs for
  9201. * @param defines The defines to update
  9202. * @param key The channel key "diffuse", "specular"... used in the shader
  9203. */
  9204. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9205. /**
  9206. * Binds a texture matrix value to its corrsponding uniform
  9207. * @param texture The texture to bind the matrix for
  9208. * @param uniformBuffer The uniform buffer receivin the data
  9209. * @param key The channel key "diffuse", "specular"... used in the shader
  9210. */
  9211. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9212. /**
  9213. * Gets the current status of the fog (should it be enabled?)
  9214. * @param mesh defines the mesh to evaluate for fog support
  9215. * @param scene defines the hosting scene
  9216. * @returns true if fog must be enabled
  9217. */
  9218. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9219. /**
  9220. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9221. * @param mesh defines the current mesh
  9222. * @param scene defines the current scene
  9223. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9224. * @param pointsCloud defines if point cloud rendering has to be turned on
  9225. * @param fogEnabled defines if fog has to be turned on
  9226. * @param alphaTest defines if alpha testing has to be turned on
  9227. * @param defines defines the current list of defines
  9228. */
  9229. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9230. /**
  9231. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9232. * @param scene defines the current scene
  9233. * @param engine defines the current engine
  9234. * @param defines specifies the list of active defines
  9235. * @param useInstances defines if instances have to be turned on
  9236. * @param useClipPlane defines if clip plane have to be turned on
  9237. */
  9238. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9239. /**
  9240. * Prepares the defines for bones
  9241. * @param mesh The mesh containing the geometry data we will draw
  9242. * @param defines The defines to update
  9243. */
  9244. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9245. /**
  9246. * Prepares the defines for morph targets
  9247. * @param mesh The mesh containing the geometry data we will draw
  9248. * @param defines The defines to update
  9249. */
  9250. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9251. /**
  9252. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9253. * @param mesh The mesh containing the geometry data we will draw
  9254. * @param defines The defines to update
  9255. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9256. * @param useBones Precise whether bones should be used or not (override mesh info)
  9257. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9258. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9259. * @returns false if defines are considered not dirty and have not been checked
  9260. */
  9261. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9262. /**
  9263. * Prepares the defines related to multiview
  9264. * @param scene The scene we are intending to draw
  9265. * @param defines The defines to update
  9266. */
  9267. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9268. /**
  9269. * Prepares the defines related to the light information passed in parameter
  9270. * @param scene The scene we are intending to draw
  9271. * @param mesh The mesh the effect is compiling for
  9272. * @param light The light the effect is compiling for
  9273. * @param lightIndex The index of the light
  9274. * @param defines The defines to update
  9275. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9276. * @param state Defines the current state regarding what is needed (normals, etc...)
  9277. */
  9278. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9279. needNormals: boolean;
  9280. needRebuild: boolean;
  9281. shadowEnabled: boolean;
  9282. specularEnabled: boolean;
  9283. lightmapMode: boolean;
  9284. }): void;
  9285. /**
  9286. * Prepares the defines related to the light information passed in parameter
  9287. * @param scene The scene we are intending to draw
  9288. * @param mesh The mesh the effect is compiling for
  9289. * @param defines The defines to update
  9290. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9291. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9292. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9293. * @returns true if normals will be required for the rest of the effect
  9294. */
  9295. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9296. /**
  9297. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9298. * @param lightIndex defines the light index
  9299. * @param uniformsList The uniform list
  9300. * @param samplersList The sampler list
  9301. * @param projectedLightTexture defines if projected texture must be used
  9302. * @param uniformBuffersList defines an optional list of uniform buffers
  9303. */
  9304. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9305. /**
  9306. * Prepares the uniforms and samplers list to be used in the effect
  9307. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9308. * @param samplersList The sampler list
  9309. * @param defines The defines helping in the list generation
  9310. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9311. */
  9312. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9313. /**
  9314. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9315. * @param defines The defines to update while falling back
  9316. * @param fallbacks The authorized effect fallbacks
  9317. * @param maxSimultaneousLights The maximum number of lights allowed
  9318. * @param rank the current rank of the Effect
  9319. * @returns The newly affected rank
  9320. */
  9321. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9322. private static _TmpMorphInfluencers;
  9323. /**
  9324. * Prepares the list of attributes required for morph targets according to the effect defines.
  9325. * @param attribs The current list of supported attribs
  9326. * @param mesh The mesh to prepare the morph targets attributes for
  9327. * @param influencers The number of influencers
  9328. */
  9329. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9330. /**
  9331. * Prepares the list of attributes required for morph targets according to the effect defines.
  9332. * @param attribs The current list of supported attribs
  9333. * @param mesh The mesh to prepare the morph targets attributes for
  9334. * @param defines The current Defines of the effect
  9335. */
  9336. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9337. /**
  9338. * Prepares the list of attributes required for bones according to the effect defines.
  9339. * @param attribs The current list of supported attribs
  9340. * @param mesh The mesh to prepare the bones attributes for
  9341. * @param defines The current Defines of the effect
  9342. * @param fallbacks The current efffect fallback strategy
  9343. */
  9344. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9345. /**
  9346. * Check and prepare the list of attributes required for instances according to the effect defines.
  9347. * @param attribs The current list of supported attribs
  9348. * @param defines The current MaterialDefines of the effect
  9349. */
  9350. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9351. /**
  9352. * Add the list of attributes required for instances to the attribs array.
  9353. * @param attribs The current list of supported attribs
  9354. */
  9355. static PushAttributesForInstances(attribs: string[]): void;
  9356. /**
  9357. * Binds the light information to the effect.
  9358. * @param light The light containing the generator
  9359. * @param effect The effect we are binding the data to
  9360. * @param lightIndex The light index in the effect used to render
  9361. */
  9362. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9363. /**
  9364. * Binds the lights information from the scene to the effect for the given mesh.
  9365. * @param light Light to bind
  9366. * @param lightIndex Light index
  9367. * @param scene The scene where the light belongs to
  9368. * @param effect The effect we are binding the data to
  9369. * @param useSpecular Defines if specular is supported
  9370. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9371. */
  9372. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9373. /**
  9374. * Binds the lights information from the scene to the effect for the given mesh.
  9375. * @param scene The scene the lights belongs to
  9376. * @param mesh The mesh we are binding the information to render
  9377. * @param effect The effect we are binding the data to
  9378. * @param defines The generated defines for the effect
  9379. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9380. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9381. */
  9382. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9383. private static _tempFogColor;
  9384. /**
  9385. * Binds the fog information from the scene to the effect for the given mesh.
  9386. * @param scene The scene the lights belongs to
  9387. * @param mesh The mesh we are binding the information to render
  9388. * @param effect The effect we are binding the data to
  9389. * @param linearSpace Defines if the fog effect is applied in linear space
  9390. */
  9391. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9392. /**
  9393. * Binds the bones information from the mesh to the effect.
  9394. * @param mesh The mesh we are binding the information to render
  9395. * @param effect The effect we are binding the data to
  9396. */
  9397. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9398. /**
  9399. * Binds the morph targets information from the mesh to the effect.
  9400. * @param abstractMesh The mesh we are binding the information to render
  9401. * @param effect The effect we are binding the data to
  9402. */
  9403. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9404. /**
  9405. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9406. * @param defines The generated defines used in the effect
  9407. * @param effect The effect we are binding the data to
  9408. * @param scene The scene we are willing to render with logarithmic scale for
  9409. */
  9410. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9411. /**
  9412. * Binds the clip plane information from the scene to the effect.
  9413. * @param scene The scene the clip plane information are extracted from
  9414. * @param effect The effect we are binding the data to
  9415. */
  9416. static BindClipPlane(effect: Effect, scene: Scene): void;
  9417. }
  9418. }
  9419. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9420. /** @hidden */
  9421. export var packingFunctions: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9427. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9428. /** @hidden */
  9429. export var shadowMapPixelShader: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9435. /** @hidden */
  9436. export var bonesDeclaration: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9442. /** @hidden */
  9443. export var morphTargetsVertexGlobalDeclaration: {
  9444. name: string;
  9445. shader: string;
  9446. };
  9447. }
  9448. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9449. /** @hidden */
  9450. export var morphTargetsVertexDeclaration: {
  9451. name: string;
  9452. shader: string;
  9453. };
  9454. }
  9455. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9456. /** @hidden */
  9457. export var instancesDeclaration: {
  9458. name: string;
  9459. shader: string;
  9460. };
  9461. }
  9462. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9463. /** @hidden */
  9464. export var helperFunctions: {
  9465. name: string;
  9466. shader: string;
  9467. };
  9468. }
  9469. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9470. /** @hidden */
  9471. export var morphTargetsVertex: {
  9472. name: string;
  9473. shader: string;
  9474. };
  9475. }
  9476. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9477. /** @hidden */
  9478. export var instancesVertex: {
  9479. name: string;
  9480. shader: string;
  9481. };
  9482. }
  9483. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9484. /** @hidden */
  9485. export var bonesVertex: {
  9486. name: string;
  9487. shader: string;
  9488. };
  9489. }
  9490. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9491. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9493. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9494. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9495. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9496. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9497. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9498. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9499. /** @hidden */
  9500. export var shadowMapVertexShader: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9506. /** @hidden */
  9507. export var depthBoxBlurPixelShader: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9513. import { Nullable } from "babylonjs/types";
  9514. import { Scene } from "babylonjs/scene";
  9515. import { Matrix } from "babylonjs/Maths/math.vector";
  9516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9518. import { Mesh } from "babylonjs/Meshes/mesh";
  9519. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9520. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9521. import { Effect } from "babylonjs/Materials/effect";
  9522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9523. import "babylonjs/Shaders/shadowMap.fragment";
  9524. import "babylonjs/Shaders/shadowMap.vertex";
  9525. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9526. import { Observable } from "babylonjs/Misc/observable";
  9527. /**
  9528. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9529. */
  9530. export interface ICustomShaderOptions {
  9531. /**
  9532. * Gets or sets the custom shader name to use
  9533. */
  9534. shaderName: string;
  9535. /**
  9536. * The list of attribute names used in the shader
  9537. */
  9538. attributes?: string[];
  9539. /**
  9540. * The list of unifrom names used in the shader
  9541. */
  9542. uniforms?: string[];
  9543. /**
  9544. * The list of sampler names used in the shader
  9545. */
  9546. samplers?: string[];
  9547. /**
  9548. * The list of defines used in the shader
  9549. */
  9550. defines?: string[];
  9551. }
  9552. /**
  9553. * Interface to implement to create a shadow generator compatible with BJS.
  9554. */
  9555. export interface IShadowGenerator {
  9556. /**
  9557. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9558. * @returns The render target texture if present otherwise, null
  9559. */
  9560. getShadowMap(): Nullable<RenderTargetTexture>;
  9561. /**
  9562. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9563. * @returns The render target texture if the shadow map is present otherwise, null
  9564. */
  9565. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9566. /**
  9567. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9568. * @param subMesh The submesh we want to render in the shadow map
  9569. * @param useInstances Defines wether will draw in the map using instances
  9570. * @returns true if ready otherwise, false
  9571. */
  9572. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9573. /**
  9574. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9575. * @param defines Defines of the material we want to update
  9576. * @param lightIndex Index of the light in the enabled light list of the material
  9577. */
  9578. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9579. /**
  9580. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9581. * defined in the generator but impacting the effect).
  9582. * It implies the unifroms available on the materials are the standard BJS ones.
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. /**
  9599. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9600. * @param onCompiled Callback triggered at the and of the effects compilation
  9601. * @param options Sets of optional options forcing the compilation with different modes
  9602. */
  9603. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9604. useInstances: boolean;
  9605. }>): void;
  9606. /**
  9607. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9608. * @param options Sets of optional options forcing the compilation with different modes
  9609. * @returns A promise that resolves when the compilation completes
  9610. */
  9611. forceCompilationAsync(options?: Partial<{
  9612. useInstances: boolean;
  9613. }>): Promise<void>;
  9614. /**
  9615. * Serializes the shadow generator setup to a json object.
  9616. * @returns The serialized JSON object
  9617. */
  9618. serialize(): any;
  9619. /**
  9620. * Disposes the Shadow map and related Textures and effects.
  9621. */
  9622. dispose(): void;
  9623. }
  9624. /**
  9625. * Default implementation IShadowGenerator.
  9626. * This is the main object responsible of generating shadows in the framework.
  9627. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9628. */
  9629. export class ShadowGenerator implements IShadowGenerator {
  9630. /**
  9631. * Shadow generator mode None: no filtering applied.
  9632. */
  9633. static readonly FILTER_NONE: number;
  9634. /**
  9635. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9636. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9637. */
  9638. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9639. /**
  9640. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9641. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9642. */
  9643. static readonly FILTER_POISSONSAMPLING: number;
  9644. /**
  9645. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9646. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9647. */
  9648. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9649. /**
  9650. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9651. * edge artifacts on steep falloff.
  9652. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9653. */
  9654. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9655. /**
  9656. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9657. * edge artifacts on steep falloff.
  9658. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9659. */
  9660. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9661. /**
  9662. * Shadow generator mode PCF: Percentage Closer Filtering
  9663. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9664. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9665. */
  9666. static readonly FILTER_PCF: number;
  9667. /**
  9668. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9669. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9670. * Contact Hardening
  9671. */
  9672. static readonly FILTER_PCSS: number;
  9673. /**
  9674. * Reserved for PCF and PCSS
  9675. * Highest Quality.
  9676. *
  9677. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9678. *
  9679. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9680. */
  9681. static readonly QUALITY_HIGH: number;
  9682. /**
  9683. * Reserved for PCF and PCSS
  9684. * Good tradeoff for quality/perf cross devices
  9685. *
  9686. * Execute PCF on a 3*3 kernel.
  9687. *
  9688. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9689. */
  9690. static readonly QUALITY_MEDIUM: number;
  9691. /**
  9692. * Reserved for PCF and PCSS
  9693. * The lowest quality but the fastest.
  9694. *
  9695. * Execute PCF on a 1*1 kernel.
  9696. *
  9697. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9698. */
  9699. static readonly QUALITY_LOW: number;
  9700. /** Gets or sets the custom shader name to use */
  9701. customShaderOptions: ICustomShaderOptions;
  9702. /**
  9703. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9704. */
  9705. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9706. /**
  9707. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9708. */
  9709. onAfterShadowMapRenderObservable: Observable<Effect>;
  9710. /**
  9711. * Observable triggered before a mesh is rendered in the shadow map.
  9712. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9713. */
  9714. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9715. /**
  9716. * Observable triggered after a mesh is rendered in the shadow map.
  9717. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9718. */
  9719. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9720. private _bias;
  9721. /**
  9722. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9723. */
  9724. get bias(): number;
  9725. /**
  9726. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9727. */
  9728. set bias(bias: number);
  9729. private _normalBias;
  9730. /**
  9731. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9732. */
  9733. get normalBias(): number;
  9734. /**
  9735. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9736. */
  9737. set normalBias(normalBias: number);
  9738. private _blurBoxOffset;
  9739. /**
  9740. * Gets the blur box offset: offset applied during the blur pass.
  9741. * Only useful if useKernelBlur = false
  9742. */
  9743. get blurBoxOffset(): number;
  9744. /**
  9745. * Sets the blur box offset: offset applied during the blur pass.
  9746. * Only useful if useKernelBlur = false
  9747. */
  9748. set blurBoxOffset(value: number);
  9749. private _blurScale;
  9750. /**
  9751. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9752. * 2 means half of the size.
  9753. */
  9754. get blurScale(): number;
  9755. /**
  9756. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9757. * 2 means half of the size.
  9758. */
  9759. set blurScale(value: number);
  9760. private _blurKernel;
  9761. /**
  9762. * Gets the blur kernel: kernel size of the blur pass.
  9763. * Only useful if useKernelBlur = true
  9764. */
  9765. get blurKernel(): number;
  9766. /**
  9767. * Sets the blur kernel: kernel size of the blur pass.
  9768. * Only useful if useKernelBlur = true
  9769. */
  9770. set blurKernel(value: number);
  9771. private _useKernelBlur;
  9772. /**
  9773. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9774. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9775. */
  9776. get useKernelBlur(): boolean;
  9777. /**
  9778. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9779. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9780. */
  9781. set useKernelBlur(value: boolean);
  9782. private _depthScale;
  9783. /**
  9784. * Gets the depth scale used in ESM mode.
  9785. */
  9786. get depthScale(): number;
  9787. /**
  9788. * Sets the depth scale used in ESM mode.
  9789. * This can override the scale stored on the light.
  9790. */
  9791. set depthScale(value: number);
  9792. private _filter;
  9793. /**
  9794. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9795. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9796. */
  9797. get filter(): number;
  9798. /**
  9799. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9800. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9801. */
  9802. set filter(value: number);
  9803. /**
  9804. * Gets if the current filter is set to Poisson Sampling.
  9805. */
  9806. get usePoissonSampling(): boolean;
  9807. /**
  9808. * Sets the current filter to Poisson Sampling.
  9809. */
  9810. set usePoissonSampling(value: boolean);
  9811. /**
  9812. * Gets if the current filter is set to ESM.
  9813. */
  9814. get useExponentialShadowMap(): boolean;
  9815. /**
  9816. * Sets the current filter is to ESM.
  9817. */
  9818. set useExponentialShadowMap(value: boolean);
  9819. /**
  9820. * Gets if the current filter is set to filtered ESM.
  9821. */
  9822. get useBlurExponentialShadowMap(): boolean;
  9823. /**
  9824. * Gets if the current filter is set to filtered ESM.
  9825. */
  9826. set useBlurExponentialShadowMap(value: boolean);
  9827. /**
  9828. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9829. * exponential to prevent steep falloff artifacts).
  9830. */
  9831. get useCloseExponentialShadowMap(): boolean;
  9832. /**
  9833. * Sets the current filter to "close ESM" (using the inverse of the
  9834. * exponential to prevent steep falloff artifacts).
  9835. */
  9836. set useCloseExponentialShadowMap(value: boolean);
  9837. /**
  9838. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9839. * exponential to prevent steep falloff artifacts).
  9840. */
  9841. get useBlurCloseExponentialShadowMap(): boolean;
  9842. /**
  9843. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9844. * exponential to prevent steep falloff artifacts).
  9845. */
  9846. set useBlurCloseExponentialShadowMap(value: boolean);
  9847. /**
  9848. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9849. */
  9850. get usePercentageCloserFiltering(): boolean;
  9851. /**
  9852. * Sets the current filter to "PCF" (percentage closer filtering).
  9853. */
  9854. set usePercentageCloserFiltering(value: boolean);
  9855. private _filteringQuality;
  9856. /**
  9857. * Gets the PCF or PCSS Quality.
  9858. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9859. */
  9860. get filteringQuality(): number;
  9861. /**
  9862. * Sets the PCF or PCSS Quality.
  9863. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9864. */
  9865. set filteringQuality(filteringQuality: number);
  9866. /**
  9867. * Gets if the current filter is set to "PCSS" (contact hardening).
  9868. */
  9869. get useContactHardeningShadow(): boolean;
  9870. /**
  9871. * Sets the current filter to "PCSS" (contact hardening).
  9872. */
  9873. set useContactHardeningShadow(value: boolean);
  9874. private _contactHardeningLightSizeUVRatio;
  9875. /**
  9876. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9877. * Using a ratio helps keeping shape stability independently of the map size.
  9878. *
  9879. * It does not account for the light projection as it was having too much
  9880. * instability during the light setup or during light position changes.
  9881. *
  9882. * Only valid if useContactHardeningShadow is true.
  9883. */
  9884. get contactHardeningLightSizeUVRatio(): number;
  9885. /**
  9886. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9887. * Using a ratio helps keeping shape stability independently of the map size.
  9888. *
  9889. * It does not account for the light projection as it was having too much
  9890. * instability during the light setup or during light position changes.
  9891. *
  9892. * Only valid if useContactHardeningShadow is true.
  9893. */
  9894. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9895. private _darkness;
  9896. /** Gets or sets the actual darkness of a shadow */
  9897. get darkness(): number;
  9898. set darkness(value: number);
  9899. /**
  9900. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9901. * 0 means strongest and 1 would means no shadow.
  9902. * @returns the darkness.
  9903. */
  9904. getDarkness(): number;
  9905. /**
  9906. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9907. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9908. * @returns the shadow generator allowing fluent coding.
  9909. */
  9910. setDarkness(darkness: number): ShadowGenerator;
  9911. private _transparencyShadow;
  9912. /** Gets or sets the ability to have transparent shadow */
  9913. get transparencyShadow(): boolean;
  9914. set transparencyShadow(value: boolean);
  9915. /**
  9916. * Sets the ability to have transparent shadow (boolean).
  9917. * @param transparent True if transparent else False
  9918. * @returns the shadow generator allowing fluent coding
  9919. */
  9920. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9921. private _shadowMap;
  9922. private _shadowMap2;
  9923. /**
  9924. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9925. * @returns The render target texture if present otherwise, null
  9926. */
  9927. getShadowMap(): Nullable<RenderTargetTexture>;
  9928. /**
  9929. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9930. * @returns The render target texture if the shadow map is present otherwise, null
  9931. */
  9932. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9933. /**
  9934. * Gets the class name of that object
  9935. * @returns "ShadowGenerator"
  9936. */
  9937. getClassName(): string;
  9938. /**
  9939. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9940. * @param mesh Mesh to add
  9941. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9942. * @returns the Shadow Generator itself
  9943. */
  9944. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9945. /**
  9946. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9947. * @param mesh Mesh to remove
  9948. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9949. * @returns the Shadow Generator itself
  9950. */
  9951. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9952. /**
  9953. * Controls the extent to which the shadows fade out at the edge of the frustum
  9954. * Used only by directionals and spots
  9955. */
  9956. frustumEdgeFalloff: number;
  9957. private _light;
  9958. /**
  9959. * Returns the associated light object.
  9960. * @returns the light generating the shadow
  9961. */
  9962. getLight(): IShadowLight;
  9963. /**
  9964. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9965. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9966. * It might on the other hand introduce peter panning.
  9967. */
  9968. forceBackFacesOnly: boolean;
  9969. private _scene;
  9970. private _lightDirection;
  9971. private _effect;
  9972. private _viewMatrix;
  9973. private _projectionMatrix;
  9974. private _transformMatrix;
  9975. private _cachedPosition;
  9976. private _cachedDirection;
  9977. private _cachedDefines;
  9978. private _currentRenderID;
  9979. private _boxBlurPostprocess;
  9980. private _kernelBlurXPostprocess;
  9981. private _kernelBlurYPostprocess;
  9982. private _blurPostProcesses;
  9983. private _mapSize;
  9984. private _currentFaceIndex;
  9985. private _currentFaceIndexCache;
  9986. private _textureType;
  9987. private _defaultTextureMatrix;
  9988. private _storedUniqueId;
  9989. /** @hidden */
  9990. static _SceneComponentInitialization: (scene: Scene) => void;
  9991. /**
  9992. * Creates a ShadowGenerator object.
  9993. * A ShadowGenerator is the required tool to use the shadows.
  9994. * Each light casting shadows needs to use its own ShadowGenerator.
  9995. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9996. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9997. * @param light The light object generating the shadows.
  9998. * @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.
  9999. */
  10000. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10001. private _initializeGenerator;
  10002. private _initializeShadowMap;
  10003. private _initializeBlurRTTAndPostProcesses;
  10004. private _renderForShadowMap;
  10005. private _renderSubMeshForShadowMap;
  10006. private _applyFilterValues;
  10007. /**
  10008. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10009. * @param onCompiled Callback triggered at the and of the effects compilation
  10010. * @param options Sets of optional options forcing the compilation with different modes
  10011. */
  10012. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10013. useInstances: boolean;
  10014. }>): void;
  10015. /**
  10016. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10017. * @param options Sets of optional options forcing the compilation with different modes
  10018. * @returns A promise that resolves when the compilation completes
  10019. */
  10020. forceCompilationAsync(options?: Partial<{
  10021. useInstances: boolean;
  10022. }>): Promise<void>;
  10023. /**
  10024. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10025. * @param subMesh The submesh we want to render in the shadow map
  10026. * @param useInstances Defines wether will draw in the map using instances
  10027. * @returns true if ready otherwise, false
  10028. */
  10029. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10030. /**
  10031. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10032. * @param defines Defines of the material we want to update
  10033. * @param lightIndex Index of the light in the enabled light list of the material
  10034. */
  10035. prepareDefines(defines: any, lightIndex: number): void;
  10036. /**
  10037. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10038. * defined in the generator but impacting the effect).
  10039. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10040. * @param effect The effect we are binfing the information for
  10041. */
  10042. bindShadowLight(lightIndex: string, effect: Effect): void;
  10043. /**
  10044. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10045. * (eq to shadow prjection matrix * light transform matrix)
  10046. * @returns The transform matrix used to create the shadow map
  10047. */
  10048. getTransformMatrix(): Matrix;
  10049. /**
  10050. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10051. * Cube and 2D textures for instance.
  10052. */
  10053. recreateShadowMap(): void;
  10054. private _disposeBlurPostProcesses;
  10055. private _disposeRTTandPostProcesses;
  10056. /**
  10057. * Disposes the ShadowGenerator.
  10058. * Returns nothing.
  10059. */
  10060. dispose(): void;
  10061. /**
  10062. * Serializes the shadow generator setup to a json object.
  10063. * @returns The serialized JSON object
  10064. */
  10065. serialize(): any;
  10066. /**
  10067. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10068. * @param parsedShadowGenerator The JSON object to parse
  10069. * @param scene The scene to create the shadow map for
  10070. * @returns The parsed shadow generator
  10071. */
  10072. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10073. }
  10074. }
  10075. declare module "babylonjs/Lights/light" {
  10076. import { Nullable } from "babylonjs/types";
  10077. import { Scene } from "babylonjs/scene";
  10078. import { Vector3 } from "babylonjs/Maths/math.vector";
  10079. import { Color3 } from "babylonjs/Maths/math.color";
  10080. import { Node } from "babylonjs/node";
  10081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10082. import { Effect } from "babylonjs/Materials/effect";
  10083. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10084. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10085. /**
  10086. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10087. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10088. * 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.
  10089. */
  10090. export abstract class Light extends Node {
  10091. /**
  10092. * Falloff Default: light is falling off following the material specification:
  10093. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10094. */
  10095. static readonly FALLOFF_DEFAULT: number;
  10096. /**
  10097. * Falloff Physical: light is falling off following the inverse squared distance law.
  10098. */
  10099. static readonly FALLOFF_PHYSICAL: number;
  10100. /**
  10101. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10102. * to enhance interoperability with other engines.
  10103. */
  10104. static readonly FALLOFF_GLTF: number;
  10105. /**
  10106. * Falloff Standard: light is falling off like in the standard material
  10107. * to enhance interoperability with other materials.
  10108. */
  10109. static readonly FALLOFF_STANDARD: number;
  10110. /**
  10111. * If every light affecting the material is in this lightmapMode,
  10112. * material.lightmapTexture adds or multiplies
  10113. * (depends on material.useLightmapAsShadowmap)
  10114. * after every other light calculations.
  10115. */
  10116. static readonly LIGHTMAP_DEFAULT: number;
  10117. /**
  10118. * material.lightmapTexture as only diffuse lighting from this light
  10119. * adds only specular lighting from this light
  10120. * adds dynamic shadows
  10121. */
  10122. static readonly LIGHTMAP_SPECULAR: number;
  10123. /**
  10124. * material.lightmapTexture as only lighting
  10125. * no light calculation from this light
  10126. * only adds dynamic shadows from this light
  10127. */
  10128. static readonly LIGHTMAP_SHADOWSONLY: number;
  10129. /**
  10130. * Each light type uses the default quantity according to its type:
  10131. * point/spot lights use luminous intensity
  10132. * directional lights use illuminance
  10133. */
  10134. static readonly INTENSITYMODE_AUTOMATIC: number;
  10135. /**
  10136. * lumen (lm)
  10137. */
  10138. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10139. /**
  10140. * candela (lm/sr)
  10141. */
  10142. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10143. /**
  10144. * lux (lm/m^2)
  10145. */
  10146. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10147. /**
  10148. * nit (cd/m^2)
  10149. */
  10150. static readonly INTENSITYMODE_LUMINANCE: number;
  10151. /**
  10152. * Light type const id of the point light.
  10153. */
  10154. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10155. /**
  10156. * Light type const id of the directional light.
  10157. */
  10158. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10159. /**
  10160. * Light type const id of the spot light.
  10161. */
  10162. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10163. /**
  10164. * Light type const id of the hemispheric light.
  10165. */
  10166. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10167. /**
  10168. * Diffuse gives the basic color to an object.
  10169. */
  10170. diffuse: Color3;
  10171. /**
  10172. * Specular produces a highlight color on an object.
  10173. * Note: This is note affecting PBR materials.
  10174. */
  10175. specular: Color3;
  10176. /**
  10177. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10178. * falling off base on range or angle.
  10179. * This can be set to any values in Light.FALLOFF_x.
  10180. *
  10181. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10182. * other types of materials.
  10183. */
  10184. falloffType: number;
  10185. /**
  10186. * Strength of the light.
  10187. * Note: By default it is define in the framework own unit.
  10188. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10189. */
  10190. intensity: number;
  10191. private _range;
  10192. protected _inverseSquaredRange: number;
  10193. /**
  10194. * Defines how far from the source the light is impacting in scene units.
  10195. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10196. */
  10197. get range(): number;
  10198. /**
  10199. * Defines how far from the source the light is impacting in scene units.
  10200. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10201. */
  10202. set range(value: number);
  10203. /**
  10204. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10205. * of light.
  10206. */
  10207. private _photometricScale;
  10208. private _intensityMode;
  10209. /**
  10210. * Gets the photometric scale used to interpret the intensity.
  10211. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10212. */
  10213. get intensityMode(): number;
  10214. /**
  10215. * Sets the photometric scale used to interpret the intensity.
  10216. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10217. */
  10218. set intensityMode(value: number);
  10219. private _radius;
  10220. /**
  10221. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10222. */
  10223. get radius(): number;
  10224. /**
  10225. * sets the light radius used by PBR Materials to simulate soft area lights.
  10226. */
  10227. set radius(value: number);
  10228. private _renderPriority;
  10229. /**
  10230. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10231. * exceeding the number allowed of the materials.
  10232. */
  10233. renderPriority: number;
  10234. private _shadowEnabled;
  10235. /**
  10236. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10237. * the current shadow generator.
  10238. */
  10239. get shadowEnabled(): boolean;
  10240. /**
  10241. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10242. * the current shadow generator.
  10243. */
  10244. set shadowEnabled(value: boolean);
  10245. private _includedOnlyMeshes;
  10246. /**
  10247. * Gets the only meshes impacted by this light.
  10248. */
  10249. get includedOnlyMeshes(): AbstractMesh[];
  10250. /**
  10251. * Sets the only meshes impacted by this light.
  10252. */
  10253. set includedOnlyMeshes(value: AbstractMesh[]);
  10254. private _excludedMeshes;
  10255. /**
  10256. * Gets the meshes not impacted by this light.
  10257. */
  10258. get excludedMeshes(): AbstractMesh[];
  10259. /**
  10260. * Sets the meshes not impacted by this light.
  10261. */
  10262. set excludedMeshes(value: AbstractMesh[]);
  10263. private _excludeWithLayerMask;
  10264. /**
  10265. * Gets the layer id use to find what meshes are not impacted by the light.
  10266. * Inactive if 0
  10267. */
  10268. get excludeWithLayerMask(): number;
  10269. /**
  10270. * Sets the layer id use to find what meshes are not impacted by the light.
  10271. * Inactive if 0
  10272. */
  10273. set excludeWithLayerMask(value: number);
  10274. private _includeOnlyWithLayerMask;
  10275. /**
  10276. * Gets the layer id use to find what meshes are impacted by the light.
  10277. * Inactive if 0
  10278. */
  10279. get includeOnlyWithLayerMask(): number;
  10280. /**
  10281. * Sets the layer id use to find what meshes are impacted by the light.
  10282. * Inactive if 0
  10283. */
  10284. set includeOnlyWithLayerMask(value: number);
  10285. private _lightmapMode;
  10286. /**
  10287. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10288. */
  10289. get lightmapMode(): number;
  10290. /**
  10291. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10292. */
  10293. set lightmapMode(value: number);
  10294. /**
  10295. * Shadow generator associted to the light.
  10296. * @hidden Internal use only.
  10297. */
  10298. _shadowGenerator: Nullable<IShadowGenerator>;
  10299. /**
  10300. * @hidden Internal use only.
  10301. */
  10302. _excludedMeshesIds: string[];
  10303. /**
  10304. * @hidden Internal use only.
  10305. */
  10306. _includedOnlyMeshesIds: string[];
  10307. /**
  10308. * The current light unifom buffer.
  10309. * @hidden Internal use only.
  10310. */
  10311. _uniformBuffer: UniformBuffer;
  10312. /** @hidden */
  10313. _renderId: number;
  10314. /**
  10315. * Creates a Light object in the scene.
  10316. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10317. * @param name The firendly name of the light
  10318. * @param scene The scene the light belongs too
  10319. */
  10320. constructor(name: string, scene: Scene);
  10321. protected abstract _buildUniformLayout(): void;
  10322. /**
  10323. * Sets the passed Effect "effect" with the Light information.
  10324. * @param effect The effect to update
  10325. * @param lightIndex The index of the light in the effect to update
  10326. * @returns The light
  10327. */
  10328. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10329. /**
  10330. * Sets the passed Effect "effect" with the Light textures.
  10331. * @param effect The effect to update
  10332. * @param lightIndex The index of the light in the effect to update
  10333. * @returns The light
  10334. */
  10335. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10336. /**
  10337. * Binds the lights information from the scene to the effect for the given mesh.
  10338. * @param lightIndex Light index
  10339. * @param scene The scene where the light belongs to
  10340. * @param effect The effect we are binding the data to
  10341. * @param useSpecular Defines if specular is supported
  10342. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10343. */
  10344. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10345. /**
  10346. * Sets the passed Effect "effect" with the Light information.
  10347. * @param effect The effect to update
  10348. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10349. * @returns The light
  10350. */
  10351. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10352. /**
  10353. * Returns the string "Light".
  10354. * @returns the class name
  10355. */
  10356. getClassName(): string;
  10357. /** @hidden */
  10358. readonly _isLight: boolean;
  10359. /**
  10360. * Converts the light information to a readable string for debug purpose.
  10361. * @param fullDetails Supports for multiple levels of logging within scene loading
  10362. * @returns the human readable light info
  10363. */
  10364. toString(fullDetails?: boolean): string;
  10365. /** @hidden */
  10366. protected _syncParentEnabledState(): void;
  10367. /**
  10368. * Set the enabled state of this node.
  10369. * @param value - the new enabled state
  10370. */
  10371. setEnabled(value: boolean): void;
  10372. /**
  10373. * Returns the Light associated shadow generator if any.
  10374. * @return the associated shadow generator.
  10375. */
  10376. getShadowGenerator(): Nullable<IShadowGenerator>;
  10377. /**
  10378. * Returns a Vector3, the absolute light position in the World.
  10379. * @returns the world space position of the light
  10380. */
  10381. getAbsolutePosition(): Vector3;
  10382. /**
  10383. * Specifies if the light will affect the passed mesh.
  10384. * @param mesh The mesh to test against the light
  10385. * @return true the mesh is affected otherwise, false.
  10386. */
  10387. canAffectMesh(mesh: AbstractMesh): boolean;
  10388. /**
  10389. * Sort function to order lights for rendering.
  10390. * @param a First Light object to compare to second.
  10391. * @param b Second Light object to compare first.
  10392. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10393. */
  10394. static CompareLightsPriority(a: Light, b: Light): number;
  10395. /**
  10396. * Releases resources associated with this node.
  10397. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10398. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10399. */
  10400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10401. /**
  10402. * Returns the light type ID (integer).
  10403. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10404. */
  10405. getTypeID(): number;
  10406. /**
  10407. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10408. * @returns the scaled intensity in intensity mode unit
  10409. */
  10410. getScaledIntensity(): number;
  10411. /**
  10412. * Returns a new Light object, named "name", from the current one.
  10413. * @param name The name of the cloned light
  10414. * @returns the new created light
  10415. */
  10416. clone(name: string): Nullable<Light>;
  10417. /**
  10418. * Serializes the current light into a Serialization object.
  10419. * @returns the serialized object.
  10420. */
  10421. serialize(): any;
  10422. /**
  10423. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10424. * This new light is named "name" and added to the passed scene.
  10425. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10426. * @param name The friendly name of the light
  10427. * @param scene The scene the new light will belong to
  10428. * @returns the constructor function
  10429. */
  10430. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10431. /**
  10432. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10433. * @param parsedLight The JSON representation of the light
  10434. * @param scene The scene to create the parsed light in
  10435. * @returns the created light after parsing
  10436. */
  10437. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10438. private _hookArrayForExcluded;
  10439. private _hookArrayForIncludedOnly;
  10440. private _resyncMeshes;
  10441. /**
  10442. * Forces the meshes to update their light related information in their rendering used effects
  10443. * @hidden Internal Use Only
  10444. */
  10445. _markMeshesAsLightDirty(): void;
  10446. /**
  10447. * Recomputes the cached photometric scale if needed.
  10448. */
  10449. private _computePhotometricScale;
  10450. /**
  10451. * Returns the Photometric Scale according to the light type and intensity mode.
  10452. */
  10453. private _getPhotometricScale;
  10454. /**
  10455. * Reorder the light in the scene according to their defined priority.
  10456. * @hidden Internal Use Only
  10457. */
  10458. _reorderLightsInScene(): void;
  10459. /**
  10460. * Prepares the list of defines specific to the light type.
  10461. * @param defines the list of defines
  10462. * @param lightIndex defines the index of the light for the effect
  10463. */
  10464. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10465. }
  10466. }
  10467. declare module "babylonjs/Actions/action" {
  10468. import { Observable } from "babylonjs/Misc/observable";
  10469. import { Condition } from "babylonjs/Actions/condition";
  10470. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10471. import { ActionManager } from "babylonjs/Actions/actionManager";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * Interface used to define Action
  10475. */
  10476. export interface IAction {
  10477. /**
  10478. * Trigger for the action
  10479. */
  10480. trigger: number;
  10481. /** Options of the trigger */
  10482. triggerOptions: any;
  10483. /**
  10484. * Gets the trigger parameters
  10485. * @returns the trigger parameters
  10486. */
  10487. getTriggerParameter(): any;
  10488. /**
  10489. * Internal only - executes current action event
  10490. * @hidden
  10491. */
  10492. _executeCurrent(evt?: ActionEvent): void;
  10493. /**
  10494. * Serialize placeholder for child classes
  10495. * @param parent of child
  10496. * @returns the serialized object
  10497. */
  10498. serialize(parent: any): any;
  10499. /**
  10500. * Internal only
  10501. * @hidden
  10502. */
  10503. _prepare(): void;
  10504. /**
  10505. * Internal only - manager for action
  10506. * @hidden
  10507. */
  10508. _actionManager: AbstractActionManager;
  10509. /**
  10510. * Adds action to chain of actions, may be a DoNothingAction
  10511. * @param action defines the next action to execute
  10512. * @returns The action passed in
  10513. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10514. */
  10515. then(action: IAction): IAction;
  10516. }
  10517. /**
  10518. * The action to be carried out following a trigger
  10519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10520. */
  10521. export class Action implements IAction {
  10522. /** the trigger, with or without parameters, for the action */
  10523. triggerOptions: any;
  10524. /**
  10525. * Trigger for the action
  10526. */
  10527. trigger: number;
  10528. /**
  10529. * Internal only - manager for action
  10530. * @hidden
  10531. */
  10532. _actionManager: ActionManager;
  10533. private _nextActiveAction;
  10534. private _child;
  10535. private _condition?;
  10536. private _triggerParameter;
  10537. /**
  10538. * An event triggered prior to action being executed.
  10539. */
  10540. onBeforeExecuteObservable: Observable<Action>;
  10541. /**
  10542. * Creates a new Action
  10543. * @param triggerOptions the trigger, with or without parameters, for the action
  10544. * @param condition an optional determinant of action
  10545. */
  10546. constructor(
  10547. /** the trigger, with or without parameters, for the action */
  10548. triggerOptions: any, condition?: Condition);
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. _prepare(): void;
  10554. /**
  10555. * Gets the trigger parameters
  10556. * @returns the trigger parameters
  10557. */
  10558. getTriggerParameter(): any;
  10559. /**
  10560. * Internal only - executes current action event
  10561. * @hidden
  10562. */
  10563. _executeCurrent(evt?: ActionEvent): void;
  10564. /**
  10565. * Execute placeholder for child classes
  10566. * @param evt optional action event
  10567. */
  10568. execute(evt?: ActionEvent): void;
  10569. /**
  10570. * Skips to next active action
  10571. */
  10572. skipToNextActiveAction(): void;
  10573. /**
  10574. * Adds action to chain of actions, may be a DoNothingAction
  10575. * @param action defines the next action to execute
  10576. * @returns The action passed in
  10577. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10578. */
  10579. then(action: Action): Action;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. _getProperty(propertyPath: string): string;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. _getEffectiveTarget(target: any, propertyPath: string): any;
  10590. /**
  10591. * Serialize placeholder for child classes
  10592. * @param parent of child
  10593. * @returns the serialized object
  10594. */
  10595. serialize(parent: any): any;
  10596. /**
  10597. * Internal only called by serialize
  10598. * @hidden
  10599. */
  10600. protected _serialize(serializedAction: any, parent?: any): any;
  10601. /**
  10602. * Internal only
  10603. * @hidden
  10604. */
  10605. static _SerializeValueAsString: (value: any) => string;
  10606. /**
  10607. * Internal only
  10608. * @hidden
  10609. */
  10610. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10611. name: string;
  10612. targetType: string;
  10613. value: string;
  10614. };
  10615. }
  10616. }
  10617. declare module "babylonjs/Actions/condition" {
  10618. import { ActionManager } from "babylonjs/Actions/actionManager";
  10619. /**
  10620. * A Condition applied to an Action
  10621. */
  10622. export class Condition {
  10623. /**
  10624. * Internal only - manager for action
  10625. * @hidden
  10626. */
  10627. _actionManager: ActionManager;
  10628. /**
  10629. * Internal only
  10630. * @hidden
  10631. */
  10632. _evaluationId: number;
  10633. /**
  10634. * Internal only
  10635. * @hidden
  10636. */
  10637. _currentResult: boolean;
  10638. /**
  10639. * Creates a new Condition
  10640. * @param actionManager the manager of the action the condition is applied to
  10641. */
  10642. constructor(actionManager: ActionManager);
  10643. /**
  10644. * Check if the current condition is valid
  10645. * @returns a boolean
  10646. */
  10647. isValid(): boolean;
  10648. /**
  10649. * Internal only
  10650. * @hidden
  10651. */
  10652. _getProperty(propertyPath: string): string;
  10653. /**
  10654. * Internal only
  10655. * @hidden
  10656. */
  10657. _getEffectiveTarget(target: any, propertyPath: string): any;
  10658. /**
  10659. * Serialize placeholder for child classes
  10660. * @returns the serialized object
  10661. */
  10662. serialize(): any;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. protected _serialize(serializedCondition: any): any;
  10668. }
  10669. /**
  10670. * Defines specific conditional operators as extensions of Condition
  10671. */
  10672. export class ValueCondition extends Condition {
  10673. /** path to specify the property of the target the conditional operator uses */
  10674. propertyPath: string;
  10675. /** the value compared by the conditional operator against the current value of the property */
  10676. value: any;
  10677. /** the conditional operator, default ValueCondition.IsEqual */
  10678. operator: number;
  10679. /**
  10680. * Internal only
  10681. * @hidden
  10682. */
  10683. private static _IsEqual;
  10684. /**
  10685. * Internal only
  10686. * @hidden
  10687. */
  10688. private static _IsDifferent;
  10689. /**
  10690. * Internal only
  10691. * @hidden
  10692. */
  10693. private static _IsGreater;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. private static _IsLesser;
  10699. /**
  10700. * returns the number for IsEqual
  10701. */
  10702. static get IsEqual(): number;
  10703. /**
  10704. * Returns the number for IsDifferent
  10705. */
  10706. static get IsDifferent(): number;
  10707. /**
  10708. * Returns the number for IsGreater
  10709. */
  10710. static get IsGreater(): number;
  10711. /**
  10712. * Returns the number for IsLesser
  10713. */
  10714. static get IsLesser(): number;
  10715. /**
  10716. * Internal only The action manager for the condition
  10717. * @hidden
  10718. */
  10719. _actionManager: ActionManager;
  10720. /**
  10721. * Internal only
  10722. * @hidden
  10723. */
  10724. private _target;
  10725. /**
  10726. * Internal only
  10727. * @hidden
  10728. */
  10729. private _effectiveTarget;
  10730. /**
  10731. * Internal only
  10732. * @hidden
  10733. */
  10734. private _property;
  10735. /**
  10736. * Creates a new ValueCondition
  10737. * @param actionManager manager for the action the condition applies to
  10738. * @param target for the action
  10739. * @param propertyPath path to specify the property of the target the conditional operator uses
  10740. * @param value the value compared by the conditional operator against the current value of the property
  10741. * @param operator the conditional operator, default ValueCondition.IsEqual
  10742. */
  10743. constructor(actionManager: ActionManager, target: any,
  10744. /** path to specify the property of the target the conditional operator uses */
  10745. propertyPath: string,
  10746. /** the value compared by the conditional operator against the current value of the property */
  10747. value: any,
  10748. /** the conditional operator, default ValueCondition.IsEqual */
  10749. operator?: number);
  10750. /**
  10751. * Compares the given value with the property value for the specified conditional operator
  10752. * @returns the result of the comparison
  10753. */
  10754. isValid(): boolean;
  10755. /**
  10756. * Serialize the ValueCondition into a JSON compatible object
  10757. * @returns serialization object
  10758. */
  10759. serialize(): any;
  10760. /**
  10761. * Gets the name of the conditional operator for the ValueCondition
  10762. * @param operator the conditional operator
  10763. * @returns the name
  10764. */
  10765. static GetOperatorName(operator: number): string;
  10766. }
  10767. /**
  10768. * Defines a predicate condition as an extension of Condition
  10769. */
  10770. export class PredicateCondition extends Condition {
  10771. /** defines the predicate function used to validate the condition */
  10772. predicate: () => boolean;
  10773. /**
  10774. * Internal only - manager for action
  10775. * @hidden
  10776. */
  10777. _actionManager: ActionManager;
  10778. /**
  10779. * Creates a new PredicateCondition
  10780. * @param actionManager manager for the action the condition applies to
  10781. * @param predicate defines the predicate function used to validate the condition
  10782. */
  10783. constructor(actionManager: ActionManager,
  10784. /** defines the predicate function used to validate the condition */
  10785. predicate: () => boolean);
  10786. /**
  10787. * @returns the validity of the predicate condition
  10788. */
  10789. isValid(): boolean;
  10790. }
  10791. /**
  10792. * Defines a state condition as an extension of Condition
  10793. */
  10794. export class StateCondition extends Condition {
  10795. /** Value to compare with target state */
  10796. value: string;
  10797. /**
  10798. * Internal only - manager for action
  10799. * @hidden
  10800. */
  10801. _actionManager: ActionManager;
  10802. /**
  10803. * Internal only
  10804. * @hidden
  10805. */
  10806. private _target;
  10807. /**
  10808. * Creates a new StateCondition
  10809. * @param actionManager manager for the action the condition applies to
  10810. * @param target of the condition
  10811. * @param value to compare with target state
  10812. */
  10813. constructor(actionManager: ActionManager, target: any,
  10814. /** Value to compare with target state */
  10815. value: string);
  10816. /**
  10817. * Gets a boolean indicating if the current condition is met
  10818. * @returns the validity of the state
  10819. */
  10820. isValid(): boolean;
  10821. /**
  10822. * Serialize the StateCondition into a JSON compatible object
  10823. * @returns serialization object
  10824. */
  10825. serialize(): any;
  10826. }
  10827. }
  10828. declare module "babylonjs/Actions/directActions" {
  10829. import { Action } from "babylonjs/Actions/action";
  10830. import { Condition } from "babylonjs/Actions/condition";
  10831. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10832. /**
  10833. * This defines an action responsible to toggle a boolean once triggered.
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10835. */
  10836. export class SwitchBooleanAction extends Action {
  10837. /**
  10838. * The path to the boolean property in the target object
  10839. */
  10840. propertyPath: string;
  10841. private _target;
  10842. private _effectiveTarget;
  10843. private _property;
  10844. /**
  10845. * Instantiate the action
  10846. * @param triggerOptions defines the trigger options
  10847. * @param target defines the object containing the boolean
  10848. * @param propertyPath defines the path to the boolean property in the target object
  10849. * @param condition defines the trigger related conditions
  10850. */
  10851. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10852. /** @hidden */
  10853. _prepare(): void;
  10854. /**
  10855. * Execute the action toggle the boolean value.
  10856. */
  10857. execute(): void;
  10858. /**
  10859. * Serializes the actions and its related information.
  10860. * @param parent defines the object to serialize in
  10861. * @returns the serialized object
  10862. */
  10863. serialize(parent: any): any;
  10864. }
  10865. /**
  10866. * This defines an action responsible to set a the state field of the target
  10867. * to a desired value once triggered.
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10869. */
  10870. export class SetStateAction extends Action {
  10871. /**
  10872. * The value to store in the state field.
  10873. */
  10874. value: string;
  10875. private _target;
  10876. /**
  10877. * Instantiate the action
  10878. * @param triggerOptions defines the trigger options
  10879. * @param target defines the object containing the state property
  10880. * @param value defines the value to store in the state field
  10881. * @param condition defines the trigger related conditions
  10882. */
  10883. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10884. /**
  10885. * Execute the action and store the value on the target state property.
  10886. */
  10887. execute(): void;
  10888. /**
  10889. * Serializes the actions and its related information.
  10890. * @param parent defines the object to serialize in
  10891. * @returns the serialized object
  10892. */
  10893. serialize(parent: any): any;
  10894. }
  10895. /**
  10896. * This defines an action responsible to set a property of the target
  10897. * to a desired value once triggered.
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10899. */
  10900. export class SetValueAction extends Action {
  10901. /**
  10902. * The path of the property to set in the target.
  10903. */
  10904. propertyPath: string;
  10905. /**
  10906. * The value to set in the property
  10907. */
  10908. value: any;
  10909. private _target;
  10910. private _effectiveTarget;
  10911. private _property;
  10912. /**
  10913. * Instantiate the action
  10914. * @param triggerOptions defines the trigger options
  10915. * @param target defines the object containing the property
  10916. * @param propertyPath defines the path of the property to set in the target
  10917. * @param value defines the value to set in the property
  10918. * @param condition defines the trigger related conditions
  10919. */
  10920. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10921. /** @hidden */
  10922. _prepare(): void;
  10923. /**
  10924. * Execute the action and set the targetted property to the desired value.
  10925. */
  10926. execute(): void;
  10927. /**
  10928. * Serializes the actions and its related information.
  10929. * @param parent defines the object to serialize in
  10930. * @returns the serialized object
  10931. */
  10932. serialize(parent: any): any;
  10933. }
  10934. /**
  10935. * This defines an action responsible to increment the target value
  10936. * to a desired value once triggered.
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10938. */
  10939. export class IncrementValueAction extends Action {
  10940. /**
  10941. * The path of the property to increment in the target.
  10942. */
  10943. propertyPath: string;
  10944. /**
  10945. * The value we should increment the property by.
  10946. */
  10947. value: any;
  10948. private _target;
  10949. private _effectiveTarget;
  10950. private _property;
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param target defines the object containing the property
  10955. * @param propertyPath defines the path of the property to increment in the target
  10956. * @param value defines the value value we should increment the property by
  10957. * @param condition defines the trigger related conditions
  10958. */
  10959. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10960. /** @hidden */
  10961. _prepare(): void;
  10962. /**
  10963. * Execute the action and increment the target of the value amount.
  10964. */
  10965. execute(): void;
  10966. /**
  10967. * Serializes the actions and its related information.
  10968. * @param parent defines the object to serialize in
  10969. * @returns the serialized object
  10970. */
  10971. serialize(parent: any): any;
  10972. }
  10973. /**
  10974. * This defines an action responsible to start an animation once triggered.
  10975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10976. */
  10977. export class PlayAnimationAction extends Action {
  10978. /**
  10979. * Where the animation should start (animation frame)
  10980. */
  10981. from: number;
  10982. /**
  10983. * Where the animation should stop (animation frame)
  10984. */
  10985. to: number;
  10986. /**
  10987. * Define if the animation should loop or stop after the first play.
  10988. */
  10989. loop?: boolean;
  10990. private _target;
  10991. /**
  10992. * Instantiate the action
  10993. * @param triggerOptions defines the trigger options
  10994. * @param target defines the target animation or animation name
  10995. * @param from defines from where the animation should start (animation frame)
  10996. * @param end defines where the animation should stop (animation frame)
  10997. * @param loop defines if the animation should loop or stop after the first play
  10998. * @param condition defines the trigger related conditions
  10999. */
  11000. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11001. /** @hidden */
  11002. _prepare(): void;
  11003. /**
  11004. * Execute the action and play the animation.
  11005. */
  11006. execute(): void;
  11007. /**
  11008. * Serializes the actions and its related information.
  11009. * @param parent defines the object to serialize in
  11010. * @returns the serialized object
  11011. */
  11012. serialize(parent: any): any;
  11013. }
  11014. /**
  11015. * This defines an action responsible to stop an animation once triggered.
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11017. */
  11018. export class StopAnimationAction extends Action {
  11019. private _target;
  11020. /**
  11021. * Instantiate the action
  11022. * @param triggerOptions defines the trigger options
  11023. * @param target defines the target animation or animation name
  11024. * @param condition defines the trigger related conditions
  11025. */
  11026. constructor(triggerOptions: any, target: any, condition?: Condition);
  11027. /** @hidden */
  11028. _prepare(): void;
  11029. /**
  11030. * Execute the action and stop the animation.
  11031. */
  11032. execute(): void;
  11033. /**
  11034. * Serializes the actions and its related information.
  11035. * @param parent defines the object to serialize in
  11036. * @returns the serialized object
  11037. */
  11038. serialize(parent: any): any;
  11039. }
  11040. /**
  11041. * This defines an action responsible that does nothing once triggered.
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11043. */
  11044. export class DoNothingAction extends Action {
  11045. /**
  11046. * Instantiate the action
  11047. * @param triggerOptions defines the trigger options
  11048. * @param condition defines the trigger related conditions
  11049. */
  11050. constructor(triggerOptions?: any, condition?: Condition);
  11051. /**
  11052. * Execute the action and do nothing.
  11053. */
  11054. execute(): void;
  11055. /**
  11056. * Serializes the actions and its related information.
  11057. * @param parent defines the object to serialize in
  11058. * @returns the serialized object
  11059. */
  11060. serialize(parent: any): any;
  11061. }
  11062. /**
  11063. * This defines an action responsible to trigger several actions once triggered.
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11065. */
  11066. export class CombineAction extends Action {
  11067. /**
  11068. * The list of aggregated animations to run.
  11069. */
  11070. children: Action[];
  11071. /**
  11072. * Instantiate the action
  11073. * @param triggerOptions defines the trigger options
  11074. * @param children defines the list of aggregated animations to run
  11075. * @param condition defines the trigger related conditions
  11076. */
  11077. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11078. /** @hidden */
  11079. _prepare(): void;
  11080. /**
  11081. * Execute the action and executes all the aggregated actions.
  11082. */
  11083. execute(evt: ActionEvent): void;
  11084. /**
  11085. * Serializes the actions and its related information.
  11086. * @param parent defines the object to serialize in
  11087. * @returns the serialized object
  11088. */
  11089. serialize(parent: any): any;
  11090. }
  11091. /**
  11092. * This defines an action responsible to run code (external event) once triggered.
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11094. */
  11095. export class ExecuteCodeAction extends Action {
  11096. /**
  11097. * The callback function to run.
  11098. */
  11099. func: (evt: ActionEvent) => void;
  11100. /**
  11101. * Instantiate the action
  11102. * @param triggerOptions defines the trigger options
  11103. * @param func defines the callback function to run
  11104. * @param condition defines the trigger related conditions
  11105. */
  11106. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11107. /**
  11108. * Execute the action and run the attached code.
  11109. */
  11110. execute(evt: ActionEvent): void;
  11111. }
  11112. /**
  11113. * This defines an action responsible to set the parent property of the target once triggered.
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11115. */
  11116. export class SetParentAction extends Action {
  11117. private _parent;
  11118. private _target;
  11119. /**
  11120. * Instantiate the action
  11121. * @param triggerOptions defines the trigger options
  11122. * @param target defines the target containing the parent property
  11123. * @param parent defines from where the animation should start (animation frame)
  11124. * @param condition defines the trigger related conditions
  11125. */
  11126. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11127. /** @hidden */
  11128. _prepare(): void;
  11129. /**
  11130. * Execute the action and set the parent property.
  11131. */
  11132. execute(): void;
  11133. /**
  11134. * Serializes the actions and its related information.
  11135. * @param parent defines the object to serialize in
  11136. * @returns the serialized object
  11137. */
  11138. serialize(parent: any): any;
  11139. }
  11140. }
  11141. declare module "babylonjs/Actions/actionManager" {
  11142. import { Nullable } from "babylonjs/types";
  11143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11144. import { Scene } from "babylonjs/scene";
  11145. import { IAction } from "babylonjs/Actions/action";
  11146. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11147. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11148. /**
  11149. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11150. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11152. */
  11153. export class ActionManager extends AbstractActionManager {
  11154. /**
  11155. * Nothing
  11156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11157. */
  11158. static readonly NothingTrigger: number;
  11159. /**
  11160. * On pick
  11161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11162. */
  11163. static readonly OnPickTrigger: number;
  11164. /**
  11165. * On left pick
  11166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11167. */
  11168. static readonly OnLeftPickTrigger: number;
  11169. /**
  11170. * On right pick
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly OnRightPickTrigger: number;
  11174. /**
  11175. * On center pick
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnCenterPickTrigger: number;
  11179. /**
  11180. * On pick down
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnPickDownTrigger: number;
  11184. /**
  11185. * On double pick
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly OnDoublePickTrigger: number;
  11189. /**
  11190. * On pick up
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnPickUpTrigger: number;
  11194. /**
  11195. * On pick out.
  11196. * This trigger will only be raised if you also declared a OnPickDown
  11197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11198. */
  11199. static readonly OnPickOutTrigger: number;
  11200. /**
  11201. * On long press
  11202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11203. */
  11204. static readonly OnLongPressTrigger: number;
  11205. /**
  11206. * On pointer over
  11207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11208. */
  11209. static readonly OnPointerOverTrigger: number;
  11210. /**
  11211. * On pointer out
  11212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11213. */
  11214. static readonly OnPointerOutTrigger: number;
  11215. /**
  11216. * On every frame
  11217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11218. */
  11219. static readonly OnEveryFrameTrigger: number;
  11220. /**
  11221. * On intersection enter
  11222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11223. */
  11224. static readonly OnIntersectionEnterTrigger: number;
  11225. /**
  11226. * On intersection exit
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11228. */
  11229. static readonly OnIntersectionExitTrigger: number;
  11230. /**
  11231. * On key down
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11233. */
  11234. static readonly OnKeyDownTrigger: number;
  11235. /**
  11236. * On key up
  11237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11238. */
  11239. static readonly OnKeyUpTrigger: number;
  11240. private _scene;
  11241. /**
  11242. * Creates a new action manager
  11243. * @param scene defines the hosting scene
  11244. */
  11245. constructor(scene: Scene);
  11246. /**
  11247. * Releases all associated resources
  11248. */
  11249. dispose(): void;
  11250. /**
  11251. * Gets hosting scene
  11252. * @returns the hosting scene
  11253. */
  11254. getScene(): Scene;
  11255. /**
  11256. * Does this action manager handles actions of any of the given triggers
  11257. * @param triggers defines the triggers to be tested
  11258. * @return a boolean indicating whether one (or more) of the triggers is handled
  11259. */
  11260. hasSpecificTriggers(triggers: number[]): boolean;
  11261. /**
  11262. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11263. * speed.
  11264. * @param triggerA defines the trigger to be tested
  11265. * @param triggerB defines the trigger to be tested
  11266. * @return a boolean indicating whether one (or more) of the triggers is handled
  11267. */
  11268. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11269. /**
  11270. * Does this action manager handles actions of a given trigger
  11271. * @param trigger defines the trigger to be tested
  11272. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11273. * @return whether the trigger is handled
  11274. */
  11275. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11276. /**
  11277. * Does this action manager has pointer triggers
  11278. */
  11279. get hasPointerTriggers(): boolean;
  11280. /**
  11281. * Does this action manager has pick triggers
  11282. */
  11283. get hasPickTriggers(): boolean;
  11284. /**
  11285. * Registers an action to this action manager
  11286. * @param action defines the action to be registered
  11287. * @return the action amended (prepared) after registration
  11288. */
  11289. registerAction(action: IAction): Nullable<IAction>;
  11290. /**
  11291. * Unregisters an action to this action manager
  11292. * @param action defines the action to be unregistered
  11293. * @return a boolean indicating whether the action has been unregistered
  11294. */
  11295. unregisterAction(action: IAction): Boolean;
  11296. /**
  11297. * Process a specific trigger
  11298. * @param trigger defines the trigger to process
  11299. * @param evt defines the event details to be processed
  11300. */
  11301. processTrigger(trigger: number, evt?: IActionEvent): void;
  11302. /** @hidden */
  11303. _getEffectiveTarget(target: any, propertyPath: string): any;
  11304. /** @hidden */
  11305. _getProperty(propertyPath: string): string;
  11306. /**
  11307. * Serialize this manager to a JSON object
  11308. * @param name defines the property name to store this manager
  11309. * @returns a JSON representation of this manager
  11310. */
  11311. serialize(name: string): any;
  11312. /**
  11313. * Creates a new ActionManager from a JSON data
  11314. * @param parsedActions defines the JSON data to read from
  11315. * @param object defines the hosting mesh
  11316. * @param scene defines the hosting scene
  11317. */
  11318. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11319. /**
  11320. * Get a trigger name by index
  11321. * @param trigger defines the trigger index
  11322. * @returns a trigger name
  11323. */
  11324. static GetTriggerName(trigger: number): string;
  11325. }
  11326. }
  11327. declare module "babylonjs/Culling/ray" {
  11328. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11329. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11331. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11332. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11333. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11334. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11335. import { Plane } from "babylonjs/Maths/math.plane";
  11336. /**
  11337. * Class representing a ray with position and direction
  11338. */
  11339. export class Ray {
  11340. /** origin point */
  11341. origin: Vector3;
  11342. /** direction */
  11343. direction: Vector3;
  11344. /** length of the ray */
  11345. length: number;
  11346. private static readonly TmpVector3;
  11347. private _tmpRay;
  11348. /**
  11349. * Creates a new ray
  11350. * @param origin origin point
  11351. * @param direction direction
  11352. * @param length length of the ray
  11353. */
  11354. constructor(
  11355. /** origin point */
  11356. origin: Vector3,
  11357. /** direction */
  11358. direction: Vector3,
  11359. /** length of the ray */
  11360. length?: number);
  11361. /**
  11362. * Checks if the ray intersects a box
  11363. * @param minimum bound of the box
  11364. * @param maximum bound of the box
  11365. * @param intersectionTreshold extra extend to be added to the box in all direction
  11366. * @returns if the box was hit
  11367. */
  11368. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11369. /**
  11370. * Checks if the ray intersects a box
  11371. * @param box the bounding box to check
  11372. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11373. * @returns if the box was hit
  11374. */
  11375. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11376. /**
  11377. * If the ray hits a sphere
  11378. * @param sphere the bounding sphere to check
  11379. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11380. * @returns true if it hits the sphere
  11381. */
  11382. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11383. /**
  11384. * If the ray hits a triange
  11385. * @param vertex0 triangle vertex
  11386. * @param vertex1 triangle vertex
  11387. * @param vertex2 triangle vertex
  11388. * @returns intersection information if hit
  11389. */
  11390. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11391. /**
  11392. * Checks if ray intersects a plane
  11393. * @param plane the plane to check
  11394. * @returns the distance away it was hit
  11395. */
  11396. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11397. /**
  11398. * Calculate the intercept of a ray on a given axis
  11399. * @param axis to check 'x' | 'y' | 'z'
  11400. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11401. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11402. */
  11403. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11404. /**
  11405. * Checks if ray intersects a mesh
  11406. * @param mesh the mesh to check
  11407. * @param fastCheck if only the bounding box should checked
  11408. * @returns picking info of the intersecton
  11409. */
  11410. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11411. /**
  11412. * Checks if ray intersects a mesh
  11413. * @param meshes the meshes to check
  11414. * @param fastCheck if only the bounding box should checked
  11415. * @param results array to store result in
  11416. * @returns Array of picking infos
  11417. */
  11418. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11419. private _comparePickingInfo;
  11420. private static smallnum;
  11421. private static rayl;
  11422. /**
  11423. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11424. * @param sega the first point of the segment to test the intersection against
  11425. * @param segb the second point of the segment to test the intersection against
  11426. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11427. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11428. */
  11429. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11430. /**
  11431. * Update the ray from viewport position
  11432. * @param x position
  11433. * @param y y position
  11434. * @param viewportWidth viewport width
  11435. * @param viewportHeight viewport height
  11436. * @param world world matrix
  11437. * @param view view matrix
  11438. * @param projection projection matrix
  11439. * @returns this ray updated
  11440. */
  11441. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11442. /**
  11443. * Creates a ray with origin and direction of 0,0,0
  11444. * @returns the new ray
  11445. */
  11446. static Zero(): Ray;
  11447. /**
  11448. * Creates a new ray from screen space and viewport
  11449. * @param x position
  11450. * @param y y position
  11451. * @param viewportWidth viewport width
  11452. * @param viewportHeight viewport height
  11453. * @param world world matrix
  11454. * @param view view matrix
  11455. * @param projection projection matrix
  11456. * @returns new ray
  11457. */
  11458. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11459. /**
  11460. * 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
  11461. * transformed to the given world matrix.
  11462. * @param origin The origin point
  11463. * @param end The end point
  11464. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11465. * @returns the new ray
  11466. */
  11467. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11468. /**
  11469. * Transforms a ray by a matrix
  11470. * @param ray ray to transform
  11471. * @param matrix matrix to apply
  11472. * @returns the resulting new ray
  11473. */
  11474. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11475. /**
  11476. * Transforms a ray by a matrix
  11477. * @param ray ray to transform
  11478. * @param matrix matrix to apply
  11479. * @param result ray to store result in
  11480. */
  11481. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11482. /**
  11483. * Unproject a ray from screen space to object space
  11484. * @param sourceX defines the screen space x coordinate to use
  11485. * @param sourceY defines the screen space y coordinate to use
  11486. * @param viewportWidth defines the current width of the viewport
  11487. * @param viewportHeight defines the current height of the viewport
  11488. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11489. * @param view defines the view matrix to use
  11490. * @param projection defines the projection matrix to use
  11491. */
  11492. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11493. }
  11494. /**
  11495. * Type used to define predicate used to select faces when a mesh intersection is detected
  11496. */
  11497. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11498. module "babylonjs/scene" {
  11499. interface Scene {
  11500. /** @hidden */
  11501. _tempPickingRay: Nullable<Ray>;
  11502. /** @hidden */
  11503. _cachedRayForTransform: Ray;
  11504. /** @hidden */
  11505. _pickWithRayInverseMatrix: Matrix;
  11506. /** @hidden */
  11507. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11508. /** @hidden */
  11509. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11510. }
  11511. }
  11512. }
  11513. declare module "babylonjs/sceneComponent" {
  11514. import { Scene } from "babylonjs/scene";
  11515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11517. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11518. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11519. import { Nullable } from "babylonjs/types";
  11520. import { Camera } from "babylonjs/Cameras/camera";
  11521. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11522. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11523. import { AbstractScene } from "babylonjs/abstractScene";
  11524. import { Mesh } from "babylonjs/Meshes/mesh";
  11525. /**
  11526. * Groups all the scene component constants in one place to ease maintenance.
  11527. * @hidden
  11528. */
  11529. export class SceneComponentConstants {
  11530. static readonly NAME_EFFECTLAYER: string;
  11531. static readonly NAME_LAYER: string;
  11532. static readonly NAME_LENSFLARESYSTEM: string;
  11533. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11534. static readonly NAME_PARTICLESYSTEM: string;
  11535. static readonly NAME_GAMEPAD: string;
  11536. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11537. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11538. static readonly NAME_DEPTHRENDERER: string;
  11539. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11540. static readonly NAME_SPRITE: string;
  11541. static readonly NAME_OUTLINERENDERER: string;
  11542. static readonly NAME_PROCEDURALTEXTURE: string;
  11543. static readonly NAME_SHADOWGENERATOR: string;
  11544. static readonly NAME_OCTREE: string;
  11545. static readonly NAME_PHYSICSENGINE: string;
  11546. static readonly NAME_AUDIO: string;
  11547. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11548. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11549. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11550. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11551. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11552. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11553. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11554. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11555. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11556. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11557. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11558. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11559. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11560. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11561. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11562. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11563. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11564. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11565. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11566. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11567. static readonly STEP_AFTERRENDER_AUDIO: number;
  11568. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11569. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11570. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11571. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11572. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11573. static readonly STEP_POINTERMOVE_SPRITE: number;
  11574. static readonly STEP_POINTERDOWN_SPRITE: number;
  11575. static readonly STEP_POINTERUP_SPRITE: number;
  11576. }
  11577. /**
  11578. * This represents a scene component.
  11579. *
  11580. * This is used to decouple the dependency the scene is having on the different workloads like
  11581. * layers, post processes...
  11582. */
  11583. export interface ISceneComponent {
  11584. /**
  11585. * The name of the component. Each component must have a unique name.
  11586. */
  11587. name: string;
  11588. /**
  11589. * The scene the component belongs to.
  11590. */
  11591. scene: Scene;
  11592. /**
  11593. * Register the component to one instance of a scene.
  11594. */
  11595. register(): void;
  11596. /**
  11597. * Rebuilds the elements related to this component in case of
  11598. * context lost for instance.
  11599. */
  11600. rebuild(): void;
  11601. /**
  11602. * Disposes the component and the associated ressources.
  11603. */
  11604. dispose(): void;
  11605. }
  11606. /**
  11607. * This represents a SERIALIZABLE scene component.
  11608. *
  11609. * This extends Scene Component to add Serialization methods on top.
  11610. */
  11611. export interface ISceneSerializableComponent extends ISceneComponent {
  11612. /**
  11613. * Adds all the elements from the container to the scene
  11614. * @param container the container holding the elements
  11615. */
  11616. addFromContainer(container: AbstractScene): void;
  11617. /**
  11618. * Removes all the elements in the container from the scene
  11619. * @param container contains the elements to remove
  11620. * @param dispose if the removed element should be disposed (default: false)
  11621. */
  11622. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11623. /**
  11624. * Serializes the component data to the specified json object
  11625. * @param serializationObject The object to serialize to
  11626. */
  11627. serialize(serializationObject: any): void;
  11628. }
  11629. /**
  11630. * Strong typing of a Mesh related stage step action
  11631. */
  11632. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11633. /**
  11634. * Strong typing of a Evaluate Sub Mesh related stage step action
  11635. */
  11636. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11637. /**
  11638. * Strong typing of a Active Mesh related stage step action
  11639. */
  11640. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11641. /**
  11642. * Strong typing of a Camera related stage step action
  11643. */
  11644. export type CameraStageAction = (camera: Camera) => void;
  11645. /**
  11646. * Strong typing of a Camera Frame buffer related stage step action
  11647. */
  11648. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11649. /**
  11650. * Strong typing of a Render Target related stage step action
  11651. */
  11652. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11653. /**
  11654. * Strong typing of a RenderingGroup related stage step action
  11655. */
  11656. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11657. /**
  11658. * Strong typing of a Mesh Render related stage step action
  11659. */
  11660. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11661. /**
  11662. * Strong typing of a simple stage step action
  11663. */
  11664. export type SimpleStageAction = () => void;
  11665. /**
  11666. * Strong typing of a render target action.
  11667. */
  11668. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11669. /**
  11670. * Strong typing of a pointer move action.
  11671. */
  11672. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11673. /**
  11674. * Strong typing of a pointer up/down action.
  11675. */
  11676. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11677. /**
  11678. * Representation of a stage in the scene (Basically a list of ordered steps)
  11679. * @hidden
  11680. */
  11681. export class Stage<T extends Function> extends Array<{
  11682. index: number;
  11683. component: ISceneComponent;
  11684. action: T;
  11685. }> {
  11686. /**
  11687. * Hide ctor from the rest of the world.
  11688. * @param items The items to add.
  11689. */
  11690. private constructor();
  11691. /**
  11692. * Creates a new Stage.
  11693. * @returns A new instance of a Stage
  11694. */
  11695. static Create<T extends Function>(): Stage<T>;
  11696. /**
  11697. * Registers a step in an ordered way in the targeted stage.
  11698. * @param index Defines the position to register the step in
  11699. * @param component Defines the component attached to the step
  11700. * @param action Defines the action to launch during the step
  11701. */
  11702. registerStep(index: number, component: ISceneComponent, action: T): void;
  11703. /**
  11704. * Clears all the steps from the stage.
  11705. */
  11706. clear(): void;
  11707. }
  11708. }
  11709. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11710. import { Nullable } from "babylonjs/types";
  11711. import { Observable } from "babylonjs/Misc/observable";
  11712. import { Scene } from "babylonjs/scene";
  11713. import { Sprite } from "babylonjs/Sprites/sprite";
  11714. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11715. import { Ray } from "babylonjs/Culling/ray";
  11716. import { Camera } from "babylonjs/Cameras/camera";
  11717. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11718. import { ISceneComponent } from "babylonjs/sceneComponent";
  11719. module "babylonjs/scene" {
  11720. interface Scene {
  11721. /** @hidden */
  11722. _pointerOverSprite: Nullable<Sprite>;
  11723. /** @hidden */
  11724. _pickedDownSprite: Nullable<Sprite>;
  11725. /** @hidden */
  11726. _tempSpritePickingRay: Nullable<Ray>;
  11727. /**
  11728. * All of the sprite managers added to this scene
  11729. * @see http://doc.babylonjs.com/babylon101/sprites
  11730. */
  11731. spriteManagers: Array<ISpriteManager>;
  11732. /**
  11733. * An event triggered when sprites rendering is about to start
  11734. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11735. */
  11736. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11737. /**
  11738. * An event triggered when sprites rendering is done
  11739. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11740. */
  11741. onAfterSpritesRenderingObservable: Observable<Scene>;
  11742. /** @hidden */
  11743. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11744. /** Launch a ray to try to pick a sprite in the scene
  11745. * @param x position on screen
  11746. * @param y position on screen
  11747. * @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
  11748. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11749. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11750. * @returns a PickingInfo
  11751. */
  11752. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11753. /** Use the given ray to pick a sprite in the scene
  11754. * @param ray The ray (in world space) to use to pick meshes
  11755. * @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
  11756. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11757. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11758. * @returns a PickingInfo
  11759. */
  11760. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11761. /** @hidden */
  11762. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11763. /** Launch a ray to try to pick sprites in the scene
  11764. * @param x position on screen
  11765. * @param y position on screen
  11766. * @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
  11767. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11768. * @returns a PickingInfo array
  11769. */
  11770. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11771. /** Use the given ray to pick sprites in the scene
  11772. * @param ray The ray (in world space) to use to pick meshes
  11773. * @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
  11774. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11775. * @returns a PickingInfo array
  11776. */
  11777. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11778. /**
  11779. * Force the sprite under the pointer
  11780. * @param sprite defines the sprite to use
  11781. */
  11782. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11783. /**
  11784. * Gets the sprite under the pointer
  11785. * @returns a Sprite or null if no sprite is under the pointer
  11786. */
  11787. getPointerOverSprite(): Nullable<Sprite>;
  11788. }
  11789. }
  11790. /**
  11791. * Defines the sprite scene component responsible to manage sprites
  11792. * in a given scene.
  11793. */
  11794. export class SpriteSceneComponent implements ISceneComponent {
  11795. /**
  11796. * The component name helpfull to identify the component in the list of scene components.
  11797. */
  11798. readonly name: string;
  11799. /**
  11800. * The scene the component belongs to.
  11801. */
  11802. scene: Scene;
  11803. /** @hidden */
  11804. private _spritePredicate;
  11805. /**
  11806. * Creates a new instance of the component for the given scene
  11807. * @param scene Defines the scene to register the component in
  11808. */
  11809. constructor(scene: Scene);
  11810. /**
  11811. * Registers the component in a given scene
  11812. */
  11813. register(): void;
  11814. /**
  11815. * Rebuilds the elements related to this component in case of
  11816. * context lost for instance.
  11817. */
  11818. rebuild(): void;
  11819. /**
  11820. * Disposes the component and the associated ressources.
  11821. */
  11822. dispose(): void;
  11823. private _pickSpriteButKeepRay;
  11824. private _pointerMove;
  11825. private _pointerDown;
  11826. private _pointerUp;
  11827. }
  11828. }
  11829. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11830. /** @hidden */
  11831. export var fogFragmentDeclaration: {
  11832. name: string;
  11833. shader: string;
  11834. };
  11835. }
  11836. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11837. /** @hidden */
  11838. export var fogFragment: {
  11839. name: string;
  11840. shader: string;
  11841. };
  11842. }
  11843. declare module "babylonjs/Shaders/sprites.fragment" {
  11844. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11845. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11846. /** @hidden */
  11847. export var spritesPixelShader: {
  11848. name: string;
  11849. shader: string;
  11850. };
  11851. }
  11852. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11853. /** @hidden */
  11854. export var fogVertexDeclaration: {
  11855. name: string;
  11856. shader: string;
  11857. };
  11858. }
  11859. declare module "babylonjs/Shaders/sprites.vertex" {
  11860. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11861. /** @hidden */
  11862. export var spritesVertexShader: {
  11863. name: string;
  11864. shader: string;
  11865. };
  11866. }
  11867. declare module "babylonjs/Sprites/spriteManager" {
  11868. import { IDisposable, Scene } from "babylonjs/scene";
  11869. import { Nullable } from "babylonjs/types";
  11870. import { Observable } from "babylonjs/Misc/observable";
  11871. import { Sprite } from "babylonjs/Sprites/sprite";
  11872. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11873. import { Camera } from "babylonjs/Cameras/camera";
  11874. import { Texture } from "babylonjs/Materials/Textures/texture";
  11875. import "babylonjs/Shaders/sprites.fragment";
  11876. import "babylonjs/Shaders/sprites.vertex";
  11877. import { Ray } from "babylonjs/Culling/ray";
  11878. /**
  11879. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11880. */
  11881. export interface ISpriteManager extends IDisposable {
  11882. /**
  11883. * Restricts the camera to viewing objects with the same layerMask.
  11884. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11885. */
  11886. layerMask: number;
  11887. /**
  11888. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11889. */
  11890. isPickable: boolean;
  11891. /**
  11892. * Specifies the rendering group id for this mesh (0 by default)
  11893. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11894. */
  11895. renderingGroupId: number;
  11896. /**
  11897. * Defines the list of sprites managed by the manager.
  11898. */
  11899. sprites: Array<Sprite>;
  11900. /**
  11901. * Tests the intersection of a sprite with a specific ray.
  11902. * @param ray The ray we are sending to test the collision
  11903. * @param camera The camera space we are sending rays in
  11904. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11905. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11906. * @returns picking info or null.
  11907. */
  11908. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11909. /**
  11910. * Intersects the sprites with a ray
  11911. * @param ray defines the ray to intersect with
  11912. * @param camera defines the current active camera
  11913. * @param predicate defines a predicate used to select candidate sprites
  11914. * @returns null if no hit or a PickingInfo array
  11915. */
  11916. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11917. /**
  11918. * Renders the list of sprites on screen.
  11919. */
  11920. render(): void;
  11921. }
  11922. /**
  11923. * Class used to manage multiple sprites on the same spritesheet
  11924. * @see http://doc.babylonjs.com/babylon101/sprites
  11925. */
  11926. export class SpriteManager implements ISpriteManager {
  11927. /** defines the manager's name */
  11928. name: string;
  11929. /** Gets the list of sprites */
  11930. sprites: Sprite[];
  11931. /** Gets or sets the rendering group id (0 by default) */
  11932. renderingGroupId: number;
  11933. /** Gets or sets camera layer mask */
  11934. layerMask: number;
  11935. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11936. fogEnabled: boolean;
  11937. /** Gets or sets a boolean indicating if the sprites are pickable */
  11938. isPickable: boolean;
  11939. /** Defines the default width of a cell in the spritesheet */
  11940. cellWidth: number;
  11941. /** Defines the default height of a cell in the spritesheet */
  11942. cellHeight: number;
  11943. /** Associative array from JSON sprite data file */
  11944. private _cellData;
  11945. /** Array of sprite names from JSON sprite data file */
  11946. private _spriteMap;
  11947. /** True when packed cell data from JSON file is ready*/
  11948. private _packedAndReady;
  11949. /**
  11950. * An event triggered when the manager is disposed.
  11951. */
  11952. onDisposeObservable: Observable<SpriteManager>;
  11953. private _onDisposeObserver;
  11954. /**
  11955. * Callback called when the manager is disposed
  11956. */
  11957. set onDispose(callback: () => void);
  11958. private _capacity;
  11959. private _fromPacked;
  11960. private _spriteTexture;
  11961. private _epsilon;
  11962. private _scene;
  11963. private _vertexData;
  11964. private _buffer;
  11965. private _vertexBuffers;
  11966. private _indexBuffer;
  11967. private _effectBase;
  11968. private _effectFog;
  11969. /**
  11970. * Gets or sets the spritesheet texture
  11971. */
  11972. get texture(): Texture;
  11973. set texture(value: Texture);
  11974. /**
  11975. * Creates a new sprite manager
  11976. * @param name defines the manager's name
  11977. * @param imgUrl defines the sprite sheet url
  11978. * @param capacity defines the maximum allowed number of sprites
  11979. * @param cellSize defines the size of a sprite cell
  11980. * @param scene defines the hosting scene
  11981. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11982. * @param samplingMode defines the smapling mode to use with spritesheet
  11983. * @param fromPacked set to false; do not alter
  11984. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11985. */
  11986. constructor(
  11987. /** defines the manager's name */
  11988. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11989. private _makePacked;
  11990. private _appendSpriteVertex;
  11991. /**
  11992. * Intersects the sprites with a ray
  11993. * @param ray defines the ray to intersect with
  11994. * @param camera defines the current active camera
  11995. * @param predicate defines a predicate used to select candidate sprites
  11996. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11997. * @returns null if no hit or a PickingInfo
  11998. */
  11999. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12000. /**
  12001. * Intersects the sprites with a ray
  12002. * @param ray defines the ray to intersect with
  12003. * @param camera defines the current active camera
  12004. * @param predicate defines a predicate used to select candidate sprites
  12005. * @returns null if no hit or a PickingInfo array
  12006. */
  12007. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  12008. /**
  12009. * Render all child sprites
  12010. */
  12011. render(): void;
  12012. /**
  12013. * Release associated resources
  12014. */
  12015. dispose(): void;
  12016. }
  12017. }
  12018. declare module "babylonjs/Sprites/sprite" {
  12019. import { Vector3 } from "babylonjs/Maths/math.vector";
  12020. import { Nullable } from "babylonjs/types";
  12021. import { ActionManager } from "babylonjs/Actions/actionManager";
  12022. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12023. import { Color4 } from "babylonjs/Maths/math.color";
  12024. /**
  12025. * Class used to represent a sprite
  12026. * @see http://doc.babylonjs.com/babylon101/sprites
  12027. */
  12028. export class Sprite {
  12029. /** defines the name */
  12030. name: string;
  12031. /** Gets or sets the current world position */
  12032. position: Vector3;
  12033. /** Gets or sets the main color */
  12034. color: Color4;
  12035. /** Gets or sets the width */
  12036. width: number;
  12037. /** Gets or sets the height */
  12038. height: number;
  12039. /** Gets or sets rotation angle */
  12040. angle: number;
  12041. /** Gets or sets the cell index in the sprite sheet */
  12042. cellIndex: number;
  12043. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12044. cellRef: string;
  12045. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12046. invertU: number;
  12047. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12048. invertV: number;
  12049. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12050. disposeWhenFinishedAnimating: boolean;
  12051. /** Gets the list of attached animations */
  12052. animations: Animation[];
  12053. /** Gets or sets a boolean indicating if the sprite can be picked */
  12054. isPickable: boolean;
  12055. /**
  12056. * Gets or sets the associated action manager
  12057. */
  12058. actionManager: Nullable<ActionManager>;
  12059. private _animationStarted;
  12060. private _loopAnimation;
  12061. private _fromIndex;
  12062. private _toIndex;
  12063. private _delay;
  12064. private _direction;
  12065. private _manager;
  12066. private _time;
  12067. private _onAnimationEnd;
  12068. /**
  12069. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12070. */
  12071. isVisible: boolean;
  12072. /**
  12073. * Gets or sets the sprite size
  12074. */
  12075. get size(): number;
  12076. set size(value: number);
  12077. /**
  12078. * Creates a new Sprite
  12079. * @param name defines the name
  12080. * @param manager defines the manager
  12081. */
  12082. constructor(
  12083. /** defines the name */
  12084. name: string, manager: ISpriteManager);
  12085. /**
  12086. * Starts an animation
  12087. * @param from defines the initial key
  12088. * @param to defines the end key
  12089. * @param loop defines if the animation must loop
  12090. * @param delay defines the start delay (in ms)
  12091. * @param onAnimationEnd defines a callback to call when animation ends
  12092. */
  12093. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12094. /** Stops current animation (if any) */
  12095. stopAnimation(): void;
  12096. /** @hidden */
  12097. _animate(deltaTime: number): void;
  12098. /** Release associated resources */
  12099. dispose(): void;
  12100. }
  12101. }
  12102. declare module "babylonjs/Collisions/pickingInfo" {
  12103. import { Nullable } from "babylonjs/types";
  12104. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12106. import { Sprite } from "babylonjs/Sprites/sprite";
  12107. import { Ray } from "babylonjs/Culling/ray";
  12108. /**
  12109. * Information about the result of picking within a scene
  12110. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12111. */
  12112. export class PickingInfo {
  12113. /** @hidden */
  12114. _pickingUnavailable: boolean;
  12115. /**
  12116. * If the pick collided with an object
  12117. */
  12118. hit: boolean;
  12119. /**
  12120. * Distance away where the pick collided
  12121. */
  12122. distance: number;
  12123. /**
  12124. * The location of pick collision
  12125. */
  12126. pickedPoint: Nullable<Vector3>;
  12127. /**
  12128. * The mesh corresponding the the pick collision
  12129. */
  12130. pickedMesh: Nullable<AbstractMesh>;
  12131. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12132. bu: number;
  12133. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12134. bv: number;
  12135. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12136. faceId: number;
  12137. /** Id of the the submesh that was picked */
  12138. subMeshId: number;
  12139. /** If a sprite was picked, this will be the sprite the pick collided with */
  12140. pickedSprite: Nullable<Sprite>;
  12141. /**
  12142. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12143. */
  12144. originMesh: Nullable<AbstractMesh>;
  12145. /**
  12146. * The ray that was used to perform the picking.
  12147. */
  12148. ray: Nullable<Ray>;
  12149. /**
  12150. * Gets the normal correspodning to the face the pick collided with
  12151. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12152. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12153. * @returns The normal correspodning to the face the pick collided with
  12154. */
  12155. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12156. /**
  12157. * Gets the texture coordinates of where the pick occured
  12158. * @returns the vector containing the coordnates of the texture
  12159. */
  12160. getTextureCoordinates(): Nullable<Vector2>;
  12161. }
  12162. }
  12163. declare module "babylonjs/Events/pointerEvents" {
  12164. import { Nullable } from "babylonjs/types";
  12165. import { Vector2 } from "babylonjs/Maths/math.vector";
  12166. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12167. import { Ray } from "babylonjs/Culling/ray";
  12168. /**
  12169. * Gather the list of pointer event types as constants.
  12170. */
  12171. export class PointerEventTypes {
  12172. /**
  12173. * 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.
  12174. */
  12175. static readonly POINTERDOWN: number;
  12176. /**
  12177. * The pointerup event is fired when a pointer is no longer active.
  12178. */
  12179. static readonly POINTERUP: number;
  12180. /**
  12181. * The pointermove event is fired when a pointer changes coordinates.
  12182. */
  12183. static readonly POINTERMOVE: number;
  12184. /**
  12185. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12186. */
  12187. static readonly POINTERWHEEL: number;
  12188. /**
  12189. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12190. */
  12191. static readonly POINTERPICK: number;
  12192. /**
  12193. * The pointertap event is fired when a the object has been touched and released without drag.
  12194. */
  12195. static readonly POINTERTAP: number;
  12196. /**
  12197. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12198. */
  12199. static readonly POINTERDOUBLETAP: number;
  12200. }
  12201. /**
  12202. * Base class of pointer info types.
  12203. */
  12204. export class PointerInfoBase {
  12205. /**
  12206. * Defines the type of event (PointerEventTypes)
  12207. */
  12208. type: number;
  12209. /**
  12210. * Defines the related dom event
  12211. */
  12212. event: PointerEvent | MouseWheelEvent;
  12213. /**
  12214. * Instantiates the base class of pointers info.
  12215. * @param type Defines the type of event (PointerEventTypes)
  12216. * @param event Defines the related dom event
  12217. */
  12218. constructor(
  12219. /**
  12220. * Defines the type of event (PointerEventTypes)
  12221. */
  12222. type: number,
  12223. /**
  12224. * Defines the related dom event
  12225. */
  12226. event: PointerEvent | MouseWheelEvent);
  12227. }
  12228. /**
  12229. * This class is used to store pointer related info for the onPrePointerObservable event.
  12230. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12231. */
  12232. export class PointerInfoPre extends PointerInfoBase {
  12233. /**
  12234. * Ray from a pointer if availible (eg. 6dof controller)
  12235. */
  12236. ray: Nullable<Ray>;
  12237. /**
  12238. * Defines the local position of the pointer on the canvas.
  12239. */
  12240. localPosition: Vector2;
  12241. /**
  12242. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12243. */
  12244. skipOnPointerObservable: boolean;
  12245. /**
  12246. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12247. * @param type Defines the type of event (PointerEventTypes)
  12248. * @param event Defines the related dom event
  12249. * @param localX Defines the local x coordinates of the pointer when the event occured
  12250. * @param localY Defines the local y coordinates of the pointer when the event occured
  12251. */
  12252. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12253. }
  12254. /**
  12255. * This type contains all the data related to a pointer event in Babylon.js.
  12256. * 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.
  12257. */
  12258. export class PointerInfo extends PointerInfoBase {
  12259. /**
  12260. * Defines the picking info associated to the info (if any)\
  12261. */
  12262. pickInfo: Nullable<PickingInfo>;
  12263. /**
  12264. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12265. * @param type Defines the type of event (PointerEventTypes)
  12266. * @param event Defines the related dom event
  12267. * @param pickInfo Defines the picking info associated to the info (if any)\
  12268. */
  12269. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12270. /**
  12271. * Defines the picking info associated to the info (if any)\
  12272. */
  12273. pickInfo: Nullable<PickingInfo>);
  12274. }
  12275. /**
  12276. * Data relating to a touch event on the screen.
  12277. */
  12278. export interface PointerTouch {
  12279. /**
  12280. * X coordinate of touch.
  12281. */
  12282. x: number;
  12283. /**
  12284. * Y coordinate of touch.
  12285. */
  12286. y: number;
  12287. /**
  12288. * Id of touch. Unique for each finger.
  12289. */
  12290. pointerId: number;
  12291. /**
  12292. * Event type passed from DOM.
  12293. */
  12294. type: any;
  12295. }
  12296. }
  12297. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12298. import { Observable } from "babylonjs/Misc/observable";
  12299. import { Nullable } from "babylonjs/types";
  12300. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12301. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12302. /**
  12303. * Manage the mouse inputs to control the movement of a free camera.
  12304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12305. */
  12306. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12307. /**
  12308. * Define if touch is enabled in the mouse input
  12309. */
  12310. touchEnabled: boolean;
  12311. /**
  12312. * Defines the camera the input is attached to.
  12313. */
  12314. camera: FreeCamera;
  12315. /**
  12316. * Defines the buttons associated with the input to handle camera move.
  12317. */
  12318. buttons: number[];
  12319. /**
  12320. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12321. */
  12322. angularSensibility: number;
  12323. private _pointerInput;
  12324. private _onMouseMove;
  12325. private _observer;
  12326. private previousPosition;
  12327. /**
  12328. * Observable for when a pointer move event occurs containing the move offset
  12329. */
  12330. onPointerMovedObservable: Observable<{
  12331. offsetX: number;
  12332. offsetY: number;
  12333. }>;
  12334. /**
  12335. * @hidden
  12336. * If the camera should be rotated automatically based on pointer movement
  12337. */
  12338. _allowCameraRotation: boolean;
  12339. /**
  12340. * Manage the mouse inputs to control the movement of a free camera.
  12341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12342. * @param touchEnabled Defines if touch is enabled or not
  12343. */
  12344. constructor(
  12345. /**
  12346. * Define if touch is enabled in the mouse input
  12347. */
  12348. touchEnabled?: boolean);
  12349. /**
  12350. * Attach the input controls to a specific dom element to get the input from.
  12351. * @param element Defines the element the controls should be listened from
  12352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12353. */
  12354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12355. /**
  12356. * Called on JS contextmenu event.
  12357. * Override this method to provide functionality.
  12358. */
  12359. protected onContextMenu(evt: PointerEvent): void;
  12360. /**
  12361. * Detach the current controls from the specified dom element.
  12362. * @param element Defines the element to stop listening the inputs from
  12363. */
  12364. detachControl(element: Nullable<HTMLElement>): void;
  12365. /**
  12366. * Gets the class name of the current intput.
  12367. * @returns the class name
  12368. */
  12369. getClassName(): string;
  12370. /**
  12371. * Get the friendly name associated with the input class.
  12372. * @returns the input friendly name
  12373. */
  12374. getSimpleName(): string;
  12375. }
  12376. }
  12377. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12378. import { Nullable } from "babylonjs/types";
  12379. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12380. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12381. /**
  12382. * Manage the touch inputs to control the movement of a free camera.
  12383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12384. */
  12385. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12386. /**
  12387. * Defines the camera the input is attached to.
  12388. */
  12389. camera: FreeCamera;
  12390. /**
  12391. * Defines the touch sensibility for rotation.
  12392. * The higher the faster.
  12393. */
  12394. touchAngularSensibility: number;
  12395. /**
  12396. * Defines the touch sensibility for move.
  12397. * The higher the faster.
  12398. */
  12399. touchMoveSensibility: number;
  12400. private _offsetX;
  12401. private _offsetY;
  12402. private _pointerPressed;
  12403. private _pointerInput;
  12404. private _observer;
  12405. private _onLostFocus;
  12406. /**
  12407. * Attach the input controls to a specific dom element to get the input from.
  12408. * @param element Defines the element the controls should be listened from
  12409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12410. */
  12411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12412. /**
  12413. * Detach the current controls from the specified dom element.
  12414. * @param element Defines the element to stop listening the inputs from
  12415. */
  12416. detachControl(element: Nullable<HTMLElement>): void;
  12417. /**
  12418. * Update the current camera state depending on the inputs that have been used this frame.
  12419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12420. */
  12421. checkInputs(): void;
  12422. /**
  12423. * Gets the class name of the current intput.
  12424. * @returns the class name
  12425. */
  12426. getClassName(): string;
  12427. /**
  12428. * Get the friendly name associated with the input class.
  12429. * @returns the input friendly name
  12430. */
  12431. getSimpleName(): string;
  12432. }
  12433. }
  12434. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12435. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12436. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12437. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12438. import { Nullable } from "babylonjs/types";
  12439. /**
  12440. * Default Inputs manager for the FreeCamera.
  12441. * It groups all the default supported inputs for ease of use.
  12442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12443. */
  12444. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12445. /**
  12446. * @hidden
  12447. */
  12448. _mouseInput: Nullable<FreeCameraMouseInput>;
  12449. /**
  12450. * Instantiates a new FreeCameraInputsManager.
  12451. * @param camera Defines the camera the inputs belong to
  12452. */
  12453. constructor(camera: FreeCamera);
  12454. /**
  12455. * Add keyboard input support to the input manager.
  12456. * @returns the current input manager
  12457. */
  12458. addKeyboard(): FreeCameraInputsManager;
  12459. /**
  12460. * Add mouse input support to the input manager.
  12461. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12462. * @returns the current input manager
  12463. */
  12464. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12465. /**
  12466. * Removes the mouse input support from the manager
  12467. * @returns the current input manager
  12468. */
  12469. removeMouse(): FreeCameraInputsManager;
  12470. /**
  12471. * Add touch input support to the input manager.
  12472. * @returns the current input manager
  12473. */
  12474. addTouch(): FreeCameraInputsManager;
  12475. /**
  12476. * Remove all attached input methods from a camera
  12477. */
  12478. clear(): void;
  12479. }
  12480. }
  12481. declare module "babylonjs/Cameras/freeCamera" {
  12482. import { Vector3 } from "babylonjs/Maths/math.vector";
  12483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12484. import { Scene } from "babylonjs/scene";
  12485. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12486. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12487. /**
  12488. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12489. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12490. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12491. */
  12492. export class FreeCamera extends TargetCamera {
  12493. /**
  12494. * Define the collision ellipsoid of the camera.
  12495. * This is helpful to simulate a camera body like the player body around the camera
  12496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12497. */
  12498. ellipsoid: Vector3;
  12499. /**
  12500. * Define an offset for the position of the ellipsoid around the camera.
  12501. * This can be helpful to determine the center of the body near the gravity center of the body
  12502. * instead of its head.
  12503. */
  12504. ellipsoidOffset: Vector3;
  12505. /**
  12506. * Enable or disable collisions of the camera with the rest of the scene objects.
  12507. */
  12508. checkCollisions: boolean;
  12509. /**
  12510. * Enable or disable gravity on the camera.
  12511. */
  12512. applyGravity: boolean;
  12513. /**
  12514. * Define the input manager associated to the camera.
  12515. */
  12516. inputs: FreeCameraInputsManager;
  12517. /**
  12518. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12519. * Higher values reduce sensitivity.
  12520. */
  12521. get angularSensibility(): number;
  12522. /**
  12523. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12524. * Higher values reduce sensitivity.
  12525. */
  12526. set angularSensibility(value: number);
  12527. /**
  12528. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12529. */
  12530. get keysUp(): number[];
  12531. set keysUp(value: number[]);
  12532. /**
  12533. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12534. */
  12535. get keysDown(): number[];
  12536. set keysDown(value: number[]);
  12537. /**
  12538. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12539. */
  12540. get keysLeft(): number[];
  12541. set keysLeft(value: number[]);
  12542. /**
  12543. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12544. */
  12545. get keysRight(): number[];
  12546. set keysRight(value: number[]);
  12547. /**
  12548. * Event raised when the camera collide with a mesh in the scene.
  12549. */
  12550. onCollide: (collidedMesh: AbstractMesh) => void;
  12551. private _collider;
  12552. private _needMoveForGravity;
  12553. private _oldPosition;
  12554. private _diffPosition;
  12555. private _newPosition;
  12556. /** @hidden */
  12557. _localDirection: Vector3;
  12558. /** @hidden */
  12559. _transformedDirection: Vector3;
  12560. /**
  12561. * Instantiates a Free Camera.
  12562. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12563. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12564. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12565. * @param name Define the name of the camera in the scene
  12566. * @param position Define the start position of the camera in the scene
  12567. * @param scene Define the scene the camera belongs to
  12568. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12569. */
  12570. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12571. /**
  12572. * Attached controls to the current camera.
  12573. * @param element Defines the element the controls should be listened from
  12574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12575. */
  12576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12577. /**
  12578. * Detach the current controls from the camera.
  12579. * The camera will stop reacting to inputs.
  12580. * @param element Defines the element to stop listening the inputs from
  12581. */
  12582. detachControl(element: HTMLElement): void;
  12583. private _collisionMask;
  12584. /**
  12585. * Define a collision mask to limit the list of object the camera can collide with
  12586. */
  12587. get collisionMask(): number;
  12588. set collisionMask(mask: number);
  12589. /** @hidden */
  12590. _collideWithWorld(displacement: Vector3): void;
  12591. private _onCollisionPositionChange;
  12592. /** @hidden */
  12593. _checkInputs(): void;
  12594. /** @hidden */
  12595. _decideIfNeedsToMove(): boolean;
  12596. /** @hidden */
  12597. _updatePosition(): void;
  12598. /**
  12599. * Destroy the camera and release the current resources hold by it.
  12600. */
  12601. dispose(): void;
  12602. /**
  12603. * Gets the current object class name.
  12604. * @return the class name
  12605. */
  12606. getClassName(): string;
  12607. }
  12608. }
  12609. declare module "babylonjs/Gamepads/gamepad" {
  12610. import { Observable } from "babylonjs/Misc/observable";
  12611. /**
  12612. * Represents a gamepad control stick position
  12613. */
  12614. export class StickValues {
  12615. /**
  12616. * The x component of the control stick
  12617. */
  12618. x: number;
  12619. /**
  12620. * The y component of the control stick
  12621. */
  12622. y: number;
  12623. /**
  12624. * Initializes the gamepad x and y control stick values
  12625. * @param x The x component of the gamepad control stick value
  12626. * @param y The y component of the gamepad control stick value
  12627. */
  12628. constructor(
  12629. /**
  12630. * The x component of the control stick
  12631. */
  12632. x: number,
  12633. /**
  12634. * The y component of the control stick
  12635. */
  12636. y: number);
  12637. }
  12638. /**
  12639. * An interface which manages callbacks for gamepad button changes
  12640. */
  12641. export interface GamepadButtonChanges {
  12642. /**
  12643. * Called when a gamepad has been changed
  12644. */
  12645. changed: boolean;
  12646. /**
  12647. * Called when a gamepad press event has been triggered
  12648. */
  12649. pressChanged: boolean;
  12650. /**
  12651. * Called when a touch event has been triggered
  12652. */
  12653. touchChanged: boolean;
  12654. /**
  12655. * Called when a value has changed
  12656. */
  12657. valueChanged: boolean;
  12658. }
  12659. /**
  12660. * Represents a gamepad
  12661. */
  12662. export class Gamepad {
  12663. /**
  12664. * The id of the gamepad
  12665. */
  12666. id: string;
  12667. /**
  12668. * The index of the gamepad
  12669. */
  12670. index: number;
  12671. /**
  12672. * The browser gamepad
  12673. */
  12674. browserGamepad: any;
  12675. /**
  12676. * Specifies what type of gamepad this represents
  12677. */
  12678. type: number;
  12679. private _leftStick;
  12680. private _rightStick;
  12681. /** @hidden */
  12682. _isConnected: boolean;
  12683. private _leftStickAxisX;
  12684. private _leftStickAxisY;
  12685. private _rightStickAxisX;
  12686. private _rightStickAxisY;
  12687. /**
  12688. * Triggered when the left control stick has been changed
  12689. */
  12690. private _onleftstickchanged;
  12691. /**
  12692. * Triggered when the right control stick has been changed
  12693. */
  12694. private _onrightstickchanged;
  12695. /**
  12696. * Represents a gamepad controller
  12697. */
  12698. static GAMEPAD: number;
  12699. /**
  12700. * Represents a generic controller
  12701. */
  12702. static GENERIC: number;
  12703. /**
  12704. * Represents an XBox controller
  12705. */
  12706. static XBOX: number;
  12707. /**
  12708. * Represents a pose-enabled controller
  12709. */
  12710. static POSE_ENABLED: number;
  12711. /**
  12712. * Represents an Dual Shock controller
  12713. */
  12714. static DUALSHOCK: number;
  12715. /**
  12716. * Specifies whether the left control stick should be Y-inverted
  12717. */
  12718. protected _invertLeftStickY: boolean;
  12719. /**
  12720. * Specifies if the gamepad has been connected
  12721. */
  12722. get isConnected(): boolean;
  12723. /**
  12724. * Initializes the gamepad
  12725. * @param id The id of the gamepad
  12726. * @param index The index of the gamepad
  12727. * @param browserGamepad The browser gamepad
  12728. * @param leftStickX The x component of the left joystick
  12729. * @param leftStickY The y component of the left joystick
  12730. * @param rightStickX The x component of the right joystick
  12731. * @param rightStickY The y component of the right joystick
  12732. */
  12733. constructor(
  12734. /**
  12735. * The id of the gamepad
  12736. */
  12737. id: string,
  12738. /**
  12739. * The index of the gamepad
  12740. */
  12741. index: number,
  12742. /**
  12743. * The browser gamepad
  12744. */
  12745. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12746. /**
  12747. * Callback triggered when the left joystick has changed
  12748. * @param callback
  12749. */
  12750. onleftstickchanged(callback: (values: StickValues) => void): void;
  12751. /**
  12752. * Callback triggered when the right joystick has changed
  12753. * @param callback
  12754. */
  12755. onrightstickchanged(callback: (values: StickValues) => void): void;
  12756. /**
  12757. * Gets the left joystick
  12758. */
  12759. get leftStick(): StickValues;
  12760. /**
  12761. * Sets the left joystick values
  12762. */
  12763. set leftStick(newValues: StickValues);
  12764. /**
  12765. * Gets the right joystick
  12766. */
  12767. get rightStick(): StickValues;
  12768. /**
  12769. * Sets the right joystick value
  12770. */
  12771. set rightStick(newValues: StickValues);
  12772. /**
  12773. * Updates the gamepad joystick positions
  12774. */
  12775. update(): void;
  12776. /**
  12777. * Disposes the gamepad
  12778. */
  12779. dispose(): void;
  12780. }
  12781. /**
  12782. * Represents a generic gamepad
  12783. */
  12784. export class GenericPad extends Gamepad {
  12785. private _buttons;
  12786. private _onbuttondown;
  12787. private _onbuttonup;
  12788. /**
  12789. * Observable triggered when a button has been pressed
  12790. */
  12791. onButtonDownObservable: Observable<number>;
  12792. /**
  12793. * Observable triggered when a button has been released
  12794. */
  12795. onButtonUpObservable: Observable<number>;
  12796. /**
  12797. * Callback triggered when a button has been pressed
  12798. * @param callback Called when a button has been pressed
  12799. */
  12800. onbuttondown(callback: (buttonPressed: number) => void): void;
  12801. /**
  12802. * Callback triggered when a button has been released
  12803. * @param callback Called when a button has been released
  12804. */
  12805. onbuttonup(callback: (buttonReleased: number) => void): void;
  12806. /**
  12807. * Initializes the generic gamepad
  12808. * @param id The id of the generic gamepad
  12809. * @param index The index of the generic gamepad
  12810. * @param browserGamepad The browser gamepad
  12811. */
  12812. constructor(id: string, index: number, browserGamepad: any);
  12813. private _setButtonValue;
  12814. /**
  12815. * Updates the generic gamepad
  12816. */
  12817. update(): void;
  12818. /**
  12819. * Disposes the generic gamepad
  12820. */
  12821. dispose(): void;
  12822. }
  12823. }
  12824. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12825. import { Nullable } from "babylonjs/types";
  12826. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12827. import { Scene } from "babylonjs/scene";
  12828. module "babylonjs/Engines/engine" {
  12829. interface Engine {
  12830. /**
  12831. * Creates a raw texture
  12832. * @param data defines the data to store in the texture
  12833. * @param width defines the width of the texture
  12834. * @param height defines the height of the texture
  12835. * @param format defines the format of the data
  12836. * @param generateMipMaps defines if the engine should generate the mip levels
  12837. * @param invertY defines if data must be stored with Y axis inverted
  12838. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12839. * @param compression defines the compression used (null by default)
  12840. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12841. * @returns the raw texture inside an InternalTexture
  12842. */
  12843. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12844. /**
  12845. * Update a raw texture
  12846. * @param texture defines the texture to update
  12847. * @param data defines the data to store in the texture
  12848. * @param format defines the format of the data
  12849. * @param invertY defines if data must be stored with Y axis inverted
  12850. */
  12851. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12852. /**
  12853. * Update a raw texture
  12854. * @param texture defines the texture to update
  12855. * @param data defines the data to store in the texture
  12856. * @param format defines the format of the data
  12857. * @param invertY defines if data must be stored with Y axis inverted
  12858. * @param compression defines the compression used (null by default)
  12859. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12860. */
  12861. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12862. /**
  12863. * Creates a new raw cube texture
  12864. * @param data defines the array of data to use to create each face
  12865. * @param size defines the size of the textures
  12866. * @param format defines the format of the data
  12867. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12868. * @param generateMipMaps defines if the engine should generate the mip levels
  12869. * @param invertY defines if data must be stored with Y axis inverted
  12870. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12871. * @param compression defines the compression used (null by default)
  12872. * @returns the cube texture as an InternalTexture
  12873. */
  12874. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12875. /**
  12876. * Update a raw cube texture
  12877. * @param texture defines the texture to udpdate
  12878. * @param data defines the data to store
  12879. * @param format defines the data format
  12880. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12881. * @param invertY defines if data must be stored with Y axis inverted
  12882. */
  12883. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12884. /**
  12885. * Update a raw cube texture
  12886. * @param texture defines the texture to udpdate
  12887. * @param data defines the data to store
  12888. * @param format defines the data format
  12889. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12890. * @param invertY defines if data must be stored with Y axis inverted
  12891. * @param compression defines the compression used (null by default)
  12892. */
  12893. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12894. /**
  12895. * Update a raw cube texture
  12896. * @param texture defines the texture to udpdate
  12897. * @param data defines the data to store
  12898. * @param format defines the data format
  12899. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12900. * @param invertY defines if data must be stored with Y axis inverted
  12901. * @param compression defines the compression used (null by default)
  12902. * @param level defines which level of the texture to update
  12903. */
  12904. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12905. /**
  12906. * Creates a new raw cube texture from a specified url
  12907. * @param url defines the url where the data is located
  12908. * @param scene defines the current scene
  12909. * @param size defines the size of the textures
  12910. * @param format defines the format of the data
  12911. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12912. * @param noMipmap defines if the engine should avoid generating the mip levels
  12913. * @param callback defines a callback used to extract texture data from loaded data
  12914. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12915. * @param onLoad defines a callback called when texture is loaded
  12916. * @param onError defines a callback called if there is an error
  12917. * @returns the cube texture as an InternalTexture
  12918. */
  12919. 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;
  12920. /**
  12921. * Creates a new raw cube texture from a specified url
  12922. * @param url defines the url where the data is located
  12923. * @param scene defines the current scene
  12924. * @param size defines the size of the textures
  12925. * @param format defines the format of the data
  12926. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12927. * @param noMipmap defines if the engine should avoid generating the mip levels
  12928. * @param callback defines a callback used to extract texture data from loaded data
  12929. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12930. * @param onLoad defines a callback called when texture is loaded
  12931. * @param onError defines a callback called if there is an error
  12932. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12933. * @param invertY defines if data must be stored with Y axis inverted
  12934. * @returns the cube texture as an InternalTexture
  12935. */
  12936. 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;
  12937. /**
  12938. * Creates a new raw 3D texture
  12939. * @param data defines the data used to create the texture
  12940. * @param width defines the width of the texture
  12941. * @param height defines the height of the texture
  12942. * @param depth defines the depth of the texture
  12943. * @param format defines the format of the texture
  12944. * @param generateMipMaps defines if the engine must generate mip levels
  12945. * @param invertY defines if data must be stored with Y axis inverted
  12946. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12947. * @param compression defines the compressed used (can be null)
  12948. * @param textureType defines the compressed used (can be null)
  12949. * @returns a new raw 3D texture (stored in an InternalTexture)
  12950. */
  12951. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12952. /**
  12953. * Update a raw 3D texture
  12954. * @param texture defines the texture to update
  12955. * @param data defines the data to store
  12956. * @param format defines the data format
  12957. * @param invertY defines if data must be stored with Y axis inverted
  12958. */
  12959. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12960. /**
  12961. * Update a raw 3D texture
  12962. * @param texture defines the texture to update
  12963. * @param data defines the data to store
  12964. * @param format defines the data format
  12965. * @param invertY defines if data must be stored with Y axis inverted
  12966. * @param compression defines the used compression (can be null)
  12967. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12968. */
  12969. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12970. /**
  12971. * Creates a new raw 2D array texture
  12972. * @param data defines the data used to create the texture
  12973. * @param width defines the width of the texture
  12974. * @param height defines the height of the texture
  12975. * @param depth defines the number of layers of the texture
  12976. * @param format defines the format of the texture
  12977. * @param generateMipMaps defines if the engine must generate mip levels
  12978. * @param invertY defines if data must be stored with Y axis inverted
  12979. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12980. * @param compression defines the compressed used (can be null)
  12981. * @param textureType defines the compressed used (can be null)
  12982. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12983. */
  12984. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12985. /**
  12986. * Update a raw 2D array texture
  12987. * @param texture defines the texture to update
  12988. * @param data defines the data to store
  12989. * @param format defines the data format
  12990. * @param invertY defines if data must be stored with Y axis inverted
  12991. */
  12992. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12993. /**
  12994. * Update a raw 2D array texture
  12995. * @param texture defines the texture to update
  12996. * @param data defines the data to store
  12997. * @param format defines the data format
  12998. * @param invertY defines if data must be stored with Y axis inverted
  12999. * @param compression defines the used compression (can be null)
  13000. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13001. */
  13002. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13003. }
  13004. }
  13005. }
  13006. declare module "babylonjs/Materials/Textures/rawTexture" {
  13007. import { Scene } from "babylonjs/scene";
  13008. import { Texture } from "babylonjs/Materials/Textures/texture";
  13009. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13010. /**
  13011. * Raw texture can help creating a texture directly from an array of data.
  13012. * This can be super useful if you either get the data from an uncompressed source or
  13013. * if you wish to create your texture pixel by pixel.
  13014. */
  13015. export class RawTexture extends Texture {
  13016. /**
  13017. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13018. */
  13019. format: number;
  13020. private _engine;
  13021. /**
  13022. * Instantiates a new RawTexture.
  13023. * Raw texture can help creating a texture directly from an array of data.
  13024. * This can be super useful if you either get the data from an uncompressed source or
  13025. * if you wish to create your texture pixel by pixel.
  13026. * @param data define the array of data to use to create the texture
  13027. * @param width define the width of the texture
  13028. * @param height define the height of the texture
  13029. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13030. * @param scene define the scene the texture belongs to
  13031. * @param generateMipMaps define whether mip maps should be generated or not
  13032. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13033. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13034. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13035. */
  13036. constructor(data: ArrayBufferView, width: number, height: number,
  13037. /**
  13038. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13039. */
  13040. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13041. /**
  13042. * Updates the texture underlying data.
  13043. * @param data Define the new data of the texture
  13044. */
  13045. update(data: ArrayBufferView): void;
  13046. /**
  13047. * Creates a luminance texture from some data.
  13048. * @param data Define the texture data
  13049. * @param width Define the width of the texture
  13050. * @param height Define the height of the texture
  13051. * @param scene Define the scene the texture belongs to
  13052. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13053. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13054. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13055. * @returns the luminance texture
  13056. */
  13057. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13058. /**
  13059. * Creates a luminance alpha texture from some data.
  13060. * @param data Define the texture data
  13061. * @param width Define the width of the texture
  13062. * @param height Define the height of the texture
  13063. * @param scene Define the scene the texture belongs to
  13064. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13065. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13066. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13067. * @returns the luminance alpha texture
  13068. */
  13069. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13070. /**
  13071. * Creates an alpha texture from some data.
  13072. * @param data Define the texture data
  13073. * @param width Define the width of the texture
  13074. * @param height Define the height of the texture
  13075. * @param scene Define the scene the texture belongs to
  13076. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13077. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13078. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13079. * @returns the alpha texture
  13080. */
  13081. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13082. /**
  13083. * Creates a RGB texture from some data.
  13084. * @param data Define the texture data
  13085. * @param width Define the width of the texture
  13086. * @param height Define the height of the texture
  13087. * @param scene Define the scene the texture belongs to
  13088. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13089. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13090. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13091. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13092. * @returns the RGB alpha texture
  13093. */
  13094. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13095. /**
  13096. * Creates a RGBA texture from some data.
  13097. * @param data Define the texture data
  13098. * @param width Define the width of the texture
  13099. * @param height Define the height of the texture
  13100. * @param scene Define the scene the texture belongs to
  13101. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13102. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13103. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13104. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13105. * @returns the RGBA texture
  13106. */
  13107. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13108. /**
  13109. * Creates a R texture from some data.
  13110. * @param data Define the texture data
  13111. * @param width Define the width of the texture
  13112. * @param height Define the height of the texture
  13113. * @param scene Define the scene the texture belongs to
  13114. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13115. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13116. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13117. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13118. * @returns the R texture
  13119. */
  13120. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13121. }
  13122. }
  13123. declare module "babylonjs/Maths/math.size" {
  13124. /**
  13125. * Interface for the size containing width and height
  13126. */
  13127. export interface ISize {
  13128. /**
  13129. * Width
  13130. */
  13131. width: number;
  13132. /**
  13133. * Heighht
  13134. */
  13135. height: number;
  13136. }
  13137. /**
  13138. * Size containing widht and height
  13139. */
  13140. export class Size implements ISize {
  13141. /**
  13142. * Width
  13143. */
  13144. width: number;
  13145. /**
  13146. * Height
  13147. */
  13148. height: number;
  13149. /**
  13150. * Creates a Size object from the given width and height (floats).
  13151. * @param width width of the new size
  13152. * @param height height of the new size
  13153. */
  13154. constructor(width: number, height: number);
  13155. /**
  13156. * Returns a string with the Size width and height
  13157. * @returns a string with the Size width and height
  13158. */
  13159. toString(): string;
  13160. /**
  13161. * "Size"
  13162. * @returns the string "Size"
  13163. */
  13164. getClassName(): string;
  13165. /**
  13166. * Returns the Size hash code.
  13167. * @returns a hash code for a unique width and height
  13168. */
  13169. getHashCode(): number;
  13170. /**
  13171. * Updates the current size from the given one.
  13172. * @param src the given size
  13173. */
  13174. copyFrom(src: Size): void;
  13175. /**
  13176. * Updates in place the current Size from the given floats.
  13177. * @param width width of the new size
  13178. * @param height height of the new size
  13179. * @returns the updated Size.
  13180. */
  13181. copyFromFloats(width: number, height: number): Size;
  13182. /**
  13183. * Updates in place the current Size from the given floats.
  13184. * @param width width to set
  13185. * @param height height to set
  13186. * @returns the updated Size.
  13187. */
  13188. set(width: number, height: number): Size;
  13189. /**
  13190. * Multiplies the width and height by numbers
  13191. * @param w factor to multiple the width by
  13192. * @param h factor to multiple the height by
  13193. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13194. */
  13195. multiplyByFloats(w: number, h: number): Size;
  13196. /**
  13197. * Clones the size
  13198. * @returns a new Size copied from the given one.
  13199. */
  13200. clone(): Size;
  13201. /**
  13202. * True if the current Size and the given one width and height are strictly equal.
  13203. * @param other the other size to compare against
  13204. * @returns True if the current Size and the given one width and height are strictly equal.
  13205. */
  13206. equals(other: Size): boolean;
  13207. /**
  13208. * The surface of the Size : width * height (float).
  13209. */
  13210. get surface(): number;
  13211. /**
  13212. * Create a new size of zero
  13213. * @returns a new Size set to (0.0, 0.0)
  13214. */
  13215. static Zero(): Size;
  13216. /**
  13217. * Sums the width and height of two sizes
  13218. * @param otherSize size to add to this size
  13219. * @returns a new Size set as the addition result of the current Size and the given one.
  13220. */
  13221. add(otherSize: Size): Size;
  13222. /**
  13223. * Subtracts the width and height of two
  13224. * @param otherSize size to subtract to this size
  13225. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13226. */
  13227. subtract(otherSize: Size): Size;
  13228. /**
  13229. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13230. * @param start starting size to lerp between
  13231. * @param end end size to lerp between
  13232. * @param amount amount to lerp between the start and end values
  13233. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13234. */
  13235. static Lerp(start: Size, end: Size, amount: number): Size;
  13236. }
  13237. }
  13238. declare module "babylonjs/Animations/runtimeAnimation" {
  13239. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13240. import { Animatable } from "babylonjs/Animations/animatable";
  13241. import { Scene } from "babylonjs/scene";
  13242. /**
  13243. * Defines a runtime animation
  13244. */
  13245. export class RuntimeAnimation {
  13246. private _events;
  13247. /**
  13248. * The current frame of the runtime animation
  13249. */
  13250. private _currentFrame;
  13251. /**
  13252. * The animation used by the runtime animation
  13253. */
  13254. private _animation;
  13255. /**
  13256. * The target of the runtime animation
  13257. */
  13258. private _target;
  13259. /**
  13260. * The initiating animatable
  13261. */
  13262. private _host;
  13263. /**
  13264. * The original value of the runtime animation
  13265. */
  13266. private _originalValue;
  13267. /**
  13268. * The original blend value of the runtime animation
  13269. */
  13270. private _originalBlendValue;
  13271. /**
  13272. * The offsets cache of the runtime animation
  13273. */
  13274. private _offsetsCache;
  13275. /**
  13276. * The high limits cache of the runtime animation
  13277. */
  13278. private _highLimitsCache;
  13279. /**
  13280. * Specifies if the runtime animation has been stopped
  13281. */
  13282. private _stopped;
  13283. /**
  13284. * The blending factor of the runtime animation
  13285. */
  13286. private _blendingFactor;
  13287. /**
  13288. * The BabylonJS scene
  13289. */
  13290. private _scene;
  13291. /**
  13292. * The current value of the runtime animation
  13293. */
  13294. private _currentValue;
  13295. /** @hidden */
  13296. _animationState: _IAnimationState;
  13297. /**
  13298. * The active target of the runtime animation
  13299. */
  13300. private _activeTargets;
  13301. private _currentActiveTarget;
  13302. private _directTarget;
  13303. /**
  13304. * The target path of the runtime animation
  13305. */
  13306. private _targetPath;
  13307. /**
  13308. * The weight of the runtime animation
  13309. */
  13310. private _weight;
  13311. /**
  13312. * The ratio offset of the runtime animation
  13313. */
  13314. private _ratioOffset;
  13315. /**
  13316. * The previous delay of the runtime animation
  13317. */
  13318. private _previousDelay;
  13319. /**
  13320. * The previous ratio of the runtime animation
  13321. */
  13322. private _previousRatio;
  13323. private _enableBlending;
  13324. private _keys;
  13325. private _minFrame;
  13326. private _maxFrame;
  13327. private _minValue;
  13328. private _maxValue;
  13329. private _targetIsArray;
  13330. /**
  13331. * Gets the current frame of the runtime animation
  13332. */
  13333. get currentFrame(): number;
  13334. /**
  13335. * Gets the weight of the runtime animation
  13336. */
  13337. get weight(): number;
  13338. /**
  13339. * Gets the current value of the runtime animation
  13340. */
  13341. get currentValue(): any;
  13342. /**
  13343. * Gets the target path of the runtime animation
  13344. */
  13345. get targetPath(): string;
  13346. /**
  13347. * Gets the actual target of the runtime animation
  13348. */
  13349. get target(): any;
  13350. /** @hidden */
  13351. _onLoop: () => void;
  13352. /**
  13353. * Create a new RuntimeAnimation object
  13354. * @param target defines the target of the animation
  13355. * @param animation defines the source animation object
  13356. * @param scene defines the hosting scene
  13357. * @param host defines the initiating Animatable
  13358. */
  13359. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13360. private _preparePath;
  13361. /**
  13362. * Gets the animation from the runtime animation
  13363. */
  13364. get animation(): Animation;
  13365. /**
  13366. * Resets the runtime animation to the beginning
  13367. * @param restoreOriginal defines whether to restore the target property to the original value
  13368. */
  13369. reset(restoreOriginal?: boolean): void;
  13370. /**
  13371. * Specifies if the runtime animation is stopped
  13372. * @returns Boolean specifying if the runtime animation is stopped
  13373. */
  13374. isStopped(): boolean;
  13375. /**
  13376. * Disposes of the runtime animation
  13377. */
  13378. dispose(): void;
  13379. /**
  13380. * Apply the interpolated value to the target
  13381. * @param currentValue defines the value computed by the animation
  13382. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13383. */
  13384. setValue(currentValue: any, weight: number): void;
  13385. private _getOriginalValues;
  13386. private _setValue;
  13387. /**
  13388. * Gets the loop pmode of the runtime animation
  13389. * @returns Loop Mode
  13390. */
  13391. private _getCorrectLoopMode;
  13392. /**
  13393. * Move the current animation to a given frame
  13394. * @param frame defines the frame to move to
  13395. */
  13396. goToFrame(frame: number): void;
  13397. /**
  13398. * @hidden Internal use only
  13399. */
  13400. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13401. /**
  13402. * Execute the current animation
  13403. * @param delay defines the delay to add to the current frame
  13404. * @param from defines the lower bound of the animation range
  13405. * @param to defines the upper bound of the animation range
  13406. * @param loop defines if the current animation must loop
  13407. * @param speedRatio defines the current speed ratio
  13408. * @param weight defines the weight of the animation (default is -1 so no weight)
  13409. * @param onLoop optional callback called when animation loops
  13410. * @returns a boolean indicating if the animation is running
  13411. */
  13412. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13413. }
  13414. }
  13415. declare module "babylonjs/Animations/animatable" {
  13416. import { Animation } from "babylonjs/Animations/animation";
  13417. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13418. import { Nullable } from "babylonjs/types";
  13419. import { Observable } from "babylonjs/Misc/observable";
  13420. import { Scene } from "babylonjs/scene";
  13421. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13422. import { Node } from "babylonjs/node";
  13423. /**
  13424. * Class used to store an actual running animation
  13425. */
  13426. export class Animatable {
  13427. /** defines the target object */
  13428. target: any;
  13429. /** defines the starting frame number (default is 0) */
  13430. fromFrame: number;
  13431. /** defines the ending frame number (default is 100) */
  13432. toFrame: number;
  13433. /** defines if the animation must loop (default is false) */
  13434. loopAnimation: boolean;
  13435. /** defines a callback to call when animation ends if it is not looping */
  13436. onAnimationEnd?: (() => void) | null | undefined;
  13437. /** defines a callback to call when animation loops */
  13438. onAnimationLoop?: (() => void) | null | undefined;
  13439. private _localDelayOffset;
  13440. private _pausedDelay;
  13441. private _runtimeAnimations;
  13442. private _paused;
  13443. private _scene;
  13444. private _speedRatio;
  13445. private _weight;
  13446. private _syncRoot;
  13447. /**
  13448. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13449. * This will only apply for non looping animation (default is true)
  13450. */
  13451. disposeOnEnd: boolean;
  13452. /**
  13453. * Gets a boolean indicating if the animation has started
  13454. */
  13455. animationStarted: boolean;
  13456. /**
  13457. * Observer raised when the animation ends
  13458. */
  13459. onAnimationEndObservable: Observable<Animatable>;
  13460. /**
  13461. * Observer raised when the animation loops
  13462. */
  13463. onAnimationLoopObservable: Observable<Animatable>;
  13464. /**
  13465. * Gets the root Animatable used to synchronize and normalize animations
  13466. */
  13467. get syncRoot(): Nullable<Animatable>;
  13468. /**
  13469. * Gets the current frame of the first RuntimeAnimation
  13470. * Used to synchronize Animatables
  13471. */
  13472. get masterFrame(): number;
  13473. /**
  13474. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13475. */
  13476. get weight(): number;
  13477. set weight(value: number);
  13478. /**
  13479. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13480. */
  13481. get speedRatio(): number;
  13482. set speedRatio(value: number);
  13483. /**
  13484. * Creates a new Animatable
  13485. * @param scene defines the hosting scene
  13486. * @param target defines the target object
  13487. * @param fromFrame defines the starting frame number (default is 0)
  13488. * @param toFrame defines the ending frame number (default is 100)
  13489. * @param loopAnimation defines if the animation must loop (default is false)
  13490. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13491. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13492. * @param animations defines a group of animation to add to the new Animatable
  13493. * @param onAnimationLoop defines a callback to call when animation loops
  13494. */
  13495. constructor(scene: Scene,
  13496. /** defines the target object */
  13497. target: any,
  13498. /** defines the starting frame number (default is 0) */
  13499. fromFrame?: number,
  13500. /** defines the ending frame number (default is 100) */
  13501. toFrame?: number,
  13502. /** defines if the animation must loop (default is false) */
  13503. loopAnimation?: boolean, speedRatio?: number,
  13504. /** defines a callback to call when animation ends if it is not looping */
  13505. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13506. /** defines a callback to call when animation loops */
  13507. onAnimationLoop?: (() => void) | null | undefined);
  13508. /**
  13509. * Synchronize and normalize current Animatable with a source Animatable
  13510. * This is useful when using animation weights and when animations are not of the same length
  13511. * @param root defines the root Animatable to synchronize with
  13512. * @returns the current Animatable
  13513. */
  13514. syncWith(root: Animatable): Animatable;
  13515. /**
  13516. * Gets the list of runtime animations
  13517. * @returns an array of RuntimeAnimation
  13518. */
  13519. getAnimations(): RuntimeAnimation[];
  13520. /**
  13521. * Adds more animations to the current animatable
  13522. * @param target defines the target of the animations
  13523. * @param animations defines the new animations to add
  13524. */
  13525. appendAnimations(target: any, animations: Animation[]): void;
  13526. /**
  13527. * Gets the source animation for a specific property
  13528. * @param property defines the propertyu to look for
  13529. * @returns null or the source animation for the given property
  13530. */
  13531. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13532. /**
  13533. * Gets the runtime animation for a specific property
  13534. * @param property defines the propertyu to look for
  13535. * @returns null or the runtime animation for the given property
  13536. */
  13537. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13538. /**
  13539. * Resets the animatable to its original state
  13540. */
  13541. reset(): void;
  13542. /**
  13543. * Allows the animatable to blend with current running animations
  13544. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13545. * @param blendingSpeed defines the blending speed to use
  13546. */
  13547. enableBlending(blendingSpeed: number): void;
  13548. /**
  13549. * Disable animation blending
  13550. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13551. */
  13552. disableBlending(): void;
  13553. /**
  13554. * Jump directly to a given frame
  13555. * @param frame defines the frame to jump to
  13556. */
  13557. goToFrame(frame: number): void;
  13558. /**
  13559. * Pause the animation
  13560. */
  13561. pause(): void;
  13562. /**
  13563. * Restart the animation
  13564. */
  13565. restart(): void;
  13566. private _raiseOnAnimationEnd;
  13567. /**
  13568. * Stop and delete the current animation
  13569. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13570. * @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)
  13571. */
  13572. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13573. /**
  13574. * Wait asynchronously for the animation to end
  13575. * @returns a promise which will be fullfilled when the animation ends
  13576. */
  13577. waitAsync(): Promise<Animatable>;
  13578. /** @hidden */
  13579. _animate(delay: number): boolean;
  13580. }
  13581. module "babylonjs/scene" {
  13582. interface Scene {
  13583. /** @hidden */
  13584. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13585. /** @hidden */
  13586. _processLateAnimationBindingsForMatrices(holder: {
  13587. totalWeight: number;
  13588. animations: RuntimeAnimation[];
  13589. originalValue: Matrix;
  13590. }): any;
  13591. /** @hidden */
  13592. _processLateAnimationBindingsForQuaternions(holder: {
  13593. totalWeight: number;
  13594. animations: RuntimeAnimation[];
  13595. originalValue: Quaternion;
  13596. }, refQuaternion: Quaternion): Quaternion;
  13597. /** @hidden */
  13598. _processLateAnimationBindings(): void;
  13599. /**
  13600. * Will start the animation sequence of a given target
  13601. * @param target defines the target
  13602. * @param from defines from which frame should animation start
  13603. * @param to defines until which frame should animation run.
  13604. * @param weight defines the weight to apply to the animation (1.0 by default)
  13605. * @param loop defines if the animation loops
  13606. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13607. * @param onAnimationEnd defines the function to be executed when the animation ends
  13608. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13609. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13610. * @param onAnimationLoop defines the callback to call when an animation loops
  13611. * @returns the animatable object created for this animation
  13612. */
  13613. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13614. /**
  13615. * Will start the animation sequence of a given target
  13616. * @param target defines the target
  13617. * @param from defines from which frame should animation start
  13618. * @param to defines until which frame should animation run.
  13619. * @param loop defines if the animation loops
  13620. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13621. * @param onAnimationEnd defines the function to be executed when the animation ends
  13622. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13623. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13624. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13625. * @param onAnimationLoop defines the callback to call when an animation loops
  13626. * @returns the animatable object created for this animation
  13627. */
  13628. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13629. /**
  13630. * Will start the animation sequence of a given target and its hierarchy
  13631. * @param target defines the target
  13632. * @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.
  13633. * @param from defines from which frame should animation start
  13634. * @param to defines until which frame should animation run.
  13635. * @param loop defines if the animation loops
  13636. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13637. * @param onAnimationEnd defines the function to be executed when the animation ends
  13638. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13639. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13640. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13641. * @param onAnimationLoop defines the callback to call when an animation loops
  13642. * @returns the list of created animatables
  13643. */
  13644. 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[];
  13645. /**
  13646. * Begin a new animation on a given node
  13647. * @param target defines the target where the animation will take place
  13648. * @param animations defines the list of animations to start
  13649. * @param from defines the initial value
  13650. * @param to defines the final value
  13651. * @param loop defines if you want animation to loop (off by default)
  13652. * @param speedRatio defines the speed ratio to apply to all animations
  13653. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13654. * @param onAnimationLoop defines the callback to call when an animation loops
  13655. * @returns the list of created animatables
  13656. */
  13657. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13658. /**
  13659. * Begin a new animation on a given node and its hierarchy
  13660. * @param target defines the root node where the animation will take place
  13661. * @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.
  13662. * @param animations defines the list of animations to start
  13663. * @param from defines the initial value
  13664. * @param to defines the final value
  13665. * @param loop defines if you want animation to loop (off by default)
  13666. * @param speedRatio defines the speed ratio to apply to all animations
  13667. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13668. * @param onAnimationLoop defines the callback to call when an animation loops
  13669. * @returns the list of animatables created for all nodes
  13670. */
  13671. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13672. /**
  13673. * Gets the animatable associated with a specific target
  13674. * @param target defines the target of the animatable
  13675. * @returns the required animatable if found
  13676. */
  13677. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13678. /**
  13679. * Gets all animatables associated with a given target
  13680. * @param target defines the target to look animatables for
  13681. * @returns an array of Animatables
  13682. */
  13683. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13684. /**
  13685. * Stops and removes all animations that have been applied to the scene
  13686. */
  13687. stopAllAnimations(): void;
  13688. /**
  13689. * Gets the current delta time used by animation engine
  13690. */
  13691. deltaTime: number;
  13692. }
  13693. }
  13694. module "babylonjs/Bones/bone" {
  13695. interface Bone {
  13696. /**
  13697. * Copy an animation range from another bone
  13698. * @param source defines the source bone
  13699. * @param rangeName defines the range name to copy
  13700. * @param frameOffset defines the frame offset
  13701. * @param rescaleAsRequired defines if rescaling must be applied if required
  13702. * @param skelDimensionsRatio defines the scaling ratio
  13703. * @returns true if operation was successful
  13704. */
  13705. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13706. }
  13707. }
  13708. }
  13709. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13710. /**
  13711. * Class used to override all child animations of a given target
  13712. */
  13713. export class AnimationPropertiesOverride {
  13714. /**
  13715. * Gets or sets a value indicating if animation blending must be used
  13716. */
  13717. enableBlending: boolean;
  13718. /**
  13719. * Gets or sets the blending speed to use when enableBlending is true
  13720. */
  13721. blendingSpeed: number;
  13722. /**
  13723. * Gets or sets the default loop mode to use
  13724. */
  13725. loopMode: number;
  13726. }
  13727. }
  13728. declare module "babylonjs/Bones/skeleton" {
  13729. import { Bone } from "babylonjs/Bones/bone";
  13730. import { Observable } from "babylonjs/Misc/observable";
  13731. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13732. import { Scene } from "babylonjs/scene";
  13733. import { Nullable } from "babylonjs/types";
  13734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13735. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13736. import { Animatable } from "babylonjs/Animations/animatable";
  13737. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13738. import { Animation } from "babylonjs/Animations/animation";
  13739. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13740. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13741. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13742. /**
  13743. * Class used to handle skinning animations
  13744. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13745. */
  13746. export class Skeleton implements IAnimatable {
  13747. /** defines the skeleton name */
  13748. name: string;
  13749. /** defines the skeleton Id */
  13750. id: string;
  13751. /**
  13752. * Defines the list of child bones
  13753. */
  13754. bones: Bone[];
  13755. /**
  13756. * Defines an estimate of the dimension of the skeleton at rest
  13757. */
  13758. dimensionsAtRest: Vector3;
  13759. /**
  13760. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13761. */
  13762. needInitialSkinMatrix: boolean;
  13763. /**
  13764. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13765. */
  13766. overrideMesh: Nullable<AbstractMesh>;
  13767. /**
  13768. * Gets the list of animations attached to this skeleton
  13769. */
  13770. animations: Array<Animation>;
  13771. private _scene;
  13772. private _isDirty;
  13773. private _transformMatrices;
  13774. private _transformMatrixTexture;
  13775. private _meshesWithPoseMatrix;
  13776. private _animatables;
  13777. private _identity;
  13778. private _synchronizedWithMesh;
  13779. private _ranges;
  13780. private _lastAbsoluteTransformsUpdateId;
  13781. private _canUseTextureForBones;
  13782. private _uniqueId;
  13783. /** @hidden */
  13784. _numBonesWithLinkedTransformNode: number;
  13785. /** @hidden */
  13786. _hasWaitingData: Nullable<boolean>;
  13787. /**
  13788. * Specifies if the skeleton should be serialized
  13789. */
  13790. doNotSerialize: boolean;
  13791. private _useTextureToStoreBoneMatrices;
  13792. /**
  13793. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13794. * Please note that this option is not available if the hardware does not support it
  13795. */
  13796. get useTextureToStoreBoneMatrices(): boolean;
  13797. set useTextureToStoreBoneMatrices(value: boolean);
  13798. private _animationPropertiesOverride;
  13799. /**
  13800. * Gets or sets the animation properties override
  13801. */
  13802. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13803. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13804. /**
  13805. * List of inspectable custom properties (used by the Inspector)
  13806. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13807. */
  13808. inspectableCustomProperties: IInspectable[];
  13809. /**
  13810. * An observable triggered before computing the skeleton's matrices
  13811. */
  13812. onBeforeComputeObservable: Observable<Skeleton>;
  13813. /**
  13814. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13815. */
  13816. get isUsingTextureForMatrices(): boolean;
  13817. /**
  13818. * Gets the unique ID of this skeleton
  13819. */
  13820. get uniqueId(): number;
  13821. /**
  13822. * Creates a new skeleton
  13823. * @param name defines the skeleton name
  13824. * @param id defines the skeleton Id
  13825. * @param scene defines the hosting scene
  13826. */
  13827. constructor(
  13828. /** defines the skeleton name */
  13829. name: string,
  13830. /** defines the skeleton Id */
  13831. id: string, scene: Scene);
  13832. /**
  13833. * Gets the current object class name.
  13834. * @return the class name
  13835. */
  13836. getClassName(): string;
  13837. /**
  13838. * Returns an array containing the root bones
  13839. * @returns an array containing the root bones
  13840. */
  13841. getChildren(): Array<Bone>;
  13842. /**
  13843. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13844. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13845. * @returns a Float32Array containing matrices data
  13846. */
  13847. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13848. /**
  13849. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13850. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13851. * @returns a raw texture containing the data
  13852. */
  13853. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13854. /**
  13855. * Gets the current hosting scene
  13856. * @returns a scene object
  13857. */
  13858. getScene(): Scene;
  13859. /**
  13860. * Gets a string representing the current skeleton data
  13861. * @param fullDetails defines a boolean indicating if we want a verbose version
  13862. * @returns a string representing the current skeleton data
  13863. */
  13864. toString(fullDetails?: boolean): string;
  13865. /**
  13866. * Get bone's index searching by name
  13867. * @param name defines bone's name to search for
  13868. * @return the indice of the bone. Returns -1 if not found
  13869. */
  13870. getBoneIndexByName(name: string): number;
  13871. /**
  13872. * Creater a new animation range
  13873. * @param name defines the name of the range
  13874. * @param from defines the start key
  13875. * @param to defines the end key
  13876. */
  13877. createAnimationRange(name: string, from: number, to: number): void;
  13878. /**
  13879. * Delete a specific animation range
  13880. * @param name defines the name of the range
  13881. * @param deleteFrames defines if frames must be removed as well
  13882. */
  13883. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13884. /**
  13885. * Gets a specific animation range
  13886. * @param name defines the name of the range to look for
  13887. * @returns the requested animation range or null if not found
  13888. */
  13889. getAnimationRange(name: string): Nullable<AnimationRange>;
  13890. /**
  13891. * Gets the list of all animation ranges defined on this skeleton
  13892. * @returns an array
  13893. */
  13894. getAnimationRanges(): Nullable<AnimationRange>[];
  13895. /**
  13896. * Copy animation range from a source skeleton.
  13897. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13898. * @param source defines the source skeleton
  13899. * @param name defines the name of the range to copy
  13900. * @param rescaleAsRequired defines if rescaling must be applied if required
  13901. * @returns true if operation was successful
  13902. */
  13903. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13904. /**
  13905. * Forces the skeleton to go to rest pose
  13906. */
  13907. returnToRest(): void;
  13908. private _getHighestAnimationFrame;
  13909. /**
  13910. * Begin a specific animation range
  13911. * @param name defines the name of the range to start
  13912. * @param loop defines if looping must be turned on (false by default)
  13913. * @param speedRatio defines the speed ratio to apply (1 by default)
  13914. * @param onAnimationEnd defines a callback which will be called when animation will end
  13915. * @returns a new animatable
  13916. */
  13917. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13918. /** @hidden */
  13919. _markAsDirty(): void;
  13920. /** @hidden */
  13921. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13922. /** @hidden */
  13923. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13924. private _computeTransformMatrices;
  13925. /**
  13926. * Build all resources required to render a skeleton
  13927. */
  13928. prepare(): void;
  13929. /**
  13930. * Gets the list of animatables currently running for this skeleton
  13931. * @returns an array of animatables
  13932. */
  13933. getAnimatables(): IAnimatable[];
  13934. /**
  13935. * Clone the current skeleton
  13936. * @param name defines the name of the new skeleton
  13937. * @param id defines the id of the new skeleton
  13938. * @returns the new skeleton
  13939. */
  13940. clone(name: string, id?: string): Skeleton;
  13941. /**
  13942. * Enable animation blending for this skeleton
  13943. * @param blendingSpeed defines the blending speed to apply
  13944. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13945. */
  13946. enableBlending(blendingSpeed?: number): void;
  13947. /**
  13948. * Releases all resources associated with the current skeleton
  13949. */
  13950. dispose(): void;
  13951. /**
  13952. * Serialize the skeleton in a JSON object
  13953. * @returns a JSON object
  13954. */
  13955. serialize(): any;
  13956. /**
  13957. * Creates a new skeleton from serialized data
  13958. * @param parsedSkeleton defines the serialized data
  13959. * @param scene defines the hosting scene
  13960. * @returns a new skeleton
  13961. */
  13962. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13963. /**
  13964. * Compute all node absolute transforms
  13965. * @param forceUpdate defines if computation must be done even if cache is up to date
  13966. */
  13967. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13968. /**
  13969. * Gets the root pose matrix
  13970. * @returns a matrix
  13971. */
  13972. getPoseMatrix(): Nullable<Matrix>;
  13973. /**
  13974. * Sorts bones per internal index
  13975. */
  13976. sortBones(): void;
  13977. private _sortBones;
  13978. }
  13979. }
  13980. declare module "babylonjs/Bones/bone" {
  13981. import { Skeleton } from "babylonjs/Bones/skeleton";
  13982. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13983. import { Nullable } from "babylonjs/types";
  13984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13985. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13986. import { Node } from "babylonjs/node";
  13987. import { Space } from "babylonjs/Maths/math.axis";
  13988. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13989. /**
  13990. * Class used to store bone information
  13991. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13992. */
  13993. export class Bone extends Node {
  13994. /**
  13995. * defines the bone name
  13996. */
  13997. name: string;
  13998. private static _tmpVecs;
  13999. private static _tmpQuat;
  14000. private static _tmpMats;
  14001. /**
  14002. * Gets the list of child bones
  14003. */
  14004. children: Bone[];
  14005. /** Gets the animations associated with this bone */
  14006. animations: import("babylonjs/Animations/animation").Animation[];
  14007. /**
  14008. * Gets or sets bone length
  14009. */
  14010. length: number;
  14011. /**
  14012. * @hidden Internal only
  14013. * Set this value to map this bone to a different index in the transform matrices
  14014. * Set this value to -1 to exclude the bone from the transform matrices
  14015. */
  14016. _index: Nullable<number>;
  14017. private _skeleton;
  14018. private _localMatrix;
  14019. private _restPose;
  14020. private _baseMatrix;
  14021. private _absoluteTransform;
  14022. private _invertedAbsoluteTransform;
  14023. private _parent;
  14024. private _scalingDeterminant;
  14025. private _worldTransform;
  14026. private _localScaling;
  14027. private _localRotation;
  14028. private _localPosition;
  14029. private _needToDecompose;
  14030. private _needToCompose;
  14031. /** @hidden */
  14032. _linkedTransformNode: Nullable<TransformNode>;
  14033. /** @hidden */
  14034. _waitingTransformNodeId: Nullable<string>;
  14035. /** @hidden */
  14036. get _matrix(): Matrix;
  14037. /** @hidden */
  14038. set _matrix(value: Matrix);
  14039. /**
  14040. * Create a new bone
  14041. * @param name defines the bone name
  14042. * @param skeleton defines the parent skeleton
  14043. * @param parentBone defines the parent (can be null if the bone is the root)
  14044. * @param localMatrix defines the local matrix
  14045. * @param restPose defines the rest pose matrix
  14046. * @param baseMatrix defines the base matrix
  14047. * @param index defines index of the bone in the hiearchy
  14048. */
  14049. constructor(
  14050. /**
  14051. * defines the bone name
  14052. */
  14053. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14054. /**
  14055. * Gets the current object class name.
  14056. * @return the class name
  14057. */
  14058. getClassName(): string;
  14059. /**
  14060. * Gets the parent skeleton
  14061. * @returns a skeleton
  14062. */
  14063. getSkeleton(): Skeleton;
  14064. /**
  14065. * Gets parent bone
  14066. * @returns a bone or null if the bone is the root of the bone hierarchy
  14067. */
  14068. getParent(): Nullable<Bone>;
  14069. /**
  14070. * Returns an array containing the root bones
  14071. * @returns an array containing the root bones
  14072. */
  14073. getChildren(): Array<Bone>;
  14074. /**
  14075. * Gets the node index in matrix array generated for rendering
  14076. * @returns the node index
  14077. */
  14078. getIndex(): number;
  14079. /**
  14080. * Sets the parent bone
  14081. * @param parent defines the parent (can be null if the bone is the root)
  14082. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14083. */
  14084. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14085. /**
  14086. * Gets the local matrix
  14087. * @returns a matrix
  14088. */
  14089. getLocalMatrix(): Matrix;
  14090. /**
  14091. * Gets the base matrix (initial matrix which remains unchanged)
  14092. * @returns a matrix
  14093. */
  14094. getBaseMatrix(): Matrix;
  14095. /**
  14096. * Gets the rest pose matrix
  14097. * @returns a matrix
  14098. */
  14099. getRestPose(): Matrix;
  14100. /**
  14101. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14102. */
  14103. getWorldMatrix(): Matrix;
  14104. /**
  14105. * Sets the local matrix to rest pose matrix
  14106. */
  14107. returnToRest(): void;
  14108. /**
  14109. * Gets the inverse of the absolute transform matrix.
  14110. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14111. * @returns a matrix
  14112. */
  14113. getInvertedAbsoluteTransform(): Matrix;
  14114. /**
  14115. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14116. * @returns a matrix
  14117. */
  14118. getAbsoluteTransform(): Matrix;
  14119. /**
  14120. * Links with the given transform node.
  14121. * The local matrix of this bone is copied from the transform node every frame.
  14122. * @param transformNode defines the transform node to link to
  14123. */
  14124. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14125. /**
  14126. * Gets the node used to drive the bone's transformation
  14127. * @returns a transform node or null
  14128. */
  14129. getTransformNode(): Nullable<TransformNode>;
  14130. /** Gets or sets current position (in local space) */
  14131. get position(): Vector3;
  14132. set position(newPosition: Vector3);
  14133. /** Gets or sets current rotation (in local space) */
  14134. get rotation(): Vector3;
  14135. set rotation(newRotation: Vector3);
  14136. /** Gets or sets current rotation quaternion (in local space) */
  14137. get rotationQuaternion(): Quaternion;
  14138. set rotationQuaternion(newRotation: Quaternion);
  14139. /** Gets or sets current scaling (in local space) */
  14140. get scaling(): Vector3;
  14141. set scaling(newScaling: Vector3);
  14142. /**
  14143. * Gets the animation properties override
  14144. */
  14145. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14146. private _decompose;
  14147. private _compose;
  14148. /**
  14149. * Update the base and local matrices
  14150. * @param matrix defines the new base or local matrix
  14151. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14152. * @param updateLocalMatrix defines if the local matrix should be updated
  14153. */
  14154. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14155. /** @hidden */
  14156. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14157. /**
  14158. * Flag the bone as dirty (Forcing it to update everything)
  14159. */
  14160. markAsDirty(): void;
  14161. /** @hidden */
  14162. _markAsDirtyAndCompose(): void;
  14163. private _markAsDirtyAndDecompose;
  14164. /**
  14165. * Translate the bone in local or world space
  14166. * @param vec The amount to translate the bone
  14167. * @param space The space that the translation is in
  14168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14169. */
  14170. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14171. /**
  14172. * Set the postion of the bone in local or world space
  14173. * @param position The position to set the bone
  14174. * @param space The space that the position is in
  14175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14176. */
  14177. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14178. /**
  14179. * Set the absolute position of the bone (world space)
  14180. * @param position The position to set the bone
  14181. * @param mesh The mesh that this bone is attached to
  14182. */
  14183. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14184. /**
  14185. * Scale the bone on the x, y and z axes (in local space)
  14186. * @param x The amount to scale the bone on the x axis
  14187. * @param y The amount to scale the bone on the y axis
  14188. * @param z The amount to scale the bone on the z axis
  14189. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14190. */
  14191. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14192. /**
  14193. * Set the bone scaling in local space
  14194. * @param scale defines the scaling vector
  14195. */
  14196. setScale(scale: Vector3): void;
  14197. /**
  14198. * Gets the current scaling in local space
  14199. * @returns the current scaling vector
  14200. */
  14201. getScale(): Vector3;
  14202. /**
  14203. * Gets the current scaling in local space and stores it in a target vector
  14204. * @param result defines the target vector
  14205. */
  14206. getScaleToRef(result: Vector3): void;
  14207. /**
  14208. * Set the yaw, pitch, and roll of the bone in local or world space
  14209. * @param yaw The rotation of the bone on the y axis
  14210. * @param pitch The rotation of the bone on the x axis
  14211. * @param roll The rotation of the bone on the z axis
  14212. * @param space The space that the axes of rotation are in
  14213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14214. */
  14215. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14216. /**
  14217. * Add a rotation to the bone on an axis in local or world space
  14218. * @param axis The axis to rotate the bone on
  14219. * @param amount The amount to rotate the bone
  14220. * @param space The space that the axis is in
  14221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14222. */
  14223. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14224. /**
  14225. * Set the rotation of the bone to a particular axis angle in local or world space
  14226. * @param axis The axis to rotate the bone on
  14227. * @param angle The angle that the bone should be rotated to
  14228. * @param space The space that the axis is in
  14229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14230. */
  14231. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14232. /**
  14233. * Set the euler rotation of the bone in local of world space
  14234. * @param rotation The euler rotation that the bone should be set to
  14235. * @param space The space that the rotation is in
  14236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14237. */
  14238. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14239. /**
  14240. * Set the quaternion rotation of the bone in local of world space
  14241. * @param quat The quaternion rotation that the bone should be set to
  14242. * @param space The space that the rotation is in
  14243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14244. */
  14245. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14246. /**
  14247. * Set the rotation matrix of the bone in local of world space
  14248. * @param rotMat The rotation matrix that the bone should be set to
  14249. * @param space The space that the rotation is in
  14250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14251. */
  14252. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14253. private _rotateWithMatrix;
  14254. private _getNegativeRotationToRef;
  14255. /**
  14256. * Get the position of the bone in local or world space
  14257. * @param space The space that the returned position is in
  14258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14259. * @returns The position of the bone
  14260. */
  14261. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14262. /**
  14263. * Copy the position of the bone to a vector3 in local or world space
  14264. * @param space The space that the returned position is in
  14265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14266. * @param result The vector3 to copy the position to
  14267. */
  14268. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14269. /**
  14270. * Get the absolute position of the bone (world space)
  14271. * @param mesh The mesh that this bone is attached to
  14272. * @returns The absolute position of the bone
  14273. */
  14274. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14275. /**
  14276. * Copy the absolute position of the bone (world space) to the result param
  14277. * @param mesh The mesh that this bone is attached to
  14278. * @param result The vector3 to copy the absolute position to
  14279. */
  14280. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14281. /**
  14282. * Compute the absolute transforms of this bone and its children
  14283. */
  14284. computeAbsoluteTransforms(): void;
  14285. /**
  14286. * Get the world direction from an axis that is in the local space of the bone
  14287. * @param localAxis The local direction that is used to compute the world direction
  14288. * @param mesh The mesh that this bone is attached to
  14289. * @returns The world direction
  14290. */
  14291. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14292. /**
  14293. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14294. * @param localAxis The local direction that is used to compute the world direction
  14295. * @param mesh The mesh that this bone is attached to
  14296. * @param result The vector3 that the world direction will be copied to
  14297. */
  14298. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14299. /**
  14300. * Get the euler rotation of the bone in local or world space
  14301. * @param space The space that the rotation should be in
  14302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14303. * @returns The euler rotation
  14304. */
  14305. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14306. /**
  14307. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14308. * @param space The space that the rotation should be in
  14309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14310. * @param result The vector3 that the rotation should be copied to
  14311. */
  14312. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14313. /**
  14314. * Get the quaternion rotation of the bone in either local or world space
  14315. * @param space The space that the rotation should be in
  14316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14317. * @returns The quaternion rotation
  14318. */
  14319. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14320. /**
  14321. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14322. * @param space The space that the rotation should be in
  14323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14324. * @param result The quaternion that the rotation should be copied to
  14325. */
  14326. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14327. /**
  14328. * Get the rotation matrix of the bone in local or world space
  14329. * @param space The space that the rotation should be in
  14330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14331. * @returns The rotation matrix
  14332. */
  14333. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14334. /**
  14335. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14336. * @param space The space that the rotation should be in
  14337. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14338. * @param result The quaternion that the rotation should be copied to
  14339. */
  14340. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14341. /**
  14342. * Get the world position of a point that is in the local space of the bone
  14343. * @param position The local position
  14344. * @param mesh The mesh that this bone is attached to
  14345. * @returns The world position
  14346. */
  14347. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14348. /**
  14349. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14350. * @param position The local position
  14351. * @param mesh The mesh that this bone is attached to
  14352. * @param result The vector3 that the world position should be copied to
  14353. */
  14354. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14355. /**
  14356. * Get the local position of a point that is in world space
  14357. * @param position The world position
  14358. * @param mesh The mesh that this bone is attached to
  14359. * @returns The local position
  14360. */
  14361. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14362. /**
  14363. * Get the local position of a point that is in world space and copy it to the result param
  14364. * @param position The world position
  14365. * @param mesh The mesh that this bone is attached to
  14366. * @param result The vector3 that the local position should be copied to
  14367. */
  14368. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14369. }
  14370. }
  14371. declare module "babylonjs/Meshes/transformNode" {
  14372. import { DeepImmutable } from "babylonjs/types";
  14373. import { Observable } from "babylonjs/Misc/observable";
  14374. import { Nullable } from "babylonjs/types";
  14375. import { Camera } from "babylonjs/Cameras/camera";
  14376. import { Scene } from "babylonjs/scene";
  14377. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14378. import { Node } from "babylonjs/node";
  14379. import { Bone } from "babylonjs/Bones/bone";
  14380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14381. import { Space } from "babylonjs/Maths/math.axis";
  14382. /**
  14383. * 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.
  14384. * @see https://doc.babylonjs.com/how_to/transformnode
  14385. */
  14386. export class TransformNode extends Node {
  14387. /**
  14388. * Object will not rotate to face the camera
  14389. */
  14390. static BILLBOARDMODE_NONE: number;
  14391. /**
  14392. * Object will rotate to face the camera but only on the x axis
  14393. */
  14394. static BILLBOARDMODE_X: number;
  14395. /**
  14396. * Object will rotate to face the camera but only on the y axis
  14397. */
  14398. static BILLBOARDMODE_Y: number;
  14399. /**
  14400. * Object will rotate to face the camera but only on the z axis
  14401. */
  14402. static BILLBOARDMODE_Z: number;
  14403. /**
  14404. * Object will rotate to face the camera
  14405. */
  14406. static BILLBOARDMODE_ALL: number;
  14407. /**
  14408. * Object will rotate to face the camera's position instead of orientation
  14409. */
  14410. static BILLBOARDMODE_USE_POSITION: number;
  14411. private _forward;
  14412. private _forwardInverted;
  14413. private _up;
  14414. private _right;
  14415. private _rightInverted;
  14416. private _position;
  14417. private _rotation;
  14418. private _rotationQuaternion;
  14419. protected _scaling: Vector3;
  14420. protected _isDirty: boolean;
  14421. private _transformToBoneReferal;
  14422. private _isAbsoluteSynced;
  14423. private _billboardMode;
  14424. /**
  14425. * Gets or sets the billboard mode. Default is 0.
  14426. *
  14427. * | Value | Type | Description |
  14428. * | --- | --- | --- |
  14429. * | 0 | BILLBOARDMODE_NONE | |
  14430. * | 1 | BILLBOARDMODE_X | |
  14431. * | 2 | BILLBOARDMODE_Y | |
  14432. * | 4 | BILLBOARDMODE_Z | |
  14433. * | 7 | BILLBOARDMODE_ALL | |
  14434. *
  14435. */
  14436. get billboardMode(): number;
  14437. set billboardMode(value: number);
  14438. private _preserveParentRotationForBillboard;
  14439. /**
  14440. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14441. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14442. */
  14443. get preserveParentRotationForBillboard(): boolean;
  14444. set preserveParentRotationForBillboard(value: boolean);
  14445. /**
  14446. * 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
  14447. */
  14448. scalingDeterminant: number;
  14449. private _infiniteDistance;
  14450. /**
  14451. * Gets or sets the distance of the object to max, often used by skybox
  14452. */
  14453. get infiniteDistance(): boolean;
  14454. set infiniteDistance(value: boolean);
  14455. /**
  14456. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14457. * By default the system will update normals to compensate
  14458. */
  14459. ignoreNonUniformScaling: boolean;
  14460. /**
  14461. * 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
  14462. */
  14463. reIntegrateRotationIntoRotationQuaternion: boolean;
  14464. /** @hidden */
  14465. _poseMatrix: Nullable<Matrix>;
  14466. /** @hidden */
  14467. _localMatrix: Matrix;
  14468. private _usePivotMatrix;
  14469. private _absolutePosition;
  14470. private _absoluteScaling;
  14471. private _absoluteRotationQuaternion;
  14472. private _pivotMatrix;
  14473. private _pivotMatrixInverse;
  14474. protected _postMultiplyPivotMatrix: boolean;
  14475. protected _isWorldMatrixFrozen: boolean;
  14476. /** @hidden */
  14477. _indexInSceneTransformNodesArray: number;
  14478. /**
  14479. * An event triggered after the world matrix is updated
  14480. */
  14481. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14482. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14483. /**
  14484. * Gets a string identifying the name of the class
  14485. * @returns "TransformNode" string
  14486. */
  14487. getClassName(): string;
  14488. /**
  14489. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14490. */
  14491. get position(): Vector3;
  14492. set position(newPosition: Vector3);
  14493. /**
  14494. * 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)).
  14495. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14496. */
  14497. get rotation(): Vector3;
  14498. set rotation(newRotation: Vector3);
  14499. /**
  14500. * 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)).
  14501. */
  14502. get scaling(): Vector3;
  14503. set scaling(newScaling: Vector3);
  14504. /**
  14505. * 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).
  14506. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14507. */
  14508. get rotationQuaternion(): Nullable<Quaternion>;
  14509. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14510. /**
  14511. * The forward direction of that transform in world space.
  14512. */
  14513. get forward(): Vector3;
  14514. /**
  14515. * The up direction of that transform in world space.
  14516. */
  14517. get up(): Vector3;
  14518. /**
  14519. * The right direction of that transform in world space.
  14520. */
  14521. get right(): Vector3;
  14522. /**
  14523. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14524. * @param matrix the matrix to copy the pose from
  14525. * @returns this TransformNode.
  14526. */
  14527. updatePoseMatrix(matrix: Matrix): TransformNode;
  14528. /**
  14529. * Returns the mesh Pose matrix.
  14530. * @returns the pose matrix
  14531. */
  14532. getPoseMatrix(): Matrix;
  14533. /** @hidden */
  14534. _isSynchronized(): boolean;
  14535. /** @hidden */
  14536. _initCache(): void;
  14537. /**
  14538. * Flag the transform node as dirty (Forcing it to update everything)
  14539. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14540. * @returns this transform node
  14541. */
  14542. markAsDirty(property: string): TransformNode;
  14543. /**
  14544. * Returns the current mesh absolute position.
  14545. * Returns a Vector3.
  14546. */
  14547. get absolutePosition(): Vector3;
  14548. /**
  14549. * Returns the current mesh absolute scaling.
  14550. * Returns a Vector3.
  14551. */
  14552. get absoluteScaling(): Vector3;
  14553. /**
  14554. * Returns the current mesh absolute rotation.
  14555. * Returns a Quaternion.
  14556. */
  14557. get absoluteRotationQuaternion(): Quaternion;
  14558. /**
  14559. * Sets a new matrix to apply before all other transformation
  14560. * @param matrix defines the transform matrix
  14561. * @returns the current TransformNode
  14562. */
  14563. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14564. /**
  14565. * Sets a new pivot matrix to the current node
  14566. * @param matrix defines the new pivot matrix to use
  14567. * @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
  14568. * @returns the current TransformNode
  14569. */
  14570. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14571. /**
  14572. * Returns the mesh pivot matrix.
  14573. * Default : Identity.
  14574. * @returns the matrix
  14575. */
  14576. getPivotMatrix(): Matrix;
  14577. /**
  14578. * Instantiate (when possible) or clone that node with its hierarchy
  14579. * @param newParent defines the new parent to use for the instance (or clone)
  14580. * @param options defines options to configure how copy is done
  14581. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14582. * @returns an instance (or a clone) of the current node with its hiearchy
  14583. */
  14584. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14585. doNotInstantiate: boolean;
  14586. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14587. /**
  14588. * Prevents the World matrix to be computed any longer
  14589. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14590. * @returns the TransformNode.
  14591. */
  14592. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14593. /**
  14594. * Allows back the World matrix computation.
  14595. * @returns the TransformNode.
  14596. */
  14597. unfreezeWorldMatrix(): this;
  14598. /**
  14599. * True if the World matrix has been frozen.
  14600. */
  14601. get isWorldMatrixFrozen(): boolean;
  14602. /**
  14603. * Retuns the mesh absolute position in the World.
  14604. * @returns a Vector3.
  14605. */
  14606. getAbsolutePosition(): Vector3;
  14607. /**
  14608. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14609. * @param absolutePosition the absolute position to set
  14610. * @returns the TransformNode.
  14611. */
  14612. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14613. /**
  14614. * Sets the mesh position in its local space.
  14615. * @param vector3 the position to set in localspace
  14616. * @returns the TransformNode.
  14617. */
  14618. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14619. /**
  14620. * Returns the mesh position in the local space from the current World matrix values.
  14621. * @returns a new Vector3.
  14622. */
  14623. getPositionExpressedInLocalSpace(): Vector3;
  14624. /**
  14625. * Translates the mesh along the passed Vector3 in its local space.
  14626. * @param vector3 the distance to translate in localspace
  14627. * @returns the TransformNode.
  14628. */
  14629. locallyTranslate(vector3: Vector3): TransformNode;
  14630. private static _lookAtVectorCache;
  14631. /**
  14632. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14633. * @param targetPoint the position (must be in same space as current mesh) to look at
  14634. * @param yawCor optional yaw (y-axis) correction in radians
  14635. * @param pitchCor optional pitch (x-axis) correction in radians
  14636. * @param rollCor optional roll (z-axis) correction in radians
  14637. * @param space the choosen space of the target
  14638. * @returns the TransformNode.
  14639. */
  14640. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14641. /**
  14642. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14643. * This Vector3 is expressed in the World space.
  14644. * @param localAxis axis to rotate
  14645. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14646. */
  14647. getDirection(localAxis: Vector3): Vector3;
  14648. /**
  14649. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14650. * localAxis is expressed in the mesh local space.
  14651. * result is computed in the Wordl space from the mesh World matrix.
  14652. * @param localAxis axis to rotate
  14653. * @param result the resulting transformnode
  14654. * @returns this TransformNode.
  14655. */
  14656. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14657. /**
  14658. * Sets this transform node rotation to the given local axis.
  14659. * @param localAxis the axis in local space
  14660. * @param yawCor optional yaw (y-axis) correction in radians
  14661. * @param pitchCor optional pitch (x-axis) correction in radians
  14662. * @param rollCor optional roll (z-axis) correction in radians
  14663. * @returns this TransformNode
  14664. */
  14665. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14666. /**
  14667. * Sets a new pivot point to the current node
  14668. * @param point defines the new pivot point to use
  14669. * @param space defines if the point is in world or local space (local by default)
  14670. * @returns the current TransformNode
  14671. */
  14672. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14673. /**
  14674. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14675. * @returns the pivot point
  14676. */
  14677. getPivotPoint(): Vector3;
  14678. /**
  14679. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14680. * @param result the vector3 to store the result
  14681. * @returns this TransformNode.
  14682. */
  14683. getPivotPointToRef(result: Vector3): TransformNode;
  14684. /**
  14685. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14686. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14687. */
  14688. getAbsolutePivotPoint(): Vector3;
  14689. /**
  14690. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14691. * @param result vector3 to store the result
  14692. * @returns this TransformNode.
  14693. */
  14694. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14695. /**
  14696. * Defines the passed node as the parent of the current node.
  14697. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14698. * @see https://doc.babylonjs.com/how_to/parenting
  14699. * @param node the node ot set as the parent
  14700. * @returns this TransformNode.
  14701. */
  14702. setParent(node: Nullable<Node>): TransformNode;
  14703. private _nonUniformScaling;
  14704. /**
  14705. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14706. */
  14707. get nonUniformScaling(): boolean;
  14708. /** @hidden */
  14709. _updateNonUniformScalingState(value: boolean): boolean;
  14710. /**
  14711. * Attach the current TransformNode to another TransformNode associated with a bone
  14712. * @param bone Bone affecting the TransformNode
  14713. * @param affectedTransformNode TransformNode associated with the bone
  14714. * @returns this object
  14715. */
  14716. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14717. /**
  14718. * Detach the transform node if its associated with a bone
  14719. * @returns this object
  14720. */
  14721. detachFromBone(): TransformNode;
  14722. private static _rotationAxisCache;
  14723. /**
  14724. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14725. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14726. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14727. * The passed axis is also normalized.
  14728. * @param axis the axis to rotate around
  14729. * @param amount the amount to rotate in radians
  14730. * @param space Space to rotate in (Default: local)
  14731. * @returns the TransformNode.
  14732. */
  14733. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14734. /**
  14735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14736. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14737. * The passed axis is also normalized. .
  14738. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14739. * @param point the point to rotate around
  14740. * @param axis the axis to rotate around
  14741. * @param amount the amount to rotate in radians
  14742. * @returns the TransformNode
  14743. */
  14744. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14745. /**
  14746. * Translates the mesh along the axis vector for the passed distance in the given space.
  14747. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14748. * @param axis the axis to translate in
  14749. * @param distance the distance to translate
  14750. * @param space Space to rotate in (Default: local)
  14751. * @returns the TransformNode.
  14752. */
  14753. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14754. /**
  14755. * Adds a rotation step to the mesh current rotation.
  14756. * x, y, z are Euler angles expressed in radians.
  14757. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14758. * This means this rotation is made in the mesh local space only.
  14759. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14760. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14761. * ```javascript
  14762. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14763. * ```
  14764. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14765. * 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.
  14766. * @param x Rotation to add
  14767. * @param y Rotation to add
  14768. * @param z Rotation to add
  14769. * @returns the TransformNode.
  14770. */
  14771. addRotation(x: number, y: number, z: number): TransformNode;
  14772. /**
  14773. * @hidden
  14774. */
  14775. protected _getEffectiveParent(): Nullable<Node>;
  14776. /**
  14777. * Computes the world matrix of the node
  14778. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14779. * @returns the world matrix
  14780. */
  14781. computeWorldMatrix(force?: boolean): Matrix;
  14782. protected _afterComputeWorldMatrix(): void;
  14783. /**
  14784. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14785. * @param func callback function to add
  14786. *
  14787. * @returns the TransformNode.
  14788. */
  14789. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14790. /**
  14791. * Removes a registered callback function.
  14792. * @param func callback function to remove
  14793. * @returns the TransformNode.
  14794. */
  14795. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14796. /**
  14797. * Gets the position of the current mesh in camera space
  14798. * @param camera defines the camera to use
  14799. * @returns a position
  14800. */
  14801. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14802. /**
  14803. * Returns the distance from the mesh to the active camera
  14804. * @param camera defines the camera to use
  14805. * @returns the distance
  14806. */
  14807. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14808. /**
  14809. * Clone the current transform node
  14810. * @param name Name of the new clone
  14811. * @param newParent New parent for the clone
  14812. * @param doNotCloneChildren Do not clone children hierarchy
  14813. * @returns the new transform node
  14814. */
  14815. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14816. /**
  14817. * Serializes the objects information.
  14818. * @param currentSerializationObject defines the object to serialize in
  14819. * @returns the serialized object
  14820. */
  14821. serialize(currentSerializationObject?: any): any;
  14822. /**
  14823. * Returns a new TransformNode object parsed from the source provided.
  14824. * @param parsedTransformNode is the source.
  14825. * @param scene the scne the object belongs to
  14826. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14827. * @returns a new TransformNode object parsed from the source provided.
  14828. */
  14829. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14830. /**
  14831. * Get all child-transformNodes of this node
  14832. * @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
  14833. * @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
  14834. * @returns an array of TransformNode
  14835. */
  14836. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14837. /**
  14838. * Releases resources associated with this transform node.
  14839. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14840. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14841. */
  14842. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14843. /**
  14844. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14845. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14846. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14847. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14848. * @returns the current mesh
  14849. */
  14850. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14851. private _syncAbsoluteScalingAndRotation;
  14852. }
  14853. }
  14854. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14855. import { Observable } from "babylonjs/Misc/observable";
  14856. import { Nullable } from "babylonjs/types";
  14857. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14858. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14860. import { Ray } from "babylonjs/Culling/ray";
  14861. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14862. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14863. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14864. /**
  14865. * Defines the types of pose enabled controllers that are supported
  14866. */
  14867. export enum PoseEnabledControllerType {
  14868. /**
  14869. * HTC Vive
  14870. */
  14871. VIVE = 0,
  14872. /**
  14873. * Oculus Rift
  14874. */
  14875. OCULUS = 1,
  14876. /**
  14877. * Windows mixed reality
  14878. */
  14879. WINDOWS = 2,
  14880. /**
  14881. * Samsung gear VR
  14882. */
  14883. GEAR_VR = 3,
  14884. /**
  14885. * Google Daydream
  14886. */
  14887. DAYDREAM = 4,
  14888. /**
  14889. * Generic
  14890. */
  14891. GENERIC = 5
  14892. }
  14893. /**
  14894. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14895. */
  14896. export interface MutableGamepadButton {
  14897. /**
  14898. * Value of the button/trigger
  14899. */
  14900. value: number;
  14901. /**
  14902. * If the button/trigger is currently touched
  14903. */
  14904. touched: boolean;
  14905. /**
  14906. * If the button/trigger is currently pressed
  14907. */
  14908. pressed: boolean;
  14909. }
  14910. /**
  14911. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14912. * @hidden
  14913. */
  14914. export interface ExtendedGamepadButton extends GamepadButton {
  14915. /**
  14916. * If the button/trigger is currently pressed
  14917. */
  14918. readonly pressed: boolean;
  14919. /**
  14920. * If the button/trigger is currently touched
  14921. */
  14922. readonly touched: boolean;
  14923. /**
  14924. * Value of the button/trigger
  14925. */
  14926. readonly value: number;
  14927. }
  14928. /** @hidden */
  14929. export interface _GamePadFactory {
  14930. /**
  14931. * Returns wether or not the current gamepad can be created for this type of controller.
  14932. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14933. * @returns true if it can be created, otherwise false
  14934. */
  14935. canCreate(gamepadInfo: any): boolean;
  14936. /**
  14937. * Creates a new instance of the Gamepad.
  14938. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14939. * @returns the new gamepad instance
  14940. */
  14941. create(gamepadInfo: any): Gamepad;
  14942. }
  14943. /**
  14944. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14945. */
  14946. export class PoseEnabledControllerHelper {
  14947. /** @hidden */
  14948. static _ControllerFactories: _GamePadFactory[];
  14949. /** @hidden */
  14950. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14951. /**
  14952. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14953. * @param vrGamepad the gamepad to initialized
  14954. * @returns a vr controller of the type the gamepad identified as
  14955. */
  14956. static InitiateController(vrGamepad: any): Gamepad;
  14957. }
  14958. /**
  14959. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14960. */
  14961. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14962. /**
  14963. * If the controller is used in a webXR session
  14964. */
  14965. isXR: boolean;
  14966. private _deviceRoomPosition;
  14967. private _deviceRoomRotationQuaternion;
  14968. /**
  14969. * The device position in babylon space
  14970. */
  14971. devicePosition: Vector3;
  14972. /**
  14973. * The device rotation in babylon space
  14974. */
  14975. deviceRotationQuaternion: Quaternion;
  14976. /**
  14977. * The scale factor of the device in babylon space
  14978. */
  14979. deviceScaleFactor: number;
  14980. /**
  14981. * (Likely devicePosition should be used instead) The device position in its room space
  14982. */
  14983. position: Vector3;
  14984. /**
  14985. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14986. */
  14987. rotationQuaternion: Quaternion;
  14988. /**
  14989. * The type of controller (Eg. Windows mixed reality)
  14990. */
  14991. controllerType: PoseEnabledControllerType;
  14992. protected _calculatedPosition: Vector3;
  14993. private _calculatedRotation;
  14994. /**
  14995. * The raw pose from the device
  14996. */
  14997. rawPose: DevicePose;
  14998. private _trackPosition;
  14999. private _maxRotationDistFromHeadset;
  15000. private _draggedRoomRotation;
  15001. /**
  15002. * @hidden
  15003. */
  15004. _disableTrackPosition(fixedPosition: Vector3): void;
  15005. /**
  15006. * Internal, the mesh attached to the controller
  15007. * @hidden
  15008. */
  15009. _mesh: Nullable<AbstractMesh>;
  15010. private _poseControlledCamera;
  15011. private _leftHandSystemQuaternion;
  15012. /**
  15013. * Internal, matrix used to convert room space to babylon space
  15014. * @hidden
  15015. */
  15016. _deviceToWorld: Matrix;
  15017. /**
  15018. * Node to be used when casting a ray from the controller
  15019. * @hidden
  15020. */
  15021. _pointingPoseNode: Nullable<TransformNode>;
  15022. /**
  15023. * Name of the child mesh that can be used to cast a ray from the controller
  15024. */
  15025. static readonly POINTING_POSE: string;
  15026. /**
  15027. * Creates a new PoseEnabledController from a gamepad
  15028. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15029. */
  15030. constructor(browserGamepad: any);
  15031. private _workingMatrix;
  15032. /**
  15033. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15034. */
  15035. update(): void;
  15036. /**
  15037. * Updates only the pose device and mesh without doing any button event checking
  15038. */
  15039. protected _updatePoseAndMesh(): void;
  15040. /**
  15041. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15042. * @param poseData raw pose fromthe device
  15043. */
  15044. updateFromDevice(poseData: DevicePose): void;
  15045. /**
  15046. * @hidden
  15047. */
  15048. _meshAttachedObservable: Observable<AbstractMesh>;
  15049. /**
  15050. * Attaches a mesh to the controller
  15051. * @param mesh the mesh to be attached
  15052. */
  15053. attachToMesh(mesh: AbstractMesh): void;
  15054. /**
  15055. * Attaches the controllers mesh to a camera
  15056. * @param camera the camera the mesh should be attached to
  15057. */
  15058. attachToPoseControlledCamera(camera: TargetCamera): void;
  15059. /**
  15060. * Disposes of the controller
  15061. */
  15062. dispose(): void;
  15063. /**
  15064. * The mesh that is attached to the controller
  15065. */
  15066. get mesh(): Nullable<AbstractMesh>;
  15067. /**
  15068. * Gets the ray of the controller in the direction the controller is pointing
  15069. * @param length the length the resulting ray should be
  15070. * @returns a ray in the direction the controller is pointing
  15071. */
  15072. getForwardRay(length?: number): Ray;
  15073. }
  15074. }
  15075. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15076. import { Observable } from "babylonjs/Misc/observable";
  15077. import { Scene } from "babylonjs/scene";
  15078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15079. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15080. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15081. import { Nullable } from "babylonjs/types";
  15082. /**
  15083. * Defines the WebVRController object that represents controllers tracked in 3D space
  15084. */
  15085. export abstract class WebVRController extends PoseEnabledController {
  15086. /**
  15087. * Internal, the default controller model for the controller
  15088. */
  15089. protected _defaultModel: Nullable<AbstractMesh>;
  15090. /**
  15091. * Fired when the trigger state has changed
  15092. */
  15093. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15094. /**
  15095. * Fired when the main button state has changed
  15096. */
  15097. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15098. /**
  15099. * Fired when the secondary button state has changed
  15100. */
  15101. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15102. /**
  15103. * Fired when the pad state has changed
  15104. */
  15105. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15106. /**
  15107. * Fired when controllers stick values have changed
  15108. */
  15109. onPadValuesChangedObservable: Observable<StickValues>;
  15110. /**
  15111. * Array of button availible on the controller
  15112. */
  15113. protected _buttons: Array<MutableGamepadButton>;
  15114. private _onButtonStateChange;
  15115. /**
  15116. * Fired when a controller button's state has changed
  15117. * @param callback the callback containing the button that was modified
  15118. */
  15119. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15120. /**
  15121. * X and Y axis corresponding to the controllers joystick
  15122. */
  15123. pad: StickValues;
  15124. /**
  15125. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15126. */
  15127. hand: string;
  15128. /**
  15129. * The default controller model for the controller
  15130. */
  15131. get defaultModel(): Nullable<AbstractMesh>;
  15132. /**
  15133. * Creates a new WebVRController from a gamepad
  15134. * @param vrGamepad the gamepad that the WebVRController should be created from
  15135. */
  15136. constructor(vrGamepad: any);
  15137. /**
  15138. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15139. */
  15140. update(): void;
  15141. /**
  15142. * Function to be called when a button is modified
  15143. */
  15144. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15145. /**
  15146. * Loads a mesh and attaches it to the controller
  15147. * @param scene the scene the mesh should be added to
  15148. * @param meshLoaded callback for when the mesh has been loaded
  15149. */
  15150. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15151. private _setButtonValue;
  15152. private _changes;
  15153. private _checkChanges;
  15154. /**
  15155. * Disposes of th webVRCOntroller
  15156. */
  15157. dispose(): void;
  15158. }
  15159. }
  15160. declare module "babylonjs/Lights/hemisphericLight" {
  15161. import { Nullable } from "babylonjs/types";
  15162. import { Scene } from "babylonjs/scene";
  15163. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15164. import { Color3 } from "babylonjs/Maths/math.color";
  15165. import { Effect } from "babylonjs/Materials/effect";
  15166. import { Light } from "babylonjs/Lights/light";
  15167. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15168. /**
  15169. * The HemisphericLight simulates the ambient environment light,
  15170. * so the passed direction is the light reflection direction, not the incoming direction.
  15171. */
  15172. export class HemisphericLight extends Light {
  15173. /**
  15174. * The groundColor is the light in the opposite direction to the one specified during creation.
  15175. * 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.
  15176. */
  15177. groundColor: Color3;
  15178. /**
  15179. * The light reflection direction, not the incoming direction.
  15180. */
  15181. direction: Vector3;
  15182. /**
  15183. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15184. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15185. * The HemisphericLight can't cast shadows.
  15186. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15187. * @param name The friendly name of the light
  15188. * @param direction The direction of the light reflection
  15189. * @param scene The scene the light belongs to
  15190. */
  15191. constructor(name: string, direction: Vector3, scene: Scene);
  15192. protected _buildUniformLayout(): void;
  15193. /**
  15194. * Returns the string "HemisphericLight".
  15195. * @return The class name
  15196. */
  15197. getClassName(): string;
  15198. /**
  15199. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15200. * Returns the updated direction.
  15201. * @param target The target the direction should point to
  15202. * @return The computed direction
  15203. */
  15204. setDirectionToTarget(target: Vector3): Vector3;
  15205. /**
  15206. * Returns the shadow generator associated to the light.
  15207. * @returns Always null for hemispheric lights because it does not support shadows.
  15208. */
  15209. getShadowGenerator(): Nullable<IShadowGenerator>;
  15210. /**
  15211. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15212. * @param effect The effect to update
  15213. * @param lightIndex The index of the light in the effect to update
  15214. * @returns The hemispheric light
  15215. */
  15216. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15217. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15218. /**
  15219. * Computes the world matrix of the node
  15220. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15221. * @param useWasUpdatedFlag defines a reserved property
  15222. * @returns the world matrix
  15223. */
  15224. computeWorldMatrix(): Matrix;
  15225. /**
  15226. * Returns the integer 3.
  15227. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15228. */
  15229. getTypeID(): number;
  15230. /**
  15231. * Prepares the list of defines specific to the light type.
  15232. * @param defines the list of defines
  15233. * @param lightIndex defines the index of the light for the effect
  15234. */
  15235. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15236. }
  15237. }
  15238. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15239. /** @hidden */
  15240. export var vrMultiviewToSingleviewPixelShader: {
  15241. name: string;
  15242. shader: string;
  15243. };
  15244. }
  15245. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15246. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15247. import { Scene } from "babylonjs/scene";
  15248. /**
  15249. * Renders to multiple views with a single draw call
  15250. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15251. */
  15252. export class MultiviewRenderTarget extends RenderTargetTexture {
  15253. /**
  15254. * Creates a multiview render target
  15255. * @param scene scene used with the render target
  15256. * @param size the size of the render target (used for each view)
  15257. */
  15258. constructor(scene: Scene, size?: number | {
  15259. width: number;
  15260. height: number;
  15261. } | {
  15262. ratio: number;
  15263. });
  15264. /**
  15265. * @hidden
  15266. * @param faceIndex the face index, if its a cube texture
  15267. */
  15268. _bindFrameBuffer(faceIndex?: number): void;
  15269. /**
  15270. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15271. * @returns the view count
  15272. */
  15273. getViewCount(): number;
  15274. }
  15275. }
  15276. declare module "babylonjs/Maths/math.frustum" {
  15277. import { Matrix } from "babylonjs/Maths/math.vector";
  15278. import { DeepImmutable } from "babylonjs/types";
  15279. import { Plane } from "babylonjs/Maths/math.plane";
  15280. /**
  15281. * Represents a camera frustum
  15282. */
  15283. export class Frustum {
  15284. /**
  15285. * Gets the planes representing the frustum
  15286. * @param transform matrix to be applied to the returned planes
  15287. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15288. */
  15289. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15290. /**
  15291. * Gets the near frustum plane transformed by the transform matrix
  15292. * @param transform transformation matrix to be applied to the resulting frustum plane
  15293. * @param frustumPlane the resuling frustum plane
  15294. */
  15295. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15296. /**
  15297. * Gets the far frustum plane transformed by the transform matrix
  15298. * @param transform transformation matrix to be applied to the resulting frustum plane
  15299. * @param frustumPlane the resuling frustum plane
  15300. */
  15301. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15302. /**
  15303. * Gets the left frustum plane transformed by the transform matrix
  15304. * @param transform transformation matrix to be applied to the resulting frustum plane
  15305. * @param frustumPlane the resuling frustum plane
  15306. */
  15307. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15308. /**
  15309. * Gets the right frustum plane transformed by the transform matrix
  15310. * @param transform transformation matrix to be applied to the resulting frustum plane
  15311. * @param frustumPlane the resuling frustum plane
  15312. */
  15313. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15314. /**
  15315. * Gets the top frustum plane transformed by the transform matrix
  15316. * @param transform transformation matrix to be applied to the resulting frustum plane
  15317. * @param frustumPlane the resuling frustum plane
  15318. */
  15319. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15320. /**
  15321. * Gets the bottom frustum plane transformed by the transform matrix
  15322. * @param transform transformation matrix to be applied to the resulting frustum plane
  15323. * @param frustumPlane the resuling frustum plane
  15324. */
  15325. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15326. /**
  15327. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15328. * @param transform transformation matrix to be applied to the resulting frustum planes
  15329. * @param frustumPlanes the resuling frustum planes
  15330. */
  15331. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15332. }
  15333. }
  15334. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15335. import { Camera } from "babylonjs/Cameras/camera";
  15336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15337. import { Nullable } from "babylonjs/types";
  15338. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15339. import { Matrix } from "babylonjs/Maths/math.vector";
  15340. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15341. module "babylonjs/Engines/engine" {
  15342. interface Engine {
  15343. /**
  15344. * Creates a new multiview render target
  15345. * @param width defines the width of the texture
  15346. * @param height defines the height of the texture
  15347. * @returns the created multiview texture
  15348. */
  15349. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15350. /**
  15351. * Binds a multiview framebuffer to be drawn to
  15352. * @param multiviewTexture texture to bind
  15353. */
  15354. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15355. }
  15356. }
  15357. module "babylonjs/Cameras/camera" {
  15358. interface Camera {
  15359. /**
  15360. * @hidden
  15361. * 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)
  15362. */
  15363. _useMultiviewToSingleView: boolean;
  15364. /**
  15365. * @hidden
  15366. * 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)
  15367. */
  15368. _multiviewTexture: Nullable<RenderTargetTexture>;
  15369. /**
  15370. * @hidden
  15371. * ensures the multiview texture of the camera exists and has the specified width/height
  15372. * @param width height to set on the multiview texture
  15373. * @param height width to set on the multiview texture
  15374. */
  15375. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15376. }
  15377. }
  15378. module "babylonjs/scene" {
  15379. interface Scene {
  15380. /** @hidden */
  15381. _transformMatrixR: Matrix;
  15382. /** @hidden */
  15383. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15384. /** @hidden */
  15385. _createMultiviewUbo(): void;
  15386. /** @hidden */
  15387. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15388. /** @hidden */
  15389. _renderMultiviewToSingleView(camera: Camera): void;
  15390. }
  15391. }
  15392. }
  15393. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15394. import { Camera } from "babylonjs/Cameras/camera";
  15395. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15396. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15397. import "babylonjs/Engines/Extensions/engine.multiview";
  15398. /**
  15399. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15400. * This will not be used for webXR as it supports displaying texture arrays directly
  15401. */
  15402. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15403. /**
  15404. * Initializes a VRMultiviewToSingleview
  15405. * @param name name of the post process
  15406. * @param camera camera to be applied to
  15407. * @param scaleFactor scaling factor to the size of the output texture
  15408. */
  15409. constructor(name: string, camera: Camera, scaleFactor: number);
  15410. }
  15411. }
  15412. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15413. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15414. import { Nullable } from "babylonjs/types";
  15415. import { Size } from "babylonjs/Maths/math.size";
  15416. import { Observable } from "babylonjs/Misc/observable";
  15417. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15418. /**
  15419. * Interface used to define additional presentation attributes
  15420. */
  15421. export interface IVRPresentationAttributes {
  15422. /**
  15423. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15424. */
  15425. highRefreshRate: boolean;
  15426. /**
  15427. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15428. */
  15429. foveationLevel: number;
  15430. }
  15431. module "babylonjs/Engines/engine" {
  15432. interface Engine {
  15433. /** @hidden */
  15434. _vrDisplay: any;
  15435. /** @hidden */
  15436. _vrSupported: boolean;
  15437. /** @hidden */
  15438. _oldSize: Size;
  15439. /** @hidden */
  15440. _oldHardwareScaleFactor: number;
  15441. /** @hidden */
  15442. _vrExclusivePointerMode: boolean;
  15443. /** @hidden */
  15444. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15445. /** @hidden */
  15446. _onVRDisplayPointerRestricted: () => void;
  15447. /** @hidden */
  15448. _onVRDisplayPointerUnrestricted: () => void;
  15449. /** @hidden */
  15450. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15451. /** @hidden */
  15452. _onVrDisplayDisconnect: Nullable<() => void>;
  15453. /** @hidden */
  15454. _onVrDisplayPresentChange: Nullable<() => void>;
  15455. /**
  15456. * Observable signaled when VR display mode changes
  15457. */
  15458. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15459. /**
  15460. * Observable signaled when VR request present is complete
  15461. */
  15462. onVRRequestPresentComplete: Observable<boolean>;
  15463. /**
  15464. * Observable signaled when VR request present starts
  15465. */
  15466. onVRRequestPresentStart: Observable<Engine>;
  15467. /**
  15468. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15469. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15470. */
  15471. isInVRExclusivePointerMode: boolean;
  15472. /**
  15473. * Gets a boolean indicating if a webVR device was detected
  15474. * @returns true if a webVR device was detected
  15475. */
  15476. isVRDevicePresent(): boolean;
  15477. /**
  15478. * Gets the current webVR device
  15479. * @returns the current webVR device (or null)
  15480. */
  15481. getVRDevice(): any;
  15482. /**
  15483. * Initializes a webVR display and starts listening to display change events
  15484. * The onVRDisplayChangedObservable will be notified upon these changes
  15485. * @returns A promise containing a VRDisplay and if vr is supported
  15486. */
  15487. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15488. /** @hidden */
  15489. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15490. /**
  15491. * Gets or sets the presentation attributes used to configure VR rendering
  15492. */
  15493. vrPresentationAttributes?: IVRPresentationAttributes;
  15494. /**
  15495. * Call this function to switch to webVR mode
  15496. * Will do nothing if webVR is not supported or if there is no webVR device
  15497. * @param options the webvr options provided to the camera. mainly used for multiview
  15498. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15499. */
  15500. enableVR(options: WebVROptions): void;
  15501. /** @hidden */
  15502. _onVRFullScreenTriggered(): void;
  15503. }
  15504. }
  15505. }
  15506. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15507. import { Nullable } from "babylonjs/types";
  15508. import { Observable } from "babylonjs/Misc/observable";
  15509. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15510. import { Scene } from "babylonjs/scene";
  15511. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15512. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15513. import { Node } from "babylonjs/node";
  15514. import { Ray } from "babylonjs/Culling/ray";
  15515. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15516. import "babylonjs/Engines/Extensions/engine.webVR";
  15517. /**
  15518. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15519. * IMPORTANT!! The data is right-hand data.
  15520. * @export
  15521. * @interface DevicePose
  15522. */
  15523. export interface DevicePose {
  15524. /**
  15525. * The position of the device, values in array are [x,y,z].
  15526. */
  15527. readonly position: Nullable<Float32Array>;
  15528. /**
  15529. * The linearVelocity of the device, values in array are [x,y,z].
  15530. */
  15531. readonly linearVelocity: Nullable<Float32Array>;
  15532. /**
  15533. * The linearAcceleration of the device, values in array are [x,y,z].
  15534. */
  15535. readonly linearAcceleration: Nullable<Float32Array>;
  15536. /**
  15537. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15538. */
  15539. readonly orientation: Nullable<Float32Array>;
  15540. /**
  15541. * The angularVelocity of the device, values in array are [x,y,z].
  15542. */
  15543. readonly angularVelocity: Nullable<Float32Array>;
  15544. /**
  15545. * The angularAcceleration of the device, values in array are [x,y,z].
  15546. */
  15547. readonly angularAcceleration: Nullable<Float32Array>;
  15548. }
  15549. /**
  15550. * Interface representing a pose controlled object in Babylon.
  15551. * A pose controlled object has both regular pose values as well as pose values
  15552. * from an external device such as a VR head mounted display
  15553. */
  15554. export interface PoseControlled {
  15555. /**
  15556. * The position of the object in babylon space.
  15557. */
  15558. position: Vector3;
  15559. /**
  15560. * The rotation quaternion of the object in babylon space.
  15561. */
  15562. rotationQuaternion: Quaternion;
  15563. /**
  15564. * The position of the device in babylon space.
  15565. */
  15566. devicePosition?: Vector3;
  15567. /**
  15568. * The rotation quaternion of the device in babylon space.
  15569. */
  15570. deviceRotationQuaternion: Quaternion;
  15571. /**
  15572. * The raw pose coming from the device.
  15573. */
  15574. rawPose: Nullable<DevicePose>;
  15575. /**
  15576. * The scale of the device to be used when translating from device space to babylon space.
  15577. */
  15578. deviceScaleFactor: number;
  15579. /**
  15580. * Updates the poseControlled values based on the input device pose.
  15581. * @param poseData the pose data to update the object with
  15582. */
  15583. updateFromDevice(poseData: DevicePose): void;
  15584. }
  15585. /**
  15586. * Set of options to customize the webVRCamera
  15587. */
  15588. export interface WebVROptions {
  15589. /**
  15590. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15591. */
  15592. trackPosition?: boolean;
  15593. /**
  15594. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15595. */
  15596. positionScale?: number;
  15597. /**
  15598. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15599. */
  15600. displayName?: string;
  15601. /**
  15602. * Should the native controller meshes be initialized. (default: true)
  15603. */
  15604. controllerMeshes?: boolean;
  15605. /**
  15606. * Creating a default HemiLight only on controllers. (default: true)
  15607. */
  15608. defaultLightingOnControllers?: boolean;
  15609. /**
  15610. * If you don't want to use the default VR button of the helper. (default: false)
  15611. */
  15612. useCustomVRButton?: boolean;
  15613. /**
  15614. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15615. */
  15616. customVRButton?: HTMLButtonElement;
  15617. /**
  15618. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15619. */
  15620. rayLength?: number;
  15621. /**
  15622. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15623. */
  15624. defaultHeight?: number;
  15625. /**
  15626. * If multiview should be used if availible (default: false)
  15627. */
  15628. useMultiview?: boolean;
  15629. }
  15630. /**
  15631. * This represents a WebVR camera.
  15632. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15633. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15634. */
  15635. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15636. private webVROptions;
  15637. /**
  15638. * @hidden
  15639. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15640. */
  15641. _vrDevice: any;
  15642. /**
  15643. * The rawPose of the vrDevice.
  15644. */
  15645. rawPose: Nullable<DevicePose>;
  15646. private _onVREnabled;
  15647. private _specsVersion;
  15648. private _attached;
  15649. private _frameData;
  15650. protected _descendants: Array<Node>;
  15651. private _deviceRoomPosition;
  15652. /** @hidden */
  15653. _deviceRoomRotationQuaternion: Quaternion;
  15654. private _standingMatrix;
  15655. /**
  15656. * Represents device position in babylon space.
  15657. */
  15658. devicePosition: Vector3;
  15659. /**
  15660. * Represents device rotation in babylon space.
  15661. */
  15662. deviceRotationQuaternion: Quaternion;
  15663. /**
  15664. * The scale of the device to be used when translating from device space to babylon space.
  15665. */
  15666. deviceScaleFactor: number;
  15667. private _deviceToWorld;
  15668. private _worldToDevice;
  15669. /**
  15670. * References to the webVR controllers for the vrDevice.
  15671. */
  15672. controllers: Array<WebVRController>;
  15673. /**
  15674. * Emits an event when a controller is attached.
  15675. */
  15676. onControllersAttachedObservable: Observable<WebVRController[]>;
  15677. /**
  15678. * Emits an event when a controller's mesh has been loaded;
  15679. */
  15680. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15681. /**
  15682. * Emits an event when the HMD's pose has been updated.
  15683. */
  15684. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15685. private _poseSet;
  15686. /**
  15687. * If the rig cameras be used as parent instead of this camera.
  15688. */
  15689. rigParenting: boolean;
  15690. private _lightOnControllers;
  15691. private _defaultHeight?;
  15692. /**
  15693. * Instantiates a WebVRFreeCamera.
  15694. * @param name The name of the WebVRFreeCamera
  15695. * @param position The starting anchor position for the camera
  15696. * @param scene The scene the camera belongs to
  15697. * @param webVROptions a set of customizable options for the webVRCamera
  15698. */
  15699. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15700. /**
  15701. * Gets the device distance from the ground in meters.
  15702. * @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.
  15703. */
  15704. deviceDistanceToRoomGround(): number;
  15705. /**
  15706. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15707. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15708. */
  15709. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15710. /**
  15711. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15712. * @returns A promise with a boolean set to if the standing matrix is supported.
  15713. */
  15714. useStandingMatrixAsync(): Promise<boolean>;
  15715. /**
  15716. * Disposes the camera
  15717. */
  15718. dispose(): void;
  15719. /**
  15720. * Gets a vrController by name.
  15721. * @param name The name of the controller to retreive
  15722. * @returns the controller matching the name specified or null if not found
  15723. */
  15724. getControllerByName(name: string): Nullable<WebVRController>;
  15725. private _leftController;
  15726. /**
  15727. * The controller corresponding to the users left hand.
  15728. */
  15729. get leftController(): Nullable<WebVRController>;
  15730. private _rightController;
  15731. /**
  15732. * The controller corresponding to the users right hand.
  15733. */
  15734. get rightController(): Nullable<WebVRController>;
  15735. /**
  15736. * Casts a ray forward from the vrCamera's gaze.
  15737. * @param length Length of the ray (default: 100)
  15738. * @returns the ray corresponding to the gaze
  15739. */
  15740. getForwardRay(length?: number): Ray;
  15741. /**
  15742. * @hidden
  15743. * Updates the camera based on device's frame data
  15744. */
  15745. _checkInputs(): void;
  15746. /**
  15747. * Updates the poseControlled values based on the input device pose.
  15748. * @param poseData Pose coming from the device
  15749. */
  15750. updateFromDevice(poseData: DevicePose): void;
  15751. private _htmlElementAttached;
  15752. private _detachIfAttached;
  15753. /**
  15754. * WebVR's attach control will start broadcasting frames to the device.
  15755. * Note that in certain browsers (chrome for example) this function must be called
  15756. * within a user-interaction callback. Example:
  15757. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15758. *
  15759. * @param element html element to attach the vrDevice to
  15760. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15761. */
  15762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15763. /**
  15764. * Detaches the camera from the html element and disables VR
  15765. *
  15766. * @param element html element to detach from
  15767. */
  15768. detachControl(element: HTMLElement): void;
  15769. /**
  15770. * @returns the name of this class
  15771. */
  15772. getClassName(): string;
  15773. /**
  15774. * Calls resetPose on the vrDisplay
  15775. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15776. */
  15777. resetToCurrentRotation(): void;
  15778. /**
  15779. * @hidden
  15780. * Updates the rig cameras (left and right eye)
  15781. */
  15782. _updateRigCameras(): void;
  15783. private _workingVector;
  15784. private _oneVector;
  15785. private _workingMatrix;
  15786. private updateCacheCalled;
  15787. private _correctPositionIfNotTrackPosition;
  15788. /**
  15789. * @hidden
  15790. * Updates the cached values of the camera
  15791. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15792. */
  15793. _updateCache(ignoreParentClass?: boolean): void;
  15794. /**
  15795. * @hidden
  15796. * Get current device position in babylon world
  15797. */
  15798. _computeDevicePosition(): void;
  15799. /**
  15800. * Updates the current device position and rotation in the babylon world
  15801. */
  15802. update(): void;
  15803. /**
  15804. * @hidden
  15805. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15806. * @returns an identity matrix
  15807. */
  15808. _getViewMatrix(): Matrix;
  15809. private _tmpMatrix;
  15810. /**
  15811. * This function is called by the two RIG cameras.
  15812. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15813. * @hidden
  15814. */
  15815. _getWebVRViewMatrix(): Matrix;
  15816. /** @hidden */
  15817. _getWebVRProjectionMatrix(): Matrix;
  15818. private _onGamepadConnectedObserver;
  15819. private _onGamepadDisconnectedObserver;
  15820. private _updateCacheWhenTrackingDisabledObserver;
  15821. /**
  15822. * Initializes the controllers and their meshes
  15823. */
  15824. initControllers(): void;
  15825. }
  15826. }
  15827. declare module "babylonjs/PostProcesses/postProcess" {
  15828. import { Nullable } from "babylonjs/types";
  15829. import { SmartArray } from "babylonjs/Misc/smartArray";
  15830. import { Observable } from "babylonjs/Misc/observable";
  15831. import { Vector2 } from "babylonjs/Maths/math.vector";
  15832. import { Camera } from "babylonjs/Cameras/camera";
  15833. import { Effect } from "babylonjs/Materials/effect";
  15834. import "babylonjs/Shaders/postprocess.vertex";
  15835. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15836. import { Engine } from "babylonjs/Engines/engine";
  15837. import { Color4 } from "babylonjs/Maths/math.color";
  15838. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15839. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15840. /**
  15841. * Size options for a post process
  15842. */
  15843. export type PostProcessOptions = {
  15844. width: number;
  15845. height: number;
  15846. };
  15847. /**
  15848. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15849. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15850. */
  15851. export class PostProcess {
  15852. /** Name of the PostProcess. */
  15853. name: string;
  15854. /**
  15855. * Gets or sets the unique id of the post process
  15856. */
  15857. uniqueId: number;
  15858. /**
  15859. * Width of the texture to apply the post process on
  15860. */
  15861. width: number;
  15862. /**
  15863. * Height of the texture to apply the post process on
  15864. */
  15865. height: number;
  15866. /**
  15867. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15868. * @hidden
  15869. */
  15870. _outputTexture: Nullable<InternalTexture>;
  15871. /**
  15872. * Sampling mode used by the shader
  15873. * See https://doc.babylonjs.com/classes/3.1/texture
  15874. */
  15875. renderTargetSamplingMode: number;
  15876. /**
  15877. * Clear color to use when screen clearing
  15878. */
  15879. clearColor: Color4;
  15880. /**
  15881. * If the buffer needs to be cleared before applying the post process. (default: true)
  15882. * Should be set to false if shader will overwrite all previous pixels.
  15883. */
  15884. autoClear: boolean;
  15885. /**
  15886. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15887. */
  15888. alphaMode: number;
  15889. /**
  15890. * Sets the setAlphaBlendConstants of the babylon engine
  15891. */
  15892. alphaConstants: Color4;
  15893. /**
  15894. * Animations to be used for the post processing
  15895. */
  15896. animations: import("babylonjs/Animations/animation").Animation[];
  15897. /**
  15898. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15899. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15900. */
  15901. enablePixelPerfectMode: boolean;
  15902. /**
  15903. * Force the postprocess to be applied without taking in account viewport
  15904. */
  15905. forceFullscreenViewport: boolean;
  15906. /**
  15907. * List of inspectable custom properties (used by the Inspector)
  15908. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15909. */
  15910. inspectableCustomProperties: IInspectable[];
  15911. /**
  15912. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15913. *
  15914. * | Value | Type | Description |
  15915. * | ----- | ----------------------------------- | ----------- |
  15916. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15917. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15918. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15919. *
  15920. */
  15921. scaleMode: number;
  15922. /**
  15923. * Force textures to be a power of two (default: false)
  15924. */
  15925. alwaysForcePOT: boolean;
  15926. private _samples;
  15927. /**
  15928. * Number of sample textures (default: 1)
  15929. */
  15930. get samples(): number;
  15931. set samples(n: number);
  15932. /**
  15933. * Modify the scale of the post process to be the same as the viewport (default: false)
  15934. */
  15935. adaptScaleToCurrentViewport: boolean;
  15936. private _camera;
  15937. private _scene;
  15938. private _engine;
  15939. private _options;
  15940. private _reusable;
  15941. private _textureType;
  15942. /**
  15943. * Smart array of input and output textures for the post process.
  15944. * @hidden
  15945. */
  15946. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15947. /**
  15948. * The index in _textures that corresponds to the output texture.
  15949. * @hidden
  15950. */
  15951. _currentRenderTextureInd: number;
  15952. private _effect;
  15953. private _samplers;
  15954. private _fragmentUrl;
  15955. private _vertexUrl;
  15956. private _parameters;
  15957. private _scaleRatio;
  15958. protected _indexParameters: any;
  15959. private _shareOutputWithPostProcess;
  15960. private _texelSize;
  15961. private _forcedOutputTexture;
  15962. /**
  15963. * Returns the fragment url or shader name used in the post process.
  15964. * @returns the fragment url or name in the shader store.
  15965. */
  15966. getEffectName(): string;
  15967. /**
  15968. * An event triggered when the postprocess is activated.
  15969. */
  15970. onActivateObservable: Observable<Camera>;
  15971. private _onActivateObserver;
  15972. /**
  15973. * A function that is added to the onActivateObservable
  15974. */
  15975. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15976. /**
  15977. * An event triggered when the postprocess changes its size.
  15978. */
  15979. onSizeChangedObservable: Observable<PostProcess>;
  15980. private _onSizeChangedObserver;
  15981. /**
  15982. * A function that is added to the onSizeChangedObservable
  15983. */
  15984. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15985. /**
  15986. * An event triggered when the postprocess applies its effect.
  15987. */
  15988. onApplyObservable: Observable<Effect>;
  15989. private _onApplyObserver;
  15990. /**
  15991. * A function that is added to the onApplyObservable
  15992. */
  15993. set onApply(callback: (effect: Effect) => void);
  15994. /**
  15995. * An event triggered before rendering the postprocess
  15996. */
  15997. onBeforeRenderObservable: Observable<Effect>;
  15998. private _onBeforeRenderObserver;
  15999. /**
  16000. * A function that is added to the onBeforeRenderObservable
  16001. */
  16002. set onBeforeRender(callback: (effect: Effect) => void);
  16003. /**
  16004. * An event triggered after rendering the postprocess
  16005. */
  16006. onAfterRenderObservable: Observable<Effect>;
  16007. private _onAfterRenderObserver;
  16008. /**
  16009. * A function that is added to the onAfterRenderObservable
  16010. */
  16011. set onAfterRender(callback: (efect: Effect) => void);
  16012. /**
  16013. * 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
  16014. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16015. */
  16016. get inputTexture(): InternalTexture;
  16017. set inputTexture(value: InternalTexture);
  16018. /**
  16019. * Gets the camera which post process is applied to.
  16020. * @returns The camera the post process is applied to.
  16021. */
  16022. getCamera(): Camera;
  16023. /**
  16024. * Gets the texel size of the postprocess.
  16025. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16026. */
  16027. get texelSize(): Vector2;
  16028. /**
  16029. * Creates a new instance PostProcess
  16030. * @param name The name of the PostProcess.
  16031. * @param fragmentUrl The url of the fragment shader to be used.
  16032. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16033. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16034. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16035. * @param camera The camera to apply the render pass to.
  16036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16037. * @param engine The engine which the post process will be applied. (default: current engine)
  16038. * @param reusable If the post process can be reused on the same frame. (default: false)
  16039. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16040. * @param textureType Type of textures used when performing the post process. (default: 0)
  16041. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16042. * @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
  16043. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16044. */
  16045. constructor(
  16046. /** Name of the PostProcess. */
  16047. 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);
  16048. /**
  16049. * Gets a string idenfifying the name of the class
  16050. * @returns "PostProcess" string
  16051. */
  16052. getClassName(): string;
  16053. /**
  16054. * Gets the engine which this post process belongs to.
  16055. * @returns The engine the post process was enabled with.
  16056. */
  16057. getEngine(): Engine;
  16058. /**
  16059. * The effect that is created when initializing the post process.
  16060. * @returns The created effect corresponding the the postprocess.
  16061. */
  16062. getEffect(): Effect;
  16063. /**
  16064. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16065. * @param postProcess The post process to share the output with.
  16066. * @returns This post process.
  16067. */
  16068. shareOutputWith(postProcess: PostProcess): PostProcess;
  16069. /**
  16070. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16071. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16072. */
  16073. useOwnOutput(): void;
  16074. /**
  16075. * Updates the effect with the current post process compile time values and recompiles the shader.
  16076. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16077. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16078. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16079. * @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
  16080. * @param onCompiled Called when the shader has been compiled.
  16081. * @param onError Called if there is an error when compiling a shader.
  16082. */
  16083. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16084. /**
  16085. * The post process is reusable if it can be used multiple times within one frame.
  16086. * @returns If the post process is reusable
  16087. */
  16088. isReusable(): boolean;
  16089. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16090. markTextureDirty(): void;
  16091. /**
  16092. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16093. * 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.
  16094. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16095. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16096. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16097. * @returns The target texture that was bound to be written to.
  16098. */
  16099. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16100. /**
  16101. * If the post process is supported.
  16102. */
  16103. get isSupported(): boolean;
  16104. /**
  16105. * The aspect ratio of the output texture.
  16106. */
  16107. get aspectRatio(): number;
  16108. /**
  16109. * Get a value indicating if the post-process is ready to be used
  16110. * @returns true if the post-process is ready (shader is compiled)
  16111. */
  16112. isReady(): boolean;
  16113. /**
  16114. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16115. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16116. */
  16117. apply(): Nullable<Effect>;
  16118. private _disposeTextures;
  16119. /**
  16120. * Disposes the post process.
  16121. * @param camera The camera to dispose the post process on.
  16122. */
  16123. dispose(camera?: Camera): void;
  16124. }
  16125. }
  16126. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16127. /** @hidden */
  16128. export var kernelBlurVaryingDeclaration: {
  16129. name: string;
  16130. shader: string;
  16131. };
  16132. }
  16133. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16134. /** @hidden */
  16135. export var kernelBlurFragment: {
  16136. name: string;
  16137. shader: string;
  16138. };
  16139. }
  16140. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16141. /** @hidden */
  16142. export var kernelBlurFragment2: {
  16143. name: string;
  16144. shader: string;
  16145. };
  16146. }
  16147. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16148. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16149. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16150. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16151. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16152. /** @hidden */
  16153. export var kernelBlurPixelShader: {
  16154. name: string;
  16155. shader: string;
  16156. };
  16157. }
  16158. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16159. /** @hidden */
  16160. export var kernelBlurVertex: {
  16161. name: string;
  16162. shader: string;
  16163. };
  16164. }
  16165. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16166. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16167. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16168. /** @hidden */
  16169. export var kernelBlurVertexShader: {
  16170. name: string;
  16171. shader: string;
  16172. };
  16173. }
  16174. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16175. import { Vector2 } from "babylonjs/Maths/math.vector";
  16176. import { Nullable } from "babylonjs/types";
  16177. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16178. import { Camera } from "babylonjs/Cameras/camera";
  16179. import { Effect } from "babylonjs/Materials/effect";
  16180. import { Engine } from "babylonjs/Engines/engine";
  16181. import "babylonjs/Shaders/kernelBlur.fragment";
  16182. import "babylonjs/Shaders/kernelBlur.vertex";
  16183. /**
  16184. * The Blur Post Process which blurs an image based on a kernel and direction.
  16185. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16186. */
  16187. export class BlurPostProcess extends PostProcess {
  16188. /** The direction in which to blur the image. */
  16189. direction: Vector2;
  16190. private blockCompilation;
  16191. protected _kernel: number;
  16192. protected _idealKernel: number;
  16193. protected _packedFloat: boolean;
  16194. private _staticDefines;
  16195. /**
  16196. * Sets the length in pixels of the blur sample region
  16197. */
  16198. set kernel(v: number);
  16199. /**
  16200. * Gets the length in pixels of the blur sample region
  16201. */
  16202. get kernel(): number;
  16203. /**
  16204. * Sets wether or not the blur needs to unpack/repack floats
  16205. */
  16206. set packedFloat(v: boolean);
  16207. /**
  16208. * Gets wether or not the blur is unpacking/repacking floats
  16209. */
  16210. get packedFloat(): boolean;
  16211. /**
  16212. * Creates a new instance BlurPostProcess
  16213. * @param name The name of the effect.
  16214. * @param direction The direction in which to blur the image.
  16215. * @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.
  16216. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16217. * @param camera The camera to apply the render pass to.
  16218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16219. * @param engine The engine which the post process will be applied. (default: current engine)
  16220. * @param reusable If the post process can be reused on the same frame. (default: false)
  16221. * @param textureType Type of textures used when performing the post process. (default: 0)
  16222. * @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)
  16223. */
  16224. constructor(name: string,
  16225. /** The direction in which to blur the image. */
  16226. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16227. /**
  16228. * Updates the effect with the current post process compile time values and recompiles the shader.
  16229. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16230. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16231. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16232. * @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
  16233. * @param onCompiled Called when the shader has been compiled.
  16234. * @param onError Called if there is an error when compiling a shader.
  16235. */
  16236. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16237. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16238. /**
  16239. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16240. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16241. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16242. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16243. * The gaps between physical kernels are compensated for in the weighting of the samples
  16244. * @param idealKernel Ideal blur kernel.
  16245. * @return Nearest best kernel.
  16246. */
  16247. protected _nearestBestKernel(idealKernel: number): number;
  16248. /**
  16249. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16250. * @param x The point on the Gaussian distribution to sample.
  16251. * @return the value of the Gaussian function at x.
  16252. */
  16253. protected _gaussianWeight(x: number): number;
  16254. /**
  16255. * Generates a string that can be used as a floating point number in GLSL.
  16256. * @param x Value to print.
  16257. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16258. * @return GLSL float string.
  16259. */
  16260. protected _glslFloat(x: number, decimalFigures?: number): string;
  16261. }
  16262. }
  16263. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16264. import { Scene } from "babylonjs/scene";
  16265. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16266. import { Plane } from "babylonjs/Maths/math.plane";
  16267. /**
  16268. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16269. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16270. * You can then easily use it as a reflectionTexture on a flat surface.
  16271. * In case the surface is not a plane, please consider relying on reflection probes.
  16272. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16273. */
  16274. export class MirrorTexture extends RenderTargetTexture {
  16275. private scene;
  16276. /**
  16277. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16278. * 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.
  16279. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16280. */
  16281. mirrorPlane: Plane;
  16282. /**
  16283. * Define the blur ratio used to blur the reflection if needed.
  16284. */
  16285. set blurRatio(value: number);
  16286. get blurRatio(): number;
  16287. /**
  16288. * Define the adaptive blur kernel used to blur the reflection if needed.
  16289. * This will autocompute the closest best match for the `blurKernel`
  16290. */
  16291. set adaptiveBlurKernel(value: number);
  16292. /**
  16293. * Define the blur kernel used to blur the reflection if needed.
  16294. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16295. */
  16296. set blurKernel(value: number);
  16297. /**
  16298. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16299. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16300. */
  16301. set blurKernelX(value: number);
  16302. get blurKernelX(): number;
  16303. /**
  16304. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16305. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16306. */
  16307. set blurKernelY(value: number);
  16308. get blurKernelY(): number;
  16309. private _autoComputeBlurKernel;
  16310. protected _onRatioRescale(): void;
  16311. private _updateGammaSpace;
  16312. private _imageProcessingConfigChangeObserver;
  16313. private _transformMatrix;
  16314. private _mirrorMatrix;
  16315. private _savedViewMatrix;
  16316. private _blurX;
  16317. private _blurY;
  16318. private _adaptiveBlurKernel;
  16319. private _blurKernelX;
  16320. private _blurKernelY;
  16321. private _blurRatio;
  16322. /**
  16323. * Instantiates a Mirror Texture.
  16324. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16325. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16326. * You can then easily use it as a reflectionTexture on a flat surface.
  16327. * In case the surface is not a plane, please consider relying on reflection probes.
  16328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16329. * @param name
  16330. * @param size
  16331. * @param scene
  16332. * @param generateMipMaps
  16333. * @param type
  16334. * @param samplingMode
  16335. * @param generateDepthBuffer
  16336. */
  16337. constructor(name: string, size: number | {
  16338. width: number;
  16339. height: number;
  16340. } | {
  16341. ratio: number;
  16342. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16343. private _preparePostProcesses;
  16344. /**
  16345. * Clone the mirror texture.
  16346. * @returns the cloned texture
  16347. */
  16348. clone(): MirrorTexture;
  16349. /**
  16350. * Serialize the texture to a JSON representation you could use in Parse later on
  16351. * @returns the serialized JSON representation
  16352. */
  16353. serialize(): any;
  16354. /**
  16355. * Dispose the texture and release its associated resources.
  16356. */
  16357. dispose(): void;
  16358. }
  16359. }
  16360. declare module "babylonjs/Materials/Textures/texture" {
  16361. import { Observable } from "babylonjs/Misc/observable";
  16362. import { Nullable } from "babylonjs/types";
  16363. import { Matrix } from "babylonjs/Maths/math.vector";
  16364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16365. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16366. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16367. import { Scene } from "babylonjs/scene";
  16368. /**
  16369. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16370. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16371. */
  16372. export class Texture extends BaseTexture {
  16373. /**
  16374. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16375. */
  16376. static SerializeBuffers: boolean;
  16377. /** @hidden */
  16378. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16379. /** @hidden */
  16380. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16381. /** @hidden */
  16382. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16383. /** nearest is mag = nearest and min = nearest and mip = linear */
  16384. static readonly NEAREST_SAMPLINGMODE: number;
  16385. /** nearest is mag = nearest and min = nearest and mip = linear */
  16386. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16387. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16388. static readonly BILINEAR_SAMPLINGMODE: number;
  16389. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16390. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16391. /** Trilinear is mag = linear and min = linear and mip = linear */
  16392. static readonly TRILINEAR_SAMPLINGMODE: number;
  16393. /** Trilinear is mag = linear and min = linear and mip = linear */
  16394. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16395. /** mag = nearest and min = nearest and mip = nearest */
  16396. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16397. /** mag = nearest and min = linear and mip = nearest */
  16398. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16399. /** mag = nearest and min = linear and mip = linear */
  16400. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16401. /** mag = nearest and min = linear and mip = none */
  16402. static readonly NEAREST_LINEAR: number;
  16403. /** mag = nearest and min = nearest and mip = none */
  16404. static readonly NEAREST_NEAREST: number;
  16405. /** mag = linear and min = nearest and mip = nearest */
  16406. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16407. /** mag = linear and min = nearest and mip = linear */
  16408. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16409. /** mag = linear and min = linear and mip = none */
  16410. static readonly LINEAR_LINEAR: number;
  16411. /** mag = linear and min = nearest and mip = none */
  16412. static readonly LINEAR_NEAREST: number;
  16413. /** Explicit coordinates mode */
  16414. static readonly EXPLICIT_MODE: number;
  16415. /** Spherical coordinates mode */
  16416. static readonly SPHERICAL_MODE: number;
  16417. /** Planar coordinates mode */
  16418. static readonly PLANAR_MODE: number;
  16419. /** Cubic coordinates mode */
  16420. static readonly CUBIC_MODE: number;
  16421. /** Projection coordinates mode */
  16422. static readonly PROJECTION_MODE: number;
  16423. /** Inverse Cubic coordinates mode */
  16424. static readonly SKYBOX_MODE: number;
  16425. /** Inverse Cubic coordinates mode */
  16426. static readonly INVCUBIC_MODE: number;
  16427. /** Equirectangular coordinates mode */
  16428. static readonly EQUIRECTANGULAR_MODE: number;
  16429. /** Equirectangular Fixed coordinates mode */
  16430. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16431. /** Equirectangular Fixed Mirrored coordinates mode */
  16432. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16433. /** Texture is not repeating outside of 0..1 UVs */
  16434. static readonly CLAMP_ADDRESSMODE: number;
  16435. /** Texture is repeating outside of 0..1 UVs */
  16436. static readonly WRAP_ADDRESSMODE: number;
  16437. /** Texture is repeating and mirrored */
  16438. static readonly MIRROR_ADDRESSMODE: number;
  16439. /**
  16440. * 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
  16441. */
  16442. static UseSerializedUrlIfAny: boolean;
  16443. /**
  16444. * Define the url of the texture.
  16445. */
  16446. url: Nullable<string>;
  16447. /**
  16448. * Define an offset on the texture to offset the u coordinates of the UVs
  16449. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16450. */
  16451. uOffset: number;
  16452. /**
  16453. * Define an offset on the texture to offset the v coordinates of the UVs
  16454. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16455. */
  16456. vOffset: number;
  16457. /**
  16458. * Define an offset on the texture to scale the u coordinates of the UVs
  16459. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16460. */
  16461. uScale: number;
  16462. /**
  16463. * Define an offset on the texture to scale the v coordinates of the UVs
  16464. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16465. */
  16466. vScale: number;
  16467. /**
  16468. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16469. * @see http://doc.babylonjs.com/how_to/more_materials
  16470. */
  16471. uAng: number;
  16472. /**
  16473. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16474. * @see http://doc.babylonjs.com/how_to/more_materials
  16475. */
  16476. vAng: number;
  16477. /**
  16478. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16479. * @see http://doc.babylonjs.com/how_to/more_materials
  16480. */
  16481. wAng: number;
  16482. /**
  16483. * Defines the center of rotation (U)
  16484. */
  16485. uRotationCenter: number;
  16486. /**
  16487. * Defines the center of rotation (V)
  16488. */
  16489. vRotationCenter: number;
  16490. /**
  16491. * Defines the center of rotation (W)
  16492. */
  16493. wRotationCenter: number;
  16494. /**
  16495. * Are mip maps generated for this texture or not.
  16496. */
  16497. get noMipmap(): boolean;
  16498. /**
  16499. * List of inspectable custom properties (used by the Inspector)
  16500. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16501. */
  16502. inspectableCustomProperties: Nullable<IInspectable[]>;
  16503. private _noMipmap;
  16504. /** @hidden */
  16505. _invertY: boolean;
  16506. private _rowGenerationMatrix;
  16507. private _cachedTextureMatrix;
  16508. private _projectionModeMatrix;
  16509. private _t0;
  16510. private _t1;
  16511. private _t2;
  16512. private _cachedUOffset;
  16513. private _cachedVOffset;
  16514. private _cachedUScale;
  16515. private _cachedVScale;
  16516. private _cachedUAng;
  16517. private _cachedVAng;
  16518. private _cachedWAng;
  16519. private _cachedProjectionMatrixId;
  16520. private _cachedCoordinatesMode;
  16521. /** @hidden */
  16522. protected _initialSamplingMode: number;
  16523. /** @hidden */
  16524. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16525. private _deleteBuffer;
  16526. protected _format: Nullable<number>;
  16527. private _delayedOnLoad;
  16528. private _delayedOnError;
  16529. private _mimeType?;
  16530. /**
  16531. * Observable triggered once the texture has been loaded.
  16532. */
  16533. onLoadObservable: Observable<Texture>;
  16534. protected _isBlocking: boolean;
  16535. /**
  16536. * Is the texture preventing material to render while loading.
  16537. * If false, a default texture will be used instead of the loading one during the preparation step.
  16538. */
  16539. set isBlocking(value: boolean);
  16540. get isBlocking(): boolean;
  16541. /**
  16542. * Get the current sampling mode associated with the texture.
  16543. */
  16544. get samplingMode(): number;
  16545. /**
  16546. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16547. */
  16548. get invertY(): boolean;
  16549. /**
  16550. * Instantiates a new texture.
  16551. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16552. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16553. * @param url defines the url of the picture to load as a texture
  16554. * @param scene defines the scene or engine the texture will belong to
  16555. * @param noMipmap defines if the texture will require mip maps or not
  16556. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16557. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16558. * @param onLoad defines a callback triggered when the texture has been loaded
  16559. * @param onError defines a callback triggered when an error occurred during the loading session
  16560. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16561. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16562. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16563. * @param mimeType defines an optional mime type information
  16564. */
  16565. 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);
  16566. /**
  16567. * Update the url (and optional buffer) of this texture if url was null during construction.
  16568. * @param url the url of the texture
  16569. * @param buffer the buffer of the texture (defaults to null)
  16570. * @param onLoad callback called when the texture is loaded (defaults to null)
  16571. */
  16572. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16573. /**
  16574. * Finish the loading sequence of a texture flagged as delayed load.
  16575. * @hidden
  16576. */
  16577. delayLoad(): void;
  16578. private _prepareRowForTextureGeneration;
  16579. /**
  16580. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16581. * @returns the transform matrix of the texture.
  16582. */
  16583. getTextureMatrix(uBase?: number): Matrix;
  16584. /**
  16585. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16586. * @returns The reflection texture transform
  16587. */
  16588. getReflectionTextureMatrix(): Matrix;
  16589. /**
  16590. * Clones the texture.
  16591. * @returns the cloned texture
  16592. */
  16593. clone(): Texture;
  16594. /**
  16595. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16596. * @returns The JSON representation of the texture
  16597. */
  16598. serialize(): any;
  16599. /**
  16600. * Get the current class name of the texture useful for serialization or dynamic coding.
  16601. * @returns "Texture"
  16602. */
  16603. getClassName(): string;
  16604. /**
  16605. * Dispose the texture and release its associated resources.
  16606. */
  16607. dispose(): void;
  16608. /**
  16609. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16610. * @param parsedTexture Define the JSON representation of the texture
  16611. * @param scene Define the scene the parsed texture should be instantiated in
  16612. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16613. * @returns The parsed texture if successful
  16614. */
  16615. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16616. /**
  16617. * Creates a texture from its base 64 representation.
  16618. * @param data Define the base64 payload without the data: prefix
  16619. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16620. * @param scene Define the scene the texture should belong to
  16621. * @param noMipmap Forces the texture to not create mip map information if true
  16622. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16623. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16624. * @param onLoad define a callback triggered when the texture has been loaded
  16625. * @param onError define a callback triggered when an error occurred during the loading session
  16626. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16627. * @returns the created texture
  16628. */
  16629. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16630. /**
  16631. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16632. * @param data Define the base64 payload without the data: prefix
  16633. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16634. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16635. * @param scene Define the scene the texture should belong to
  16636. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16637. * @param noMipmap Forces the texture to not create mip map information if true
  16638. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16639. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16640. * @param onLoad define a callback triggered when the texture has been loaded
  16641. * @param onError define a callback triggered when an error occurred during the loading session
  16642. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16643. * @returns the created texture
  16644. */
  16645. 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;
  16646. }
  16647. }
  16648. declare module "babylonjs/PostProcesses/postProcessManager" {
  16649. import { Nullable } from "babylonjs/types";
  16650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16651. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16652. import { Scene } from "babylonjs/scene";
  16653. /**
  16654. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16655. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16656. */
  16657. export class PostProcessManager {
  16658. private _scene;
  16659. private _indexBuffer;
  16660. private _vertexBuffers;
  16661. /**
  16662. * Creates a new instance PostProcess
  16663. * @param scene The scene that the post process is associated with.
  16664. */
  16665. constructor(scene: Scene);
  16666. private _prepareBuffers;
  16667. private _buildIndexBuffer;
  16668. /**
  16669. * Rebuilds the vertex buffers of the manager.
  16670. * @hidden
  16671. */
  16672. _rebuild(): void;
  16673. /**
  16674. * Prepares a frame to be run through a post process.
  16675. * @param sourceTexture The input texture to the post procesess. (default: null)
  16676. * @param postProcesses An array of post processes to be run. (default: null)
  16677. * @returns True if the post processes were able to be run.
  16678. * @hidden
  16679. */
  16680. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16681. /**
  16682. * Manually render a set of post processes to a texture.
  16683. * @param postProcesses An array of post processes to be run.
  16684. * @param targetTexture The target texture to render to.
  16685. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16686. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16687. * @param lodLevel defines which lod of the texture to render to
  16688. */
  16689. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16690. /**
  16691. * Finalize the result of the output of the postprocesses.
  16692. * @param doNotPresent If true the result will not be displayed to the screen.
  16693. * @param targetTexture The target texture to render to.
  16694. * @param faceIndex The index of the face to bind the target texture to.
  16695. * @param postProcesses The array of post processes to render.
  16696. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16697. * @hidden
  16698. */
  16699. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16700. /**
  16701. * Disposes of the post process manager.
  16702. */
  16703. dispose(): void;
  16704. }
  16705. }
  16706. declare module "babylonjs/Misc/gradients" {
  16707. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16708. /** Interface used by value gradients (color, factor, ...) */
  16709. export interface IValueGradient {
  16710. /**
  16711. * Gets or sets the gradient value (between 0 and 1)
  16712. */
  16713. gradient: number;
  16714. }
  16715. /** Class used to store color4 gradient */
  16716. export class ColorGradient implements IValueGradient {
  16717. /**
  16718. * Gets or sets the gradient value (between 0 and 1)
  16719. */
  16720. gradient: number;
  16721. /**
  16722. * Gets or sets first associated color
  16723. */
  16724. color1: Color4;
  16725. /**
  16726. * Gets or sets second associated color
  16727. */
  16728. color2?: Color4;
  16729. /**
  16730. * Will get a color picked randomly between color1 and color2.
  16731. * If color2 is undefined then color1 will be used
  16732. * @param result defines the target Color4 to store the result in
  16733. */
  16734. getColorToRef(result: Color4): void;
  16735. }
  16736. /** Class used to store color 3 gradient */
  16737. export class Color3Gradient implements IValueGradient {
  16738. /**
  16739. * Gets or sets the gradient value (between 0 and 1)
  16740. */
  16741. gradient: number;
  16742. /**
  16743. * Gets or sets the associated color
  16744. */
  16745. color: Color3;
  16746. }
  16747. /** Class used to store factor gradient */
  16748. export class FactorGradient implements IValueGradient {
  16749. /**
  16750. * Gets or sets the gradient value (between 0 and 1)
  16751. */
  16752. gradient: number;
  16753. /**
  16754. * Gets or sets first associated factor
  16755. */
  16756. factor1: number;
  16757. /**
  16758. * Gets or sets second associated factor
  16759. */
  16760. factor2?: number;
  16761. /**
  16762. * Will get a number picked randomly between factor1 and factor2.
  16763. * If factor2 is undefined then factor1 will be used
  16764. * @returns the picked number
  16765. */
  16766. getFactor(): number;
  16767. }
  16768. /**
  16769. * Helper used to simplify some generic gradient tasks
  16770. */
  16771. export class GradientHelper {
  16772. /**
  16773. * Gets the current gradient from an array of IValueGradient
  16774. * @param ratio defines the current ratio to get
  16775. * @param gradients defines the array of IValueGradient
  16776. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16777. */
  16778. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16779. }
  16780. }
  16781. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16782. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16783. import { Nullable } from "babylonjs/types";
  16784. module "babylonjs/Engines/thinEngine" {
  16785. interface ThinEngine {
  16786. /**
  16787. * Creates a dynamic texture
  16788. * @param width defines the width of the texture
  16789. * @param height defines the height of the texture
  16790. * @param generateMipMaps defines if the engine should generate the mip levels
  16791. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16792. * @returns the dynamic texture inside an InternalTexture
  16793. */
  16794. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16795. /**
  16796. * Update the content of a dynamic texture
  16797. * @param texture defines the texture to update
  16798. * @param canvas defines the canvas containing the source
  16799. * @param invertY defines if data must be stored with Y axis inverted
  16800. * @param premulAlpha defines if alpha is stored as premultiplied
  16801. * @param format defines the format of the data
  16802. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16803. */
  16804. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16805. }
  16806. }
  16807. }
  16808. declare module "babylonjs/Misc/canvasGenerator" {
  16809. /**
  16810. * Helper class used to generate a canvas to manipulate images
  16811. */
  16812. export class CanvasGenerator {
  16813. /**
  16814. * Create a new canvas (or offscreen canvas depending on the context)
  16815. * @param width defines the expected width
  16816. * @param height defines the expected height
  16817. * @return a new canvas or offscreen canvas
  16818. */
  16819. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16820. }
  16821. }
  16822. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16823. import { Scene } from "babylonjs/scene";
  16824. import { Texture } from "babylonjs/Materials/Textures/texture";
  16825. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16826. /**
  16827. * A class extending Texture allowing drawing on a texture
  16828. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16829. */
  16830. export class DynamicTexture extends Texture {
  16831. private _generateMipMaps;
  16832. private _canvas;
  16833. private _context;
  16834. private _engine;
  16835. /**
  16836. * Creates a DynamicTexture
  16837. * @param name defines the name of the texture
  16838. * @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
  16839. * @param scene defines the scene where you want the texture
  16840. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16841. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16842. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16843. */
  16844. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16845. /**
  16846. * Get the current class name of the texture useful for serialization or dynamic coding.
  16847. * @returns "DynamicTexture"
  16848. */
  16849. getClassName(): string;
  16850. /**
  16851. * Gets the current state of canRescale
  16852. */
  16853. get canRescale(): boolean;
  16854. private _recreate;
  16855. /**
  16856. * Scales the texture
  16857. * @param ratio the scale factor to apply to both width and height
  16858. */
  16859. scale(ratio: number): void;
  16860. /**
  16861. * Resizes the texture
  16862. * @param width the new width
  16863. * @param height the new height
  16864. */
  16865. scaleTo(width: number, height: number): void;
  16866. /**
  16867. * Gets the context of the canvas used by the texture
  16868. * @returns the canvas context of the dynamic texture
  16869. */
  16870. getContext(): CanvasRenderingContext2D;
  16871. /**
  16872. * Clears the texture
  16873. */
  16874. clear(): void;
  16875. /**
  16876. * Updates the texture
  16877. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16878. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16879. */
  16880. update(invertY?: boolean, premulAlpha?: boolean): void;
  16881. /**
  16882. * Draws text onto the texture
  16883. * @param text defines the text to be drawn
  16884. * @param x defines the placement of the text from the left
  16885. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16886. * @param font defines the font to be used with font-style, font-size, font-name
  16887. * @param color defines the color used for the text
  16888. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16889. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16890. * @param update defines whether texture is immediately update (default is true)
  16891. */
  16892. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16893. /**
  16894. * Clones the texture
  16895. * @returns the clone of the texture.
  16896. */
  16897. clone(): DynamicTexture;
  16898. /**
  16899. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16900. * @returns a serialized dynamic texture object
  16901. */
  16902. serialize(): any;
  16903. /** @hidden */
  16904. _rebuild(): void;
  16905. }
  16906. }
  16907. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16908. import { Scene } from "babylonjs/scene";
  16909. import { ISceneComponent } from "babylonjs/sceneComponent";
  16910. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16911. module "babylonjs/abstractScene" {
  16912. interface AbstractScene {
  16913. /**
  16914. * The list of procedural textures added to the scene
  16915. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16916. */
  16917. proceduralTextures: Array<ProceduralTexture>;
  16918. }
  16919. }
  16920. /**
  16921. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16922. * in a given scene.
  16923. */
  16924. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16925. /**
  16926. * The component name helpfull to identify the component in the list of scene components.
  16927. */
  16928. readonly name: string;
  16929. /**
  16930. * The scene the component belongs to.
  16931. */
  16932. scene: Scene;
  16933. /**
  16934. * Creates a new instance of the component for the given scene
  16935. * @param scene Defines the scene to register the component in
  16936. */
  16937. constructor(scene: Scene);
  16938. /**
  16939. * Registers the component in a given scene
  16940. */
  16941. register(): void;
  16942. /**
  16943. * Rebuilds the elements related to this component in case of
  16944. * context lost for instance.
  16945. */
  16946. rebuild(): void;
  16947. /**
  16948. * Disposes the component and the associated ressources.
  16949. */
  16950. dispose(): void;
  16951. private _beforeClear;
  16952. }
  16953. }
  16954. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16956. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16957. module "babylonjs/Engines/thinEngine" {
  16958. interface ThinEngine {
  16959. /**
  16960. * Creates a new render target cube texture
  16961. * @param size defines the size of the texture
  16962. * @param options defines the options used to create the texture
  16963. * @returns a new render target cube texture stored in an InternalTexture
  16964. */
  16965. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16966. }
  16967. }
  16968. }
  16969. declare module "babylonjs/Shaders/procedural.vertex" {
  16970. /** @hidden */
  16971. export var proceduralVertexShader: {
  16972. name: string;
  16973. shader: string;
  16974. };
  16975. }
  16976. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16977. import { Observable } from "babylonjs/Misc/observable";
  16978. import { Nullable } from "babylonjs/types";
  16979. import { Scene } from "babylonjs/scene";
  16980. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16981. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16982. import { Effect } from "babylonjs/Materials/effect";
  16983. import { Texture } from "babylonjs/Materials/Textures/texture";
  16984. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16985. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16986. import "babylonjs/Shaders/procedural.vertex";
  16987. /**
  16988. * 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.
  16989. * This is the base class of any Procedural texture and contains most of the shareable code.
  16990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16991. */
  16992. export class ProceduralTexture extends Texture {
  16993. isCube: boolean;
  16994. /**
  16995. * Define if the texture is enabled or not (disabled texture will not render)
  16996. */
  16997. isEnabled: boolean;
  16998. /**
  16999. * Define if the texture must be cleared before rendering (default is true)
  17000. */
  17001. autoClear: boolean;
  17002. /**
  17003. * Callback called when the texture is generated
  17004. */
  17005. onGenerated: () => void;
  17006. /**
  17007. * Event raised when the texture is generated
  17008. */
  17009. onGeneratedObservable: Observable<ProceduralTexture>;
  17010. /** @hidden */
  17011. _generateMipMaps: boolean;
  17012. /** @hidden **/
  17013. _effect: Effect;
  17014. /** @hidden */
  17015. _textures: {
  17016. [key: string]: Texture;
  17017. };
  17018. private _size;
  17019. private _currentRefreshId;
  17020. private _frameId;
  17021. private _refreshRate;
  17022. private _vertexBuffers;
  17023. private _indexBuffer;
  17024. private _uniforms;
  17025. private _samplers;
  17026. private _fragment;
  17027. private _floats;
  17028. private _ints;
  17029. private _floatsArrays;
  17030. private _colors3;
  17031. private _colors4;
  17032. private _vectors2;
  17033. private _vectors3;
  17034. private _matrices;
  17035. private _fallbackTexture;
  17036. private _fallbackTextureUsed;
  17037. private _engine;
  17038. private _cachedDefines;
  17039. private _contentUpdateId;
  17040. private _contentData;
  17041. /**
  17042. * Instantiates a new procedural texture.
  17043. * 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.
  17044. * This is the base class of any Procedural texture and contains most of the shareable code.
  17045. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17046. * @param name Define the name of the texture
  17047. * @param size Define the size of the texture to create
  17048. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17049. * @param scene Define the scene the texture belongs to
  17050. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17051. * @param generateMipMaps Define if the texture should creates mip maps or not
  17052. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17053. */
  17054. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17055. /**
  17056. * The effect that is created when initializing the post process.
  17057. * @returns The created effect corresponding the the postprocess.
  17058. */
  17059. getEffect(): Effect;
  17060. /**
  17061. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17062. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17063. */
  17064. getContent(): Nullable<ArrayBufferView>;
  17065. private _createIndexBuffer;
  17066. /** @hidden */
  17067. _rebuild(): void;
  17068. /**
  17069. * Resets the texture in order to recreate its associated resources.
  17070. * This can be called in case of context loss
  17071. */
  17072. reset(): void;
  17073. protected _getDefines(): string;
  17074. /**
  17075. * Is the texture ready to be used ? (rendered at least once)
  17076. * @returns true if ready, otherwise, false.
  17077. */
  17078. isReady(): boolean;
  17079. /**
  17080. * Resets the refresh counter of the texture and start bak from scratch.
  17081. * Could be useful to regenerate the texture if it is setup to render only once.
  17082. */
  17083. resetRefreshCounter(): void;
  17084. /**
  17085. * Set the fragment shader to use in order to render the texture.
  17086. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17087. */
  17088. setFragment(fragment: any): void;
  17089. /**
  17090. * Define the refresh rate of the texture or the rendering frequency.
  17091. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17092. */
  17093. get refreshRate(): number;
  17094. set refreshRate(value: number);
  17095. /** @hidden */
  17096. _shouldRender(): boolean;
  17097. /**
  17098. * Get the size the texture is rendering at.
  17099. * @returns the size (texture is always squared)
  17100. */
  17101. getRenderSize(): number;
  17102. /**
  17103. * Resize the texture to new value.
  17104. * @param size Define the new size the texture should have
  17105. * @param generateMipMaps Define whether the new texture should create mip maps
  17106. */
  17107. resize(size: number, generateMipMaps: boolean): void;
  17108. private _checkUniform;
  17109. /**
  17110. * Set a texture in the shader program used to render.
  17111. * @param name Define the name of the uniform samplers as defined in the shader
  17112. * @param texture Define the texture to bind to this sampler
  17113. * @return the texture itself allowing "fluent" like uniform updates
  17114. */
  17115. setTexture(name: string, texture: Texture): ProceduralTexture;
  17116. /**
  17117. * Set a float in the shader.
  17118. * @param name Define the name of the uniform as defined in the shader
  17119. * @param value Define the value to give to the uniform
  17120. * @return the texture itself allowing "fluent" like uniform updates
  17121. */
  17122. setFloat(name: string, value: number): ProceduralTexture;
  17123. /**
  17124. * Set a int in the shader.
  17125. * @param name Define the name of the uniform as defined in the shader
  17126. * @param value Define the value to give to the uniform
  17127. * @return the texture itself allowing "fluent" like uniform updates
  17128. */
  17129. setInt(name: string, value: number): ProceduralTexture;
  17130. /**
  17131. * Set an array of floats in the shader.
  17132. * @param name Define the name of the uniform as defined in the shader
  17133. * @param value Define the value to give to the uniform
  17134. * @return the texture itself allowing "fluent" like uniform updates
  17135. */
  17136. setFloats(name: string, value: number[]): ProceduralTexture;
  17137. /**
  17138. * Set a vec3 in the shader from a Color3.
  17139. * @param name Define the name of the uniform as defined in the shader
  17140. * @param value Define the value to give to the uniform
  17141. * @return the texture itself allowing "fluent" like uniform updates
  17142. */
  17143. setColor3(name: string, value: Color3): ProceduralTexture;
  17144. /**
  17145. * Set a vec4 in the shader from a Color4.
  17146. * @param name Define the name of the uniform as defined in the shader
  17147. * @param value Define the value to give to the uniform
  17148. * @return the texture itself allowing "fluent" like uniform updates
  17149. */
  17150. setColor4(name: string, value: Color4): ProceduralTexture;
  17151. /**
  17152. * Set a vec2 in the shader from a Vector2.
  17153. * @param name Define the name of the uniform as defined in the shader
  17154. * @param value Define the value to give to the uniform
  17155. * @return the texture itself allowing "fluent" like uniform updates
  17156. */
  17157. setVector2(name: string, value: Vector2): ProceduralTexture;
  17158. /**
  17159. * Set a vec3 in the shader from a Vector3.
  17160. * @param name Define the name of the uniform as defined in the shader
  17161. * @param value Define the value to give to the uniform
  17162. * @return the texture itself allowing "fluent" like uniform updates
  17163. */
  17164. setVector3(name: string, value: Vector3): ProceduralTexture;
  17165. /**
  17166. * Set a mat4 in the shader from a MAtrix.
  17167. * @param name Define the name of the uniform as defined in the shader
  17168. * @param value Define the value to give to the uniform
  17169. * @return the texture itself allowing "fluent" like uniform updates
  17170. */
  17171. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17172. /**
  17173. * Render the texture to its associated render target.
  17174. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17175. */
  17176. render(useCameraPostProcess?: boolean): void;
  17177. /**
  17178. * Clone the texture.
  17179. * @returns the cloned texture
  17180. */
  17181. clone(): ProceduralTexture;
  17182. /**
  17183. * Dispose the texture and release its asoociated resources.
  17184. */
  17185. dispose(): void;
  17186. }
  17187. }
  17188. declare module "babylonjs/Particles/baseParticleSystem" {
  17189. import { Nullable } from "babylonjs/types";
  17190. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17192. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17193. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17194. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17195. import { Scene } from "babylonjs/scene";
  17196. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17197. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17198. import { Texture } from "babylonjs/Materials/Textures/texture";
  17199. import { Color4 } from "babylonjs/Maths/math.color";
  17200. import { Animation } from "babylonjs/Animations/animation";
  17201. /**
  17202. * This represents the base class for particle system in Babylon.
  17203. * 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.
  17204. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17205. * @example https://doc.babylonjs.com/babylon101/particles
  17206. */
  17207. export class BaseParticleSystem {
  17208. /**
  17209. * Source color is added to the destination color without alpha affecting the result
  17210. */
  17211. static BLENDMODE_ONEONE: number;
  17212. /**
  17213. * Blend current color and particle color using particle’s alpha
  17214. */
  17215. static BLENDMODE_STANDARD: number;
  17216. /**
  17217. * Add current color and particle color multiplied by particle’s alpha
  17218. */
  17219. static BLENDMODE_ADD: number;
  17220. /**
  17221. * Multiply current color with particle color
  17222. */
  17223. static BLENDMODE_MULTIPLY: number;
  17224. /**
  17225. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17226. */
  17227. static BLENDMODE_MULTIPLYADD: number;
  17228. /**
  17229. * List of animations used by the particle system.
  17230. */
  17231. animations: Animation[];
  17232. /**
  17233. * The id of the Particle system.
  17234. */
  17235. id: string;
  17236. /**
  17237. * The friendly name of the Particle system.
  17238. */
  17239. name: string;
  17240. /**
  17241. * The rendering group used by the Particle system to chose when to render.
  17242. */
  17243. renderingGroupId: number;
  17244. /**
  17245. * The emitter represents the Mesh or position we are attaching the particle system to.
  17246. */
  17247. emitter: Nullable<AbstractMesh | Vector3>;
  17248. /**
  17249. * The maximum number of particles to emit per frame
  17250. */
  17251. emitRate: number;
  17252. /**
  17253. * If you want to launch only a few particles at once, that can be done, as well.
  17254. */
  17255. manualEmitCount: number;
  17256. /**
  17257. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17258. */
  17259. updateSpeed: number;
  17260. /**
  17261. * The amount of time the particle system is running (depends of the overall update speed).
  17262. */
  17263. targetStopDuration: number;
  17264. /**
  17265. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17266. */
  17267. disposeOnStop: boolean;
  17268. /**
  17269. * Minimum power of emitting particles.
  17270. */
  17271. minEmitPower: number;
  17272. /**
  17273. * Maximum power of emitting particles.
  17274. */
  17275. maxEmitPower: number;
  17276. /**
  17277. * Minimum life time of emitting particles.
  17278. */
  17279. minLifeTime: number;
  17280. /**
  17281. * Maximum life time of emitting particles.
  17282. */
  17283. maxLifeTime: number;
  17284. /**
  17285. * Minimum Size of emitting particles.
  17286. */
  17287. minSize: number;
  17288. /**
  17289. * Maximum Size of emitting particles.
  17290. */
  17291. maxSize: number;
  17292. /**
  17293. * Minimum scale of emitting particles on X axis.
  17294. */
  17295. minScaleX: number;
  17296. /**
  17297. * Maximum scale of emitting particles on X axis.
  17298. */
  17299. maxScaleX: number;
  17300. /**
  17301. * Minimum scale of emitting particles on Y axis.
  17302. */
  17303. minScaleY: number;
  17304. /**
  17305. * Maximum scale of emitting particles on Y axis.
  17306. */
  17307. maxScaleY: number;
  17308. /**
  17309. * Gets or sets the minimal initial rotation in radians.
  17310. */
  17311. minInitialRotation: number;
  17312. /**
  17313. * Gets or sets the maximal initial rotation in radians.
  17314. */
  17315. maxInitialRotation: number;
  17316. /**
  17317. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17318. */
  17319. minAngularSpeed: number;
  17320. /**
  17321. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17322. */
  17323. maxAngularSpeed: number;
  17324. /**
  17325. * The texture used to render each particle. (this can be a spritesheet)
  17326. */
  17327. particleTexture: Nullable<Texture>;
  17328. /**
  17329. * The layer mask we are rendering the particles through.
  17330. */
  17331. layerMask: number;
  17332. /**
  17333. * This can help using your own shader to render the particle system.
  17334. * The according effect will be created
  17335. */
  17336. customShader: any;
  17337. /**
  17338. * By default particle system starts as soon as they are created. This prevents the
  17339. * automatic start to happen and let you decide when to start emitting particles.
  17340. */
  17341. preventAutoStart: boolean;
  17342. private _noiseTexture;
  17343. /**
  17344. * Gets or sets a texture used to add random noise to particle positions
  17345. */
  17346. get noiseTexture(): Nullable<ProceduralTexture>;
  17347. set noiseTexture(value: Nullable<ProceduralTexture>);
  17348. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17349. noiseStrength: Vector3;
  17350. /**
  17351. * Callback triggered when the particle animation is ending.
  17352. */
  17353. onAnimationEnd: Nullable<() => void>;
  17354. /**
  17355. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17356. */
  17357. blendMode: number;
  17358. /**
  17359. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17360. * to override the particles.
  17361. */
  17362. forceDepthWrite: boolean;
  17363. /** 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 */
  17364. preWarmCycles: number;
  17365. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17366. preWarmStepOffset: number;
  17367. /**
  17368. * 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)
  17369. */
  17370. spriteCellChangeSpeed: number;
  17371. /**
  17372. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17373. */
  17374. startSpriteCellID: number;
  17375. /**
  17376. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17377. */
  17378. endSpriteCellID: number;
  17379. /**
  17380. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17381. */
  17382. spriteCellWidth: number;
  17383. /**
  17384. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17385. */
  17386. spriteCellHeight: number;
  17387. /**
  17388. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17389. */
  17390. spriteRandomStartCell: boolean;
  17391. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17392. translationPivot: Vector2;
  17393. /** @hidden */
  17394. protected _isAnimationSheetEnabled: boolean;
  17395. /**
  17396. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17397. */
  17398. beginAnimationOnStart: boolean;
  17399. /**
  17400. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17401. */
  17402. beginAnimationFrom: number;
  17403. /**
  17404. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17405. */
  17406. beginAnimationTo: number;
  17407. /**
  17408. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17409. */
  17410. beginAnimationLoop: boolean;
  17411. /**
  17412. * Gets or sets a world offset applied to all particles
  17413. */
  17414. worldOffset: Vector3;
  17415. /**
  17416. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17417. */
  17418. get isAnimationSheetEnabled(): boolean;
  17419. set isAnimationSheetEnabled(value: boolean);
  17420. /**
  17421. * Get hosting scene
  17422. * @returns the scene
  17423. */
  17424. getScene(): Scene;
  17425. /**
  17426. * You can use gravity if you want to give an orientation to your particles.
  17427. */
  17428. gravity: Vector3;
  17429. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17430. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17431. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17432. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17433. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17434. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17435. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17436. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17437. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17438. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17439. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17440. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17441. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17442. /**
  17443. * Defines the delay in milliseconds before starting the system (0 by default)
  17444. */
  17445. startDelay: number;
  17446. /**
  17447. * Gets the current list of drag gradients.
  17448. * You must use addDragGradient and removeDragGradient to udpate this list
  17449. * @returns the list of drag gradients
  17450. */
  17451. getDragGradients(): Nullable<Array<FactorGradient>>;
  17452. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17453. limitVelocityDamping: number;
  17454. /**
  17455. * Gets the current list of limit velocity gradients.
  17456. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17457. * @returns the list of limit velocity gradients
  17458. */
  17459. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17460. /**
  17461. * Gets the current list of color gradients.
  17462. * You must use addColorGradient and removeColorGradient to udpate this list
  17463. * @returns the list of color gradients
  17464. */
  17465. getColorGradients(): Nullable<Array<ColorGradient>>;
  17466. /**
  17467. * Gets the current list of size gradients.
  17468. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17469. * @returns the list of size gradients
  17470. */
  17471. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17472. /**
  17473. * Gets the current list of color remap gradients.
  17474. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17475. * @returns the list of color remap gradients
  17476. */
  17477. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17478. /**
  17479. * Gets the current list of alpha remap gradients.
  17480. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17481. * @returns the list of alpha remap gradients
  17482. */
  17483. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17484. /**
  17485. * Gets the current list of life time gradients.
  17486. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17487. * @returns the list of life time gradients
  17488. */
  17489. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17490. /**
  17491. * Gets the current list of angular speed gradients.
  17492. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17493. * @returns the list of angular speed gradients
  17494. */
  17495. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17496. /**
  17497. * Gets the current list of velocity gradients.
  17498. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17499. * @returns the list of velocity gradients
  17500. */
  17501. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17502. /**
  17503. * Gets the current list of start size gradients.
  17504. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17505. * @returns the list of start size gradients
  17506. */
  17507. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17508. /**
  17509. * Gets the current list of emit rate gradients.
  17510. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17511. * @returns the list of emit rate gradients
  17512. */
  17513. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17514. /**
  17515. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17516. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17517. */
  17518. get direction1(): Vector3;
  17519. set direction1(value: Vector3);
  17520. /**
  17521. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17522. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17523. */
  17524. get direction2(): Vector3;
  17525. set direction2(value: Vector3);
  17526. /**
  17527. * 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.
  17528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17529. */
  17530. get minEmitBox(): Vector3;
  17531. set minEmitBox(value: Vector3);
  17532. /**
  17533. * 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.
  17534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17535. */
  17536. get maxEmitBox(): Vector3;
  17537. set maxEmitBox(value: Vector3);
  17538. /**
  17539. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17540. */
  17541. color1: Color4;
  17542. /**
  17543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17544. */
  17545. color2: Color4;
  17546. /**
  17547. * Color the particle will have at the end of its lifetime
  17548. */
  17549. colorDead: Color4;
  17550. /**
  17551. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17552. */
  17553. textureMask: Color4;
  17554. /**
  17555. * The particle emitter type defines the emitter used by the particle system.
  17556. * It can be for example box, sphere, or cone...
  17557. */
  17558. particleEmitterType: IParticleEmitterType;
  17559. /** @hidden */
  17560. _isSubEmitter: boolean;
  17561. /**
  17562. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17563. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17564. */
  17565. billboardMode: number;
  17566. protected _isBillboardBased: boolean;
  17567. /**
  17568. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17569. */
  17570. get isBillboardBased(): boolean;
  17571. set isBillboardBased(value: boolean);
  17572. /**
  17573. * The scene the particle system belongs to.
  17574. */
  17575. protected _scene: Scene;
  17576. /**
  17577. * Local cache of defines for image processing.
  17578. */
  17579. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17580. /**
  17581. * Default configuration related to image processing available in the standard Material.
  17582. */
  17583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17584. /**
  17585. * Gets the image processing configuration used either in this material.
  17586. */
  17587. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17588. /**
  17589. * Sets the Default image processing configuration used either in the this material.
  17590. *
  17591. * If sets to null, the scene one is in use.
  17592. */
  17593. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17594. /**
  17595. * Attaches a new image processing configuration to the Standard Material.
  17596. * @param configuration
  17597. */
  17598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17599. /** @hidden */
  17600. protected _reset(): void;
  17601. /** @hidden */
  17602. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17603. /**
  17604. * Instantiates a particle system.
  17605. * 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.
  17606. * @param name The name of the particle system
  17607. */
  17608. constructor(name: string);
  17609. /**
  17610. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17611. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17612. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17613. * @returns the emitter
  17614. */
  17615. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17616. /**
  17617. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17618. * @param radius The radius of the hemisphere to emit from
  17619. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17620. * @returns the emitter
  17621. */
  17622. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17623. /**
  17624. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17625. * @param radius The radius of the sphere to emit from
  17626. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17627. * @returns the emitter
  17628. */
  17629. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17630. /**
  17631. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17632. * @param radius The radius of the sphere to emit from
  17633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17635. * @returns the emitter
  17636. */
  17637. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17638. /**
  17639. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17640. * @param radius The radius of the emission cylinder
  17641. * @param height The height of the emission cylinder
  17642. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17643. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17644. * @returns the emitter
  17645. */
  17646. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17647. /**
  17648. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17649. * @param radius The radius of the cylinder to emit from
  17650. * @param height The height of the emission cylinder
  17651. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17654. * @returns the emitter
  17655. */
  17656. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17657. /**
  17658. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17659. * @param radius The radius of the cone to emit from
  17660. * @param angle The base angle of the cone
  17661. * @returns the emitter
  17662. */
  17663. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17664. /**
  17665. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17668. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17669. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17670. * @returns the emitter
  17671. */
  17672. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17673. }
  17674. }
  17675. declare module "babylonjs/Particles/subEmitter" {
  17676. import { Scene } from "babylonjs/scene";
  17677. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17678. /**
  17679. * Type of sub emitter
  17680. */
  17681. export enum SubEmitterType {
  17682. /**
  17683. * Attached to the particle over it's lifetime
  17684. */
  17685. ATTACHED = 0,
  17686. /**
  17687. * Created when the particle dies
  17688. */
  17689. END = 1
  17690. }
  17691. /**
  17692. * Sub emitter class used to emit particles from an existing particle
  17693. */
  17694. export class SubEmitter {
  17695. /**
  17696. * the particle system to be used by the sub emitter
  17697. */
  17698. particleSystem: ParticleSystem;
  17699. /**
  17700. * Type of the submitter (Default: END)
  17701. */
  17702. type: SubEmitterType;
  17703. /**
  17704. * 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)
  17705. * Note: This only is supported when using an emitter of type Mesh
  17706. */
  17707. inheritDirection: boolean;
  17708. /**
  17709. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17710. */
  17711. inheritedVelocityAmount: number;
  17712. /**
  17713. * Creates a sub emitter
  17714. * @param particleSystem the particle system to be used by the sub emitter
  17715. */
  17716. constructor(
  17717. /**
  17718. * the particle system to be used by the sub emitter
  17719. */
  17720. particleSystem: ParticleSystem);
  17721. /**
  17722. * Clones the sub emitter
  17723. * @returns the cloned sub emitter
  17724. */
  17725. clone(): SubEmitter;
  17726. /**
  17727. * Serialize current object to a JSON object
  17728. * @returns the serialized object
  17729. */
  17730. serialize(): any;
  17731. /** @hidden */
  17732. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17733. /**
  17734. * Creates a new SubEmitter from a serialized JSON version
  17735. * @param serializationObject defines the JSON object to read from
  17736. * @param scene defines the hosting scene
  17737. * @param rootUrl defines the rootUrl for data loading
  17738. * @returns a new SubEmitter
  17739. */
  17740. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17741. /** Release associated resources */
  17742. dispose(): void;
  17743. }
  17744. }
  17745. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17746. /** @hidden */
  17747. export var clipPlaneFragmentDeclaration: {
  17748. name: string;
  17749. shader: string;
  17750. };
  17751. }
  17752. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17753. /** @hidden */
  17754. export var imageProcessingDeclaration: {
  17755. name: string;
  17756. shader: string;
  17757. };
  17758. }
  17759. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17760. /** @hidden */
  17761. export var imageProcessingFunctions: {
  17762. name: string;
  17763. shader: string;
  17764. };
  17765. }
  17766. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17767. /** @hidden */
  17768. export var clipPlaneFragment: {
  17769. name: string;
  17770. shader: string;
  17771. };
  17772. }
  17773. declare module "babylonjs/Shaders/particles.fragment" {
  17774. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17775. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17776. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17777. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17778. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17779. /** @hidden */
  17780. export var particlesPixelShader: {
  17781. name: string;
  17782. shader: string;
  17783. };
  17784. }
  17785. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17786. /** @hidden */
  17787. export var clipPlaneVertexDeclaration: {
  17788. name: string;
  17789. shader: string;
  17790. };
  17791. }
  17792. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17793. /** @hidden */
  17794. export var clipPlaneVertex: {
  17795. name: string;
  17796. shader: string;
  17797. };
  17798. }
  17799. declare module "babylonjs/Shaders/particles.vertex" {
  17800. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17801. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17802. /** @hidden */
  17803. export var particlesVertexShader: {
  17804. name: string;
  17805. shader: string;
  17806. };
  17807. }
  17808. declare module "babylonjs/Particles/particleSystem" {
  17809. import { Nullable } from "babylonjs/types";
  17810. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17811. import { Observable } from "babylonjs/Misc/observable";
  17812. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17813. import { Effect } from "babylonjs/Materials/effect";
  17814. import { Scene, IDisposable } from "babylonjs/scene";
  17815. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17816. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17817. import { Particle } from "babylonjs/Particles/particle";
  17818. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17819. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17820. import "babylonjs/Shaders/particles.fragment";
  17821. import "babylonjs/Shaders/particles.vertex";
  17822. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17823. /**
  17824. * This represents a particle system in Babylon.
  17825. * 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.
  17826. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17827. * @example https://doc.babylonjs.com/babylon101/particles
  17828. */
  17829. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17830. /**
  17831. * Billboard mode will only apply to Y axis
  17832. */
  17833. static readonly BILLBOARDMODE_Y: number;
  17834. /**
  17835. * Billboard mode will apply to all axes
  17836. */
  17837. static readonly BILLBOARDMODE_ALL: number;
  17838. /**
  17839. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17840. */
  17841. static readonly BILLBOARDMODE_STRETCHED: number;
  17842. /**
  17843. * This function can be defined to provide custom update for active particles.
  17844. * This function will be called instead of regular update (age, position, color, etc.).
  17845. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17846. */
  17847. updateFunction: (particles: Particle[]) => void;
  17848. private _emitterWorldMatrix;
  17849. /**
  17850. * This function can be defined to specify initial direction for every new particle.
  17851. * It by default use the emitterType defined function
  17852. */
  17853. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17854. /**
  17855. * This function can be defined to specify initial position for every new particle.
  17856. * It by default use the emitterType defined function
  17857. */
  17858. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17859. /**
  17860. * @hidden
  17861. */
  17862. _inheritedVelocityOffset: Vector3;
  17863. /**
  17864. * An event triggered when the system is disposed
  17865. */
  17866. onDisposeObservable: Observable<ParticleSystem>;
  17867. private _onDisposeObserver;
  17868. /**
  17869. * Sets a callback that will be triggered when the system is disposed
  17870. */
  17871. set onDispose(callback: () => void);
  17872. private _particles;
  17873. private _epsilon;
  17874. private _capacity;
  17875. private _stockParticles;
  17876. private _newPartsExcess;
  17877. private _vertexData;
  17878. private _vertexBuffer;
  17879. private _vertexBuffers;
  17880. private _spriteBuffer;
  17881. private _indexBuffer;
  17882. private _effect;
  17883. private _customEffect;
  17884. private _cachedDefines;
  17885. private _scaledColorStep;
  17886. private _colorDiff;
  17887. private _scaledDirection;
  17888. private _scaledGravity;
  17889. private _currentRenderId;
  17890. private _alive;
  17891. private _useInstancing;
  17892. private _started;
  17893. private _stopped;
  17894. private _actualFrame;
  17895. private _scaledUpdateSpeed;
  17896. private _vertexBufferSize;
  17897. /** @hidden */
  17898. _currentEmitRateGradient: Nullable<FactorGradient>;
  17899. /** @hidden */
  17900. _currentEmitRate1: number;
  17901. /** @hidden */
  17902. _currentEmitRate2: number;
  17903. /** @hidden */
  17904. _currentStartSizeGradient: Nullable<FactorGradient>;
  17905. /** @hidden */
  17906. _currentStartSize1: number;
  17907. /** @hidden */
  17908. _currentStartSize2: number;
  17909. private readonly _rawTextureWidth;
  17910. private _rampGradientsTexture;
  17911. private _useRampGradients;
  17912. /** Gets or sets a boolean indicating that ramp gradients must be used
  17913. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17914. */
  17915. get useRampGradients(): boolean;
  17916. set useRampGradients(value: boolean);
  17917. /**
  17918. * 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.
  17919. * 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: [])
  17920. */
  17921. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17922. private _subEmitters;
  17923. /**
  17924. * @hidden
  17925. * If the particle systems emitter should be disposed when the particle system is disposed
  17926. */
  17927. _disposeEmitterOnDispose: boolean;
  17928. /**
  17929. * The current active Sub-systems, this property is used by the root particle system only.
  17930. */
  17931. activeSubSystems: Array<ParticleSystem>;
  17932. private _rootParticleSystem;
  17933. /**
  17934. * Gets the current list of active particles
  17935. */
  17936. get particles(): Particle[];
  17937. /**
  17938. * Returns the string "ParticleSystem"
  17939. * @returns a string containing the class name
  17940. */
  17941. getClassName(): string;
  17942. /**
  17943. * Instantiates a particle system.
  17944. * 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.
  17945. * @param name The name of the particle system
  17946. * @param capacity The max number of particles alive at the same time
  17947. * @param scene The scene the particle system belongs to
  17948. * @param customEffect a custom effect used to change the way particles are rendered by default
  17949. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17950. * @param epsilon Offset used to render the particles
  17951. */
  17952. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17953. private _addFactorGradient;
  17954. private _removeFactorGradient;
  17955. /**
  17956. * Adds a new life time gradient
  17957. * @param gradient defines the gradient to use (between 0 and 1)
  17958. * @param factor defines the life time factor to affect to the specified gradient
  17959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17960. * @returns the current particle system
  17961. */
  17962. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17963. /**
  17964. * Remove a specific life time gradient
  17965. * @param gradient defines the gradient to remove
  17966. * @returns the current particle system
  17967. */
  17968. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17969. /**
  17970. * Adds a new size gradient
  17971. * @param gradient defines the gradient to use (between 0 and 1)
  17972. * @param factor defines the size factor to affect to the specified gradient
  17973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17974. * @returns the current particle system
  17975. */
  17976. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17977. /**
  17978. * Remove a specific size gradient
  17979. * @param gradient defines the gradient to remove
  17980. * @returns the current particle system
  17981. */
  17982. removeSizeGradient(gradient: number): IParticleSystem;
  17983. /**
  17984. * Adds a new color remap gradient
  17985. * @param gradient defines the gradient to use (between 0 and 1)
  17986. * @param min defines the color remap minimal range
  17987. * @param max defines the color remap maximal range
  17988. * @returns the current particle system
  17989. */
  17990. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17991. /**
  17992. * Remove a specific color remap gradient
  17993. * @param gradient defines the gradient to remove
  17994. * @returns the current particle system
  17995. */
  17996. removeColorRemapGradient(gradient: number): IParticleSystem;
  17997. /**
  17998. * Adds a new alpha remap gradient
  17999. * @param gradient defines the gradient to use (between 0 and 1)
  18000. * @param min defines the alpha remap minimal range
  18001. * @param max defines the alpha remap maximal range
  18002. * @returns the current particle system
  18003. */
  18004. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18005. /**
  18006. * Remove a specific alpha remap gradient
  18007. * @param gradient defines the gradient to remove
  18008. * @returns the current particle system
  18009. */
  18010. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18011. /**
  18012. * Adds a new angular speed gradient
  18013. * @param gradient defines the gradient to use (between 0 and 1)
  18014. * @param factor defines the angular speed to affect to the specified gradient
  18015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18016. * @returns the current particle system
  18017. */
  18018. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18019. /**
  18020. * Remove a specific angular speed gradient
  18021. * @param gradient defines the gradient to remove
  18022. * @returns the current particle system
  18023. */
  18024. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18025. /**
  18026. * Adds a new velocity gradient
  18027. * @param gradient defines the gradient to use (between 0 and 1)
  18028. * @param factor defines the velocity to affect to the specified gradient
  18029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18030. * @returns the current particle system
  18031. */
  18032. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18033. /**
  18034. * Remove a specific velocity gradient
  18035. * @param gradient defines the gradient to remove
  18036. * @returns the current particle system
  18037. */
  18038. removeVelocityGradient(gradient: number): IParticleSystem;
  18039. /**
  18040. * Adds a new limit velocity gradient
  18041. * @param gradient defines the gradient to use (between 0 and 1)
  18042. * @param factor defines the limit velocity value to affect to the specified gradient
  18043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18044. * @returns the current particle system
  18045. */
  18046. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18047. /**
  18048. * Remove a specific limit velocity gradient
  18049. * @param gradient defines the gradient to remove
  18050. * @returns the current particle system
  18051. */
  18052. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18053. /**
  18054. * Adds a new drag gradient
  18055. * @param gradient defines the gradient to use (between 0 and 1)
  18056. * @param factor defines the drag value to affect to the specified gradient
  18057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18058. * @returns the current particle system
  18059. */
  18060. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18061. /**
  18062. * Remove a specific drag gradient
  18063. * @param gradient defines the gradient to remove
  18064. * @returns the current particle system
  18065. */
  18066. removeDragGradient(gradient: number): IParticleSystem;
  18067. /**
  18068. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18069. * @param gradient defines the gradient to use (between 0 and 1)
  18070. * @param factor defines the emit rate value to affect to the specified gradient
  18071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18072. * @returns the current particle system
  18073. */
  18074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18075. /**
  18076. * Remove a specific emit rate gradient
  18077. * @param gradient defines the gradient to remove
  18078. * @returns the current particle system
  18079. */
  18080. removeEmitRateGradient(gradient: number): IParticleSystem;
  18081. /**
  18082. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18083. * @param gradient defines the gradient to use (between 0 and 1)
  18084. * @param factor defines the start size value to affect to the specified gradient
  18085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18086. * @returns the current particle system
  18087. */
  18088. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18089. /**
  18090. * Remove a specific start size gradient
  18091. * @param gradient defines the gradient to remove
  18092. * @returns the current particle system
  18093. */
  18094. removeStartSizeGradient(gradient: number): IParticleSystem;
  18095. private _createRampGradientTexture;
  18096. /**
  18097. * Gets the current list of ramp gradients.
  18098. * You must use addRampGradient and removeRampGradient to udpate this list
  18099. * @returns the list of ramp gradients
  18100. */
  18101. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18102. /**
  18103. * Adds a new ramp gradient used to remap particle colors
  18104. * @param gradient defines the gradient to use (between 0 and 1)
  18105. * @param color defines the color to affect to the specified gradient
  18106. * @returns the current particle system
  18107. */
  18108. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18109. /**
  18110. * Remove a specific ramp gradient
  18111. * @param gradient defines the gradient to remove
  18112. * @returns the current particle system
  18113. */
  18114. removeRampGradient(gradient: number): ParticleSystem;
  18115. /**
  18116. * Adds a new color gradient
  18117. * @param gradient defines the gradient to use (between 0 and 1)
  18118. * @param color1 defines the color to affect to the specified gradient
  18119. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18120. * @returns this particle system
  18121. */
  18122. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18123. /**
  18124. * Remove a specific color gradient
  18125. * @param gradient defines the gradient to remove
  18126. * @returns this particle system
  18127. */
  18128. removeColorGradient(gradient: number): IParticleSystem;
  18129. private _fetchR;
  18130. protected _reset(): void;
  18131. private _resetEffect;
  18132. private _createVertexBuffers;
  18133. private _createIndexBuffer;
  18134. /**
  18135. * Gets the maximum number of particles active at the same time.
  18136. * @returns The max number of active particles.
  18137. */
  18138. getCapacity(): number;
  18139. /**
  18140. * Gets whether there are still active particles in the system.
  18141. * @returns True if it is alive, otherwise false.
  18142. */
  18143. isAlive(): boolean;
  18144. /**
  18145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18146. * @returns True if it has been started, otherwise false.
  18147. */
  18148. isStarted(): boolean;
  18149. private _prepareSubEmitterInternalArray;
  18150. /**
  18151. * Starts the particle system and begins to emit
  18152. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18153. */
  18154. start(delay?: number): void;
  18155. /**
  18156. * Stops the particle system.
  18157. * @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.
  18158. */
  18159. stop(stopSubEmitters?: boolean): void;
  18160. /**
  18161. * Remove all active particles
  18162. */
  18163. reset(): void;
  18164. /**
  18165. * @hidden (for internal use only)
  18166. */
  18167. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18168. /**
  18169. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18170. * Its lifetime will start back at 0.
  18171. */
  18172. recycleParticle: (particle: Particle) => void;
  18173. private _stopSubEmitters;
  18174. private _createParticle;
  18175. private _removeFromRoot;
  18176. private _emitFromParticle;
  18177. private _update;
  18178. /** @hidden */
  18179. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18180. /** @hidden */
  18181. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18182. /** @hidden */
  18183. private _getEffect;
  18184. /**
  18185. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18186. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18187. */
  18188. animate(preWarmOnly?: boolean): void;
  18189. private _appendParticleVertices;
  18190. /**
  18191. * Rebuilds the particle system.
  18192. */
  18193. rebuild(): void;
  18194. /**
  18195. * Is this system ready to be used/rendered
  18196. * @return true if the system is ready
  18197. */
  18198. isReady(): boolean;
  18199. private _render;
  18200. /**
  18201. * Renders the particle system in its current state.
  18202. * @returns the current number of particles
  18203. */
  18204. render(): number;
  18205. /**
  18206. * Disposes the particle system and free the associated resources
  18207. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18208. */
  18209. dispose(disposeTexture?: boolean): void;
  18210. /**
  18211. * Clones the particle system.
  18212. * @param name The name of the cloned object
  18213. * @param newEmitter The new emitter to use
  18214. * @returns the cloned particle system
  18215. */
  18216. clone(name: string, newEmitter: any): ParticleSystem;
  18217. /**
  18218. * Serializes the particle system to a JSON object.
  18219. * @returns the JSON object
  18220. */
  18221. serialize(): any;
  18222. /** @hidden */
  18223. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18224. /** @hidden */
  18225. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18226. /**
  18227. * Parses a JSON object to create a particle system.
  18228. * @param parsedParticleSystem The JSON object to parse
  18229. * @param scene The scene to create the particle system in
  18230. * @param rootUrl The root url to use to load external dependencies like texture
  18231. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18232. * @returns the Parsed particle system
  18233. */
  18234. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18235. }
  18236. }
  18237. declare module "babylonjs/Particles/particle" {
  18238. import { Nullable } from "babylonjs/types";
  18239. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18240. import { Color4 } from "babylonjs/Maths/math.color";
  18241. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18242. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18243. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18244. /**
  18245. * A particle represents one of the element emitted by a particle system.
  18246. * This is mainly define by its coordinates, direction, velocity and age.
  18247. */
  18248. export class Particle {
  18249. /**
  18250. * The particle system the particle belongs to.
  18251. */
  18252. particleSystem: ParticleSystem;
  18253. private static _Count;
  18254. /**
  18255. * Unique ID of the particle
  18256. */
  18257. id: number;
  18258. /**
  18259. * The world position of the particle in the scene.
  18260. */
  18261. position: Vector3;
  18262. /**
  18263. * The world direction of the particle in the scene.
  18264. */
  18265. direction: Vector3;
  18266. /**
  18267. * The color of the particle.
  18268. */
  18269. color: Color4;
  18270. /**
  18271. * The color change of the particle per step.
  18272. */
  18273. colorStep: Color4;
  18274. /**
  18275. * Defines how long will the life of the particle be.
  18276. */
  18277. lifeTime: number;
  18278. /**
  18279. * The current age of the particle.
  18280. */
  18281. age: number;
  18282. /**
  18283. * The current size of the particle.
  18284. */
  18285. size: number;
  18286. /**
  18287. * The current scale of the particle.
  18288. */
  18289. scale: Vector2;
  18290. /**
  18291. * The current angle of the particle.
  18292. */
  18293. angle: number;
  18294. /**
  18295. * Defines how fast is the angle changing.
  18296. */
  18297. angularSpeed: number;
  18298. /**
  18299. * Defines the cell index used by the particle to be rendered from a sprite.
  18300. */
  18301. cellIndex: number;
  18302. /**
  18303. * The information required to support color remapping
  18304. */
  18305. remapData: Vector4;
  18306. /** @hidden */
  18307. _randomCellOffset?: number;
  18308. /** @hidden */
  18309. _initialDirection: Nullable<Vector3>;
  18310. /** @hidden */
  18311. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18312. /** @hidden */
  18313. _initialStartSpriteCellID: number;
  18314. /** @hidden */
  18315. _initialEndSpriteCellID: number;
  18316. /** @hidden */
  18317. _currentColorGradient: Nullable<ColorGradient>;
  18318. /** @hidden */
  18319. _currentColor1: Color4;
  18320. /** @hidden */
  18321. _currentColor2: Color4;
  18322. /** @hidden */
  18323. _currentSizeGradient: Nullable<FactorGradient>;
  18324. /** @hidden */
  18325. _currentSize1: number;
  18326. /** @hidden */
  18327. _currentSize2: number;
  18328. /** @hidden */
  18329. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18330. /** @hidden */
  18331. _currentAngularSpeed1: number;
  18332. /** @hidden */
  18333. _currentAngularSpeed2: number;
  18334. /** @hidden */
  18335. _currentVelocityGradient: Nullable<FactorGradient>;
  18336. /** @hidden */
  18337. _currentVelocity1: number;
  18338. /** @hidden */
  18339. _currentVelocity2: number;
  18340. /** @hidden */
  18341. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18342. /** @hidden */
  18343. _currentLimitVelocity1: number;
  18344. /** @hidden */
  18345. _currentLimitVelocity2: number;
  18346. /** @hidden */
  18347. _currentDragGradient: Nullable<FactorGradient>;
  18348. /** @hidden */
  18349. _currentDrag1: number;
  18350. /** @hidden */
  18351. _currentDrag2: number;
  18352. /** @hidden */
  18353. _randomNoiseCoordinates1: Vector3;
  18354. /** @hidden */
  18355. _randomNoiseCoordinates2: Vector3;
  18356. /**
  18357. * Creates a new instance Particle
  18358. * @param particleSystem the particle system the particle belongs to
  18359. */
  18360. constructor(
  18361. /**
  18362. * The particle system the particle belongs to.
  18363. */
  18364. particleSystem: ParticleSystem);
  18365. private updateCellInfoFromSystem;
  18366. /**
  18367. * Defines how the sprite cell index is updated for the particle
  18368. */
  18369. updateCellIndex(): void;
  18370. /** @hidden */
  18371. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18372. /** @hidden */
  18373. _inheritParticleInfoToSubEmitters(): void;
  18374. /** @hidden */
  18375. _reset(): void;
  18376. /**
  18377. * Copy the properties of particle to another one.
  18378. * @param other the particle to copy the information to.
  18379. */
  18380. copyTo(other: Particle): void;
  18381. }
  18382. }
  18383. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18384. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18385. import { Effect } from "babylonjs/Materials/effect";
  18386. import { Particle } from "babylonjs/Particles/particle";
  18387. /**
  18388. * Particle emitter represents a volume emitting particles.
  18389. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18390. */
  18391. export interface IParticleEmitterType {
  18392. /**
  18393. * Called by the particle System when the direction is computed for the created particle.
  18394. * @param worldMatrix is the world matrix of the particle system
  18395. * @param directionToUpdate is the direction vector to update with the result
  18396. * @param particle is the particle we are computed the direction for
  18397. */
  18398. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18399. /**
  18400. * Called by the particle System when the position is computed for the created particle.
  18401. * @param worldMatrix is the world matrix of the particle system
  18402. * @param positionToUpdate is the position vector to update with the result
  18403. * @param particle is the particle we are computed the position for
  18404. */
  18405. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18406. /**
  18407. * Clones the current emitter and returns a copy of it
  18408. * @returns the new emitter
  18409. */
  18410. clone(): IParticleEmitterType;
  18411. /**
  18412. * Called by the GPUParticleSystem to setup the update shader
  18413. * @param effect defines the update shader
  18414. */
  18415. applyToShader(effect: Effect): void;
  18416. /**
  18417. * Returns a string to use to update the GPU particles update shader
  18418. * @returns the effect defines string
  18419. */
  18420. getEffectDefines(): string;
  18421. /**
  18422. * Returns a string representing the class name
  18423. * @returns a string containing the class name
  18424. */
  18425. getClassName(): string;
  18426. /**
  18427. * Serializes the particle system to a JSON object.
  18428. * @returns the JSON object
  18429. */
  18430. serialize(): any;
  18431. /**
  18432. * Parse properties from a JSON object
  18433. * @param serializationObject defines the JSON object
  18434. */
  18435. parse(serializationObject: any): void;
  18436. }
  18437. }
  18438. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18439. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18440. import { Effect } from "babylonjs/Materials/effect";
  18441. import { Particle } from "babylonjs/Particles/particle";
  18442. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18443. /**
  18444. * Particle emitter emitting particles from the inside of a box.
  18445. * It emits the particles randomly between 2 given directions.
  18446. */
  18447. export class BoxParticleEmitter implements IParticleEmitterType {
  18448. /**
  18449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18450. */
  18451. direction1: Vector3;
  18452. /**
  18453. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18454. */
  18455. direction2: Vector3;
  18456. /**
  18457. * 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.
  18458. */
  18459. minEmitBox: Vector3;
  18460. /**
  18461. * 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.
  18462. */
  18463. maxEmitBox: Vector3;
  18464. /**
  18465. * Creates a new instance BoxParticleEmitter
  18466. */
  18467. constructor();
  18468. /**
  18469. * Called by the particle System when the direction is computed for the created particle.
  18470. * @param worldMatrix is the world matrix of the particle system
  18471. * @param directionToUpdate is the direction vector to update with the result
  18472. * @param particle is the particle we are computed the direction for
  18473. */
  18474. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18475. /**
  18476. * Called by the particle System when the position is computed for the created particle.
  18477. * @param worldMatrix is the world matrix of the particle system
  18478. * @param positionToUpdate is the position vector to update with the result
  18479. * @param particle is the particle we are computed the position for
  18480. */
  18481. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18482. /**
  18483. * Clones the current emitter and returns a copy of it
  18484. * @returns the new emitter
  18485. */
  18486. clone(): BoxParticleEmitter;
  18487. /**
  18488. * Called by the GPUParticleSystem to setup the update shader
  18489. * @param effect defines the update shader
  18490. */
  18491. applyToShader(effect: Effect): void;
  18492. /**
  18493. * Returns a string to use to update the GPU particles update shader
  18494. * @returns a string containng the defines string
  18495. */
  18496. getEffectDefines(): string;
  18497. /**
  18498. * Returns the string "BoxParticleEmitter"
  18499. * @returns a string containing the class name
  18500. */
  18501. getClassName(): string;
  18502. /**
  18503. * Serializes the particle system to a JSON object.
  18504. * @returns the JSON object
  18505. */
  18506. serialize(): any;
  18507. /**
  18508. * Parse properties from a JSON object
  18509. * @param serializationObject defines the JSON object
  18510. */
  18511. parse(serializationObject: any): void;
  18512. }
  18513. }
  18514. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18515. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18516. import { Effect } from "babylonjs/Materials/effect";
  18517. import { Particle } from "babylonjs/Particles/particle";
  18518. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18519. /**
  18520. * Particle emitter emitting particles from the inside of a cone.
  18521. * It emits the particles alongside the cone volume from the base to the particle.
  18522. * The emission direction might be randomized.
  18523. */
  18524. export class ConeParticleEmitter implements IParticleEmitterType {
  18525. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18526. directionRandomizer: number;
  18527. private _radius;
  18528. private _angle;
  18529. private _height;
  18530. /**
  18531. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18532. */
  18533. radiusRange: number;
  18534. /**
  18535. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18536. */
  18537. heightRange: number;
  18538. /**
  18539. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18540. */
  18541. emitFromSpawnPointOnly: boolean;
  18542. /**
  18543. * Gets or sets the radius of the emission cone
  18544. */
  18545. get radius(): number;
  18546. set radius(value: number);
  18547. /**
  18548. * Gets or sets the angle of the emission cone
  18549. */
  18550. get angle(): number;
  18551. set angle(value: number);
  18552. private _buildHeight;
  18553. /**
  18554. * Creates a new instance ConeParticleEmitter
  18555. * @param radius the radius of the emission cone (1 by default)
  18556. * @param angle the cone base angle (PI by default)
  18557. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18558. */
  18559. constructor(radius?: number, angle?: number,
  18560. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18561. directionRandomizer?: number);
  18562. /**
  18563. * Called by the particle System when the direction is computed for the created particle.
  18564. * @param worldMatrix is the world matrix of the particle system
  18565. * @param directionToUpdate is the direction vector to update with the result
  18566. * @param particle is the particle we are computed the direction for
  18567. */
  18568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18569. /**
  18570. * Called by the particle System when the position is computed for the created particle.
  18571. * @param worldMatrix is the world matrix of the particle system
  18572. * @param positionToUpdate is the position vector to update with the result
  18573. * @param particle is the particle we are computed the position for
  18574. */
  18575. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18576. /**
  18577. * Clones the current emitter and returns a copy of it
  18578. * @returns the new emitter
  18579. */
  18580. clone(): ConeParticleEmitter;
  18581. /**
  18582. * Called by the GPUParticleSystem to setup the update shader
  18583. * @param effect defines the update shader
  18584. */
  18585. applyToShader(effect: Effect): void;
  18586. /**
  18587. * Returns a string to use to update the GPU particles update shader
  18588. * @returns a string containng the defines string
  18589. */
  18590. getEffectDefines(): string;
  18591. /**
  18592. * Returns the string "ConeParticleEmitter"
  18593. * @returns a string containing the class name
  18594. */
  18595. getClassName(): string;
  18596. /**
  18597. * Serializes the particle system to a JSON object.
  18598. * @returns the JSON object
  18599. */
  18600. serialize(): any;
  18601. /**
  18602. * Parse properties from a JSON object
  18603. * @param serializationObject defines the JSON object
  18604. */
  18605. parse(serializationObject: any): void;
  18606. }
  18607. }
  18608. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18609. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18610. import { Effect } from "babylonjs/Materials/effect";
  18611. import { Particle } from "babylonjs/Particles/particle";
  18612. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18613. /**
  18614. * Particle emitter emitting particles from the inside of a cylinder.
  18615. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18616. */
  18617. export class CylinderParticleEmitter implements IParticleEmitterType {
  18618. /**
  18619. * The radius of the emission cylinder.
  18620. */
  18621. radius: number;
  18622. /**
  18623. * The height of the emission cylinder.
  18624. */
  18625. height: number;
  18626. /**
  18627. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18628. */
  18629. radiusRange: number;
  18630. /**
  18631. * How much to randomize the particle direction [0-1].
  18632. */
  18633. directionRandomizer: number;
  18634. /**
  18635. * Creates a new instance CylinderParticleEmitter
  18636. * @param radius the radius of the emission cylinder (1 by default)
  18637. * @param height the height of the emission cylinder (1 by default)
  18638. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18639. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18640. */
  18641. constructor(
  18642. /**
  18643. * The radius of the emission cylinder.
  18644. */
  18645. radius?: number,
  18646. /**
  18647. * The height of the emission cylinder.
  18648. */
  18649. height?: number,
  18650. /**
  18651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18652. */
  18653. radiusRange?: number,
  18654. /**
  18655. * How much to randomize the particle direction [0-1].
  18656. */
  18657. directionRandomizer?: number);
  18658. /**
  18659. * Called by the particle System when the direction is computed for the created particle.
  18660. * @param worldMatrix is the world matrix of the particle system
  18661. * @param directionToUpdate is the direction vector to update with the result
  18662. * @param particle is the particle we are computed the direction for
  18663. */
  18664. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18665. /**
  18666. * Called by the particle System when the position is computed for the created particle.
  18667. * @param worldMatrix is the world matrix of the particle system
  18668. * @param positionToUpdate is the position vector to update with the result
  18669. * @param particle is the particle we are computed the position for
  18670. */
  18671. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18672. /**
  18673. * Clones the current emitter and returns a copy of it
  18674. * @returns the new emitter
  18675. */
  18676. clone(): CylinderParticleEmitter;
  18677. /**
  18678. * Called by the GPUParticleSystem to setup the update shader
  18679. * @param effect defines the update shader
  18680. */
  18681. applyToShader(effect: Effect): void;
  18682. /**
  18683. * Returns a string to use to update the GPU particles update shader
  18684. * @returns a string containng the defines string
  18685. */
  18686. getEffectDefines(): string;
  18687. /**
  18688. * Returns the string "CylinderParticleEmitter"
  18689. * @returns a string containing the class name
  18690. */
  18691. getClassName(): string;
  18692. /**
  18693. * Serializes the particle system to a JSON object.
  18694. * @returns the JSON object
  18695. */
  18696. serialize(): any;
  18697. /**
  18698. * Parse properties from a JSON object
  18699. * @param serializationObject defines the JSON object
  18700. */
  18701. parse(serializationObject: any): void;
  18702. }
  18703. /**
  18704. * Particle emitter emitting particles from the inside of a cylinder.
  18705. * It emits the particles randomly between two vectors.
  18706. */
  18707. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18708. /**
  18709. * The min limit of the emission direction.
  18710. */
  18711. direction1: Vector3;
  18712. /**
  18713. * The max limit of the emission direction.
  18714. */
  18715. direction2: Vector3;
  18716. /**
  18717. * Creates a new instance CylinderDirectedParticleEmitter
  18718. * @param radius the radius of the emission cylinder (1 by default)
  18719. * @param height the height of the emission cylinder (1 by default)
  18720. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18721. * @param direction1 the min limit of the emission direction (up vector by default)
  18722. * @param direction2 the max limit of the emission direction (up vector by default)
  18723. */
  18724. constructor(radius?: number, height?: number, radiusRange?: number,
  18725. /**
  18726. * The min limit of the emission direction.
  18727. */
  18728. direction1?: Vector3,
  18729. /**
  18730. * The max limit of the emission direction.
  18731. */
  18732. direction2?: Vector3);
  18733. /**
  18734. * Called by the particle System when the direction is computed for the created particle.
  18735. * @param worldMatrix is the world matrix of the particle system
  18736. * @param directionToUpdate is the direction vector to update with the result
  18737. * @param particle is the particle we are computed the direction for
  18738. */
  18739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18740. /**
  18741. * Clones the current emitter and returns a copy of it
  18742. * @returns the new emitter
  18743. */
  18744. clone(): CylinderDirectedParticleEmitter;
  18745. /**
  18746. * Called by the GPUParticleSystem to setup the update shader
  18747. * @param effect defines the update shader
  18748. */
  18749. applyToShader(effect: Effect): void;
  18750. /**
  18751. * Returns a string to use to update the GPU particles update shader
  18752. * @returns a string containng the defines string
  18753. */
  18754. getEffectDefines(): string;
  18755. /**
  18756. * Returns the string "CylinderDirectedParticleEmitter"
  18757. * @returns a string containing the class name
  18758. */
  18759. getClassName(): string;
  18760. /**
  18761. * Serializes the particle system to a JSON object.
  18762. * @returns the JSON object
  18763. */
  18764. serialize(): any;
  18765. /**
  18766. * Parse properties from a JSON object
  18767. * @param serializationObject defines the JSON object
  18768. */
  18769. parse(serializationObject: any): void;
  18770. }
  18771. }
  18772. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18773. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18774. import { Effect } from "babylonjs/Materials/effect";
  18775. import { Particle } from "babylonjs/Particles/particle";
  18776. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18777. /**
  18778. * Particle emitter emitting particles from the inside of a hemisphere.
  18779. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18780. */
  18781. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18782. /**
  18783. * The radius of the emission hemisphere.
  18784. */
  18785. radius: number;
  18786. /**
  18787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18788. */
  18789. radiusRange: number;
  18790. /**
  18791. * How much to randomize the particle direction [0-1].
  18792. */
  18793. directionRandomizer: number;
  18794. /**
  18795. * Creates a new instance HemisphericParticleEmitter
  18796. * @param radius the radius of the emission hemisphere (1 by default)
  18797. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18798. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18799. */
  18800. constructor(
  18801. /**
  18802. * The radius of the emission hemisphere.
  18803. */
  18804. radius?: number,
  18805. /**
  18806. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18807. */
  18808. radiusRange?: number,
  18809. /**
  18810. * How much to randomize the particle direction [0-1].
  18811. */
  18812. directionRandomizer?: number);
  18813. /**
  18814. * Called by the particle System when the direction is computed for the created particle.
  18815. * @param worldMatrix is the world matrix of the particle system
  18816. * @param directionToUpdate is the direction vector to update with the result
  18817. * @param particle is the particle we are computed the direction for
  18818. */
  18819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18820. /**
  18821. * Called by the particle System when the position is computed for the created particle.
  18822. * @param worldMatrix is the world matrix of the particle system
  18823. * @param positionToUpdate is the position vector to update with the result
  18824. * @param particle is the particle we are computed the position for
  18825. */
  18826. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18827. /**
  18828. * Clones the current emitter and returns a copy of it
  18829. * @returns the new emitter
  18830. */
  18831. clone(): HemisphericParticleEmitter;
  18832. /**
  18833. * Called by the GPUParticleSystem to setup the update shader
  18834. * @param effect defines the update shader
  18835. */
  18836. applyToShader(effect: Effect): void;
  18837. /**
  18838. * Returns a string to use to update the GPU particles update shader
  18839. * @returns a string containng the defines string
  18840. */
  18841. getEffectDefines(): string;
  18842. /**
  18843. * Returns the string "HemisphericParticleEmitter"
  18844. * @returns a string containing the class name
  18845. */
  18846. getClassName(): string;
  18847. /**
  18848. * Serializes the particle system to a JSON object.
  18849. * @returns the JSON object
  18850. */
  18851. serialize(): any;
  18852. /**
  18853. * Parse properties from a JSON object
  18854. * @param serializationObject defines the JSON object
  18855. */
  18856. parse(serializationObject: any): void;
  18857. }
  18858. }
  18859. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18860. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18861. import { Effect } from "babylonjs/Materials/effect";
  18862. import { Particle } from "babylonjs/Particles/particle";
  18863. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18864. /**
  18865. * Particle emitter emitting particles from a point.
  18866. * It emits the particles randomly between 2 given directions.
  18867. */
  18868. export class PointParticleEmitter implements IParticleEmitterType {
  18869. /**
  18870. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18871. */
  18872. direction1: Vector3;
  18873. /**
  18874. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18875. */
  18876. direction2: Vector3;
  18877. /**
  18878. * Creates a new instance PointParticleEmitter
  18879. */
  18880. constructor();
  18881. /**
  18882. * Called by the particle System when the direction is computed for the created particle.
  18883. * @param worldMatrix is the world matrix of the particle system
  18884. * @param directionToUpdate is the direction vector to update with the result
  18885. * @param particle is the particle we are computed the direction for
  18886. */
  18887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18888. /**
  18889. * Called by the particle System when the position is computed for the created particle.
  18890. * @param worldMatrix is the world matrix of the particle system
  18891. * @param positionToUpdate is the position vector to update with the result
  18892. * @param particle is the particle we are computed the position for
  18893. */
  18894. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18895. /**
  18896. * Clones the current emitter and returns a copy of it
  18897. * @returns the new emitter
  18898. */
  18899. clone(): PointParticleEmitter;
  18900. /**
  18901. * Called by the GPUParticleSystem to setup the update shader
  18902. * @param effect defines the update shader
  18903. */
  18904. applyToShader(effect: Effect): void;
  18905. /**
  18906. * Returns a string to use to update the GPU particles update shader
  18907. * @returns a string containng the defines string
  18908. */
  18909. getEffectDefines(): string;
  18910. /**
  18911. * Returns the string "PointParticleEmitter"
  18912. * @returns a string containing the class name
  18913. */
  18914. getClassName(): string;
  18915. /**
  18916. * Serializes the particle system to a JSON object.
  18917. * @returns the JSON object
  18918. */
  18919. serialize(): any;
  18920. /**
  18921. * Parse properties from a JSON object
  18922. * @param serializationObject defines the JSON object
  18923. */
  18924. parse(serializationObject: any): void;
  18925. }
  18926. }
  18927. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18928. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18929. import { Effect } from "babylonjs/Materials/effect";
  18930. import { Particle } from "babylonjs/Particles/particle";
  18931. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18932. /**
  18933. * Particle emitter emitting particles from the inside of a sphere.
  18934. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18935. */
  18936. export class SphereParticleEmitter implements IParticleEmitterType {
  18937. /**
  18938. * The radius of the emission sphere.
  18939. */
  18940. radius: number;
  18941. /**
  18942. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18943. */
  18944. radiusRange: number;
  18945. /**
  18946. * How much to randomize the particle direction [0-1].
  18947. */
  18948. directionRandomizer: number;
  18949. /**
  18950. * Creates a new instance SphereParticleEmitter
  18951. * @param radius the radius of the emission sphere (1 by default)
  18952. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18953. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18954. */
  18955. constructor(
  18956. /**
  18957. * The radius of the emission sphere.
  18958. */
  18959. radius?: number,
  18960. /**
  18961. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18962. */
  18963. radiusRange?: number,
  18964. /**
  18965. * How much to randomize the particle direction [0-1].
  18966. */
  18967. directionRandomizer?: number);
  18968. /**
  18969. * Called by the particle System when the direction is computed for the created particle.
  18970. * @param worldMatrix is the world matrix of the particle system
  18971. * @param directionToUpdate is the direction vector to update with the result
  18972. * @param particle is the particle we are computed the direction for
  18973. */
  18974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18975. /**
  18976. * Called by the particle System when the position is computed for the created particle.
  18977. * @param worldMatrix is the world matrix of the particle system
  18978. * @param positionToUpdate is the position vector to update with the result
  18979. * @param particle is the particle we are computed the position for
  18980. */
  18981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18982. /**
  18983. * Clones the current emitter and returns a copy of it
  18984. * @returns the new emitter
  18985. */
  18986. clone(): SphereParticleEmitter;
  18987. /**
  18988. * Called by the GPUParticleSystem to setup the update shader
  18989. * @param effect defines the update shader
  18990. */
  18991. applyToShader(effect: Effect): void;
  18992. /**
  18993. * Returns a string to use to update the GPU particles update shader
  18994. * @returns a string containng the defines string
  18995. */
  18996. getEffectDefines(): string;
  18997. /**
  18998. * Returns the string "SphereParticleEmitter"
  18999. * @returns a string containing the class name
  19000. */
  19001. getClassName(): string;
  19002. /**
  19003. * Serializes the particle system to a JSON object.
  19004. * @returns the JSON object
  19005. */
  19006. serialize(): any;
  19007. /**
  19008. * Parse properties from a JSON object
  19009. * @param serializationObject defines the JSON object
  19010. */
  19011. parse(serializationObject: any): void;
  19012. }
  19013. /**
  19014. * Particle emitter emitting particles from the inside of a sphere.
  19015. * It emits the particles randomly between two vectors.
  19016. */
  19017. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19018. /**
  19019. * The min limit of the emission direction.
  19020. */
  19021. direction1: Vector3;
  19022. /**
  19023. * The max limit of the emission direction.
  19024. */
  19025. direction2: Vector3;
  19026. /**
  19027. * Creates a new instance SphereDirectedParticleEmitter
  19028. * @param radius the radius of the emission sphere (1 by default)
  19029. * @param direction1 the min limit of the emission direction (up vector by default)
  19030. * @param direction2 the max limit of the emission direction (up vector by default)
  19031. */
  19032. constructor(radius?: number,
  19033. /**
  19034. * The min limit of the emission direction.
  19035. */
  19036. direction1?: Vector3,
  19037. /**
  19038. * The max limit of the emission direction.
  19039. */
  19040. direction2?: Vector3);
  19041. /**
  19042. * Called by the particle System when the direction is computed for the created particle.
  19043. * @param worldMatrix is the world matrix of the particle system
  19044. * @param directionToUpdate is the direction vector to update with the result
  19045. * @param particle is the particle we are computed the direction for
  19046. */
  19047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19048. /**
  19049. * Clones the current emitter and returns a copy of it
  19050. * @returns the new emitter
  19051. */
  19052. clone(): SphereDirectedParticleEmitter;
  19053. /**
  19054. * Called by the GPUParticleSystem to setup the update shader
  19055. * @param effect defines the update shader
  19056. */
  19057. applyToShader(effect: Effect): void;
  19058. /**
  19059. * Returns a string to use to update the GPU particles update shader
  19060. * @returns a string containng the defines string
  19061. */
  19062. getEffectDefines(): string;
  19063. /**
  19064. * Returns the string "SphereDirectedParticleEmitter"
  19065. * @returns a string containing the class name
  19066. */
  19067. getClassName(): string;
  19068. /**
  19069. * Serializes the particle system to a JSON object.
  19070. * @returns the JSON object
  19071. */
  19072. serialize(): any;
  19073. /**
  19074. * Parse properties from a JSON object
  19075. * @param serializationObject defines the JSON object
  19076. */
  19077. parse(serializationObject: any): void;
  19078. }
  19079. }
  19080. declare module "babylonjs/Particles/EmitterTypes/index" {
  19081. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19082. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19083. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19084. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19085. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19086. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19087. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19088. }
  19089. declare module "babylonjs/Particles/IParticleSystem" {
  19090. import { Nullable } from "babylonjs/types";
  19091. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19092. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19095. import { Texture } from "babylonjs/Materials/Textures/texture";
  19096. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19097. import { Scene } from "babylonjs/scene";
  19098. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19099. import { Animation } from "babylonjs/Animations/animation";
  19100. /**
  19101. * Interface representing a particle system in Babylon.js.
  19102. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19103. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19104. */
  19105. export interface IParticleSystem {
  19106. /**
  19107. * List of animations used by the particle system.
  19108. */
  19109. animations: Animation[];
  19110. /**
  19111. * The id of the Particle system.
  19112. */
  19113. id: string;
  19114. /**
  19115. * The name of the Particle system.
  19116. */
  19117. name: string;
  19118. /**
  19119. * The emitter represents the Mesh or position we are attaching the particle system to.
  19120. */
  19121. emitter: Nullable<AbstractMesh | Vector3>;
  19122. /**
  19123. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19124. */
  19125. isBillboardBased: boolean;
  19126. /**
  19127. * The rendering group used by the Particle system to chose when to render.
  19128. */
  19129. renderingGroupId: number;
  19130. /**
  19131. * The layer mask we are rendering the particles through.
  19132. */
  19133. layerMask: number;
  19134. /**
  19135. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19136. */
  19137. updateSpeed: number;
  19138. /**
  19139. * The amount of time the particle system is running (depends of the overall update speed).
  19140. */
  19141. targetStopDuration: number;
  19142. /**
  19143. * The texture used to render each particle. (this can be a spritesheet)
  19144. */
  19145. particleTexture: Nullable<Texture>;
  19146. /**
  19147. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19148. */
  19149. blendMode: number;
  19150. /**
  19151. * Minimum life time of emitting particles.
  19152. */
  19153. minLifeTime: number;
  19154. /**
  19155. * Maximum life time of emitting particles.
  19156. */
  19157. maxLifeTime: number;
  19158. /**
  19159. * Minimum Size of emitting particles.
  19160. */
  19161. minSize: number;
  19162. /**
  19163. * Maximum Size of emitting particles.
  19164. */
  19165. maxSize: number;
  19166. /**
  19167. * Minimum scale of emitting particles on X axis.
  19168. */
  19169. minScaleX: number;
  19170. /**
  19171. * Maximum scale of emitting particles on X axis.
  19172. */
  19173. maxScaleX: number;
  19174. /**
  19175. * Minimum scale of emitting particles on Y axis.
  19176. */
  19177. minScaleY: number;
  19178. /**
  19179. * Maximum scale of emitting particles on Y axis.
  19180. */
  19181. maxScaleY: number;
  19182. /**
  19183. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19184. */
  19185. color1: Color4;
  19186. /**
  19187. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19188. */
  19189. color2: Color4;
  19190. /**
  19191. * Color the particle will have at the end of its lifetime.
  19192. */
  19193. colorDead: Color4;
  19194. /**
  19195. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19196. */
  19197. emitRate: number;
  19198. /**
  19199. * You can use gravity if you want to give an orientation to your particles.
  19200. */
  19201. gravity: Vector3;
  19202. /**
  19203. * Minimum power of emitting particles.
  19204. */
  19205. minEmitPower: number;
  19206. /**
  19207. * Maximum power of emitting particles.
  19208. */
  19209. maxEmitPower: number;
  19210. /**
  19211. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19212. */
  19213. minAngularSpeed: number;
  19214. /**
  19215. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19216. */
  19217. maxAngularSpeed: number;
  19218. /**
  19219. * Gets or sets the minimal initial rotation in radians.
  19220. */
  19221. minInitialRotation: number;
  19222. /**
  19223. * Gets or sets the maximal initial rotation in radians.
  19224. */
  19225. maxInitialRotation: number;
  19226. /**
  19227. * The particle emitter type defines the emitter used by the particle system.
  19228. * It can be for example box, sphere, or cone...
  19229. */
  19230. particleEmitterType: Nullable<IParticleEmitterType>;
  19231. /**
  19232. * Defines the delay in milliseconds before starting the system (0 by default)
  19233. */
  19234. startDelay: number;
  19235. /**
  19236. * 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
  19237. */
  19238. preWarmCycles: number;
  19239. /**
  19240. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19241. */
  19242. preWarmStepOffset: number;
  19243. /**
  19244. * 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)
  19245. */
  19246. spriteCellChangeSpeed: number;
  19247. /**
  19248. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19249. */
  19250. startSpriteCellID: number;
  19251. /**
  19252. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19253. */
  19254. endSpriteCellID: number;
  19255. /**
  19256. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19257. */
  19258. spriteCellWidth: number;
  19259. /**
  19260. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19261. */
  19262. spriteCellHeight: number;
  19263. /**
  19264. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19265. */
  19266. spriteRandomStartCell: boolean;
  19267. /**
  19268. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19269. */
  19270. isAnimationSheetEnabled: boolean;
  19271. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19272. translationPivot: Vector2;
  19273. /**
  19274. * Gets or sets a texture used to add random noise to particle positions
  19275. */
  19276. noiseTexture: Nullable<BaseTexture>;
  19277. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19278. noiseStrength: Vector3;
  19279. /**
  19280. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19281. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19282. */
  19283. billboardMode: number;
  19284. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19285. limitVelocityDamping: number;
  19286. /**
  19287. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19288. */
  19289. beginAnimationOnStart: boolean;
  19290. /**
  19291. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19292. */
  19293. beginAnimationFrom: number;
  19294. /**
  19295. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19296. */
  19297. beginAnimationTo: number;
  19298. /**
  19299. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19300. */
  19301. beginAnimationLoop: boolean;
  19302. /**
  19303. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19304. */
  19305. disposeOnStop: boolean;
  19306. /**
  19307. * Gets the maximum number of particles active at the same time.
  19308. * @returns The max number of active particles.
  19309. */
  19310. getCapacity(): number;
  19311. /**
  19312. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19313. * @returns True if it has been started, otherwise false.
  19314. */
  19315. isStarted(): boolean;
  19316. /**
  19317. * Animates the particle system for this frame.
  19318. */
  19319. animate(): void;
  19320. /**
  19321. * Renders the particle system in its current state.
  19322. * @returns the current number of particles
  19323. */
  19324. render(): number;
  19325. /**
  19326. * Dispose the particle system and frees its associated resources.
  19327. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19328. */
  19329. dispose(disposeTexture?: boolean): void;
  19330. /**
  19331. * Clones the particle system.
  19332. * @param name The name of the cloned object
  19333. * @param newEmitter The new emitter to use
  19334. * @returns the cloned particle system
  19335. */
  19336. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19337. /**
  19338. * Serializes the particle system to a JSON object.
  19339. * @returns the JSON object
  19340. */
  19341. serialize(): any;
  19342. /**
  19343. * Rebuild the particle system
  19344. */
  19345. rebuild(): void;
  19346. /**
  19347. * Starts the particle system and begins to emit
  19348. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19349. */
  19350. start(delay?: number): void;
  19351. /**
  19352. * Stops the particle system.
  19353. */
  19354. stop(): void;
  19355. /**
  19356. * Remove all active particles
  19357. */
  19358. reset(): void;
  19359. /**
  19360. * Is this system ready to be used/rendered
  19361. * @return true if the system is ready
  19362. */
  19363. isReady(): boolean;
  19364. /**
  19365. * Adds a new color gradient
  19366. * @param gradient defines the gradient to use (between 0 and 1)
  19367. * @param color1 defines the color to affect to the specified gradient
  19368. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19369. * @returns the current particle system
  19370. */
  19371. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19372. /**
  19373. * Remove a specific color gradient
  19374. * @param gradient defines the gradient to remove
  19375. * @returns the current particle system
  19376. */
  19377. removeColorGradient(gradient: number): IParticleSystem;
  19378. /**
  19379. * Adds a new size gradient
  19380. * @param gradient defines the gradient to use (between 0 and 1)
  19381. * @param factor defines the size factor to affect to the specified gradient
  19382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19383. * @returns the current particle system
  19384. */
  19385. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19386. /**
  19387. * Remove a specific size gradient
  19388. * @param gradient defines the gradient to remove
  19389. * @returns the current particle system
  19390. */
  19391. removeSizeGradient(gradient: number): IParticleSystem;
  19392. /**
  19393. * Gets the current list of color gradients.
  19394. * You must use addColorGradient and removeColorGradient to udpate this list
  19395. * @returns the list of color gradients
  19396. */
  19397. getColorGradients(): Nullable<Array<ColorGradient>>;
  19398. /**
  19399. * Gets the current list of size gradients.
  19400. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19401. * @returns the list of size gradients
  19402. */
  19403. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19404. /**
  19405. * Gets the current list of angular speed gradients.
  19406. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19407. * @returns the list of angular speed gradients
  19408. */
  19409. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19410. /**
  19411. * Adds a new angular speed gradient
  19412. * @param gradient defines the gradient to use (between 0 and 1)
  19413. * @param factor defines the angular speed to affect to the specified gradient
  19414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19415. * @returns the current particle system
  19416. */
  19417. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19418. /**
  19419. * Remove a specific angular speed gradient
  19420. * @param gradient defines the gradient to remove
  19421. * @returns the current particle system
  19422. */
  19423. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19424. /**
  19425. * Gets the current list of velocity gradients.
  19426. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19427. * @returns the list of velocity gradients
  19428. */
  19429. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19430. /**
  19431. * Adds a new velocity gradient
  19432. * @param gradient defines the gradient to use (between 0 and 1)
  19433. * @param factor defines the velocity to affect to the specified gradient
  19434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19435. * @returns the current particle system
  19436. */
  19437. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19438. /**
  19439. * Remove a specific velocity gradient
  19440. * @param gradient defines the gradient to remove
  19441. * @returns the current particle system
  19442. */
  19443. removeVelocityGradient(gradient: number): IParticleSystem;
  19444. /**
  19445. * Gets the current list of limit velocity gradients.
  19446. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19447. * @returns the list of limit velocity gradients
  19448. */
  19449. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19450. /**
  19451. * Adds a new limit velocity gradient
  19452. * @param gradient defines the gradient to use (between 0 and 1)
  19453. * @param factor defines the limit velocity to affect to the specified gradient
  19454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19455. * @returns the current particle system
  19456. */
  19457. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19458. /**
  19459. * Remove a specific limit velocity gradient
  19460. * @param gradient defines the gradient to remove
  19461. * @returns the current particle system
  19462. */
  19463. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19464. /**
  19465. * Adds a new drag gradient
  19466. * @param gradient defines the gradient to use (between 0 and 1)
  19467. * @param factor defines the drag to affect to the specified gradient
  19468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19469. * @returns the current particle system
  19470. */
  19471. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19472. /**
  19473. * Remove a specific drag gradient
  19474. * @param gradient defines the gradient to remove
  19475. * @returns the current particle system
  19476. */
  19477. removeDragGradient(gradient: number): IParticleSystem;
  19478. /**
  19479. * Gets the current list of drag gradients.
  19480. * You must use addDragGradient and removeDragGradient to udpate this list
  19481. * @returns the list of drag gradients
  19482. */
  19483. getDragGradients(): Nullable<Array<FactorGradient>>;
  19484. /**
  19485. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19486. * @param gradient defines the gradient to use (between 0 and 1)
  19487. * @param factor defines the emit rate to affect to the specified gradient
  19488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19489. * @returns the current particle system
  19490. */
  19491. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19492. /**
  19493. * Remove a specific emit rate gradient
  19494. * @param gradient defines the gradient to remove
  19495. * @returns the current particle system
  19496. */
  19497. removeEmitRateGradient(gradient: number): IParticleSystem;
  19498. /**
  19499. * Gets the current list of emit rate gradients.
  19500. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19501. * @returns the list of emit rate gradients
  19502. */
  19503. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19504. /**
  19505. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19506. * @param gradient defines the gradient to use (between 0 and 1)
  19507. * @param factor defines the start size to affect to the specified gradient
  19508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19509. * @returns the current particle system
  19510. */
  19511. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19512. /**
  19513. * Remove a specific start size gradient
  19514. * @param gradient defines the gradient to remove
  19515. * @returns the current particle system
  19516. */
  19517. removeStartSizeGradient(gradient: number): IParticleSystem;
  19518. /**
  19519. * Gets the current list of start size gradients.
  19520. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19521. * @returns the list of start size gradients
  19522. */
  19523. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19524. /**
  19525. * Adds a new life time gradient
  19526. * @param gradient defines the gradient to use (between 0 and 1)
  19527. * @param factor defines the life time factor to affect to the specified gradient
  19528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19529. * @returns the current particle system
  19530. */
  19531. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19532. /**
  19533. * Remove a specific life time gradient
  19534. * @param gradient defines the gradient to remove
  19535. * @returns the current particle system
  19536. */
  19537. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19538. /**
  19539. * Gets the current list of life time gradients.
  19540. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19541. * @returns the list of life time gradients
  19542. */
  19543. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19544. /**
  19545. * Gets the current list of color gradients.
  19546. * You must use addColorGradient and removeColorGradient to udpate this list
  19547. * @returns the list of color gradients
  19548. */
  19549. getColorGradients(): Nullable<Array<ColorGradient>>;
  19550. /**
  19551. * Adds a new ramp gradient used to remap particle colors
  19552. * @param gradient defines the gradient to use (between 0 and 1)
  19553. * @param color defines the color to affect to the specified gradient
  19554. * @returns the current particle system
  19555. */
  19556. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19557. /**
  19558. * Gets the current list of ramp gradients.
  19559. * You must use addRampGradient and removeRampGradient to udpate this list
  19560. * @returns the list of ramp gradients
  19561. */
  19562. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19563. /** Gets or sets a boolean indicating that ramp gradients must be used
  19564. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19565. */
  19566. useRampGradients: boolean;
  19567. /**
  19568. * Adds a new color remap gradient
  19569. * @param gradient defines the gradient to use (between 0 and 1)
  19570. * @param min defines the color remap minimal range
  19571. * @param max defines the color remap maximal range
  19572. * @returns the current particle system
  19573. */
  19574. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19575. /**
  19576. * Gets the current list of color remap gradients.
  19577. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19578. * @returns the list of color remap gradients
  19579. */
  19580. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19581. /**
  19582. * Adds a new alpha remap gradient
  19583. * @param gradient defines the gradient to use (between 0 and 1)
  19584. * @param min defines the alpha remap minimal range
  19585. * @param max defines the alpha remap maximal range
  19586. * @returns the current particle system
  19587. */
  19588. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19589. /**
  19590. * Gets the current list of alpha remap gradients.
  19591. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19592. * @returns the list of alpha remap gradients
  19593. */
  19594. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19595. /**
  19596. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19599. * @returns the emitter
  19600. */
  19601. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19602. /**
  19603. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19604. * @param radius The radius of the hemisphere to emit from
  19605. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19606. * @returns the emitter
  19607. */
  19608. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19609. /**
  19610. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19611. * @param radius The radius of the sphere to emit from
  19612. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19613. * @returns the emitter
  19614. */
  19615. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19616. /**
  19617. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19618. * @param radius The radius of the sphere to emit from
  19619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19621. * @returns the emitter
  19622. */
  19623. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19624. /**
  19625. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19626. * @param radius The radius of the emission cylinder
  19627. * @param height The height of the emission cylinder
  19628. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19629. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19630. * @returns the emitter
  19631. */
  19632. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19633. /**
  19634. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19635. * @param radius The radius of the cylinder to emit from
  19636. * @param height The height of the emission cylinder
  19637. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19640. * @returns the emitter
  19641. */
  19642. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19643. /**
  19644. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19645. * @param radius The radius of the cone to emit from
  19646. * @param angle The base angle of the cone
  19647. * @returns the emitter
  19648. */
  19649. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19650. /**
  19651. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19654. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19655. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19656. * @returns the emitter
  19657. */
  19658. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19659. /**
  19660. * Get hosting scene
  19661. * @returns the scene
  19662. */
  19663. getScene(): Scene;
  19664. }
  19665. }
  19666. declare module "babylonjs/Meshes/instancedMesh" {
  19667. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19668. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19669. import { Camera } from "babylonjs/Cameras/camera";
  19670. import { Node } from "babylonjs/node";
  19671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19672. import { Mesh } from "babylonjs/Meshes/mesh";
  19673. import { Material } from "babylonjs/Materials/material";
  19674. import { Skeleton } from "babylonjs/Bones/skeleton";
  19675. import { Light } from "babylonjs/Lights/light";
  19676. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19677. /**
  19678. * Creates an instance based on a source mesh.
  19679. */
  19680. export class InstancedMesh extends AbstractMesh {
  19681. private _sourceMesh;
  19682. private _currentLOD;
  19683. /** @hidden */
  19684. _indexInSourceMeshInstanceArray: number;
  19685. constructor(name: string, source: Mesh);
  19686. /**
  19687. * Returns the string "InstancedMesh".
  19688. */
  19689. getClassName(): string;
  19690. /** Gets the list of lights affecting that mesh */
  19691. get lightSources(): Light[];
  19692. _resyncLightSources(): void;
  19693. _resyncLightSource(light: Light): void;
  19694. _removeLightSource(light: Light, dispose: boolean): void;
  19695. /**
  19696. * If the source mesh receives shadows
  19697. */
  19698. get receiveShadows(): boolean;
  19699. /**
  19700. * The material of the source mesh
  19701. */
  19702. get material(): Nullable<Material>;
  19703. /**
  19704. * Visibility of the source mesh
  19705. */
  19706. get visibility(): number;
  19707. /**
  19708. * Skeleton of the source mesh
  19709. */
  19710. get skeleton(): Nullable<Skeleton>;
  19711. /**
  19712. * Rendering ground id of the source mesh
  19713. */
  19714. get renderingGroupId(): number;
  19715. set renderingGroupId(value: number);
  19716. /**
  19717. * Returns the total number of vertices (integer).
  19718. */
  19719. getTotalVertices(): number;
  19720. /**
  19721. * Returns a positive integer : the total number of indices in this mesh geometry.
  19722. * @returns the numner of indices or zero if the mesh has no geometry.
  19723. */
  19724. getTotalIndices(): number;
  19725. /**
  19726. * The source mesh of the instance
  19727. */
  19728. get sourceMesh(): Mesh;
  19729. /**
  19730. * Is this node ready to be used/rendered
  19731. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19732. * @return {boolean} is it ready
  19733. */
  19734. isReady(completeCheck?: boolean): boolean;
  19735. /**
  19736. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19737. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19738. * @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.
  19739. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19740. */
  19741. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19742. /**
  19743. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19744. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19745. * The `data` are either a numeric array either a Float32Array.
  19746. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19747. * 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).
  19748. * Note that a new underlying VertexBuffer object is created each call.
  19749. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19750. *
  19751. * Possible `kind` values :
  19752. * - VertexBuffer.PositionKind
  19753. * - VertexBuffer.UVKind
  19754. * - VertexBuffer.UV2Kind
  19755. * - VertexBuffer.UV3Kind
  19756. * - VertexBuffer.UV4Kind
  19757. * - VertexBuffer.UV5Kind
  19758. * - VertexBuffer.UV6Kind
  19759. * - VertexBuffer.ColorKind
  19760. * - VertexBuffer.MatricesIndicesKind
  19761. * - VertexBuffer.MatricesIndicesExtraKind
  19762. * - VertexBuffer.MatricesWeightsKind
  19763. * - VertexBuffer.MatricesWeightsExtraKind
  19764. *
  19765. * Returns the Mesh.
  19766. */
  19767. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19768. /**
  19769. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19770. * If the mesh has no geometry, it is simply returned as it is.
  19771. * The `data` are either a numeric array either a Float32Array.
  19772. * No new underlying VertexBuffer object is created.
  19773. * 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.
  19774. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19775. *
  19776. * Possible `kind` values :
  19777. * - VertexBuffer.PositionKind
  19778. * - VertexBuffer.UVKind
  19779. * - VertexBuffer.UV2Kind
  19780. * - VertexBuffer.UV3Kind
  19781. * - VertexBuffer.UV4Kind
  19782. * - VertexBuffer.UV5Kind
  19783. * - VertexBuffer.UV6Kind
  19784. * - VertexBuffer.ColorKind
  19785. * - VertexBuffer.MatricesIndicesKind
  19786. * - VertexBuffer.MatricesIndicesExtraKind
  19787. * - VertexBuffer.MatricesWeightsKind
  19788. * - VertexBuffer.MatricesWeightsExtraKind
  19789. *
  19790. * Returns the Mesh.
  19791. */
  19792. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19793. /**
  19794. * Sets the mesh indices.
  19795. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19796. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19797. * This method creates a new index buffer each call.
  19798. * Returns the Mesh.
  19799. */
  19800. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19801. /**
  19802. * Boolean : True if the mesh owns the requested kind of data.
  19803. */
  19804. isVerticesDataPresent(kind: string): boolean;
  19805. /**
  19806. * Returns an array of indices (IndicesArray).
  19807. */
  19808. getIndices(): Nullable<IndicesArray>;
  19809. get _positions(): Nullable<Vector3[]>;
  19810. /**
  19811. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19812. * This means the mesh underlying bounding box and sphere are recomputed.
  19813. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19814. * @returns the current mesh
  19815. */
  19816. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19817. /** @hidden */
  19818. _preActivate(): InstancedMesh;
  19819. /** @hidden */
  19820. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19821. /** @hidden */
  19822. _postActivate(): void;
  19823. getWorldMatrix(): Matrix;
  19824. get isAnInstance(): boolean;
  19825. /**
  19826. * Returns the current associated LOD AbstractMesh.
  19827. */
  19828. getLOD(camera: Camera): AbstractMesh;
  19829. /** @hidden */
  19830. _syncSubMeshes(): InstancedMesh;
  19831. /** @hidden */
  19832. _generatePointsArray(): boolean;
  19833. /**
  19834. * Creates a new InstancedMesh from the current mesh.
  19835. * - name (string) : the cloned mesh name
  19836. * - newParent (optional Node) : the optional Node to parent the clone to.
  19837. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19838. *
  19839. * Returns the clone.
  19840. */
  19841. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19842. /**
  19843. * Disposes the InstancedMesh.
  19844. * Returns nothing.
  19845. */
  19846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19847. }
  19848. module "babylonjs/Meshes/mesh" {
  19849. interface Mesh {
  19850. /**
  19851. * Register a custom buffer that will be instanced
  19852. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19853. * @param kind defines the buffer kind
  19854. * @param stride defines the stride in floats
  19855. */
  19856. registerInstancedBuffer(kind: string, stride: number): void;
  19857. /** @hidden */
  19858. _userInstancedBuffersStorage: {
  19859. data: {
  19860. [key: string]: Float32Array;
  19861. };
  19862. sizes: {
  19863. [key: string]: number;
  19864. };
  19865. vertexBuffers: {
  19866. [key: string]: Nullable<VertexBuffer>;
  19867. };
  19868. strides: {
  19869. [key: string]: number;
  19870. };
  19871. };
  19872. }
  19873. }
  19874. module "babylonjs/Meshes/abstractMesh" {
  19875. interface AbstractMesh {
  19876. /**
  19877. * Object used to store instanced buffers defined by user
  19878. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19879. */
  19880. instancedBuffers: {
  19881. [key: string]: any;
  19882. };
  19883. }
  19884. }
  19885. }
  19886. declare module "babylonjs/Materials/shaderMaterial" {
  19887. import { Scene } from "babylonjs/scene";
  19888. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19890. import { Mesh } from "babylonjs/Meshes/mesh";
  19891. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19893. import { Texture } from "babylonjs/Materials/Textures/texture";
  19894. import { Material } from "babylonjs/Materials/material";
  19895. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19896. /**
  19897. * Defines the options associated with the creation of a shader material.
  19898. */
  19899. export interface IShaderMaterialOptions {
  19900. /**
  19901. * Does the material work in alpha blend mode
  19902. */
  19903. needAlphaBlending: boolean;
  19904. /**
  19905. * Does the material work in alpha test mode
  19906. */
  19907. needAlphaTesting: boolean;
  19908. /**
  19909. * The list of attribute names used in the shader
  19910. */
  19911. attributes: string[];
  19912. /**
  19913. * The list of unifrom names used in the shader
  19914. */
  19915. uniforms: string[];
  19916. /**
  19917. * The list of UBO names used in the shader
  19918. */
  19919. uniformBuffers: string[];
  19920. /**
  19921. * The list of sampler names used in the shader
  19922. */
  19923. samplers: string[];
  19924. /**
  19925. * The list of defines used in the shader
  19926. */
  19927. defines: string[];
  19928. }
  19929. /**
  19930. * 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.
  19931. *
  19932. * This returned material effects how the mesh will look based on the code in the shaders.
  19933. *
  19934. * @see http://doc.babylonjs.com/how_to/shader_material
  19935. */
  19936. export class ShaderMaterial extends Material {
  19937. private _shaderPath;
  19938. private _options;
  19939. private _textures;
  19940. private _textureArrays;
  19941. private _floats;
  19942. private _ints;
  19943. private _floatsArrays;
  19944. private _colors3;
  19945. private _colors3Arrays;
  19946. private _colors4;
  19947. private _colors4Arrays;
  19948. private _vectors2;
  19949. private _vectors3;
  19950. private _vectors4;
  19951. private _matrices;
  19952. private _matrixArrays;
  19953. private _matrices3x3;
  19954. private _matrices2x2;
  19955. private _vectors2Arrays;
  19956. private _vectors3Arrays;
  19957. private _vectors4Arrays;
  19958. private _cachedWorldViewMatrix;
  19959. private _cachedWorldViewProjectionMatrix;
  19960. private _renderId;
  19961. private _multiview;
  19962. /**
  19963. * Instantiate a new shader material.
  19964. * 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.
  19965. * This returned material effects how the mesh will look based on the code in the shaders.
  19966. * @see http://doc.babylonjs.com/how_to/shader_material
  19967. * @param name Define the name of the material in the scene
  19968. * @param scene Define the scene the material belongs to
  19969. * @param shaderPath Defines the route to the shader code in one of three ways:
  19970. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19971. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19972. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19973. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19974. * @param options Define the options used to create the shader
  19975. */
  19976. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19977. /**
  19978. * Gets the shader path used to define the shader code
  19979. * It can be modified to trigger a new compilation
  19980. */
  19981. get shaderPath(): any;
  19982. /**
  19983. * Sets the shader path used to define the shader code
  19984. * It can be modified to trigger a new compilation
  19985. */
  19986. set shaderPath(shaderPath: any);
  19987. /**
  19988. * Gets the options used to compile the shader.
  19989. * They can be modified to trigger a new compilation
  19990. */
  19991. get options(): IShaderMaterialOptions;
  19992. /**
  19993. * Gets the current class name of the material e.g. "ShaderMaterial"
  19994. * Mainly use in serialization.
  19995. * @returns the class name
  19996. */
  19997. getClassName(): string;
  19998. /**
  19999. * Specifies if the material will require alpha blending
  20000. * @returns a boolean specifying if alpha blending is needed
  20001. */
  20002. needAlphaBlending(): boolean;
  20003. /**
  20004. * Specifies if this material should be rendered in alpha test mode
  20005. * @returns a boolean specifying if an alpha test is needed.
  20006. */
  20007. needAlphaTesting(): boolean;
  20008. private _checkUniform;
  20009. /**
  20010. * Set a texture in the shader.
  20011. * @param name Define the name of the uniform samplers as defined in the shader
  20012. * @param texture Define the texture to bind to this sampler
  20013. * @return the material itself allowing "fluent" like uniform updates
  20014. */
  20015. setTexture(name: string, texture: Texture): ShaderMaterial;
  20016. /**
  20017. * Set a texture array in the shader.
  20018. * @param name Define the name of the uniform sampler array as defined in the shader
  20019. * @param textures Define the list of textures to bind to this sampler
  20020. * @return the material itself allowing "fluent" like uniform updates
  20021. */
  20022. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20023. /**
  20024. * Set a float in the shader.
  20025. * @param name Define the name of the uniform as defined in the shader
  20026. * @param value Define the value to give to the uniform
  20027. * @return the material itself allowing "fluent" like uniform updates
  20028. */
  20029. setFloat(name: string, value: number): ShaderMaterial;
  20030. /**
  20031. * Set a int in the shader.
  20032. * @param name Define the name of the uniform as defined in the shader
  20033. * @param value Define the value to give to the uniform
  20034. * @return the material itself allowing "fluent" like uniform updates
  20035. */
  20036. setInt(name: string, value: number): ShaderMaterial;
  20037. /**
  20038. * Set an array of floats in the shader.
  20039. * @param name Define the name of the uniform as defined in the shader
  20040. * @param value Define the value to give to the uniform
  20041. * @return the material itself allowing "fluent" like uniform updates
  20042. */
  20043. setFloats(name: string, value: number[]): ShaderMaterial;
  20044. /**
  20045. * Set a vec3 in the shader from a Color3.
  20046. * @param name Define the name of the uniform as defined in the shader
  20047. * @param value Define the value to give to the uniform
  20048. * @return the material itself allowing "fluent" like uniform updates
  20049. */
  20050. setColor3(name: string, value: Color3): ShaderMaterial;
  20051. /**
  20052. * Set a vec3 array in the shader from a Color3 array.
  20053. * @param name Define the name of the uniform as defined in the shader
  20054. * @param value Define the value to give to the uniform
  20055. * @return the material itself allowing "fluent" like uniform updates
  20056. */
  20057. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20058. /**
  20059. * Set a vec4 in the shader from a Color4.
  20060. * @param name Define the name of the uniform as defined in the shader
  20061. * @param value Define the value to give to the uniform
  20062. * @return the material itself allowing "fluent" like uniform updates
  20063. */
  20064. setColor4(name: string, value: Color4): ShaderMaterial;
  20065. /**
  20066. * Set a vec4 array in the shader from a Color4 array.
  20067. * @param name Define the name of the uniform as defined in the shader
  20068. * @param value Define the value to give to the uniform
  20069. * @return the material itself allowing "fluent" like uniform updates
  20070. */
  20071. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20072. /**
  20073. * Set a vec2 in the shader from a Vector2.
  20074. * @param name Define the name of the uniform as defined in the shader
  20075. * @param value Define the value to give to the uniform
  20076. * @return the material itself allowing "fluent" like uniform updates
  20077. */
  20078. setVector2(name: string, value: Vector2): ShaderMaterial;
  20079. /**
  20080. * Set a vec3 in the shader from a Vector3.
  20081. * @param name Define the name of the uniform as defined in the shader
  20082. * @param value Define the value to give to the uniform
  20083. * @return the material itself allowing "fluent" like uniform updates
  20084. */
  20085. setVector3(name: string, value: Vector3): ShaderMaterial;
  20086. /**
  20087. * Set a vec4 in the shader from a Vector4.
  20088. * @param name Define the name of the uniform as defined in the shader
  20089. * @param value Define the value to give to the uniform
  20090. * @return the material itself allowing "fluent" like uniform updates
  20091. */
  20092. setVector4(name: string, value: Vector4): ShaderMaterial;
  20093. /**
  20094. * Set a mat4 in the shader from a Matrix.
  20095. * @param name Define the name of the uniform as defined in the shader
  20096. * @param value Define the value to give to the uniform
  20097. * @return the material itself allowing "fluent" like uniform updates
  20098. */
  20099. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20100. /**
  20101. * Set a float32Array in the shader from a matrix array.
  20102. * @param name Define the name of the uniform as defined in the shader
  20103. * @param value Define the value to give to the uniform
  20104. * @return the material itself allowing "fluent" like uniform updates
  20105. */
  20106. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20107. /**
  20108. * Set a mat3 in the shader from a Float32Array.
  20109. * @param name Define the name of the uniform as defined in the shader
  20110. * @param value Define the value to give to the uniform
  20111. * @return the material itself allowing "fluent" like uniform updates
  20112. */
  20113. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20114. /**
  20115. * Set a mat2 in the shader from a Float32Array.
  20116. * @param name Define the name of the uniform as defined in the shader
  20117. * @param value Define the value to give to the uniform
  20118. * @return the material itself allowing "fluent" like uniform updates
  20119. */
  20120. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20121. /**
  20122. * Set a vec2 array in the shader from a number array.
  20123. * @param name Define the name of the uniform as defined in the shader
  20124. * @param value Define the value to give to the uniform
  20125. * @return the material itself allowing "fluent" like uniform updates
  20126. */
  20127. setArray2(name: string, value: number[]): ShaderMaterial;
  20128. /**
  20129. * Set a vec3 array in the shader from a number array.
  20130. * @param name Define the name of the uniform as defined in the shader
  20131. * @param value Define the value to give to the uniform
  20132. * @return the material itself allowing "fluent" like uniform updates
  20133. */
  20134. setArray3(name: string, value: number[]): ShaderMaterial;
  20135. /**
  20136. * Set a vec4 array in the shader from a number array.
  20137. * @param name Define the name of the uniform as defined in the shader
  20138. * @param value Define the value to give to the uniform
  20139. * @return the material itself allowing "fluent" like uniform updates
  20140. */
  20141. setArray4(name: string, value: number[]): ShaderMaterial;
  20142. private _checkCache;
  20143. /**
  20144. * Specifies that the submesh is ready to be used
  20145. * @param mesh defines the mesh to check
  20146. * @param subMesh defines which submesh to check
  20147. * @param useInstances specifies that instances should be used
  20148. * @returns a boolean indicating that the submesh is ready or not
  20149. */
  20150. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20151. /**
  20152. * Checks if the material is ready to render the requested mesh
  20153. * @param mesh Define the mesh to render
  20154. * @param useInstances Define whether or not the material is used with instances
  20155. * @returns true if ready, otherwise false
  20156. */
  20157. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20158. /**
  20159. * Binds the world matrix to the material
  20160. * @param world defines the world transformation matrix
  20161. */
  20162. bindOnlyWorldMatrix(world: Matrix): void;
  20163. /**
  20164. * Binds the material to the mesh
  20165. * @param world defines the world transformation matrix
  20166. * @param mesh defines the mesh to bind the material to
  20167. */
  20168. bind(world: Matrix, mesh?: Mesh): void;
  20169. /**
  20170. * Gets the active textures from the material
  20171. * @returns an array of textures
  20172. */
  20173. getActiveTextures(): BaseTexture[];
  20174. /**
  20175. * Specifies if the material uses a texture
  20176. * @param texture defines the texture to check against the material
  20177. * @returns a boolean specifying if the material uses the texture
  20178. */
  20179. hasTexture(texture: BaseTexture): boolean;
  20180. /**
  20181. * Makes a duplicate of the material, and gives it a new name
  20182. * @param name defines the new name for the duplicated material
  20183. * @returns the cloned material
  20184. */
  20185. clone(name: string): ShaderMaterial;
  20186. /**
  20187. * Disposes the material
  20188. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20189. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20190. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20191. */
  20192. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20193. /**
  20194. * Serializes this material in a JSON representation
  20195. * @returns the serialized material object
  20196. */
  20197. serialize(): any;
  20198. /**
  20199. * Creates a shader material from parsed shader material data
  20200. * @param source defines the JSON represnetation of the material
  20201. * @param scene defines the hosting scene
  20202. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20203. * @returns a new material
  20204. */
  20205. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20206. }
  20207. }
  20208. declare module "babylonjs/Shaders/color.fragment" {
  20209. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20210. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20211. /** @hidden */
  20212. export var colorPixelShader: {
  20213. name: string;
  20214. shader: string;
  20215. };
  20216. }
  20217. declare module "babylonjs/Shaders/color.vertex" {
  20218. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20219. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20220. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20221. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20222. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20223. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20224. /** @hidden */
  20225. export var colorVertexShader: {
  20226. name: string;
  20227. shader: string;
  20228. };
  20229. }
  20230. declare module "babylonjs/Meshes/linesMesh" {
  20231. import { Nullable } from "babylonjs/types";
  20232. import { Scene } from "babylonjs/scene";
  20233. import { Color3 } from "babylonjs/Maths/math.color";
  20234. import { Node } from "babylonjs/node";
  20235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20236. import { Mesh } from "babylonjs/Meshes/mesh";
  20237. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20238. import { Effect } from "babylonjs/Materials/effect";
  20239. import { Material } from "babylonjs/Materials/material";
  20240. import "babylonjs/Shaders/color.fragment";
  20241. import "babylonjs/Shaders/color.vertex";
  20242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20243. /**
  20244. * Line mesh
  20245. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20246. */
  20247. export class LinesMesh extends Mesh {
  20248. /**
  20249. * If vertex color should be applied to the mesh
  20250. */
  20251. readonly useVertexColor?: boolean | undefined;
  20252. /**
  20253. * If vertex alpha should be applied to the mesh
  20254. */
  20255. readonly useVertexAlpha?: boolean | undefined;
  20256. /**
  20257. * Color of the line (Default: White)
  20258. */
  20259. color: Color3;
  20260. /**
  20261. * Alpha of the line (Default: 1)
  20262. */
  20263. alpha: number;
  20264. /**
  20265. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20266. * This margin is expressed in world space coordinates, so its value may vary.
  20267. * Default value is 0.1
  20268. */
  20269. intersectionThreshold: number;
  20270. private _colorShader;
  20271. private color4;
  20272. /**
  20273. * Creates a new LinesMesh
  20274. * @param name defines the name
  20275. * @param scene defines the hosting scene
  20276. * @param parent defines the parent mesh if any
  20277. * @param source defines the optional source LinesMesh used to clone data from
  20278. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20279. * When false, achieved by calling a clone(), also passing False.
  20280. * This will make creation of children, recursive.
  20281. * @param useVertexColor defines if this LinesMesh supports vertex color
  20282. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20283. */
  20284. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20285. /**
  20286. * If vertex color should be applied to the mesh
  20287. */
  20288. useVertexColor?: boolean | undefined,
  20289. /**
  20290. * If vertex alpha should be applied to the mesh
  20291. */
  20292. useVertexAlpha?: boolean | undefined);
  20293. private _addClipPlaneDefine;
  20294. private _removeClipPlaneDefine;
  20295. isReady(): boolean;
  20296. /**
  20297. * Returns the string "LineMesh"
  20298. */
  20299. getClassName(): string;
  20300. /**
  20301. * @hidden
  20302. */
  20303. get material(): Material;
  20304. /**
  20305. * @hidden
  20306. */
  20307. set material(value: Material);
  20308. /**
  20309. * @hidden
  20310. */
  20311. get checkCollisions(): boolean;
  20312. /** @hidden */
  20313. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20314. /** @hidden */
  20315. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20316. /**
  20317. * Disposes of the line mesh
  20318. * @param doNotRecurse If children should be disposed
  20319. */
  20320. dispose(doNotRecurse?: boolean): void;
  20321. /**
  20322. * Returns a new LineMesh object cloned from the current one.
  20323. */
  20324. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20325. /**
  20326. * Creates a new InstancedLinesMesh object from the mesh model.
  20327. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20328. * @param name defines the name of the new instance
  20329. * @returns a new InstancedLinesMesh
  20330. */
  20331. createInstance(name: string): InstancedLinesMesh;
  20332. }
  20333. /**
  20334. * Creates an instance based on a source LinesMesh
  20335. */
  20336. export class InstancedLinesMesh extends InstancedMesh {
  20337. /**
  20338. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20339. * This margin is expressed in world space coordinates, so its value may vary.
  20340. * Initilized with the intersectionThreshold value of the source LinesMesh
  20341. */
  20342. intersectionThreshold: number;
  20343. constructor(name: string, source: LinesMesh);
  20344. /**
  20345. * Returns the string "InstancedLinesMesh".
  20346. */
  20347. getClassName(): string;
  20348. }
  20349. }
  20350. declare module "babylonjs/Shaders/line.fragment" {
  20351. /** @hidden */
  20352. export var linePixelShader: {
  20353. name: string;
  20354. shader: string;
  20355. };
  20356. }
  20357. declare module "babylonjs/Shaders/line.vertex" {
  20358. /** @hidden */
  20359. export var lineVertexShader: {
  20360. name: string;
  20361. shader: string;
  20362. };
  20363. }
  20364. declare module "babylonjs/Rendering/edgesRenderer" {
  20365. import { Nullable } from "babylonjs/types";
  20366. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20368. import { Vector3 } from "babylonjs/Maths/math.vector";
  20369. import { IDisposable } from "babylonjs/scene";
  20370. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20371. import "babylonjs/Shaders/line.fragment";
  20372. import "babylonjs/Shaders/line.vertex";
  20373. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20374. module "babylonjs/Meshes/abstractMesh" {
  20375. interface AbstractMesh {
  20376. /**
  20377. * Gets the edgesRenderer associated with the mesh
  20378. */
  20379. edgesRenderer: Nullable<EdgesRenderer>;
  20380. }
  20381. }
  20382. module "babylonjs/Meshes/linesMesh" {
  20383. interface LinesMesh {
  20384. /**
  20385. * Enables the edge rendering mode on the mesh.
  20386. * This mode makes the mesh edges visible
  20387. * @param epsilon defines the maximal distance between two angles to detect a face
  20388. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20389. * @returns the currentAbstractMesh
  20390. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20391. */
  20392. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20393. }
  20394. }
  20395. module "babylonjs/Meshes/linesMesh" {
  20396. interface InstancedLinesMesh {
  20397. /**
  20398. * Enables the edge rendering mode on the mesh.
  20399. * This mode makes the mesh edges visible
  20400. * @param epsilon defines the maximal distance between two angles to detect a face
  20401. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20402. * @returns the current InstancedLinesMesh
  20403. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20404. */
  20405. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20406. }
  20407. }
  20408. /**
  20409. * Defines the minimum contract an Edges renderer should follow.
  20410. */
  20411. export interface IEdgesRenderer extends IDisposable {
  20412. /**
  20413. * Gets or sets a boolean indicating if the edgesRenderer is active
  20414. */
  20415. isEnabled: boolean;
  20416. /**
  20417. * Renders the edges of the attached mesh,
  20418. */
  20419. render(): void;
  20420. /**
  20421. * Checks wether or not the edges renderer is ready to render.
  20422. * @return true if ready, otherwise false.
  20423. */
  20424. isReady(): boolean;
  20425. }
  20426. /**
  20427. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20428. */
  20429. export class EdgesRenderer implements IEdgesRenderer {
  20430. /**
  20431. * Define the size of the edges with an orthographic camera
  20432. */
  20433. edgesWidthScalerForOrthographic: number;
  20434. /**
  20435. * Define the size of the edges with a perspective camera
  20436. */
  20437. edgesWidthScalerForPerspective: number;
  20438. protected _source: AbstractMesh;
  20439. protected _linesPositions: number[];
  20440. protected _linesNormals: number[];
  20441. protected _linesIndices: number[];
  20442. protected _epsilon: number;
  20443. protected _indicesCount: number;
  20444. protected _lineShader: ShaderMaterial;
  20445. protected _ib: DataBuffer;
  20446. protected _buffers: {
  20447. [key: string]: Nullable<VertexBuffer>;
  20448. };
  20449. protected _checkVerticesInsteadOfIndices: boolean;
  20450. private _meshRebuildObserver;
  20451. private _meshDisposeObserver;
  20452. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20453. isEnabled: boolean;
  20454. /**
  20455. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20456. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20457. * @param source Mesh used to create edges
  20458. * @param epsilon sum of angles in adjacency to check for edge
  20459. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20460. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20461. */
  20462. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20463. protected _prepareRessources(): void;
  20464. /** @hidden */
  20465. _rebuild(): void;
  20466. /**
  20467. * Releases the required resources for the edges renderer
  20468. */
  20469. dispose(): void;
  20470. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20471. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20472. /**
  20473. * Checks if the pair of p0 and p1 is en edge
  20474. * @param faceIndex
  20475. * @param edge
  20476. * @param faceNormals
  20477. * @param p0
  20478. * @param p1
  20479. * @private
  20480. */
  20481. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20482. /**
  20483. * push line into the position, normal and index buffer
  20484. * @protected
  20485. */
  20486. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20487. /**
  20488. * Generates lines edges from adjacencjes
  20489. * @private
  20490. */
  20491. _generateEdgesLines(): void;
  20492. /**
  20493. * Checks wether or not the edges renderer is ready to render.
  20494. * @return true if ready, otherwise false.
  20495. */
  20496. isReady(): boolean;
  20497. /**
  20498. * Renders the edges of the attached mesh,
  20499. */
  20500. render(): void;
  20501. }
  20502. /**
  20503. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20504. */
  20505. export class LineEdgesRenderer extends EdgesRenderer {
  20506. /**
  20507. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20508. * @param source LineMesh used to generate edges
  20509. * @param epsilon not important (specified angle for edge detection)
  20510. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20511. */
  20512. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20513. /**
  20514. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20515. */
  20516. _generateEdgesLines(): void;
  20517. }
  20518. }
  20519. declare module "babylonjs/Rendering/renderingGroup" {
  20520. import { SmartArray } from "babylonjs/Misc/smartArray";
  20521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20523. import { Nullable } from "babylonjs/types";
  20524. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20525. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20526. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20527. import { Material } from "babylonjs/Materials/material";
  20528. import { Scene } from "babylonjs/scene";
  20529. /**
  20530. * This represents the object necessary to create a rendering group.
  20531. * This is exclusively used and created by the rendering manager.
  20532. * To modify the behavior, you use the available helpers in your scene or meshes.
  20533. * @hidden
  20534. */
  20535. export class RenderingGroup {
  20536. index: number;
  20537. private static _zeroVector;
  20538. private _scene;
  20539. private _opaqueSubMeshes;
  20540. private _transparentSubMeshes;
  20541. private _alphaTestSubMeshes;
  20542. private _depthOnlySubMeshes;
  20543. private _particleSystems;
  20544. private _spriteManagers;
  20545. private _opaqueSortCompareFn;
  20546. private _alphaTestSortCompareFn;
  20547. private _transparentSortCompareFn;
  20548. private _renderOpaque;
  20549. private _renderAlphaTest;
  20550. private _renderTransparent;
  20551. /** @hidden */
  20552. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20553. onBeforeTransparentRendering: () => void;
  20554. /**
  20555. * Set the opaque sort comparison function.
  20556. * If null the sub meshes will be render in the order they were created
  20557. */
  20558. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20559. /**
  20560. * Set the alpha test sort comparison function.
  20561. * If null the sub meshes will be render in the order they were created
  20562. */
  20563. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20564. /**
  20565. * Set the transparent sort comparison function.
  20566. * If null the sub meshes will be render in the order they were created
  20567. */
  20568. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20569. /**
  20570. * Creates a new rendering group.
  20571. * @param index The rendering group index
  20572. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20573. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20574. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20575. */
  20576. 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>);
  20577. /**
  20578. * Render all the sub meshes contained in the group.
  20579. * @param customRenderFunction Used to override the default render behaviour of the group.
  20580. * @returns true if rendered some submeshes.
  20581. */
  20582. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20583. /**
  20584. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20585. * @param subMeshes The submeshes to render
  20586. */
  20587. private renderOpaqueSorted;
  20588. /**
  20589. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20590. * @param subMeshes The submeshes to render
  20591. */
  20592. private renderAlphaTestSorted;
  20593. /**
  20594. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20595. * @param subMeshes The submeshes to render
  20596. */
  20597. private renderTransparentSorted;
  20598. /**
  20599. * Renders the submeshes in a specified order.
  20600. * @param subMeshes The submeshes to sort before render
  20601. * @param sortCompareFn The comparison function use to sort
  20602. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20603. * @param transparent Specifies to activate blending if true
  20604. */
  20605. private static renderSorted;
  20606. /**
  20607. * Renders the submeshes in the order they were dispatched (no sort applied).
  20608. * @param subMeshes The submeshes to render
  20609. */
  20610. private static renderUnsorted;
  20611. /**
  20612. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20613. * are rendered back to front if in the same alpha index.
  20614. *
  20615. * @param a The first submesh
  20616. * @param b The second submesh
  20617. * @returns The result of the comparison
  20618. */
  20619. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20620. /**
  20621. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20622. * are rendered back to front.
  20623. *
  20624. * @param a The first submesh
  20625. * @param b The second submesh
  20626. * @returns The result of the comparison
  20627. */
  20628. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20629. /**
  20630. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20631. * are rendered front to back (prevent overdraw).
  20632. *
  20633. * @param a The first submesh
  20634. * @param b The second submesh
  20635. * @returns The result of the comparison
  20636. */
  20637. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20638. /**
  20639. * Resets the different lists of submeshes to prepare a new frame.
  20640. */
  20641. prepare(): void;
  20642. dispose(): void;
  20643. /**
  20644. * Inserts the submesh in its correct queue depending on its material.
  20645. * @param subMesh The submesh to dispatch
  20646. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20647. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20648. */
  20649. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20650. dispatchSprites(spriteManager: ISpriteManager): void;
  20651. dispatchParticles(particleSystem: IParticleSystem): void;
  20652. private _renderParticles;
  20653. private _renderSprites;
  20654. }
  20655. }
  20656. declare module "babylonjs/Rendering/renderingManager" {
  20657. import { Nullable } from "babylonjs/types";
  20658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20659. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20660. import { SmartArray } from "babylonjs/Misc/smartArray";
  20661. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20662. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20663. import { Material } from "babylonjs/Materials/material";
  20664. import { Scene } from "babylonjs/scene";
  20665. import { Camera } from "babylonjs/Cameras/camera";
  20666. /**
  20667. * Interface describing the different options available in the rendering manager
  20668. * regarding Auto Clear between groups.
  20669. */
  20670. export interface IRenderingManagerAutoClearSetup {
  20671. /**
  20672. * Defines whether or not autoclear is enable.
  20673. */
  20674. autoClear: boolean;
  20675. /**
  20676. * Defines whether or not to autoclear the depth buffer.
  20677. */
  20678. depth: boolean;
  20679. /**
  20680. * Defines whether or not to autoclear the stencil buffer.
  20681. */
  20682. stencil: boolean;
  20683. }
  20684. /**
  20685. * This class is used by the onRenderingGroupObservable
  20686. */
  20687. export class RenderingGroupInfo {
  20688. /**
  20689. * The Scene that being rendered
  20690. */
  20691. scene: Scene;
  20692. /**
  20693. * The camera currently used for the rendering pass
  20694. */
  20695. camera: Nullable<Camera>;
  20696. /**
  20697. * The ID of the renderingGroup being processed
  20698. */
  20699. renderingGroupId: number;
  20700. }
  20701. /**
  20702. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20703. * It is enable to manage the different groups as well as the different necessary sort functions.
  20704. * This should not be used directly aside of the few static configurations
  20705. */
  20706. export class RenderingManager {
  20707. /**
  20708. * The max id used for rendering groups (not included)
  20709. */
  20710. static MAX_RENDERINGGROUPS: number;
  20711. /**
  20712. * The min id used for rendering groups (included)
  20713. */
  20714. static MIN_RENDERINGGROUPS: number;
  20715. /**
  20716. * Used to globally prevent autoclearing scenes.
  20717. */
  20718. static AUTOCLEAR: boolean;
  20719. /**
  20720. * @hidden
  20721. */
  20722. _useSceneAutoClearSetup: boolean;
  20723. private _scene;
  20724. private _renderingGroups;
  20725. private _depthStencilBufferAlreadyCleaned;
  20726. private _autoClearDepthStencil;
  20727. private _customOpaqueSortCompareFn;
  20728. private _customAlphaTestSortCompareFn;
  20729. private _customTransparentSortCompareFn;
  20730. private _renderingGroupInfo;
  20731. /**
  20732. * Instantiates a new rendering group for a particular scene
  20733. * @param scene Defines the scene the groups belongs to
  20734. */
  20735. constructor(scene: Scene);
  20736. private _clearDepthStencilBuffer;
  20737. /**
  20738. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20739. * @hidden
  20740. */
  20741. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20742. /**
  20743. * Resets the different information of the group to prepare a new frame
  20744. * @hidden
  20745. */
  20746. reset(): void;
  20747. /**
  20748. * Dispose and release the group and its associated resources.
  20749. * @hidden
  20750. */
  20751. dispose(): void;
  20752. /**
  20753. * Clear the info related to rendering groups preventing retention points during dispose.
  20754. */
  20755. freeRenderingGroups(): void;
  20756. private _prepareRenderingGroup;
  20757. /**
  20758. * Add a sprite manager to the rendering manager in order to render it this frame.
  20759. * @param spriteManager Define the sprite manager to render
  20760. */
  20761. dispatchSprites(spriteManager: ISpriteManager): void;
  20762. /**
  20763. * Add a particle system to the rendering manager in order to render it this frame.
  20764. * @param particleSystem Define the particle system to render
  20765. */
  20766. dispatchParticles(particleSystem: IParticleSystem): void;
  20767. /**
  20768. * Add a submesh to the manager in order to render it this frame
  20769. * @param subMesh The submesh to dispatch
  20770. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20771. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20772. */
  20773. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20774. /**
  20775. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20776. * This allowed control for front to back rendering or reversly depending of the special needs.
  20777. *
  20778. * @param renderingGroupId The rendering group id corresponding to its index
  20779. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20780. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20781. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20782. */
  20783. 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;
  20784. /**
  20785. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20786. *
  20787. * @param renderingGroupId The rendering group id corresponding to its index
  20788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20789. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20790. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20791. */
  20792. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20793. /**
  20794. * Gets the current auto clear configuration for one rendering group of the rendering
  20795. * manager.
  20796. * @param index the rendering group index to get the information for
  20797. * @returns The auto clear setup for the requested rendering group
  20798. */
  20799. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20800. }
  20801. }
  20802. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20803. import { Observable } from "babylonjs/Misc/observable";
  20804. import { SmartArray } from "babylonjs/Misc/smartArray";
  20805. import { Nullable } from "babylonjs/types";
  20806. import { Camera } from "babylonjs/Cameras/camera";
  20807. import { Scene } from "babylonjs/scene";
  20808. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20809. import { Color4 } from "babylonjs/Maths/math.color";
  20810. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20812. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20813. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20814. import { Texture } from "babylonjs/Materials/Textures/texture";
  20815. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20816. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20817. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20818. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20819. import { Engine } from "babylonjs/Engines/engine";
  20820. /**
  20821. * This Helps creating a texture that will be created from a camera in your scene.
  20822. * It is basically a dynamic texture that could be used to create special effects for instance.
  20823. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20824. */
  20825. export class RenderTargetTexture extends Texture {
  20826. isCube: boolean;
  20827. /**
  20828. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20829. */
  20830. static readonly REFRESHRATE_RENDER_ONCE: number;
  20831. /**
  20832. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20833. */
  20834. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20835. /**
  20836. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20837. * the central point of your effect and can save a lot of performances.
  20838. */
  20839. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20840. /**
  20841. * Use this predicate to dynamically define the list of mesh you want to render.
  20842. * If set, the renderList property will be overwritten.
  20843. */
  20844. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20845. private _renderList;
  20846. /**
  20847. * Use this list to define the list of mesh you want to render.
  20848. */
  20849. get renderList(): Nullable<Array<AbstractMesh>>;
  20850. set renderList(value: Nullable<Array<AbstractMesh>>);
  20851. private _hookArray;
  20852. /**
  20853. * Define if particles should be rendered in your texture.
  20854. */
  20855. renderParticles: boolean;
  20856. /**
  20857. * Define if sprites should be rendered in your texture.
  20858. */
  20859. renderSprites: boolean;
  20860. /**
  20861. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20862. */
  20863. coordinatesMode: number;
  20864. /**
  20865. * Define the camera used to render the texture.
  20866. */
  20867. activeCamera: Nullable<Camera>;
  20868. /**
  20869. * Override the render function of the texture with your own one.
  20870. */
  20871. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20872. /**
  20873. * Define if camera post processes should be use while rendering the texture.
  20874. */
  20875. useCameraPostProcesses: boolean;
  20876. /**
  20877. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20878. */
  20879. ignoreCameraViewport: boolean;
  20880. private _postProcessManager;
  20881. private _postProcesses;
  20882. private _resizeObserver;
  20883. /**
  20884. * An event triggered when the texture is unbind.
  20885. */
  20886. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20887. /**
  20888. * An event triggered when the texture is unbind.
  20889. */
  20890. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20891. private _onAfterUnbindObserver;
  20892. /**
  20893. * Set a after unbind callback in the texture.
  20894. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20895. */
  20896. set onAfterUnbind(callback: () => void);
  20897. /**
  20898. * An event triggered before rendering the texture
  20899. */
  20900. onBeforeRenderObservable: Observable<number>;
  20901. private _onBeforeRenderObserver;
  20902. /**
  20903. * Set a before render callback in the texture.
  20904. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20905. */
  20906. set onBeforeRender(callback: (faceIndex: number) => void);
  20907. /**
  20908. * An event triggered after rendering the texture
  20909. */
  20910. onAfterRenderObservable: Observable<number>;
  20911. private _onAfterRenderObserver;
  20912. /**
  20913. * Set a after render callback in the texture.
  20914. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20915. */
  20916. set onAfterRender(callback: (faceIndex: number) => void);
  20917. /**
  20918. * An event triggered after the texture clear
  20919. */
  20920. onClearObservable: Observable<Engine>;
  20921. private _onClearObserver;
  20922. /**
  20923. * Set a clear callback in the texture.
  20924. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20925. */
  20926. set onClear(callback: (Engine: Engine) => void);
  20927. /**
  20928. * An event triggered when the texture is resized.
  20929. */
  20930. onResizeObservable: Observable<RenderTargetTexture>;
  20931. /**
  20932. * Define the clear color of the Render Target if it should be different from the scene.
  20933. */
  20934. clearColor: Color4;
  20935. protected _size: number | {
  20936. width: number;
  20937. height: number;
  20938. };
  20939. protected _initialSizeParameter: number | {
  20940. width: number;
  20941. height: number;
  20942. } | {
  20943. ratio: number;
  20944. };
  20945. protected _sizeRatio: Nullable<number>;
  20946. /** @hidden */
  20947. _generateMipMaps: boolean;
  20948. protected _renderingManager: RenderingManager;
  20949. /** @hidden */
  20950. _waitingRenderList: string[];
  20951. protected _doNotChangeAspectRatio: boolean;
  20952. protected _currentRefreshId: number;
  20953. protected _refreshRate: number;
  20954. protected _textureMatrix: Matrix;
  20955. protected _samples: number;
  20956. protected _renderTargetOptions: RenderTargetCreationOptions;
  20957. /**
  20958. * Gets render target creation options that were used.
  20959. */
  20960. get renderTargetOptions(): RenderTargetCreationOptions;
  20961. protected _engine: Engine;
  20962. protected _onRatioRescale(): void;
  20963. /**
  20964. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20965. * It must define where the camera used to render the texture is set
  20966. */
  20967. boundingBoxPosition: Vector3;
  20968. private _boundingBoxSize;
  20969. /**
  20970. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20971. * When defined, the cubemap will switch to local mode
  20972. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20973. * @example https://www.babylonjs-playground.com/#RNASML
  20974. */
  20975. set boundingBoxSize(value: Vector3);
  20976. get boundingBoxSize(): Vector3;
  20977. /**
  20978. * In case the RTT has been created with a depth texture, get the associated
  20979. * depth texture.
  20980. * Otherwise, return null.
  20981. */
  20982. depthStencilTexture: Nullable<InternalTexture>;
  20983. /**
  20984. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20985. * or used a shadow, depth texture...
  20986. * @param name The friendly name of the texture
  20987. * @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)
  20988. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20989. * @param generateMipMaps True if mip maps need to be generated after render.
  20990. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20991. * @param type The type of the buffer in the RTT (int, half float, float...)
  20992. * @param isCube True if a cube texture needs to be created
  20993. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20994. * @param generateDepthBuffer True to generate a depth buffer
  20995. * @param generateStencilBuffer True to generate a stencil buffer
  20996. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20997. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20998. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20999. */
  21000. constructor(name: string, size: number | {
  21001. width: number;
  21002. height: number;
  21003. } | {
  21004. ratio: number;
  21005. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21006. /**
  21007. * Creates a depth stencil texture.
  21008. * This is only available in WebGL 2 or with the depth texture extension available.
  21009. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21010. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21011. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21012. */
  21013. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21014. private _processSizeParameter;
  21015. /**
  21016. * Define the number of samples to use in case of MSAA.
  21017. * It defaults to one meaning no MSAA has been enabled.
  21018. */
  21019. get samples(): number;
  21020. set samples(value: number);
  21021. /**
  21022. * Resets the refresh counter of the texture and start bak from scratch.
  21023. * Could be useful to regenerate the texture if it is setup to render only once.
  21024. */
  21025. resetRefreshCounter(): void;
  21026. /**
  21027. * Define the refresh rate of the texture or the rendering frequency.
  21028. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21029. */
  21030. get refreshRate(): number;
  21031. set refreshRate(value: number);
  21032. /**
  21033. * Adds a post process to the render target rendering passes.
  21034. * @param postProcess define the post process to add
  21035. */
  21036. addPostProcess(postProcess: PostProcess): void;
  21037. /**
  21038. * Clear all the post processes attached to the render target
  21039. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21040. */
  21041. clearPostProcesses(dispose?: boolean): void;
  21042. /**
  21043. * Remove one of the post process from the list of attached post processes to the texture
  21044. * @param postProcess define the post process to remove from the list
  21045. */
  21046. removePostProcess(postProcess: PostProcess): void;
  21047. /** @hidden */
  21048. _shouldRender(): boolean;
  21049. /**
  21050. * Gets the actual render size of the texture.
  21051. * @returns the width of the render size
  21052. */
  21053. getRenderSize(): number;
  21054. /**
  21055. * Gets the actual render width of the texture.
  21056. * @returns the width of the render size
  21057. */
  21058. getRenderWidth(): number;
  21059. /**
  21060. * Gets the actual render height of the texture.
  21061. * @returns the height of the render size
  21062. */
  21063. getRenderHeight(): number;
  21064. /**
  21065. * Get if the texture can be rescaled or not.
  21066. */
  21067. get canRescale(): boolean;
  21068. /**
  21069. * Resize the texture using a ratio.
  21070. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21071. */
  21072. scale(ratio: number): void;
  21073. /**
  21074. * Get the texture reflection matrix used to rotate/transform the reflection.
  21075. * @returns the reflection matrix
  21076. */
  21077. getReflectionTextureMatrix(): Matrix;
  21078. /**
  21079. * Resize the texture to a new desired size.
  21080. * Be carrefull as it will recreate all the data in the new texture.
  21081. * @param size Define the new size. It can be:
  21082. * - a number for squared texture,
  21083. * - an object containing { width: number, height: number }
  21084. * - or an object containing a ratio { ratio: number }
  21085. */
  21086. resize(size: number | {
  21087. width: number;
  21088. height: number;
  21089. } | {
  21090. ratio: number;
  21091. }): void;
  21092. /**
  21093. * Renders all the objects from the render list into the texture.
  21094. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21095. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21096. */
  21097. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21098. private _bestReflectionRenderTargetDimension;
  21099. /**
  21100. * @hidden
  21101. * @param faceIndex face index to bind to if this is a cubetexture
  21102. */
  21103. _bindFrameBuffer(faceIndex?: number): void;
  21104. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21105. private renderToTarget;
  21106. /**
  21107. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21108. * This allowed control for front to back rendering or reversly depending of the special needs.
  21109. *
  21110. * @param renderingGroupId The rendering group id corresponding to its index
  21111. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21112. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21113. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21114. */
  21115. 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;
  21116. /**
  21117. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21118. *
  21119. * @param renderingGroupId The rendering group id corresponding to its index
  21120. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21121. */
  21122. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21123. /**
  21124. * Clones the texture.
  21125. * @returns the cloned texture
  21126. */
  21127. clone(): RenderTargetTexture;
  21128. /**
  21129. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21130. * @returns The JSON representation of the texture
  21131. */
  21132. serialize(): any;
  21133. /**
  21134. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21135. */
  21136. disposeFramebufferObjects(): void;
  21137. /**
  21138. * Dispose the texture and release its associated resources.
  21139. */
  21140. dispose(): void;
  21141. /** @hidden */
  21142. _rebuild(): void;
  21143. /**
  21144. * Clear the info related to rendering groups preventing retention point in material dispose.
  21145. */
  21146. freeRenderingGroups(): void;
  21147. /**
  21148. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21149. * @returns the view count
  21150. */
  21151. getViewCount(): number;
  21152. }
  21153. }
  21154. declare module "babylonjs/Materials/material" {
  21155. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21156. import { SmartArray } from "babylonjs/Misc/smartArray";
  21157. import { Observable } from "babylonjs/Misc/observable";
  21158. import { Nullable } from "babylonjs/types";
  21159. import { Scene } from "babylonjs/scene";
  21160. import { Matrix } from "babylonjs/Maths/math.vector";
  21161. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21163. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21164. import { Effect } from "babylonjs/Materials/effect";
  21165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21166. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21167. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21168. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21169. import { Mesh } from "babylonjs/Meshes/mesh";
  21170. import { Animation } from "babylonjs/Animations/animation";
  21171. /**
  21172. * Options for compiling materials.
  21173. */
  21174. export interface IMaterialCompilationOptions {
  21175. /**
  21176. * Defines whether clip planes are enabled.
  21177. */
  21178. clipPlane: boolean;
  21179. /**
  21180. * Defines whether instances are enabled.
  21181. */
  21182. useInstances: boolean;
  21183. }
  21184. /**
  21185. * Base class for the main features of a material in Babylon.js
  21186. */
  21187. export class Material implements IAnimatable {
  21188. /**
  21189. * Returns the triangle fill mode
  21190. */
  21191. static readonly TriangleFillMode: number;
  21192. /**
  21193. * Returns the wireframe mode
  21194. */
  21195. static readonly WireFrameFillMode: number;
  21196. /**
  21197. * Returns the point fill mode
  21198. */
  21199. static readonly PointFillMode: number;
  21200. /**
  21201. * Returns the point list draw mode
  21202. */
  21203. static readonly PointListDrawMode: number;
  21204. /**
  21205. * Returns the line list draw mode
  21206. */
  21207. static readonly LineListDrawMode: number;
  21208. /**
  21209. * Returns the line loop draw mode
  21210. */
  21211. static readonly LineLoopDrawMode: number;
  21212. /**
  21213. * Returns the line strip draw mode
  21214. */
  21215. static readonly LineStripDrawMode: number;
  21216. /**
  21217. * Returns the triangle strip draw mode
  21218. */
  21219. static readonly TriangleStripDrawMode: number;
  21220. /**
  21221. * Returns the triangle fan draw mode
  21222. */
  21223. static readonly TriangleFanDrawMode: number;
  21224. /**
  21225. * Stores the clock-wise side orientation
  21226. */
  21227. static readonly ClockWiseSideOrientation: number;
  21228. /**
  21229. * Stores the counter clock-wise side orientation
  21230. */
  21231. static readonly CounterClockWiseSideOrientation: number;
  21232. /**
  21233. * The dirty texture flag value
  21234. */
  21235. static readonly TextureDirtyFlag: number;
  21236. /**
  21237. * The dirty light flag value
  21238. */
  21239. static readonly LightDirtyFlag: number;
  21240. /**
  21241. * The dirty fresnel flag value
  21242. */
  21243. static readonly FresnelDirtyFlag: number;
  21244. /**
  21245. * The dirty attribute flag value
  21246. */
  21247. static readonly AttributesDirtyFlag: number;
  21248. /**
  21249. * The dirty misc flag value
  21250. */
  21251. static readonly MiscDirtyFlag: number;
  21252. /**
  21253. * The all dirty flag value
  21254. */
  21255. static readonly AllDirtyFlag: number;
  21256. /**
  21257. * The ID of the material
  21258. */
  21259. id: string;
  21260. /**
  21261. * Gets or sets the unique id of the material
  21262. */
  21263. uniqueId: number;
  21264. /**
  21265. * The name of the material
  21266. */
  21267. name: string;
  21268. /**
  21269. * Gets or sets user defined metadata
  21270. */
  21271. metadata: any;
  21272. /**
  21273. * For internal use only. Please do not use.
  21274. */
  21275. reservedDataStore: any;
  21276. /**
  21277. * Specifies if the ready state should be checked on each call
  21278. */
  21279. checkReadyOnEveryCall: boolean;
  21280. /**
  21281. * Specifies if the ready state should be checked once
  21282. */
  21283. checkReadyOnlyOnce: boolean;
  21284. /**
  21285. * The state of the material
  21286. */
  21287. state: string;
  21288. /**
  21289. * The alpha value of the material
  21290. */
  21291. protected _alpha: number;
  21292. /**
  21293. * List of inspectable custom properties (used by the Inspector)
  21294. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21295. */
  21296. inspectableCustomProperties: IInspectable[];
  21297. /**
  21298. * Sets the alpha value of the material
  21299. */
  21300. set alpha(value: number);
  21301. /**
  21302. * Gets the alpha value of the material
  21303. */
  21304. get alpha(): number;
  21305. /**
  21306. * Specifies if back face culling is enabled
  21307. */
  21308. protected _backFaceCulling: boolean;
  21309. /**
  21310. * Sets the back-face culling state
  21311. */
  21312. set backFaceCulling(value: boolean);
  21313. /**
  21314. * Gets the back-face culling state
  21315. */
  21316. get backFaceCulling(): boolean;
  21317. /**
  21318. * Stores the value for side orientation
  21319. */
  21320. sideOrientation: number;
  21321. /**
  21322. * Callback triggered when the material is compiled
  21323. */
  21324. onCompiled: Nullable<(effect: Effect) => void>;
  21325. /**
  21326. * Callback triggered when an error occurs
  21327. */
  21328. onError: Nullable<(effect: Effect, errors: string) => void>;
  21329. /**
  21330. * Callback triggered to get the render target textures
  21331. */
  21332. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21333. /**
  21334. * Gets a boolean indicating that current material needs to register RTT
  21335. */
  21336. get hasRenderTargetTextures(): boolean;
  21337. /**
  21338. * Specifies if the material should be serialized
  21339. */
  21340. doNotSerialize: boolean;
  21341. /**
  21342. * @hidden
  21343. */
  21344. _storeEffectOnSubMeshes: boolean;
  21345. /**
  21346. * Stores the animations for the material
  21347. */
  21348. animations: Nullable<Array<Animation>>;
  21349. /**
  21350. * An event triggered when the material is disposed
  21351. */
  21352. onDisposeObservable: Observable<Material>;
  21353. /**
  21354. * An observer which watches for dispose events
  21355. */
  21356. private _onDisposeObserver;
  21357. private _onUnBindObservable;
  21358. /**
  21359. * Called during a dispose event
  21360. */
  21361. set onDispose(callback: () => void);
  21362. private _onBindObservable;
  21363. /**
  21364. * An event triggered when the material is bound
  21365. */
  21366. get onBindObservable(): Observable<AbstractMesh>;
  21367. /**
  21368. * An observer which watches for bind events
  21369. */
  21370. private _onBindObserver;
  21371. /**
  21372. * Called during a bind event
  21373. */
  21374. set onBind(callback: (Mesh: AbstractMesh) => void);
  21375. /**
  21376. * An event triggered when the material is unbound
  21377. */
  21378. get onUnBindObservable(): Observable<Material>;
  21379. /**
  21380. * Stores the value of the alpha mode
  21381. */
  21382. private _alphaMode;
  21383. /**
  21384. * Sets the value of the alpha mode.
  21385. *
  21386. * | Value | Type | Description |
  21387. * | --- | --- | --- |
  21388. * | 0 | ALPHA_DISABLE | |
  21389. * | 1 | ALPHA_ADD | |
  21390. * | 2 | ALPHA_COMBINE | |
  21391. * | 3 | ALPHA_SUBTRACT | |
  21392. * | 4 | ALPHA_MULTIPLY | |
  21393. * | 5 | ALPHA_MAXIMIZED | |
  21394. * | 6 | ALPHA_ONEONE | |
  21395. * | 7 | ALPHA_PREMULTIPLIED | |
  21396. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21397. * | 9 | ALPHA_INTERPOLATE | |
  21398. * | 10 | ALPHA_SCREENMODE | |
  21399. *
  21400. */
  21401. set alphaMode(value: number);
  21402. /**
  21403. * Gets the value of the alpha mode
  21404. */
  21405. get alphaMode(): number;
  21406. /**
  21407. * Stores the state of the need depth pre-pass value
  21408. */
  21409. private _needDepthPrePass;
  21410. /**
  21411. * Sets the need depth pre-pass value
  21412. */
  21413. set needDepthPrePass(value: boolean);
  21414. /**
  21415. * Gets the depth pre-pass value
  21416. */
  21417. get needDepthPrePass(): boolean;
  21418. /**
  21419. * Specifies if depth writing should be disabled
  21420. */
  21421. disableDepthWrite: boolean;
  21422. /**
  21423. * Specifies if depth writing should be forced
  21424. */
  21425. forceDepthWrite: boolean;
  21426. /**
  21427. * Specifies the depth function that should be used. 0 means the default engine function
  21428. */
  21429. depthFunction: number;
  21430. /**
  21431. * Specifies if there should be a separate pass for culling
  21432. */
  21433. separateCullingPass: boolean;
  21434. /**
  21435. * Stores the state specifing if fog should be enabled
  21436. */
  21437. private _fogEnabled;
  21438. /**
  21439. * Sets the state for enabling fog
  21440. */
  21441. set fogEnabled(value: boolean);
  21442. /**
  21443. * Gets the value of the fog enabled state
  21444. */
  21445. get fogEnabled(): boolean;
  21446. /**
  21447. * Stores the size of points
  21448. */
  21449. pointSize: number;
  21450. /**
  21451. * Stores the z offset value
  21452. */
  21453. zOffset: number;
  21454. /**
  21455. * Gets a value specifying if wireframe mode is enabled
  21456. */
  21457. get wireframe(): boolean;
  21458. /**
  21459. * Sets the state of wireframe mode
  21460. */
  21461. set wireframe(value: boolean);
  21462. /**
  21463. * Gets the value specifying if point clouds are enabled
  21464. */
  21465. get pointsCloud(): boolean;
  21466. /**
  21467. * Sets the state of point cloud mode
  21468. */
  21469. set pointsCloud(value: boolean);
  21470. /**
  21471. * Gets the material fill mode
  21472. */
  21473. get fillMode(): number;
  21474. /**
  21475. * Sets the material fill mode
  21476. */
  21477. set fillMode(value: number);
  21478. /**
  21479. * @hidden
  21480. * Stores the effects for the material
  21481. */
  21482. _effect: Nullable<Effect>;
  21483. /**
  21484. * Specifies if uniform buffers should be used
  21485. */
  21486. private _useUBO;
  21487. /**
  21488. * Stores a reference to the scene
  21489. */
  21490. private _scene;
  21491. /**
  21492. * Stores the fill mode state
  21493. */
  21494. private _fillMode;
  21495. /**
  21496. * Specifies if the depth write state should be cached
  21497. */
  21498. private _cachedDepthWriteState;
  21499. /**
  21500. * Specifies if the depth function state should be cached
  21501. */
  21502. private _cachedDepthFunctionState;
  21503. /**
  21504. * Stores the uniform buffer
  21505. */
  21506. protected _uniformBuffer: UniformBuffer;
  21507. /** @hidden */
  21508. _indexInSceneMaterialArray: number;
  21509. /** @hidden */
  21510. meshMap: Nullable<{
  21511. [id: string]: AbstractMesh | undefined;
  21512. }>;
  21513. /**
  21514. * Creates a material instance
  21515. * @param name defines the name of the material
  21516. * @param scene defines the scene to reference
  21517. * @param doNotAdd specifies if the material should be added to the scene
  21518. */
  21519. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21520. /**
  21521. * Returns a string representation of the current material
  21522. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21523. * @returns a string with material information
  21524. */
  21525. toString(fullDetails?: boolean): string;
  21526. /**
  21527. * Gets the class name of the material
  21528. * @returns a string with the class name of the material
  21529. */
  21530. getClassName(): string;
  21531. /**
  21532. * Specifies if updates for the material been locked
  21533. */
  21534. get isFrozen(): boolean;
  21535. /**
  21536. * Locks updates for the material
  21537. */
  21538. freeze(): void;
  21539. /**
  21540. * Unlocks updates for the material
  21541. */
  21542. unfreeze(): void;
  21543. /**
  21544. * Specifies if the material is ready to be used
  21545. * @param mesh defines the mesh to check
  21546. * @param useInstances specifies if instances should be used
  21547. * @returns a boolean indicating if the material is ready to be used
  21548. */
  21549. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21550. /**
  21551. * Specifies that the submesh is ready to be used
  21552. * @param mesh defines the mesh to check
  21553. * @param subMesh defines which submesh to check
  21554. * @param useInstances specifies that instances should be used
  21555. * @returns a boolean indicating that the submesh is ready or not
  21556. */
  21557. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21558. /**
  21559. * Returns the material effect
  21560. * @returns the effect associated with the material
  21561. */
  21562. getEffect(): Nullable<Effect>;
  21563. /**
  21564. * Returns the current scene
  21565. * @returns a Scene
  21566. */
  21567. getScene(): Scene;
  21568. /**
  21569. * Specifies if the material will require alpha blending
  21570. * @returns a boolean specifying if alpha blending is needed
  21571. */
  21572. needAlphaBlending(): boolean;
  21573. /**
  21574. * Specifies if the mesh will require alpha blending
  21575. * @param mesh defines the mesh to check
  21576. * @returns a boolean specifying if alpha blending is needed for the mesh
  21577. */
  21578. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21579. /**
  21580. * Specifies if this material should be rendered in alpha test mode
  21581. * @returns a boolean specifying if an alpha test is needed.
  21582. */
  21583. needAlphaTesting(): boolean;
  21584. /**
  21585. * Gets the texture used for the alpha test
  21586. * @returns the texture to use for alpha testing
  21587. */
  21588. getAlphaTestTexture(): Nullable<BaseTexture>;
  21589. /**
  21590. * Marks the material to indicate that it needs to be re-calculated
  21591. */
  21592. markDirty(): void;
  21593. /** @hidden */
  21594. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21595. /**
  21596. * Binds the material to the mesh
  21597. * @param world defines the world transformation matrix
  21598. * @param mesh defines the mesh to bind the material to
  21599. */
  21600. bind(world: Matrix, mesh?: Mesh): void;
  21601. /**
  21602. * Binds the submesh to the material
  21603. * @param world defines the world transformation matrix
  21604. * @param mesh defines the mesh containing the submesh
  21605. * @param subMesh defines the submesh to bind the material to
  21606. */
  21607. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21608. /**
  21609. * Binds the world matrix to the material
  21610. * @param world defines the world transformation matrix
  21611. */
  21612. bindOnlyWorldMatrix(world: Matrix): void;
  21613. /**
  21614. * Binds the scene's uniform buffer to the effect.
  21615. * @param effect defines the effect to bind to the scene uniform buffer
  21616. * @param sceneUbo defines the uniform buffer storing scene data
  21617. */
  21618. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21619. /**
  21620. * Binds the view matrix to the effect
  21621. * @param effect defines the effect to bind the view matrix to
  21622. */
  21623. bindView(effect: Effect): void;
  21624. /**
  21625. * Binds the view projection matrix to the effect
  21626. * @param effect defines the effect to bind the view projection matrix to
  21627. */
  21628. bindViewProjection(effect: Effect): void;
  21629. /**
  21630. * Specifies if material alpha testing should be turned on for the mesh
  21631. * @param mesh defines the mesh to check
  21632. */
  21633. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21634. /**
  21635. * Processes to execute after binding the material to a mesh
  21636. * @param mesh defines the rendered mesh
  21637. */
  21638. protected _afterBind(mesh?: Mesh): void;
  21639. /**
  21640. * Unbinds the material from the mesh
  21641. */
  21642. unbind(): void;
  21643. /**
  21644. * Gets the active textures from the material
  21645. * @returns an array of textures
  21646. */
  21647. getActiveTextures(): BaseTexture[];
  21648. /**
  21649. * Specifies if the material uses a texture
  21650. * @param texture defines the texture to check against the material
  21651. * @returns a boolean specifying if the material uses the texture
  21652. */
  21653. hasTexture(texture: BaseTexture): boolean;
  21654. /**
  21655. * Makes a duplicate of the material, and gives it a new name
  21656. * @param name defines the new name for the duplicated material
  21657. * @returns the cloned material
  21658. */
  21659. clone(name: string): Nullable<Material>;
  21660. /**
  21661. * Gets the meshes bound to the material
  21662. * @returns an array of meshes bound to the material
  21663. */
  21664. getBindedMeshes(): AbstractMesh[];
  21665. /**
  21666. * Force shader compilation
  21667. * @param mesh defines the mesh associated with this material
  21668. * @param onCompiled defines a function to execute once the material is compiled
  21669. * @param options defines the options to configure the compilation
  21670. * @param onError defines a function to execute if the material fails compiling
  21671. */
  21672. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21673. /**
  21674. * Force shader compilation
  21675. * @param mesh defines the mesh that will use this material
  21676. * @param options defines additional options for compiling the shaders
  21677. * @returns a promise that resolves when the compilation completes
  21678. */
  21679. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21680. private static readonly _AllDirtyCallBack;
  21681. private static readonly _ImageProcessingDirtyCallBack;
  21682. private static readonly _TextureDirtyCallBack;
  21683. private static readonly _FresnelDirtyCallBack;
  21684. private static readonly _MiscDirtyCallBack;
  21685. private static readonly _LightsDirtyCallBack;
  21686. private static readonly _AttributeDirtyCallBack;
  21687. private static _FresnelAndMiscDirtyCallBack;
  21688. private static _TextureAndMiscDirtyCallBack;
  21689. private static readonly _DirtyCallbackArray;
  21690. private static readonly _RunDirtyCallBacks;
  21691. /**
  21692. * Marks a define in the material to indicate that it needs to be re-computed
  21693. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21694. */
  21695. markAsDirty(flag: number): void;
  21696. /**
  21697. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21698. * @param func defines a function which checks material defines against the submeshes
  21699. */
  21700. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21701. /**
  21702. * Indicates that we need to re-calculated for all submeshes
  21703. */
  21704. protected _markAllSubMeshesAsAllDirty(): void;
  21705. /**
  21706. * Indicates that image processing needs to be re-calculated for all submeshes
  21707. */
  21708. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21709. /**
  21710. * Indicates that textures need to be re-calculated for all submeshes
  21711. */
  21712. protected _markAllSubMeshesAsTexturesDirty(): void;
  21713. /**
  21714. * Indicates that fresnel needs to be re-calculated for all submeshes
  21715. */
  21716. protected _markAllSubMeshesAsFresnelDirty(): void;
  21717. /**
  21718. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21719. */
  21720. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21721. /**
  21722. * Indicates that lights need to be re-calculated for all submeshes
  21723. */
  21724. protected _markAllSubMeshesAsLightsDirty(): void;
  21725. /**
  21726. * Indicates that attributes need to be re-calculated for all submeshes
  21727. */
  21728. protected _markAllSubMeshesAsAttributesDirty(): void;
  21729. /**
  21730. * Indicates that misc needs to be re-calculated for all submeshes
  21731. */
  21732. protected _markAllSubMeshesAsMiscDirty(): void;
  21733. /**
  21734. * Indicates that textures and misc need to be re-calculated for all submeshes
  21735. */
  21736. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21737. /**
  21738. * Disposes the material
  21739. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21740. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21741. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21742. */
  21743. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21744. /** @hidden */
  21745. private releaseVertexArrayObject;
  21746. /**
  21747. * Serializes this material
  21748. * @returns the serialized material object
  21749. */
  21750. serialize(): any;
  21751. /**
  21752. * Creates a material from parsed material data
  21753. * @param parsedMaterial defines parsed material data
  21754. * @param scene defines the hosting scene
  21755. * @param rootUrl defines the root URL to use to load textures
  21756. * @returns a new material
  21757. */
  21758. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21759. }
  21760. }
  21761. declare module "babylonjs/Materials/multiMaterial" {
  21762. import { Nullable } from "babylonjs/types";
  21763. import { Scene } from "babylonjs/scene";
  21764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21765. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21767. import { Material } from "babylonjs/Materials/material";
  21768. /**
  21769. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21770. * separate meshes. This can be use to improve performances.
  21771. * @see http://doc.babylonjs.com/how_to/multi_materials
  21772. */
  21773. export class MultiMaterial extends Material {
  21774. private _subMaterials;
  21775. /**
  21776. * Gets or Sets the list of Materials used within the multi material.
  21777. * They need to be ordered according to the submeshes order in the associated mesh
  21778. */
  21779. get subMaterials(): Nullable<Material>[];
  21780. set subMaterials(value: Nullable<Material>[]);
  21781. /**
  21782. * Function used to align with Node.getChildren()
  21783. * @returns the list of Materials used within the multi material
  21784. */
  21785. getChildren(): Nullable<Material>[];
  21786. /**
  21787. * Instantiates a new Multi Material
  21788. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21789. * separate meshes. This can be use to improve performances.
  21790. * @see http://doc.babylonjs.com/how_to/multi_materials
  21791. * @param name Define the name in the scene
  21792. * @param scene Define the scene the material belongs to
  21793. */
  21794. constructor(name: string, scene: Scene);
  21795. private _hookArray;
  21796. /**
  21797. * Get one of the submaterial by its index in the submaterials array
  21798. * @param index The index to look the sub material at
  21799. * @returns The Material if the index has been defined
  21800. */
  21801. getSubMaterial(index: number): Nullable<Material>;
  21802. /**
  21803. * Get the list of active textures for the whole sub materials list.
  21804. * @returns All the textures that will be used during the rendering
  21805. */
  21806. getActiveTextures(): BaseTexture[];
  21807. /**
  21808. * Gets the current class name of the material e.g. "MultiMaterial"
  21809. * Mainly use in serialization.
  21810. * @returns the class name
  21811. */
  21812. getClassName(): string;
  21813. /**
  21814. * Checks if the material is ready to render the requested sub mesh
  21815. * @param mesh Define the mesh the submesh belongs to
  21816. * @param subMesh Define the sub mesh to look readyness for
  21817. * @param useInstances Define whether or not the material is used with instances
  21818. * @returns true if ready, otherwise false
  21819. */
  21820. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21821. /**
  21822. * Clones the current material and its related sub materials
  21823. * @param name Define the name of the newly cloned material
  21824. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21825. * @returns the cloned material
  21826. */
  21827. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21828. /**
  21829. * Serializes the materials into a JSON representation.
  21830. * @returns the JSON representation
  21831. */
  21832. serialize(): any;
  21833. /**
  21834. * Dispose the material and release its associated resources
  21835. * @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)
  21836. * @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)
  21837. * @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)
  21838. */
  21839. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21840. /**
  21841. * Creates a MultiMaterial from parsed MultiMaterial data.
  21842. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21843. * @param scene defines the hosting scene
  21844. * @returns a new MultiMaterial
  21845. */
  21846. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21847. }
  21848. }
  21849. declare module "babylonjs/Meshes/subMesh" {
  21850. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21851. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21852. import { Engine } from "babylonjs/Engines/engine";
  21853. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21854. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21855. import { Effect } from "babylonjs/Materials/effect";
  21856. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21857. import { Plane } from "babylonjs/Maths/math.plane";
  21858. import { Collider } from "babylonjs/Collisions/collider";
  21859. import { Material } from "babylonjs/Materials/material";
  21860. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21862. import { Mesh } from "babylonjs/Meshes/mesh";
  21863. import { Ray } from "babylonjs/Culling/ray";
  21864. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21865. /**
  21866. * Base class for submeshes
  21867. */
  21868. export class BaseSubMesh {
  21869. /** @hidden */
  21870. _materialDefines: Nullable<MaterialDefines>;
  21871. /** @hidden */
  21872. _materialEffect: Nullable<Effect>;
  21873. /**
  21874. * Gets material defines used by the effect associated to the sub mesh
  21875. */
  21876. get materialDefines(): Nullable<MaterialDefines>;
  21877. /**
  21878. * Sets material defines used by the effect associated to the sub mesh
  21879. */
  21880. set materialDefines(defines: Nullable<MaterialDefines>);
  21881. /**
  21882. * Gets associated effect
  21883. */
  21884. get effect(): Nullable<Effect>;
  21885. /**
  21886. * Sets associated effect (effect used to render this submesh)
  21887. * @param effect defines the effect to associate with
  21888. * @param defines defines the set of defines used to compile this effect
  21889. */
  21890. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21891. }
  21892. /**
  21893. * Defines a subdivision inside a mesh
  21894. */
  21895. export class SubMesh extends BaseSubMesh implements ICullable {
  21896. /** the material index to use */
  21897. materialIndex: number;
  21898. /** vertex index start */
  21899. verticesStart: number;
  21900. /** vertices count */
  21901. verticesCount: number;
  21902. /** index start */
  21903. indexStart: number;
  21904. /** indices count */
  21905. indexCount: number;
  21906. /** @hidden */
  21907. _linesIndexCount: number;
  21908. private _mesh;
  21909. private _renderingMesh;
  21910. private _boundingInfo;
  21911. private _linesIndexBuffer;
  21912. /** @hidden */
  21913. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21914. /** @hidden */
  21915. _trianglePlanes: Plane[];
  21916. /** @hidden */
  21917. _lastColliderTransformMatrix: Nullable<Matrix>;
  21918. /** @hidden */
  21919. _renderId: number;
  21920. /** @hidden */
  21921. _alphaIndex: number;
  21922. /** @hidden */
  21923. _distanceToCamera: number;
  21924. /** @hidden */
  21925. _id: number;
  21926. private _currentMaterial;
  21927. /**
  21928. * Add a new submesh to a mesh
  21929. * @param materialIndex defines the material index to use
  21930. * @param verticesStart defines vertex index start
  21931. * @param verticesCount defines vertices count
  21932. * @param indexStart defines index start
  21933. * @param indexCount defines indices count
  21934. * @param mesh defines the parent mesh
  21935. * @param renderingMesh defines an optional rendering mesh
  21936. * @param createBoundingBox defines if bounding box should be created for this submesh
  21937. * @returns the new submesh
  21938. */
  21939. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21940. /**
  21941. * Creates a new submesh
  21942. * @param materialIndex defines the material index to use
  21943. * @param verticesStart defines vertex index start
  21944. * @param verticesCount defines vertices count
  21945. * @param indexStart defines index start
  21946. * @param indexCount defines indices count
  21947. * @param mesh defines the parent mesh
  21948. * @param renderingMesh defines an optional rendering mesh
  21949. * @param createBoundingBox defines if bounding box should be created for this submesh
  21950. */
  21951. constructor(
  21952. /** the material index to use */
  21953. materialIndex: number,
  21954. /** vertex index start */
  21955. verticesStart: number,
  21956. /** vertices count */
  21957. verticesCount: number,
  21958. /** index start */
  21959. indexStart: number,
  21960. /** indices count */
  21961. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21962. /**
  21963. * Returns true if this submesh covers the entire parent mesh
  21964. * @ignorenaming
  21965. */
  21966. get IsGlobal(): boolean;
  21967. /**
  21968. * Returns the submesh BoudingInfo object
  21969. * @returns current bounding info (or mesh's one if the submesh is global)
  21970. */
  21971. getBoundingInfo(): BoundingInfo;
  21972. /**
  21973. * Sets the submesh BoundingInfo
  21974. * @param boundingInfo defines the new bounding info to use
  21975. * @returns the SubMesh
  21976. */
  21977. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21978. /**
  21979. * Returns the mesh of the current submesh
  21980. * @return the parent mesh
  21981. */
  21982. getMesh(): AbstractMesh;
  21983. /**
  21984. * Returns the rendering mesh of the submesh
  21985. * @returns the rendering mesh (could be different from parent mesh)
  21986. */
  21987. getRenderingMesh(): Mesh;
  21988. /**
  21989. * Returns the submesh material
  21990. * @returns null or the current material
  21991. */
  21992. getMaterial(): Nullable<Material>;
  21993. /**
  21994. * Sets a new updated BoundingInfo object to the submesh
  21995. * @param data defines an optional position array to use to determine the bounding info
  21996. * @returns the SubMesh
  21997. */
  21998. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21999. /** @hidden */
  22000. _checkCollision(collider: Collider): boolean;
  22001. /**
  22002. * Updates the submesh BoundingInfo
  22003. * @param world defines the world matrix to use to update the bounding info
  22004. * @returns the submesh
  22005. */
  22006. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22007. /**
  22008. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22009. * @param frustumPlanes defines the frustum planes
  22010. * @returns true if the submesh is intersecting with the frustum
  22011. */
  22012. isInFrustum(frustumPlanes: Plane[]): boolean;
  22013. /**
  22014. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22015. * @param frustumPlanes defines the frustum planes
  22016. * @returns true if the submesh is inside the frustum
  22017. */
  22018. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22019. /**
  22020. * Renders the submesh
  22021. * @param enableAlphaMode defines if alpha needs to be used
  22022. * @returns the submesh
  22023. */
  22024. render(enableAlphaMode: boolean): SubMesh;
  22025. /**
  22026. * @hidden
  22027. */
  22028. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22029. /**
  22030. * Checks if the submesh intersects with a ray
  22031. * @param ray defines the ray to test
  22032. * @returns true is the passed ray intersects the submesh bounding box
  22033. */
  22034. canIntersects(ray: Ray): boolean;
  22035. /**
  22036. * Intersects current submesh with a ray
  22037. * @param ray defines the ray to test
  22038. * @param positions defines mesh's positions array
  22039. * @param indices defines mesh's indices array
  22040. * @param fastCheck defines if only bounding info should be used
  22041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22042. * @returns intersection info or null if no intersection
  22043. */
  22044. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22045. /** @hidden */
  22046. private _intersectLines;
  22047. /** @hidden */
  22048. private _intersectUnIndexedLines;
  22049. /** @hidden */
  22050. private _intersectTriangles;
  22051. /** @hidden */
  22052. private _intersectUnIndexedTriangles;
  22053. /** @hidden */
  22054. _rebuild(): void;
  22055. /**
  22056. * Creates a new submesh from the passed mesh
  22057. * @param newMesh defines the new hosting mesh
  22058. * @param newRenderingMesh defines an optional rendering mesh
  22059. * @returns the new submesh
  22060. */
  22061. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22062. /**
  22063. * Release associated resources
  22064. */
  22065. dispose(): void;
  22066. /**
  22067. * Gets the class name
  22068. * @returns the string "SubMesh".
  22069. */
  22070. getClassName(): string;
  22071. /**
  22072. * Creates a new submesh from indices data
  22073. * @param materialIndex the index of the main mesh material
  22074. * @param startIndex the index where to start the copy in the mesh indices array
  22075. * @param indexCount the number of indices to copy then from the startIndex
  22076. * @param mesh the main mesh to create the submesh from
  22077. * @param renderingMesh the optional rendering mesh
  22078. * @returns a new submesh
  22079. */
  22080. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22081. }
  22082. }
  22083. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22084. /**
  22085. * Class used to represent data loading progression
  22086. */
  22087. export class SceneLoaderFlags {
  22088. private static _ForceFullSceneLoadingForIncremental;
  22089. private static _ShowLoadingScreen;
  22090. private static _CleanBoneMatrixWeights;
  22091. private static _loggingLevel;
  22092. /**
  22093. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22094. */
  22095. static get ForceFullSceneLoadingForIncremental(): boolean;
  22096. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22097. /**
  22098. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22099. */
  22100. static get ShowLoadingScreen(): boolean;
  22101. static set ShowLoadingScreen(value: boolean);
  22102. /**
  22103. * Defines the current logging level (while loading the scene)
  22104. * @ignorenaming
  22105. */
  22106. static get loggingLevel(): number;
  22107. static set loggingLevel(value: number);
  22108. /**
  22109. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22110. */
  22111. static get CleanBoneMatrixWeights(): boolean;
  22112. static set CleanBoneMatrixWeights(value: boolean);
  22113. }
  22114. }
  22115. declare module "babylonjs/Meshes/geometry" {
  22116. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22117. import { Scene } from "babylonjs/scene";
  22118. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22119. import { Engine } from "babylonjs/Engines/engine";
  22120. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22121. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22122. import { Effect } from "babylonjs/Materials/effect";
  22123. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22124. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22125. import { Mesh } from "babylonjs/Meshes/mesh";
  22126. /**
  22127. * Class used to store geometry data (vertex buffers + index buffer)
  22128. */
  22129. export class Geometry implements IGetSetVerticesData {
  22130. /**
  22131. * Gets or sets the ID of the geometry
  22132. */
  22133. id: string;
  22134. /**
  22135. * Gets or sets the unique ID of the geometry
  22136. */
  22137. uniqueId: number;
  22138. /**
  22139. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22140. */
  22141. delayLoadState: number;
  22142. /**
  22143. * Gets the file containing the data to load when running in delay load state
  22144. */
  22145. delayLoadingFile: Nullable<string>;
  22146. /**
  22147. * Callback called when the geometry is updated
  22148. */
  22149. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22150. private _scene;
  22151. private _engine;
  22152. private _meshes;
  22153. private _totalVertices;
  22154. /** @hidden */
  22155. _indices: IndicesArray;
  22156. /** @hidden */
  22157. _vertexBuffers: {
  22158. [key: string]: VertexBuffer;
  22159. };
  22160. private _isDisposed;
  22161. private _extend;
  22162. private _boundingBias;
  22163. /** @hidden */
  22164. _delayInfo: Array<string>;
  22165. private _indexBuffer;
  22166. private _indexBufferIsUpdatable;
  22167. /** @hidden */
  22168. _boundingInfo: Nullable<BoundingInfo>;
  22169. /** @hidden */
  22170. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22171. /** @hidden */
  22172. _softwareSkinningFrameId: number;
  22173. private _vertexArrayObjects;
  22174. private _updatable;
  22175. /** @hidden */
  22176. _positions: Nullable<Vector3[]>;
  22177. /**
  22178. * 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
  22179. */
  22180. get boundingBias(): Vector2;
  22181. /**
  22182. * 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
  22183. */
  22184. set boundingBias(value: Vector2);
  22185. /**
  22186. * Static function used to attach a new empty geometry to a mesh
  22187. * @param mesh defines the mesh to attach the geometry to
  22188. * @returns the new Geometry
  22189. */
  22190. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22191. /**
  22192. * Creates a new geometry
  22193. * @param id defines the unique ID
  22194. * @param scene defines the hosting scene
  22195. * @param vertexData defines the VertexData used to get geometry data
  22196. * @param updatable defines if geometry must be updatable (false by default)
  22197. * @param mesh defines the mesh that will be associated with the geometry
  22198. */
  22199. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22200. /**
  22201. * Gets the current extend of the geometry
  22202. */
  22203. get extend(): {
  22204. minimum: Vector3;
  22205. maximum: Vector3;
  22206. };
  22207. /**
  22208. * Gets the hosting scene
  22209. * @returns the hosting Scene
  22210. */
  22211. getScene(): Scene;
  22212. /**
  22213. * Gets the hosting engine
  22214. * @returns the hosting Engine
  22215. */
  22216. getEngine(): Engine;
  22217. /**
  22218. * Defines if the geometry is ready to use
  22219. * @returns true if the geometry is ready to be used
  22220. */
  22221. isReady(): boolean;
  22222. /**
  22223. * Gets a value indicating that the geometry should not be serialized
  22224. */
  22225. get doNotSerialize(): boolean;
  22226. /** @hidden */
  22227. _rebuild(): void;
  22228. /**
  22229. * Affects all geometry data in one call
  22230. * @param vertexData defines the geometry data
  22231. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22232. */
  22233. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22234. /**
  22235. * Set specific vertex data
  22236. * @param kind defines the data kind (Position, normal, etc...)
  22237. * @param data defines the vertex data to use
  22238. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22239. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22240. */
  22241. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22242. /**
  22243. * Removes a specific vertex data
  22244. * @param kind defines the data kind (Position, normal, etc...)
  22245. */
  22246. removeVerticesData(kind: string): void;
  22247. /**
  22248. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22249. * @param buffer defines the vertex buffer to use
  22250. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22251. */
  22252. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22253. /**
  22254. * Update a specific vertex buffer
  22255. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22256. * It will do nothing if the buffer is not updatable
  22257. * @param kind defines the data kind (Position, normal, etc...)
  22258. * @param data defines the data to use
  22259. * @param offset defines the offset in the target buffer where to store the data
  22260. * @param useBytes set to true if the offset is in bytes
  22261. */
  22262. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22263. /**
  22264. * Update a specific vertex buffer
  22265. * This function will create a new buffer if the current one is not updatable
  22266. * @param kind defines the data kind (Position, normal, etc...)
  22267. * @param data defines the data to use
  22268. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22269. */
  22270. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22271. private _updateBoundingInfo;
  22272. /** @hidden */
  22273. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22274. /**
  22275. * Gets total number of vertices
  22276. * @returns the total number of vertices
  22277. */
  22278. getTotalVertices(): number;
  22279. /**
  22280. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22281. * @param kind defines the data kind (Position, normal, etc...)
  22282. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22283. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22284. * @returns a float array containing vertex data
  22285. */
  22286. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22287. /**
  22288. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22289. * @param kind defines the data kind (Position, normal, etc...)
  22290. * @returns true if the vertex buffer with the specified kind is updatable
  22291. */
  22292. isVertexBufferUpdatable(kind: string): boolean;
  22293. /**
  22294. * Gets a specific vertex buffer
  22295. * @param kind defines the data kind (Position, normal, etc...)
  22296. * @returns a VertexBuffer
  22297. */
  22298. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22299. /**
  22300. * Returns all vertex buffers
  22301. * @return an object holding all vertex buffers indexed by kind
  22302. */
  22303. getVertexBuffers(): Nullable<{
  22304. [key: string]: VertexBuffer;
  22305. }>;
  22306. /**
  22307. * Gets a boolean indicating if specific vertex buffer is present
  22308. * @param kind defines the data kind (Position, normal, etc...)
  22309. * @returns true if data is present
  22310. */
  22311. isVerticesDataPresent(kind: string): boolean;
  22312. /**
  22313. * Gets a list of all attached data kinds (Position, normal, etc...)
  22314. * @returns a list of string containing all kinds
  22315. */
  22316. getVerticesDataKinds(): string[];
  22317. /**
  22318. * Update index buffer
  22319. * @param indices defines the indices to store in the index buffer
  22320. * @param offset defines the offset in the target buffer where to store the data
  22321. * @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)
  22322. */
  22323. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22324. /**
  22325. * Creates a new index buffer
  22326. * @param indices defines the indices to store in the index buffer
  22327. * @param totalVertices defines the total number of vertices (could be null)
  22328. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22329. */
  22330. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22331. /**
  22332. * Return the total number of indices
  22333. * @returns the total number of indices
  22334. */
  22335. getTotalIndices(): number;
  22336. /**
  22337. * Gets the index buffer array
  22338. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22339. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22340. * @returns the index buffer array
  22341. */
  22342. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22343. /**
  22344. * Gets the index buffer
  22345. * @return the index buffer
  22346. */
  22347. getIndexBuffer(): Nullable<DataBuffer>;
  22348. /** @hidden */
  22349. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22350. /**
  22351. * Release the associated resources for a specific mesh
  22352. * @param mesh defines the source mesh
  22353. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22354. */
  22355. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22356. /**
  22357. * Apply current geometry to a given mesh
  22358. * @param mesh defines the mesh to apply geometry to
  22359. */
  22360. applyToMesh(mesh: Mesh): void;
  22361. private _updateExtend;
  22362. private _applyToMesh;
  22363. private notifyUpdate;
  22364. /**
  22365. * Load the geometry if it was flagged as delay loaded
  22366. * @param scene defines the hosting scene
  22367. * @param onLoaded defines a callback called when the geometry is loaded
  22368. */
  22369. load(scene: Scene, onLoaded?: () => void): void;
  22370. private _queueLoad;
  22371. /**
  22372. * Invert the geometry to move from a right handed system to a left handed one.
  22373. */
  22374. toLeftHanded(): void;
  22375. /** @hidden */
  22376. _resetPointsArrayCache(): void;
  22377. /** @hidden */
  22378. _generatePointsArray(): boolean;
  22379. /**
  22380. * Gets a value indicating if the geometry is disposed
  22381. * @returns true if the geometry was disposed
  22382. */
  22383. isDisposed(): boolean;
  22384. private _disposeVertexArrayObjects;
  22385. /**
  22386. * Free all associated resources
  22387. */
  22388. dispose(): void;
  22389. /**
  22390. * Clone the current geometry into a new geometry
  22391. * @param id defines the unique ID of the new geometry
  22392. * @returns a new geometry object
  22393. */
  22394. copy(id: string): Geometry;
  22395. /**
  22396. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22397. * @return a JSON representation of the current geometry data (without the vertices data)
  22398. */
  22399. serialize(): any;
  22400. private toNumberArray;
  22401. /**
  22402. * Serialize all vertices data into a JSON oject
  22403. * @returns a JSON representation of the current geometry data
  22404. */
  22405. serializeVerticeData(): any;
  22406. /**
  22407. * Extracts a clone of a mesh geometry
  22408. * @param mesh defines the source mesh
  22409. * @param id defines the unique ID of the new geometry object
  22410. * @returns the new geometry object
  22411. */
  22412. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22413. /**
  22414. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22415. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22416. * Be aware Math.random() could cause collisions, but:
  22417. * "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"
  22418. * @returns a string containing a new GUID
  22419. */
  22420. static RandomId(): string;
  22421. /** @hidden */
  22422. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22423. private static _CleanMatricesWeights;
  22424. /**
  22425. * Create a new geometry from persisted data (Using .babylon file format)
  22426. * @param parsedVertexData defines the persisted data
  22427. * @param scene defines the hosting scene
  22428. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22429. * @returns the new geometry object
  22430. */
  22431. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22432. }
  22433. }
  22434. declare module "babylonjs/Meshes/mesh.vertexData" {
  22435. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22436. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22437. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22438. import { Geometry } from "babylonjs/Meshes/geometry";
  22439. import { Mesh } from "babylonjs/Meshes/mesh";
  22440. /**
  22441. * Define an interface for all classes that will get and set the data on vertices
  22442. */
  22443. export interface IGetSetVerticesData {
  22444. /**
  22445. * Gets a boolean indicating if specific vertex data is present
  22446. * @param kind defines the vertex data kind to use
  22447. * @returns true is data kind is present
  22448. */
  22449. isVerticesDataPresent(kind: string): boolean;
  22450. /**
  22451. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22452. * @param kind defines the data kind (Position, normal, etc...)
  22453. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22454. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22455. * @returns a float array containing vertex data
  22456. */
  22457. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22458. /**
  22459. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22460. * @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.
  22461. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22462. * @returns the indices array or an empty array if the mesh has no geometry
  22463. */
  22464. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22465. /**
  22466. * Set specific vertex data
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. * @param data defines the vertex data to use
  22469. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22470. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22471. */
  22472. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22473. /**
  22474. * Update a specific associated vertex buffer
  22475. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22476. * - VertexBuffer.PositionKind
  22477. * - VertexBuffer.UVKind
  22478. * - VertexBuffer.UV2Kind
  22479. * - VertexBuffer.UV3Kind
  22480. * - VertexBuffer.UV4Kind
  22481. * - VertexBuffer.UV5Kind
  22482. * - VertexBuffer.UV6Kind
  22483. * - VertexBuffer.ColorKind
  22484. * - VertexBuffer.MatricesIndicesKind
  22485. * - VertexBuffer.MatricesIndicesExtraKind
  22486. * - VertexBuffer.MatricesWeightsKind
  22487. * - VertexBuffer.MatricesWeightsExtraKind
  22488. * @param data defines the data source
  22489. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22490. * @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)
  22491. */
  22492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22493. /**
  22494. * Creates a new index buffer
  22495. * @param indices defines the indices to store in the index buffer
  22496. * @param totalVertices defines the total number of vertices (could be null)
  22497. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22498. */
  22499. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22500. }
  22501. /**
  22502. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22503. */
  22504. export class VertexData {
  22505. /**
  22506. * Mesh side orientation : usually the external or front surface
  22507. */
  22508. static readonly FRONTSIDE: number;
  22509. /**
  22510. * Mesh side orientation : usually the internal or back surface
  22511. */
  22512. static readonly BACKSIDE: number;
  22513. /**
  22514. * Mesh side orientation : both internal and external or front and back surfaces
  22515. */
  22516. static readonly DOUBLESIDE: number;
  22517. /**
  22518. * Mesh side orientation : by default, `FRONTSIDE`
  22519. */
  22520. static readonly DEFAULTSIDE: number;
  22521. /**
  22522. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22523. */
  22524. positions: Nullable<FloatArray>;
  22525. /**
  22526. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22527. */
  22528. normals: Nullable<FloatArray>;
  22529. /**
  22530. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22531. */
  22532. tangents: Nullable<FloatArray>;
  22533. /**
  22534. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22535. */
  22536. uvs: Nullable<FloatArray>;
  22537. /**
  22538. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22539. */
  22540. uvs2: Nullable<FloatArray>;
  22541. /**
  22542. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22543. */
  22544. uvs3: Nullable<FloatArray>;
  22545. /**
  22546. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22547. */
  22548. uvs4: Nullable<FloatArray>;
  22549. /**
  22550. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22551. */
  22552. uvs5: Nullable<FloatArray>;
  22553. /**
  22554. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22555. */
  22556. uvs6: Nullable<FloatArray>;
  22557. /**
  22558. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22559. */
  22560. colors: Nullable<FloatArray>;
  22561. /**
  22562. * 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).
  22563. */
  22564. matricesIndices: Nullable<FloatArray>;
  22565. /**
  22566. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22567. */
  22568. matricesWeights: Nullable<FloatArray>;
  22569. /**
  22570. * An array extending the number of possible indices
  22571. */
  22572. matricesIndicesExtra: Nullable<FloatArray>;
  22573. /**
  22574. * An array extending the number of possible weights when the number of indices is extended
  22575. */
  22576. matricesWeightsExtra: Nullable<FloatArray>;
  22577. /**
  22578. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22579. */
  22580. indices: Nullable<IndicesArray>;
  22581. /**
  22582. * Uses the passed data array to set the set the values for the specified kind of data
  22583. * @param data a linear array of floating numbers
  22584. * @param kind the type of data that is being set, eg positions, colors etc
  22585. */
  22586. set(data: FloatArray, kind: string): void;
  22587. /**
  22588. * Associates the vertexData to the passed Mesh.
  22589. * Sets it as updatable or not (default `false`)
  22590. * @param mesh the mesh the vertexData is applied to
  22591. * @param updatable when used and having the value true allows new data to update the vertexData
  22592. * @returns the VertexData
  22593. */
  22594. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22595. /**
  22596. * Associates the vertexData to the passed Geometry.
  22597. * Sets it as updatable or not (default `false`)
  22598. * @param geometry the geometry the vertexData is applied to
  22599. * @param updatable when used and having the value true allows new data to update the vertexData
  22600. * @returns VertexData
  22601. */
  22602. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22603. /**
  22604. * Updates the associated mesh
  22605. * @param mesh the mesh to be updated
  22606. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22607. * @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
  22608. * @returns VertexData
  22609. */
  22610. updateMesh(mesh: Mesh): VertexData;
  22611. /**
  22612. * Updates the associated geometry
  22613. * @param geometry the geometry to be updated
  22614. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22615. * @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
  22616. * @returns VertexData.
  22617. */
  22618. updateGeometry(geometry: Geometry): VertexData;
  22619. private _applyTo;
  22620. private _update;
  22621. /**
  22622. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22623. * @param matrix the transforming matrix
  22624. * @returns the VertexData
  22625. */
  22626. transform(matrix: Matrix): VertexData;
  22627. /**
  22628. * Merges the passed VertexData into the current one
  22629. * @param other the VertexData to be merged into the current one
  22630. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22631. * @returns the modified VertexData
  22632. */
  22633. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22634. private _mergeElement;
  22635. private _validate;
  22636. /**
  22637. * Serializes the VertexData
  22638. * @returns a serialized object
  22639. */
  22640. serialize(): any;
  22641. /**
  22642. * Extracts the vertexData from a mesh
  22643. * @param mesh the mesh from which to extract the VertexData
  22644. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22645. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22646. * @returns the object VertexData associated to the passed mesh
  22647. */
  22648. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22649. /**
  22650. * Extracts the vertexData from the geometry
  22651. * @param geometry the geometry from which to extract the VertexData
  22652. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22653. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22654. * @returns the object VertexData associated to the passed mesh
  22655. */
  22656. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22657. private static _ExtractFrom;
  22658. /**
  22659. * Creates the VertexData for a Ribbon
  22660. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22661. * * pathArray array of paths, each of which an array of successive Vector3
  22662. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22663. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22664. * * 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
  22665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22666. * * 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)
  22667. * * 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)
  22668. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22669. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22670. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22671. * @returns the VertexData of the ribbon
  22672. */
  22673. static CreateRibbon(options: {
  22674. pathArray: Vector3[][];
  22675. closeArray?: boolean;
  22676. closePath?: boolean;
  22677. offset?: number;
  22678. sideOrientation?: number;
  22679. frontUVs?: Vector4;
  22680. backUVs?: Vector4;
  22681. invertUV?: boolean;
  22682. uvs?: Vector2[];
  22683. colors?: Color4[];
  22684. }): VertexData;
  22685. /**
  22686. * Creates the VertexData for a box
  22687. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22688. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22689. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22690. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22691. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22692. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22693. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22695. * * 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)
  22696. * * 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)
  22697. * @returns the VertexData of the box
  22698. */
  22699. static CreateBox(options: {
  22700. size?: number;
  22701. width?: number;
  22702. height?: number;
  22703. depth?: number;
  22704. faceUV?: Vector4[];
  22705. faceColors?: Color4[];
  22706. sideOrientation?: number;
  22707. frontUVs?: Vector4;
  22708. backUVs?: Vector4;
  22709. }): VertexData;
  22710. /**
  22711. * Creates the VertexData for a tiled box
  22712. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22713. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22714. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22715. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22716. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22717. * @returns the VertexData of the box
  22718. */
  22719. static CreateTiledBox(options: {
  22720. pattern?: number;
  22721. width?: number;
  22722. height?: number;
  22723. depth?: number;
  22724. tileSize?: number;
  22725. tileWidth?: number;
  22726. tileHeight?: number;
  22727. alignHorizontal?: number;
  22728. alignVertical?: number;
  22729. faceUV?: Vector4[];
  22730. faceColors?: Color4[];
  22731. sideOrientation?: number;
  22732. }): VertexData;
  22733. /**
  22734. * Creates the VertexData for a tiled plane
  22735. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22736. * * pattern a limited pattern arrangement depending on the number
  22737. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22738. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22739. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22741. * * 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)
  22742. * * 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)
  22743. * @returns the VertexData of the tiled plane
  22744. */
  22745. static CreateTiledPlane(options: {
  22746. pattern?: number;
  22747. tileSize?: number;
  22748. tileWidth?: number;
  22749. tileHeight?: number;
  22750. size?: number;
  22751. width?: number;
  22752. height?: number;
  22753. alignHorizontal?: number;
  22754. alignVertical?: number;
  22755. sideOrientation?: number;
  22756. frontUVs?: Vector4;
  22757. backUVs?: Vector4;
  22758. }): VertexData;
  22759. /**
  22760. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22762. * * segments sets the number of horizontal strips optional, default 32
  22763. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22764. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22765. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22766. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22767. * * 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
  22768. * * 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
  22769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22770. * * 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)
  22771. * * 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)
  22772. * @returns the VertexData of the ellipsoid
  22773. */
  22774. static CreateSphere(options: {
  22775. segments?: number;
  22776. diameter?: number;
  22777. diameterX?: number;
  22778. diameterY?: number;
  22779. diameterZ?: number;
  22780. arc?: number;
  22781. slice?: number;
  22782. sideOrientation?: number;
  22783. frontUVs?: Vector4;
  22784. backUVs?: Vector4;
  22785. }): VertexData;
  22786. /**
  22787. * Creates the VertexData for a cylinder, cone or prism
  22788. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22789. * * height sets the height (y direction) of the cylinder, optional, default 2
  22790. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22791. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22792. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22793. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22794. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22795. * * 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
  22796. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22797. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22798. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22799. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22801. * * 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)
  22802. * * 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)
  22803. * @returns the VertexData of the cylinder, cone or prism
  22804. */
  22805. static CreateCylinder(options: {
  22806. height?: number;
  22807. diameterTop?: number;
  22808. diameterBottom?: number;
  22809. diameter?: number;
  22810. tessellation?: number;
  22811. subdivisions?: number;
  22812. arc?: number;
  22813. faceColors?: Color4[];
  22814. faceUV?: Vector4[];
  22815. hasRings?: boolean;
  22816. enclose?: boolean;
  22817. sideOrientation?: number;
  22818. frontUVs?: Vector4;
  22819. backUVs?: Vector4;
  22820. }): VertexData;
  22821. /**
  22822. * Creates the VertexData for a torus
  22823. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22824. * * diameter the diameter of the torus, optional default 1
  22825. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22826. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22828. * * 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)
  22829. * * 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)
  22830. * @returns the VertexData of the torus
  22831. */
  22832. static CreateTorus(options: {
  22833. diameter?: number;
  22834. thickness?: number;
  22835. tessellation?: number;
  22836. sideOrientation?: number;
  22837. frontUVs?: Vector4;
  22838. backUVs?: Vector4;
  22839. }): VertexData;
  22840. /**
  22841. * Creates the VertexData of the LineSystem
  22842. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22843. * - lines an array of lines, each line being an array of successive Vector3
  22844. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22845. * @returns the VertexData of the LineSystem
  22846. */
  22847. static CreateLineSystem(options: {
  22848. lines: Vector3[][];
  22849. colors?: Nullable<Color4[][]>;
  22850. }): VertexData;
  22851. /**
  22852. * Create the VertexData for a DashedLines
  22853. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22854. * - points an array successive Vector3
  22855. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22856. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22857. * - dashNb the intended total number of dashes, optional, default 200
  22858. * @returns the VertexData for the DashedLines
  22859. */
  22860. static CreateDashedLines(options: {
  22861. points: Vector3[];
  22862. dashSize?: number;
  22863. gapSize?: number;
  22864. dashNb?: number;
  22865. }): VertexData;
  22866. /**
  22867. * Creates the VertexData for a Ground
  22868. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22869. * - width the width (x direction) of the ground, optional, default 1
  22870. * - height the height (z direction) of the ground, optional, default 1
  22871. * - subdivisions the number of subdivisions per side, optional, default 1
  22872. * @returns the VertexData of the Ground
  22873. */
  22874. static CreateGround(options: {
  22875. width?: number;
  22876. height?: number;
  22877. subdivisions?: number;
  22878. subdivisionsX?: number;
  22879. subdivisionsY?: number;
  22880. }): VertexData;
  22881. /**
  22882. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22883. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22884. * * xmin the ground minimum X coordinate, optional, default -1
  22885. * * zmin the ground minimum Z coordinate, optional, default -1
  22886. * * xmax the ground maximum X coordinate, optional, default 1
  22887. * * zmax the ground maximum Z coordinate, optional, default 1
  22888. * * 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}
  22889. * * 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}
  22890. * @returns the VertexData of the TiledGround
  22891. */
  22892. static CreateTiledGround(options: {
  22893. xmin: number;
  22894. zmin: number;
  22895. xmax: number;
  22896. zmax: number;
  22897. subdivisions?: {
  22898. w: number;
  22899. h: number;
  22900. };
  22901. precision?: {
  22902. w: number;
  22903. h: number;
  22904. };
  22905. }): VertexData;
  22906. /**
  22907. * Creates the VertexData of the Ground designed from a heightmap
  22908. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22909. * * width the width (x direction) of the ground
  22910. * * height the height (z direction) of the ground
  22911. * * subdivisions the number of subdivisions per side
  22912. * * minHeight the minimum altitude on the ground, optional, default 0
  22913. * * maxHeight the maximum altitude on the ground, optional default 1
  22914. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22915. * * buffer the array holding the image color data
  22916. * * bufferWidth the width of image
  22917. * * bufferHeight the height of image
  22918. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22919. * @returns the VertexData of the Ground designed from a heightmap
  22920. */
  22921. static CreateGroundFromHeightMap(options: {
  22922. width: number;
  22923. height: number;
  22924. subdivisions: number;
  22925. minHeight: number;
  22926. maxHeight: number;
  22927. colorFilter: Color3;
  22928. buffer: Uint8Array;
  22929. bufferWidth: number;
  22930. bufferHeight: number;
  22931. alphaFilter: number;
  22932. }): VertexData;
  22933. /**
  22934. * Creates the VertexData for a Plane
  22935. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22936. * * size sets the width and height of the plane to the value of size, optional default 1
  22937. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22938. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22940. * * 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)
  22941. * * 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)
  22942. * @returns the VertexData of the box
  22943. */
  22944. static CreatePlane(options: {
  22945. size?: number;
  22946. width?: number;
  22947. height?: number;
  22948. sideOrientation?: number;
  22949. frontUVs?: Vector4;
  22950. backUVs?: Vector4;
  22951. }): VertexData;
  22952. /**
  22953. * Creates the VertexData of the Disc or regular Polygon
  22954. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22955. * * radius the radius of the disc, optional default 0.5
  22956. * * tessellation the number of polygon sides, optional, default 64
  22957. * * 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
  22958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22959. * * 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)
  22960. * * 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)
  22961. * @returns the VertexData of the box
  22962. */
  22963. static CreateDisc(options: {
  22964. radius?: number;
  22965. tessellation?: number;
  22966. arc?: number;
  22967. sideOrientation?: number;
  22968. frontUVs?: Vector4;
  22969. backUVs?: Vector4;
  22970. }): VertexData;
  22971. /**
  22972. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22973. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22974. * @param polygon a mesh built from polygonTriangulation.build()
  22975. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22976. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22977. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22978. * @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)
  22979. * @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)
  22980. * @returns the VertexData of the Polygon
  22981. */
  22982. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22983. /**
  22984. * Creates the VertexData of the IcoSphere
  22985. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22986. * * radius the radius of the IcoSphere, optional default 1
  22987. * * radiusX allows stretching in the x direction, optional, default radius
  22988. * * radiusY allows stretching in the y direction, optional, default radius
  22989. * * radiusZ allows stretching in the z direction, optional, default radius
  22990. * * flat when true creates a flat shaded mesh, optional, default true
  22991. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22993. * * 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)
  22994. * * 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)
  22995. * @returns the VertexData of the IcoSphere
  22996. */
  22997. static CreateIcoSphere(options: {
  22998. radius?: number;
  22999. radiusX?: number;
  23000. radiusY?: number;
  23001. radiusZ?: number;
  23002. flat?: boolean;
  23003. subdivisions?: number;
  23004. sideOrientation?: number;
  23005. frontUVs?: Vector4;
  23006. backUVs?: Vector4;
  23007. }): VertexData;
  23008. /**
  23009. * Creates the VertexData for a Polyhedron
  23010. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23011. * * type provided types are:
  23012. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23013. * * 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)
  23014. * * size the size of the IcoSphere, optional default 1
  23015. * * sizeX allows stretching in the x direction, optional, default size
  23016. * * sizeY allows stretching in the y direction, optional, default size
  23017. * * sizeZ allows stretching in the z direction, optional, default size
  23018. * * 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
  23019. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23020. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23021. * * flat when true creates a flat shaded mesh, optional, default true
  23022. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23024. * * 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)
  23025. * * 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)
  23026. * @returns the VertexData of the Polyhedron
  23027. */
  23028. static CreatePolyhedron(options: {
  23029. type?: number;
  23030. size?: number;
  23031. sizeX?: number;
  23032. sizeY?: number;
  23033. sizeZ?: number;
  23034. custom?: any;
  23035. faceUV?: Vector4[];
  23036. faceColors?: Color4[];
  23037. flat?: boolean;
  23038. sideOrientation?: number;
  23039. frontUVs?: Vector4;
  23040. backUVs?: Vector4;
  23041. }): VertexData;
  23042. /**
  23043. * Creates the VertexData for a TorusKnot
  23044. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23045. * * radius the radius of the torus knot, optional, default 2
  23046. * * tube the thickness of the tube, optional, default 0.5
  23047. * * radialSegments the number of sides on each tube segments, optional, default 32
  23048. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23049. * * p the number of windings around the z axis, optional, default 2
  23050. * * q the number of windings around the x axis, optional, default 3
  23051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23052. * * 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)
  23053. * * 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)
  23054. * @returns the VertexData of the Torus Knot
  23055. */
  23056. static CreateTorusKnot(options: {
  23057. radius?: number;
  23058. tube?: number;
  23059. radialSegments?: number;
  23060. tubularSegments?: number;
  23061. p?: number;
  23062. q?: number;
  23063. sideOrientation?: number;
  23064. frontUVs?: Vector4;
  23065. backUVs?: Vector4;
  23066. }): VertexData;
  23067. /**
  23068. * Compute normals for given positions and indices
  23069. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23070. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23071. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23072. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23073. * * facetNormals : optional array of facet normals (vector3)
  23074. * * facetPositions : optional array of facet positions (vector3)
  23075. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23076. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23077. * * bInfo : optional bounding info, required for facetPartitioning computation
  23078. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23079. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23080. * * useRightHandedSystem: optional boolean to for right handed system computation
  23081. * * depthSort : optional boolean to enable the facet depth sort computation
  23082. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23083. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23084. */
  23085. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23086. facetNormals?: any;
  23087. facetPositions?: any;
  23088. facetPartitioning?: any;
  23089. ratio?: number;
  23090. bInfo?: any;
  23091. bbSize?: Vector3;
  23092. subDiv?: any;
  23093. useRightHandedSystem?: boolean;
  23094. depthSort?: boolean;
  23095. distanceTo?: Vector3;
  23096. depthSortedFacets?: any;
  23097. }): void;
  23098. /** @hidden */
  23099. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23100. /**
  23101. * Applies VertexData created from the imported parameters to the geometry
  23102. * @param parsedVertexData the parsed data from an imported file
  23103. * @param geometry the geometry to apply the VertexData to
  23104. */
  23105. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23106. }
  23107. }
  23108. declare module "babylonjs/Morph/morphTarget" {
  23109. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23110. import { Observable } from "babylonjs/Misc/observable";
  23111. import { Nullable, FloatArray } from "babylonjs/types";
  23112. import { Scene } from "babylonjs/scene";
  23113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23114. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23115. /**
  23116. * Defines a target to use with MorphTargetManager
  23117. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23118. */
  23119. export class MorphTarget implements IAnimatable {
  23120. /** defines the name of the target */
  23121. name: string;
  23122. /**
  23123. * Gets or sets the list of animations
  23124. */
  23125. animations: import("babylonjs/Animations/animation").Animation[];
  23126. private _scene;
  23127. private _positions;
  23128. private _normals;
  23129. private _tangents;
  23130. private _uvs;
  23131. private _influence;
  23132. private _uniqueId;
  23133. /**
  23134. * Observable raised when the influence changes
  23135. */
  23136. onInfluenceChanged: Observable<boolean>;
  23137. /** @hidden */
  23138. _onDataLayoutChanged: Observable<void>;
  23139. /**
  23140. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23141. */
  23142. get influence(): number;
  23143. set influence(influence: number);
  23144. /**
  23145. * Gets or sets the id of the morph Target
  23146. */
  23147. id: string;
  23148. private _animationPropertiesOverride;
  23149. /**
  23150. * Gets or sets the animation properties override
  23151. */
  23152. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23153. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23154. /**
  23155. * Creates a new MorphTarget
  23156. * @param name defines the name of the target
  23157. * @param influence defines the influence to use
  23158. * @param scene defines the scene the morphtarget belongs to
  23159. */
  23160. constructor(
  23161. /** defines the name of the target */
  23162. name: string, influence?: number, scene?: Nullable<Scene>);
  23163. /**
  23164. * Gets the unique ID of this manager
  23165. */
  23166. get uniqueId(): number;
  23167. /**
  23168. * Gets a boolean defining if the target contains position data
  23169. */
  23170. get hasPositions(): boolean;
  23171. /**
  23172. * Gets a boolean defining if the target contains normal data
  23173. */
  23174. get hasNormals(): boolean;
  23175. /**
  23176. * Gets a boolean defining if the target contains tangent data
  23177. */
  23178. get hasTangents(): boolean;
  23179. /**
  23180. * Gets a boolean defining if the target contains texture coordinates data
  23181. */
  23182. get hasUVs(): boolean;
  23183. /**
  23184. * Affects position data to this target
  23185. * @param data defines the position data to use
  23186. */
  23187. setPositions(data: Nullable<FloatArray>): void;
  23188. /**
  23189. * Gets the position data stored in this target
  23190. * @returns a FloatArray containing the position data (or null if not present)
  23191. */
  23192. getPositions(): Nullable<FloatArray>;
  23193. /**
  23194. * Affects normal data to this target
  23195. * @param data defines the normal data to use
  23196. */
  23197. setNormals(data: Nullable<FloatArray>): void;
  23198. /**
  23199. * Gets the normal data stored in this target
  23200. * @returns a FloatArray containing the normal data (or null if not present)
  23201. */
  23202. getNormals(): Nullable<FloatArray>;
  23203. /**
  23204. * Affects tangent data to this target
  23205. * @param data defines the tangent data to use
  23206. */
  23207. setTangents(data: Nullable<FloatArray>): void;
  23208. /**
  23209. * Gets the tangent data stored in this target
  23210. * @returns a FloatArray containing the tangent data (or null if not present)
  23211. */
  23212. getTangents(): Nullable<FloatArray>;
  23213. /**
  23214. * Affects texture coordinates data to this target
  23215. * @param data defines the texture coordinates data to use
  23216. */
  23217. setUVs(data: Nullable<FloatArray>): void;
  23218. /**
  23219. * Gets the texture coordinates data stored in this target
  23220. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23221. */
  23222. getUVs(): Nullable<FloatArray>;
  23223. /**
  23224. * Clone the current target
  23225. * @returns a new MorphTarget
  23226. */
  23227. clone(): MorphTarget;
  23228. /**
  23229. * Serializes the current target into a Serialization object
  23230. * @returns the serialized object
  23231. */
  23232. serialize(): any;
  23233. /**
  23234. * Returns the string "MorphTarget"
  23235. * @returns "MorphTarget"
  23236. */
  23237. getClassName(): string;
  23238. /**
  23239. * Creates a new target from serialized data
  23240. * @param serializationObject defines the serialized data to use
  23241. * @returns a new MorphTarget
  23242. */
  23243. static Parse(serializationObject: any): MorphTarget;
  23244. /**
  23245. * Creates a MorphTarget from mesh data
  23246. * @param mesh defines the source mesh
  23247. * @param name defines the name to use for the new target
  23248. * @param influence defines the influence to attach to the target
  23249. * @returns a new MorphTarget
  23250. */
  23251. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23252. }
  23253. }
  23254. declare module "babylonjs/Morph/morphTargetManager" {
  23255. import { Nullable } from "babylonjs/types";
  23256. import { Scene } from "babylonjs/scene";
  23257. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23258. /**
  23259. * This class is used to deform meshes using morphing between different targets
  23260. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23261. */
  23262. export class MorphTargetManager {
  23263. private _targets;
  23264. private _targetInfluenceChangedObservers;
  23265. private _targetDataLayoutChangedObservers;
  23266. private _activeTargets;
  23267. private _scene;
  23268. private _influences;
  23269. private _supportsNormals;
  23270. private _supportsTangents;
  23271. private _supportsUVs;
  23272. private _vertexCount;
  23273. private _uniqueId;
  23274. private _tempInfluences;
  23275. /**
  23276. * Gets or sets a boolean indicating if normals must be morphed
  23277. */
  23278. enableNormalMorphing: boolean;
  23279. /**
  23280. * Gets or sets a boolean indicating if tangents must be morphed
  23281. */
  23282. enableTangentMorphing: boolean;
  23283. /**
  23284. * Gets or sets a boolean indicating if UV must be morphed
  23285. */
  23286. enableUVMorphing: boolean;
  23287. /**
  23288. * Creates a new MorphTargetManager
  23289. * @param scene defines the current scene
  23290. */
  23291. constructor(scene?: Nullable<Scene>);
  23292. /**
  23293. * Gets the unique ID of this manager
  23294. */
  23295. get uniqueId(): number;
  23296. /**
  23297. * Gets the number of vertices handled by this manager
  23298. */
  23299. get vertexCount(): number;
  23300. /**
  23301. * Gets a boolean indicating if this manager supports morphing of normals
  23302. */
  23303. get supportsNormals(): boolean;
  23304. /**
  23305. * Gets a boolean indicating if this manager supports morphing of tangents
  23306. */
  23307. get supportsTangents(): boolean;
  23308. /**
  23309. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23310. */
  23311. get supportsUVs(): boolean;
  23312. /**
  23313. * Gets the number of targets stored in this manager
  23314. */
  23315. get numTargets(): number;
  23316. /**
  23317. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23318. */
  23319. get numInfluencers(): number;
  23320. /**
  23321. * Gets the list of influences (one per target)
  23322. */
  23323. get influences(): Float32Array;
  23324. /**
  23325. * Gets the active target at specified index. An active target is a target with an influence > 0
  23326. * @param index defines the index to check
  23327. * @returns the requested target
  23328. */
  23329. getActiveTarget(index: number): MorphTarget;
  23330. /**
  23331. * Gets the target at specified index
  23332. * @param index defines the index to check
  23333. * @returns the requested target
  23334. */
  23335. getTarget(index: number): MorphTarget;
  23336. /**
  23337. * Add a new target to this manager
  23338. * @param target defines the target to add
  23339. */
  23340. addTarget(target: MorphTarget): void;
  23341. /**
  23342. * Removes a target from the manager
  23343. * @param target defines the target to remove
  23344. */
  23345. removeTarget(target: MorphTarget): void;
  23346. /**
  23347. * Clone the current manager
  23348. * @returns a new MorphTargetManager
  23349. */
  23350. clone(): MorphTargetManager;
  23351. /**
  23352. * Serializes the current manager into a Serialization object
  23353. * @returns the serialized object
  23354. */
  23355. serialize(): any;
  23356. private _syncActiveTargets;
  23357. /**
  23358. * Syncrhonize the targets with all the meshes using this morph target manager
  23359. */
  23360. synchronize(): void;
  23361. /**
  23362. * Creates a new MorphTargetManager from serialized data
  23363. * @param serializationObject defines the serialized data
  23364. * @param scene defines the hosting scene
  23365. * @returns the new MorphTargetManager
  23366. */
  23367. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23368. }
  23369. }
  23370. declare module "babylonjs/Meshes/meshLODLevel" {
  23371. import { Mesh } from "babylonjs/Meshes/mesh";
  23372. import { Nullable } from "babylonjs/types";
  23373. /**
  23374. * Class used to represent a specific level of detail of a mesh
  23375. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23376. */
  23377. export class MeshLODLevel {
  23378. /** Defines the distance where this level should start being displayed */
  23379. distance: number;
  23380. /** Defines the mesh to use to render this level */
  23381. mesh: Nullable<Mesh>;
  23382. /**
  23383. * Creates a new LOD level
  23384. * @param distance defines the distance where this level should star being displayed
  23385. * @param mesh defines the mesh to use to render this level
  23386. */
  23387. constructor(
  23388. /** Defines the distance where this level should start being displayed */
  23389. distance: number,
  23390. /** Defines the mesh to use to render this level */
  23391. mesh: Nullable<Mesh>);
  23392. }
  23393. }
  23394. declare module "babylonjs/Meshes/groundMesh" {
  23395. import { Scene } from "babylonjs/scene";
  23396. import { Vector3 } from "babylonjs/Maths/math.vector";
  23397. import { Mesh } from "babylonjs/Meshes/mesh";
  23398. /**
  23399. * Mesh representing the gorund
  23400. */
  23401. export class GroundMesh extends Mesh {
  23402. /** If octree should be generated */
  23403. generateOctree: boolean;
  23404. private _heightQuads;
  23405. /** @hidden */
  23406. _subdivisionsX: number;
  23407. /** @hidden */
  23408. _subdivisionsY: number;
  23409. /** @hidden */
  23410. _width: number;
  23411. /** @hidden */
  23412. _height: number;
  23413. /** @hidden */
  23414. _minX: number;
  23415. /** @hidden */
  23416. _maxX: number;
  23417. /** @hidden */
  23418. _minZ: number;
  23419. /** @hidden */
  23420. _maxZ: number;
  23421. constructor(name: string, scene: Scene);
  23422. /**
  23423. * "GroundMesh"
  23424. * @returns "GroundMesh"
  23425. */
  23426. getClassName(): string;
  23427. /**
  23428. * The minimum of x and y subdivisions
  23429. */
  23430. get subdivisions(): number;
  23431. /**
  23432. * X subdivisions
  23433. */
  23434. get subdivisionsX(): number;
  23435. /**
  23436. * Y subdivisions
  23437. */
  23438. get subdivisionsY(): number;
  23439. /**
  23440. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23441. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23442. * @param chunksCount the number of subdivisions for x and y
  23443. * @param octreeBlocksSize (Default: 32)
  23444. */
  23445. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23446. /**
  23447. * Returns a height (y) value in the Worl system :
  23448. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23449. * @param x x coordinate
  23450. * @param z z coordinate
  23451. * @returns the ground y position if (x, z) are outside the ground surface.
  23452. */
  23453. getHeightAtCoordinates(x: number, z: number): number;
  23454. /**
  23455. * Returns a normalized vector (Vector3) orthogonal to the ground
  23456. * at the ground coordinates (x, z) expressed in the World system.
  23457. * @param x x coordinate
  23458. * @param z z coordinate
  23459. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23460. */
  23461. getNormalAtCoordinates(x: number, z: number): Vector3;
  23462. /**
  23463. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23464. * at the ground coordinates (x, z) expressed in the World system.
  23465. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23466. * @param x x coordinate
  23467. * @param z z coordinate
  23468. * @param ref vector to store the result
  23469. * @returns the GroundMesh.
  23470. */
  23471. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23472. /**
  23473. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23474. * if the ground has been updated.
  23475. * This can be used in the render loop.
  23476. * @returns the GroundMesh.
  23477. */
  23478. updateCoordinateHeights(): GroundMesh;
  23479. private _getFacetAt;
  23480. private _initHeightQuads;
  23481. private _computeHeightQuads;
  23482. /**
  23483. * Serializes this ground mesh
  23484. * @param serializationObject object to write serialization to
  23485. */
  23486. serialize(serializationObject: any): void;
  23487. /**
  23488. * Parses a serialized ground mesh
  23489. * @param parsedMesh the serialized mesh
  23490. * @param scene the scene to create the ground mesh in
  23491. * @returns the created ground mesh
  23492. */
  23493. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23494. }
  23495. }
  23496. declare module "babylonjs/Physics/physicsJoint" {
  23497. import { Vector3 } from "babylonjs/Maths/math.vector";
  23498. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23499. /**
  23500. * Interface for Physics-Joint data
  23501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23502. */
  23503. export interface PhysicsJointData {
  23504. /**
  23505. * The main pivot of the joint
  23506. */
  23507. mainPivot?: Vector3;
  23508. /**
  23509. * The connected pivot of the joint
  23510. */
  23511. connectedPivot?: Vector3;
  23512. /**
  23513. * The main axis of the joint
  23514. */
  23515. mainAxis?: Vector3;
  23516. /**
  23517. * The connected axis of the joint
  23518. */
  23519. connectedAxis?: Vector3;
  23520. /**
  23521. * The collision of the joint
  23522. */
  23523. collision?: boolean;
  23524. /**
  23525. * Native Oimo/Cannon/Energy data
  23526. */
  23527. nativeParams?: any;
  23528. }
  23529. /**
  23530. * This is a holder class for the physics joint created by the physics plugin
  23531. * It holds a set of functions to control the underlying joint
  23532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23533. */
  23534. export class PhysicsJoint {
  23535. /**
  23536. * The type of the physics joint
  23537. */
  23538. type: number;
  23539. /**
  23540. * The data for the physics joint
  23541. */
  23542. jointData: PhysicsJointData;
  23543. private _physicsJoint;
  23544. protected _physicsPlugin: IPhysicsEnginePlugin;
  23545. /**
  23546. * Initializes the physics joint
  23547. * @param type The type of the physics joint
  23548. * @param jointData The data for the physics joint
  23549. */
  23550. constructor(
  23551. /**
  23552. * The type of the physics joint
  23553. */
  23554. type: number,
  23555. /**
  23556. * The data for the physics joint
  23557. */
  23558. jointData: PhysicsJointData);
  23559. /**
  23560. * Gets the physics joint
  23561. */
  23562. get physicsJoint(): any;
  23563. /**
  23564. * Sets the physics joint
  23565. */
  23566. set physicsJoint(newJoint: any);
  23567. /**
  23568. * Sets the physics plugin
  23569. */
  23570. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23571. /**
  23572. * Execute a function that is physics-plugin specific.
  23573. * @param {Function} func the function that will be executed.
  23574. * It accepts two parameters: the physics world and the physics joint
  23575. */
  23576. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23577. /**
  23578. * Distance-Joint type
  23579. */
  23580. static DistanceJoint: number;
  23581. /**
  23582. * Hinge-Joint type
  23583. */
  23584. static HingeJoint: number;
  23585. /**
  23586. * Ball-and-Socket joint type
  23587. */
  23588. static BallAndSocketJoint: number;
  23589. /**
  23590. * Wheel-Joint type
  23591. */
  23592. static WheelJoint: number;
  23593. /**
  23594. * Slider-Joint type
  23595. */
  23596. static SliderJoint: number;
  23597. /**
  23598. * Prismatic-Joint type
  23599. */
  23600. static PrismaticJoint: number;
  23601. /**
  23602. * Universal-Joint type
  23603. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23604. */
  23605. static UniversalJoint: number;
  23606. /**
  23607. * Hinge-Joint 2 type
  23608. */
  23609. static Hinge2Joint: number;
  23610. /**
  23611. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23612. */
  23613. static PointToPointJoint: number;
  23614. /**
  23615. * Spring-Joint type
  23616. */
  23617. static SpringJoint: number;
  23618. /**
  23619. * Lock-Joint type
  23620. */
  23621. static LockJoint: number;
  23622. }
  23623. /**
  23624. * A class representing a physics distance joint
  23625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23626. */
  23627. export class DistanceJoint extends PhysicsJoint {
  23628. /**
  23629. *
  23630. * @param jointData The data for the Distance-Joint
  23631. */
  23632. constructor(jointData: DistanceJointData);
  23633. /**
  23634. * Update the predefined distance.
  23635. * @param maxDistance The maximum preferred distance
  23636. * @param minDistance The minimum preferred distance
  23637. */
  23638. updateDistance(maxDistance: number, minDistance?: number): void;
  23639. }
  23640. /**
  23641. * Represents a Motor-Enabled Joint
  23642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23643. */
  23644. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23645. /**
  23646. * Initializes the Motor-Enabled Joint
  23647. * @param type The type of the joint
  23648. * @param jointData The physica joint data for the joint
  23649. */
  23650. constructor(type: number, jointData: PhysicsJointData);
  23651. /**
  23652. * Set the motor values.
  23653. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23654. * @param force the force to apply
  23655. * @param maxForce max force for this motor.
  23656. */
  23657. setMotor(force?: number, maxForce?: number): void;
  23658. /**
  23659. * Set the motor's limits.
  23660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23661. * @param upperLimit The upper limit of the motor
  23662. * @param lowerLimit The lower limit of the motor
  23663. */
  23664. setLimit(upperLimit: number, lowerLimit?: number): void;
  23665. }
  23666. /**
  23667. * This class represents a single physics Hinge-Joint
  23668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23669. */
  23670. export class HingeJoint extends MotorEnabledJoint {
  23671. /**
  23672. * Initializes the Hinge-Joint
  23673. * @param jointData The joint data for the Hinge-Joint
  23674. */
  23675. constructor(jointData: PhysicsJointData);
  23676. /**
  23677. * Set the motor values.
  23678. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23679. * @param {number} force the force to apply
  23680. * @param {number} maxForce max force for this motor.
  23681. */
  23682. setMotor(force?: number, maxForce?: number): void;
  23683. /**
  23684. * Set the motor's limits.
  23685. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23686. * @param upperLimit The upper limit of the motor
  23687. * @param lowerLimit The lower limit of the motor
  23688. */
  23689. setLimit(upperLimit: number, lowerLimit?: number): void;
  23690. }
  23691. /**
  23692. * This class represents a dual hinge physics joint (same as wheel joint)
  23693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23694. */
  23695. export class Hinge2Joint extends MotorEnabledJoint {
  23696. /**
  23697. * Initializes the Hinge2-Joint
  23698. * @param jointData The joint data for the Hinge2-Joint
  23699. */
  23700. constructor(jointData: PhysicsJointData);
  23701. /**
  23702. * Set the motor values.
  23703. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23704. * @param {number} targetSpeed the speed the motor is to reach
  23705. * @param {number} maxForce max force for this motor.
  23706. * @param {motorIndex} the motor's index, 0 or 1.
  23707. */
  23708. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23709. /**
  23710. * Set the motor limits.
  23711. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23712. * @param {number} upperLimit the upper limit
  23713. * @param {number} lowerLimit lower limit
  23714. * @param {motorIndex} the motor's index, 0 or 1.
  23715. */
  23716. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23717. }
  23718. /**
  23719. * Interface for a motor enabled joint
  23720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23721. */
  23722. export interface IMotorEnabledJoint {
  23723. /**
  23724. * Physics joint
  23725. */
  23726. physicsJoint: any;
  23727. /**
  23728. * Sets the motor of the motor-enabled joint
  23729. * @param force The force of the motor
  23730. * @param maxForce The maximum force of the motor
  23731. * @param motorIndex The index of the motor
  23732. */
  23733. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23734. /**
  23735. * Sets the limit of the motor
  23736. * @param upperLimit The upper limit of the motor
  23737. * @param lowerLimit The lower limit of the motor
  23738. * @param motorIndex The index of the motor
  23739. */
  23740. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23741. }
  23742. /**
  23743. * Joint data for a Distance-Joint
  23744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23745. */
  23746. export interface DistanceJointData extends PhysicsJointData {
  23747. /**
  23748. * Max distance the 2 joint objects can be apart
  23749. */
  23750. maxDistance: number;
  23751. }
  23752. /**
  23753. * Joint data from a spring joint
  23754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23755. */
  23756. export interface SpringJointData extends PhysicsJointData {
  23757. /**
  23758. * Length of the spring
  23759. */
  23760. length: number;
  23761. /**
  23762. * Stiffness of the spring
  23763. */
  23764. stiffness: number;
  23765. /**
  23766. * Damping of the spring
  23767. */
  23768. damping: number;
  23769. /** this callback will be called when applying the force to the impostors. */
  23770. forceApplicationCallback: () => void;
  23771. }
  23772. }
  23773. declare module "babylonjs/Physics/physicsRaycastResult" {
  23774. import { Vector3 } from "babylonjs/Maths/math.vector";
  23775. /**
  23776. * Holds the data for the raycast result
  23777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23778. */
  23779. export class PhysicsRaycastResult {
  23780. private _hasHit;
  23781. private _hitDistance;
  23782. private _hitNormalWorld;
  23783. private _hitPointWorld;
  23784. private _rayFromWorld;
  23785. private _rayToWorld;
  23786. /**
  23787. * Gets if there was a hit
  23788. */
  23789. get hasHit(): boolean;
  23790. /**
  23791. * Gets the distance from the hit
  23792. */
  23793. get hitDistance(): number;
  23794. /**
  23795. * Gets the hit normal/direction in the world
  23796. */
  23797. get hitNormalWorld(): Vector3;
  23798. /**
  23799. * Gets the hit point in the world
  23800. */
  23801. get hitPointWorld(): Vector3;
  23802. /**
  23803. * Gets the ray "start point" of the ray in the world
  23804. */
  23805. get rayFromWorld(): Vector3;
  23806. /**
  23807. * Gets the ray "end point" of the ray in the world
  23808. */
  23809. get rayToWorld(): Vector3;
  23810. /**
  23811. * Sets the hit data (normal & point in world space)
  23812. * @param hitNormalWorld defines the normal in world space
  23813. * @param hitPointWorld defines the point in world space
  23814. */
  23815. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23816. /**
  23817. * Sets the distance from the start point to the hit point
  23818. * @param distance
  23819. */
  23820. setHitDistance(distance: number): void;
  23821. /**
  23822. * Calculates the distance manually
  23823. */
  23824. calculateHitDistance(): void;
  23825. /**
  23826. * Resets all the values to default
  23827. * @param from The from point on world space
  23828. * @param to The to point on world space
  23829. */
  23830. reset(from?: Vector3, to?: Vector3): void;
  23831. }
  23832. /**
  23833. * Interface for the size containing width and height
  23834. */
  23835. interface IXYZ {
  23836. /**
  23837. * X
  23838. */
  23839. x: number;
  23840. /**
  23841. * Y
  23842. */
  23843. y: number;
  23844. /**
  23845. * Z
  23846. */
  23847. z: number;
  23848. }
  23849. }
  23850. declare module "babylonjs/Physics/IPhysicsEngine" {
  23851. import { Nullable } from "babylonjs/types";
  23852. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23854. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23855. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23856. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23857. /**
  23858. * Interface used to describe a physics joint
  23859. */
  23860. export interface PhysicsImpostorJoint {
  23861. /** Defines the main impostor to which the joint is linked */
  23862. mainImpostor: PhysicsImpostor;
  23863. /** Defines the impostor that is connected to the main impostor using this joint */
  23864. connectedImpostor: PhysicsImpostor;
  23865. /** Defines the joint itself */
  23866. joint: PhysicsJoint;
  23867. }
  23868. /** @hidden */
  23869. export interface IPhysicsEnginePlugin {
  23870. world: any;
  23871. name: string;
  23872. setGravity(gravity: Vector3): void;
  23873. setTimeStep(timeStep: number): void;
  23874. getTimeStep(): number;
  23875. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23876. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23877. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23878. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23879. removePhysicsBody(impostor: PhysicsImpostor): void;
  23880. generateJoint(joint: PhysicsImpostorJoint): void;
  23881. removeJoint(joint: PhysicsImpostorJoint): void;
  23882. isSupported(): boolean;
  23883. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23884. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23885. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23887. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23888. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23889. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23890. getBodyMass(impostor: PhysicsImpostor): number;
  23891. getBodyFriction(impostor: PhysicsImpostor): number;
  23892. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23893. getBodyRestitution(impostor: PhysicsImpostor): number;
  23894. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23895. getBodyPressure?(impostor: PhysicsImpostor): number;
  23896. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23897. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23898. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23899. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23900. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23901. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23902. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23903. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23904. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23905. sleepBody(impostor: PhysicsImpostor): void;
  23906. wakeUpBody(impostor: PhysicsImpostor): void;
  23907. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23908. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23909. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23911. getRadius(impostor: PhysicsImpostor): number;
  23912. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23913. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23914. dispose(): void;
  23915. }
  23916. /**
  23917. * Interface used to define a physics engine
  23918. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23919. */
  23920. export interface IPhysicsEngine {
  23921. /**
  23922. * Gets the gravity vector used by the simulation
  23923. */
  23924. gravity: Vector3;
  23925. /**
  23926. * Sets the gravity vector used by the simulation
  23927. * @param gravity defines the gravity vector to use
  23928. */
  23929. setGravity(gravity: Vector3): void;
  23930. /**
  23931. * Set the time step of the physics engine.
  23932. * Default is 1/60.
  23933. * To slow it down, enter 1/600 for example.
  23934. * To speed it up, 1/30
  23935. * @param newTimeStep the new timestep to apply to this world.
  23936. */
  23937. setTimeStep(newTimeStep: number): void;
  23938. /**
  23939. * Get the time step of the physics engine.
  23940. * @returns the current time step
  23941. */
  23942. getTimeStep(): number;
  23943. /**
  23944. * Set the sub time step of the physics engine.
  23945. * Default is 0 meaning there is no sub steps
  23946. * To increase physics resolution precision, set a small value (like 1 ms)
  23947. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23948. */
  23949. setSubTimeStep(subTimeStep: number): void;
  23950. /**
  23951. * Get the sub time step of the physics engine.
  23952. * @returns the current sub time step
  23953. */
  23954. getSubTimeStep(): number;
  23955. /**
  23956. * Release all resources
  23957. */
  23958. dispose(): void;
  23959. /**
  23960. * Gets the name of the current physics plugin
  23961. * @returns the name of the plugin
  23962. */
  23963. getPhysicsPluginName(): string;
  23964. /**
  23965. * Adding a new impostor for the impostor tracking.
  23966. * This will be done by the impostor itself.
  23967. * @param impostor the impostor to add
  23968. */
  23969. addImpostor(impostor: PhysicsImpostor): void;
  23970. /**
  23971. * Remove an impostor from the engine.
  23972. * This impostor and its mesh will not longer be updated by the physics engine.
  23973. * @param impostor the impostor to remove
  23974. */
  23975. removeImpostor(impostor: PhysicsImpostor): void;
  23976. /**
  23977. * Add a joint to the physics engine
  23978. * @param mainImpostor defines the main impostor to which the joint is added.
  23979. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23980. * @param joint defines the joint that will connect both impostors.
  23981. */
  23982. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23983. /**
  23984. * Removes a joint from the simulation
  23985. * @param mainImpostor defines the impostor used with the joint
  23986. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23987. * @param joint defines the joint to remove
  23988. */
  23989. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23990. /**
  23991. * Gets the current plugin used to run the simulation
  23992. * @returns current plugin
  23993. */
  23994. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23995. /**
  23996. * Gets the list of physic impostors
  23997. * @returns an array of PhysicsImpostor
  23998. */
  23999. getImpostors(): Array<PhysicsImpostor>;
  24000. /**
  24001. * Gets the impostor for a physics enabled object
  24002. * @param object defines the object impersonated by the impostor
  24003. * @returns the PhysicsImpostor or null if not found
  24004. */
  24005. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24006. /**
  24007. * Gets the impostor for a physics body object
  24008. * @param body defines physics body used by the impostor
  24009. * @returns the PhysicsImpostor or null if not found
  24010. */
  24011. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24012. /**
  24013. * Does a raycast in the physics world
  24014. * @param from when should the ray start?
  24015. * @param to when should the ray end?
  24016. * @returns PhysicsRaycastResult
  24017. */
  24018. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24019. /**
  24020. * Called by the scene. No need to call it.
  24021. * @param delta defines the timespam between frames
  24022. */
  24023. _step(delta: number): void;
  24024. }
  24025. }
  24026. declare module "babylonjs/Physics/physicsImpostor" {
  24027. import { Nullable, IndicesArray } from "babylonjs/types";
  24028. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24029. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24031. import { Scene } from "babylonjs/scene";
  24032. import { Bone } from "babylonjs/Bones/bone";
  24033. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24034. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24035. import { Space } from "babylonjs/Maths/math.axis";
  24036. /**
  24037. * The interface for the physics imposter parameters
  24038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24039. */
  24040. export interface PhysicsImpostorParameters {
  24041. /**
  24042. * The mass of the physics imposter
  24043. */
  24044. mass: number;
  24045. /**
  24046. * The friction of the physics imposter
  24047. */
  24048. friction?: number;
  24049. /**
  24050. * The coefficient of restitution of the physics imposter
  24051. */
  24052. restitution?: number;
  24053. /**
  24054. * The native options of the physics imposter
  24055. */
  24056. nativeOptions?: any;
  24057. /**
  24058. * Specifies if the parent should be ignored
  24059. */
  24060. ignoreParent?: boolean;
  24061. /**
  24062. * Specifies if bi-directional transformations should be disabled
  24063. */
  24064. disableBidirectionalTransformation?: boolean;
  24065. /**
  24066. * The pressure inside the physics imposter, soft object only
  24067. */
  24068. pressure?: number;
  24069. /**
  24070. * The stiffness the physics imposter, soft object only
  24071. */
  24072. stiffness?: number;
  24073. /**
  24074. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24075. */
  24076. velocityIterations?: number;
  24077. /**
  24078. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24079. */
  24080. positionIterations?: number;
  24081. /**
  24082. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24083. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24084. * Add to fix multiple points
  24085. */
  24086. fixedPoints?: number;
  24087. /**
  24088. * The collision margin around a soft object
  24089. */
  24090. margin?: number;
  24091. /**
  24092. * The collision margin around a soft object
  24093. */
  24094. damping?: number;
  24095. /**
  24096. * The path for a rope based on an extrusion
  24097. */
  24098. path?: any;
  24099. /**
  24100. * The shape of an extrusion used for a rope based on an extrusion
  24101. */
  24102. shape?: any;
  24103. }
  24104. /**
  24105. * Interface for a physics-enabled object
  24106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24107. */
  24108. export interface IPhysicsEnabledObject {
  24109. /**
  24110. * The position of the physics-enabled object
  24111. */
  24112. position: Vector3;
  24113. /**
  24114. * The rotation of the physics-enabled object
  24115. */
  24116. rotationQuaternion: Nullable<Quaternion>;
  24117. /**
  24118. * The scale of the physics-enabled object
  24119. */
  24120. scaling: Vector3;
  24121. /**
  24122. * The rotation of the physics-enabled object
  24123. */
  24124. rotation?: Vector3;
  24125. /**
  24126. * The parent of the physics-enabled object
  24127. */
  24128. parent?: any;
  24129. /**
  24130. * The bounding info of the physics-enabled object
  24131. * @returns The bounding info of the physics-enabled object
  24132. */
  24133. getBoundingInfo(): BoundingInfo;
  24134. /**
  24135. * Computes the world matrix
  24136. * @param force Specifies if the world matrix should be computed by force
  24137. * @returns A world matrix
  24138. */
  24139. computeWorldMatrix(force: boolean): Matrix;
  24140. /**
  24141. * Gets the world matrix
  24142. * @returns A world matrix
  24143. */
  24144. getWorldMatrix?(): Matrix;
  24145. /**
  24146. * Gets the child meshes
  24147. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24148. * @returns An array of abstract meshes
  24149. */
  24150. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24151. /**
  24152. * Gets the vertex data
  24153. * @param kind The type of vertex data
  24154. * @returns A nullable array of numbers, or a float32 array
  24155. */
  24156. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24157. /**
  24158. * Gets the indices from the mesh
  24159. * @returns A nullable array of index arrays
  24160. */
  24161. getIndices?(): Nullable<IndicesArray>;
  24162. /**
  24163. * Gets the scene from the mesh
  24164. * @returns the indices array or null
  24165. */
  24166. getScene?(): Scene;
  24167. /**
  24168. * Gets the absolute position from the mesh
  24169. * @returns the absolute position
  24170. */
  24171. getAbsolutePosition(): Vector3;
  24172. /**
  24173. * Gets the absolute pivot point from the mesh
  24174. * @returns the absolute pivot point
  24175. */
  24176. getAbsolutePivotPoint(): Vector3;
  24177. /**
  24178. * Rotates the mesh
  24179. * @param axis The axis of rotation
  24180. * @param amount The amount of rotation
  24181. * @param space The space of the rotation
  24182. * @returns The rotation transform node
  24183. */
  24184. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24185. /**
  24186. * Translates the mesh
  24187. * @param axis The axis of translation
  24188. * @param distance The distance of translation
  24189. * @param space The space of the translation
  24190. * @returns The transform node
  24191. */
  24192. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24193. /**
  24194. * Sets the absolute position of the mesh
  24195. * @param absolutePosition The absolute position of the mesh
  24196. * @returns The transform node
  24197. */
  24198. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24199. /**
  24200. * Gets the class name of the mesh
  24201. * @returns The class name
  24202. */
  24203. getClassName(): string;
  24204. }
  24205. /**
  24206. * Represents a physics imposter
  24207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24208. */
  24209. export class PhysicsImpostor {
  24210. /**
  24211. * The physics-enabled object used as the physics imposter
  24212. */
  24213. object: IPhysicsEnabledObject;
  24214. /**
  24215. * The type of the physics imposter
  24216. */
  24217. type: number;
  24218. private _options;
  24219. private _scene?;
  24220. /**
  24221. * The default object size of the imposter
  24222. */
  24223. static DEFAULT_OBJECT_SIZE: Vector3;
  24224. /**
  24225. * The identity quaternion of the imposter
  24226. */
  24227. static IDENTITY_QUATERNION: Quaternion;
  24228. /** @hidden */
  24229. _pluginData: any;
  24230. private _physicsEngine;
  24231. private _physicsBody;
  24232. private _bodyUpdateRequired;
  24233. private _onBeforePhysicsStepCallbacks;
  24234. private _onAfterPhysicsStepCallbacks;
  24235. /** @hidden */
  24236. _onPhysicsCollideCallbacks: Array<{
  24237. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24238. otherImpostors: Array<PhysicsImpostor>;
  24239. }>;
  24240. private _deltaPosition;
  24241. private _deltaRotation;
  24242. private _deltaRotationConjugated;
  24243. /** @hidden */
  24244. _isFromLine: boolean;
  24245. private _parent;
  24246. private _isDisposed;
  24247. private static _tmpVecs;
  24248. private static _tmpQuat;
  24249. /**
  24250. * Specifies if the physics imposter is disposed
  24251. */
  24252. get isDisposed(): boolean;
  24253. /**
  24254. * Gets the mass of the physics imposter
  24255. */
  24256. get mass(): number;
  24257. set mass(value: number);
  24258. /**
  24259. * Gets the coefficient of friction
  24260. */
  24261. get friction(): number;
  24262. /**
  24263. * Sets the coefficient of friction
  24264. */
  24265. set friction(value: number);
  24266. /**
  24267. * Gets the coefficient of restitution
  24268. */
  24269. get restitution(): number;
  24270. /**
  24271. * Sets the coefficient of restitution
  24272. */
  24273. set restitution(value: number);
  24274. /**
  24275. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24276. */
  24277. get pressure(): number;
  24278. /**
  24279. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24280. */
  24281. set pressure(value: number);
  24282. /**
  24283. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24284. */
  24285. get stiffness(): number;
  24286. /**
  24287. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24288. */
  24289. set stiffness(value: number);
  24290. /**
  24291. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24292. */
  24293. get velocityIterations(): number;
  24294. /**
  24295. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24296. */
  24297. set velocityIterations(value: number);
  24298. /**
  24299. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24300. */
  24301. get positionIterations(): number;
  24302. /**
  24303. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24304. */
  24305. set positionIterations(value: number);
  24306. /**
  24307. * The unique id of the physics imposter
  24308. * set by the physics engine when adding this impostor to the array
  24309. */
  24310. uniqueId: number;
  24311. /**
  24312. * @hidden
  24313. */
  24314. soft: boolean;
  24315. /**
  24316. * @hidden
  24317. */
  24318. segments: number;
  24319. private _joints;
  24320. /**
  24321. * Initializes the physics imposter
  24322. * @param object The physics-enabled object used as the physics imposter
  24323. * @param type The type of the physics imposter
  24324. * @param _options The options for the physics imposter
  24325. * @param _scene The Babylon scene
  24326. */
  24327. constructor(
  24328. /**
  24329. * The physics-enabled object used as the physics imposter
  24330. */
  24331. object: IPhysicsEnabledObject,
  24332. /**
  24333. * The type of the physics imposter
  24334. */
  24335. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24336. /**
  24337. * This function will completly initialize this impostor.
  24338. * It will create a new body - but only if this mesh has no parent.
  24339. * If it has, this impostor will not be used other than to define the impostor
  24340. * of the child mesh.
  24341. * @hidden
  24342. */
  24343. _init(): void;
  24344. private _getPhysicsParent;
  24345. /**
  24346. * Should a new body be generated.
  24347. * @returns boolean specifying if body initialization is required
  24348. */
  24349. isBodyInitRequired(): boolean;
  24350. /**
  24351. * Sets the updated scaling
  24352. * @param updated Specifies if the scaling is updated
  24353. */
  24354. setScalingUpdated(): void;
  24355. /**
  24356. * Force a regeneration of this or the parent's impostor's body.
  24357. * Use under cautious - This will remove all joints already implemented.
  24358. */
  24359. forceUpdate(): void;
  24360. /**
  24361. * Gets the body that holds this impostor. Either its own, or its parent.
  24362. */
  24363. get physicsBody(): any;
  24364. /**
  24365. * Get the parent of the physics imposter
  24366. * @returns Physics imposter or null
  24367. */
  24368. get parent(): Nullable<PhysicsImpostor>;
  24369. /**
  24370. * Sets the parent of the physics imposter
  24371. */
  24372. set parent(value: Nullable<PhysicsImpostor>);
  24373. /**
  24374. * Set the physics body. Used mainly by the physics engine/plugin
  24375. */
  24376. set physicsBody(physicsBody: any);
  24377. /**
  24378. * Resets the update flags
  24379. */
  24380. resetUpdateFlags(): void;
  24381. /**
  24382. * Gets the object extend size
  24383. * @returns the object extend size
  24384. */
  24385. getObjectExtendSize(): Vector3;
  24386. /**
  24387. * Gets the object center
  24388. * @returns The object center
  24389. */
  24390. getObjectCenter(): Vector3;
  24391. /**
  24392. * Get a specific parametes from the options parameter
  24393. * @param paramName The object parameter name
  24394. * @returns The object parameter
  24395. */
  24396. getParam(paramName: string): any;
  24397. /**
  24398. * Sets a specific parameter in the options given to the physics plugin
  24399. * @param paramName The parameter name
  24400. * @param value The value of the parameter
  24401. */
  24402. setParam(paramName: string, value: number): void;
  24403. /**
  24404. * Specifically change the body's mass option. Won't recreate the physics body object
  24405. * @param mass The mass of the physics imposter
  24406. */
  24407. setMass(mass: number): void;
  24408. /**
  24409. * Gets the linear velocity
  24410. * @returns linear velocity or null
  24411. */
  24412. getLinearVelocity(): Nullable<Vector3>;
  24413. /**
  24414. * Sets the linear velocity
  24415. * @param velocity linear velocity or null
  24416. */
  24417. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24418. /**
  24419. * Gets the angular velocity
  24420. * @returns angular velocity or null
  24421. */
  24422. getAngularVelocity(): Nullable<Vector3>;
  24423. /**
  24424. * Sets the angular velocity
  24425. * @param velocity The velocity or null
  24426. */
  24427. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24428. /**
  24429. * Execute a function with the physics plugin native code
  24430. * Provide a function the will have two variables - the world object and the physics body object
  24431. * @param func The function to execute with the physics plugin native code
  24432. */
  24433. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24434. /**
  24435. * Register a function that will be executed before the physics world is stepping forward
  24436. * @param func The function to execute before the physics world is stepped forward
  24437. */
  24438. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24439. /**
  24440. * Unregister a function that will be executed before the physics world is stepping forward
  24441. * @param func The function to execute before the physics world is stepped forward
  24442. */
  24443. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24444. /**
  24445. * Register a function that will be executed after the physics step
  24446. * @param func The function to execute after physics step
  24447. */
  24448. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24449. /**
  24450. * Unregisters a function that will be executed after the physics step
  24451. * @param func The function to execute after physics step
  24452. */
  24453. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24454. /**
  24455. * register a function that will be executed when this impostor collides against a different body
  24456. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24457. * @param func Callback that is executed on collision
  24458. */
  24459. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24460. /**
  24461. * Unregisters the physics imposter on contact
  24462. * @param collideAgainst The physics object to collide against
  24463. * @param func Callback to execute on collision
  24464. */
  24465. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24466. private _tmpQuat;
  24467. private _tmpQuat2;
  24468. /**
  24469. * Get the parent rotation
  24470. * @returns The parent rotation
  24471. */
  24472. getParentsRotation(): Quaternion;
  24473. /**
  24474. * this function is executed by the physics engine.
  24475. */
  24476. beforeStep: () => void;
  24477. /**
  24478. * this function is executed by the physics engine
  24479. */
  24480. afterStep: () => void;
  24481. /**
  24482. * Legacy collision detection event support
  24483. */
  24484. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24485. /**
  24486. * event and body object due to cannon's event-based architecture.
  24487. */
  24488. onCollide: (e: {
  24489. body: any;
  24490. }) => void;
  24491. /**
  24492. * Apply a force
  24493. * @param force The force to apply
  24494. * @param contactPoint The contact point for the force
  24495. * @returns The physics imposter
  24496. */
  24497. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24498. /**
  24499. * Apply an impulse
  24500. * @param force The impulse force
  24501. * @param contactPoint The contact point for the impulse force
  24502. * @returns The physics imposter
  24503. */
  24504. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24505. /**
  24506. * A help function to create a joint
  24507. * @param otherImpostor A physics imposter used to create a joint
  24508. * @param jointType The type of joint
  24509. * @param jointData The data for the joint
  24510. * @returns The physics imposter
  24511. */
  24512. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24513. /**
  24514. * Add a joint to this impostor with a different impostor
  24515. * @param otherImpostor A physics imposter used to add a joint
  24516. * @param joint The joint to add
  24517. * @returns The physics imposter
  24518. */
  24519. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24520. /**
  24521. * Add an anchor to a cloth impostor
  24522. * @param otherImpostor rigid impostor to anchor to
  24523. * @param width ratio across width from 0 to 1
  24524. * @param height ratio up height from 0 to 1
  24525. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24526. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24527. * @returns impostor the soft imposter
  24528. */
  24529. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24530. /**
  24531. * Add a hook to a rope impostor
  24532. * @param otherImpostor rigid impostor to anchor to
  24533. * @param length ratio across rope from 0 to 1
  24534. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24535. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24536. * @returns impostor the rope imposter
  24537. */
  24538. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24539. /**
  24540. * Will keep this body still, in a sleep mode.
  24541. * @returns the physics imposter
  24542. */
  24543. sleep(): PhysicsImpostor;
  24544. /**
  24545. * Wake the body up.
  24546. * @returns The physics imposter
  24547. */
  24548. wakeUp(): PhysicsImpostor;
  24549. /**
  24550. * Clones the physics imposter
  24551. * @param newObject The physics imposter clones to this physics-enabled object
  24552. * @returns A nullable physics imposter
  24553. */
  24554. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24555. /**
  24556. * Disposes the physics imposter
  24557. */
  24558. dispose(): void;
  24559. /**
  24560. * Sets the delta position
  24561. * @param position The delta position amount
  24562. */
  24563. setDeltaPosition(position: Vector3): void;
  24564. /**
  24565. * Sets the delta rotation
  24566. * @param rotation The delta rotation amount
  24567. */
  24568. setDeltaRotation(rotation: Quaternion): void;
  24569. /**
  24570. * Gets the box size of the physics imposter and stores the result in the input parameter
  24571. * @param result Stores the box size
  24572. * @returns The physics imposter
  24573. */
  24574. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24575. /**
  24576. * Gets the radius of the physics imposter
  24577. * @returns Radius of the physics imposter
  24578. */
  24579. getRadius(): number;
  24580. /**
  24581. * Sync a bone with this impostor
  24582. * @param bone The bone to sync to the impostor.
  24583. * @param boneMesh The mesh that the bone is influencing.
  24584. * @param jointPivot The pivot of the joint / bone in local space.
  24585. * @param distToJoint Optional distance from the impostor to the joint.
  24586. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24587. */
  24588. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24589. /**
  24590. * Sync impostor to a bone
  24591. * @param bone The bone that the impostor will be synced to.
  24592. * @param boneMesh The mesh that the bone is influencing.
  24593. * @param jointPivot The pivot of the joint / bone in local space.
  24594. * @param distToJoint Optional distance from the impostor to the joint.
  24595. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24596. * @param boneAxis Optional vector3 axis the bone is aligned with
  24597. */
  24598. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24599. /**
  24600. * No-Imposter type
  24601. */
  24602. static NoImpostor: number;
  24603. /**
  24604. * Sphere-Imposter type
  24605. */
  24606. static SphereImpostor: number;
  24607. /**
  24608. * Box-Imposter type
  24609. */
  24610. static BoxImpostor: number;
  24611. /**
  24612. * Plane-Imposter type
  24613. */
  24614. static PlaneImpostor: number;
  24615. /**
  24616. * Mesh-imposter type
  24617. */
  24618. static MeshImpostor: number;
  24619. /**
  24620. * Capsule-Impostor type (Ammo.js plugin only)
  24621. */
  24622. static CapsuleImpostor: number;
  24623. /**
  24624. * Cylinder-Imposter type
  24625. */
  24626. static CylinderImpostor: number;
  24627. /**
  24628. * Particle-Imposter type
  24629. */
  24630. static ParticleImpostor: number;
  24631. /**
  24632. * Heightmap-Imposter type
  24633. */
  24634. static HeightmapImpostor: number;
  24635. /**
  24636. * ConvexHull-Impostor type (Ammo.js plugin only)
  24637. */
  24638. static ConvexHullImpostor: number;
  24639. /**
  24640. * Custom-Imposter type (Ammo.js plugin only)
  24641. */
  24642. static CustomImpostor: number;
  24643. /**
  24644. * Rope-Imposter type
  24645. */
  24646. static RopeImpostor: number;
  24647. /**
  24648. * Cloth-Imposter type
  24649. */
  24650. static ClothImpostor: number;
  24651. /**
  24652. * Softbody-Imposter type
  24653. */
  24654. static SoftbodyImpostor: number;
  24655. }
  24656. }
  24657. declare module "babylonjs/Meshes/mesh" {
  24658. import { Observable } from "babylonjs/Misc/observable";
  24659. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24660. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24661. import { Camera } from "babylonjs/Cameras/camera";
  24662. import { Scene } from "babylonjs/scene";
  24663. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24664. import { Color4 } from "babylonjs/Maths/math.color";
  24665. import { Engine } from "babylonjs/Engines/engine";
  24666. import { Node } from "babylonjs/node";
  24667. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24668. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24669. import { Buffer } from "babylonjs/Meshes/buffer";
  24670. import { Geometry } from "babylonjs/Meshes/geometry";
  24671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24673. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24674. import { Effect } from "babylonjs/Materials/effect";
  24675. import { Material } from "babylonjs/Materials/material";
  24676. import { Skeleton } from "babylonjs/Bones/skeleton";
  24677. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24678. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24679. import { Path3D } from "babylonjs/Maths/math.path";
  24680. import { Plane } from "babylonjs/Maths/math.plane";
  24681. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24682. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24683. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24684. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24685. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24686. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24687. /**
  24688. * @hidden
  24689. **/
  24690. export class _CreationDataStorage {
  24691. closePath?: boolean;
  24692. closeArray?: boolean;
  24693. idx: number[];
  24694. dashSize: number;
  24695. gapSize: number;
  24696. path3D: Path3D;
  24697. pathArray: Vector3[][];
  24698. arc: number;
  24699. radius: number;
  24700. cap: number;
  24701. tessellation: number;
  24702. }
  24703. /**
  24704. * @hidden
  24705. **/
  24706. class _InstanceDataStorage {
  24707. visibleInstances: any;
  24708. batchCache: _InstancesBatch;
  24709. instancesBufferSize: number;
  24710. instancesBuffer: Nullable<Buffer>;
  24711. instancesData: Float32Array;
  24712. overridenInstanceCount: number;
  24713. isFrozen: boolean;
  24714. previousBatch: Nullable<_InstancesBatch>;
  24715. hardwareInstancedRendering: boolean;
  24716. sideOrientation: number;
  24717. manualUpdate: boolean;
  24718. }
  24719. /**
  24720. * @hidden
  24721. **/
  24722. export class _InstancesBatch {
  24723. mustReturn: boolean;
  24724. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24725. renderSelf: boolean[];
  24726. hardwareInstancedRendering: boolean[];
  24727. }
  24728. /**
  24729. * Class used to represent renderable models
  24730. */
  24731. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24732. /**
  24733. * Mesh side orientation : usually the external or front surface
  24734. */
  24735. static readonly FRONTSIDE: number;
  24736. /**
  24737. * Mesh side orientation : usually the internal or back surface
  24738. */
  24739. static readonly BACKSIDE: number;
  24740. /**
  24741. * Mesh side orientation : both internal and external or front and back surfaces
  24742. */
  24743. static readonly DOUBLESIDE: number;
  24744. /**
  24745. * Mesh side orientation : by default, `FRONTSIDE`
  24746. */
  24747. static readonly DEFAULTSIDE: number;
  24748. /**
  24749. * Mesh cap setting : no cap
  24750. */
  24751. static readonly NO_CAP: number;
  24752. /**
  24753. * Mesh cap setting : one cap at the beginning of the mesh
  24754. */
  24755. static readonly CAP_START: number;
  24756. /**
  24757. * Mesh cap setting : one cap at the end of the mesh
  24758. */
  24759. static readonly CAP_END: number;
  24760. /**
  24761. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24762. */
  24763. static readonly CAP_ALL: number;
  24764. /**
  24765. * Mesh pattern setting : no flip or rotate
  24766. */
  24767. static readonly NO_FLIP: number;
  24768. /**
  24769. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24770. */
  24771. static readonly FLIP_TILE: number;
  24772. /**
  24773. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24774. */
  24775. static readonly ROTATE_TILE: number;
  24776. /**
  24777. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24778. */
  24779. static readonly FLIP_ROW: number;
  24780. /**
  24781. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24782. */
  24783. static readonly ROTATE_ROW: number;
  24784. /**
  24785. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24786. */
  24787. static readonly FLIP_N_ROTATE_TILE: number;
  24788. /**
  24789. * Mesh pattern setting : rotate pattern and rotate
  24790. */
  24791. static readonly FLIP_N_ROTATE_ROW: number;
  24792. /**
  24793. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24794. */
  24795. static readonly CENTER: number;
  24796. /**
  24797. * Mesh tile positioning : part tiles on left
  24798. */
  24799. static readonly LEFT: number;
  24800. /**
  24801. * Mesh tile positioning : part tiles on right
  24802. */
  24803. static readonly RIGHT: number;
  24804. /**
  24805. * Mesh tile positioning : part tiles on top
  24806. */
  24807. static readonly TOP: number;
  24808. /**
  24809. * Mesh tile positioning : part tiles on bottom
  24810. */
  24811. static readonly BOTTOM: number;
  24812. /**
  24813. * Gets the default side orientation.
  24814. * @param orientation the orientation to value to attempt to get
  24815. * @returns the default orientation
  24816. * @hidden
  24817. */
  24818. static _GetDefaultSideOrientation(orientation?: number): number;
  24819. private _internalMeshDataInfo;
  24820. /**
  24821. * An event triggered before rendering the mesh
  24822. */
  24823. get onBeforeRenderObservable(): Observable<Mesh>;
  24824. /**
  24825. * An event triggered before binding the mesh
  24826. */
  24827. get onBeforeBindObservable(): Observable<Mesh>;
  24828. /**
  24829. * An event triggered after rendering the mesh
  24830. */
  24831. get onAfterRenderObservable(): Observable<Mesh>;
  24832. /**
  24833. * An event triggered before drawing the mesh
  24834. */
  24835. get onBeforeDrawObservable(): Observable<Mesh>;
  24836. private _onBeforeDrawObserver;
  24837. /**
  24838. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24839. */
  24840. set onBeforeDraw(callback: () => void);
  24841. get hasInstances(): boolean;
  24842. /**
  24843. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24844. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24845. */
  24846. delayLoadState: number;
  24847. /**
  24848. * Gets the list of instances created from this mesh
  24849. * it is not supposed to be modified manually.
  24850. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24851. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24852. */
  24853. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24854. /**
  24855. * Gets the file containing delay loading data for this mesh
  24856. */
  24857. delayLoadingFile: string;
  24858. /** @hidden */
  24859. _binaryInfo: any;
  24860. /**
  24861. * User defined function used to change how LOD level selection is done
  24862. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24863. */
  24864. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24865. /**
  24866. * Gets or sets the morph target manager
  24867. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24868. */
  24869. get morphTargetManager(): Nullable<MorphTargetManager>;
  24870. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24871. /** @hidden */
  24872. _creationDataStorage: Nullable<_CreationDataStorage>;
  24873. /** @hidden */
  24874. _geometry: Nullable<Geometry>;
  24875. /** @hidden */
  24876. _delayInfo: Array<string>;
  24877. /** @hidden */
  24878. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24879. /** @hidden */
  24880. _instanceDataStorage: _InstanceDataStorage;
  24881. private _effectiveMaterial;
  24882. /** @hidden */
  24883. _shouldGenerateFlatShading: boolean;
  24884. /** @hidden */
  24885. _originalBuilderSideOrientation: number;
  24886. /**
  24887. * Use this property to change the original side orientation defined at construction time
  24888. */
  24889. overrideMaterialSideOrientation: Nullable<number>;
  24890. /**
  24891. * Gets the source mesh (the one used to clone this one from)
  24892. */
  24893. get source(): Nullable<Mesh>;
  24894. /**
  24895. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24896. */
  24897. get isUnIndexed(): boolean;
  24898. set isUnIndexed(value: boolean);
  24899. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24900. get worldMatrixInstancedBuffer(): Float32Array;
  24901. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24902. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24903. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24904. /**
  24905. * @constructor
  24906. * @param name The value used by scene.getMeshByName() to do a lookup.
  24907. * @param scene The scene to add this mesh to.
  24908. * @param parent The parent of this mesh, if it has one
  24909. * @param source An optional Mesh from which geometry is shared, cloned.
  24910. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24911. * When false, achieved by calling a clone(), also passing False.
  24912. * This will make creation of children, recursive.
  24913. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24914. */
  24915. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24916. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24917. doNotInstantiate: boolean;
  24918. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24919. /**
  24920. * Gets the class name
  24921. * @returns the string "Mesh".
  24922. */
  24923. getClassName(): string;
  24924. /** @hidden */
  24925. get _isMesh(): boolean;
  24926. /**
  24927. * Returns a description of this mesh
  24928. * @param fullDetails define if full details about this mesh must be used
  24929. * @returns a descriptive string representing this mesh
  24930. */
  24931. toString(fullDetails?: boolean): string;
  24932. /** @hidden */
  24933. _unBindEffect(): void;
  24934. /**
  24935. * Gets a boolean indicating if this mesh has LOD
  24936. */
  24937. get hasLODLevels(): boolean;
  24938. /**
  24939. * Gets the list of MeshLODLevel associated with the current mesh
  24940. * @returns an array of MeshLODLevel
  24941. */
  24942. getLODLevels(): MeshLODLevel[];
  24943. private _sortLODLevels;
  24944. /**
  24945. * Add a mesh as LOD level triggered at the given distance.
  24946. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24947. * @param distance The distance from the center of the object to show this level
  24948. * @param mesh The mesh to be added as LOD level (can be null)
  24949. * @return This mesh (for chaining)
  24950. */
  24951. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24952. /**
  24953. * Returns the LOD level mesh at the passed distance or null if not found.
  24954. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24955. * @param distance The distance from the center of the object to show this level
  24956. * @returns a Mesh or `null`
  24957. */
  24958. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24959. /**
  24960. * Remove a mesh from the LOD array
  24961. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24962. * @param mesh defines the mesh to be removed
  24963. * @return This mesh (for chaining)
  24964. */
  24965. removeLODLevel(mesh: Mesh): Mesh;
  24966. /**
  24967. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24968. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24969. * @param camera defines the camera to use to compute distance
  24970. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24971. * @return This mesh (for chaining)
  24972. */
  24973. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24974. /**
  24975. * Gets the mesh internal Geometry object
  24976. */
  24977. get geometry(): Nullable<Geometry>;
  24978. /**
  24979. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24980. * @returns the total number of vertices
  24981. */
  24982. getTotalVertices(): number;
  24983. /**
  24984. * Returns the content of an associated vertex buffer
  24985. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24986. * - VertexBuffer.PositionKind
  24987. * - VertexBuffer.UVKind
  24988. * - VertexBuffer.UV2Kind
  24989. * - VertexBuffer.UV3Kind
  24990. * - VertexBuffer.UV4Kind
  24991. * - VertexBuffer.UV5Kind
  24992. * - VertexBuffer.UV6Kind
  24993. * - VertexBuffer.ColorKind
  24994. * - VertexBuffer.MatricesIndicesKind
  24995. * - VertexBuffer.MatricesIndicesExtraKind
  24996. * - VertexBuffer.MatricesWeightsKind
  24997. * - VertexBuffer.MatricesWeightsExtraKind
  24998. * @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
  24999. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25000. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25001. */
  25002. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25003. /**
  25004. * Returns the mesh VertexBuffer object from the requested `kind`
  25005. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25006. * - VertexBuffer.PositionKind
  25007. * - VertexBuffer.NormalKind
  25008. * - VertexBuffer.UVKind
  25009. * - VertexBuffer.UV2Kind
  25010. * - VertexBuffer.UV3Kind
  25011. * - VertexBuffer.UV4Kind
  25012. * - VertexBuffer.UV5Kind
  25013. * - VertexBuffer.UV6Kind
  25014. * - VertexBuffer.ColorKind
  25015. * - VertexBuffer.MatricesIndicesKind
  25016. * - VertexBuffer.MatricesIndicesExtraKind
  25017. * - VertexBuffer.MatricesWeightsKind
  25018. * - VertexBuffer.MatricesWeightsExtraKind
  25019. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25020. */
  25021. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25022. /**
  25023. * Tests if a specific vertex buffer is associated with this mesh
  25024. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25025. * - VertexBuffer.PositionKind
  25026. * - VertexBuffer.NormalKind
  25027. * - VertexBuffer.UVKind
  25028. * - VertexBuffer.UV2Kind
  25029. * - VertexBuffer.UV3Kind
  25030. * - VertexBuffer.UV4Kind
  25031. * - VertexBuffer.UV5Kind
  25032. * - VertexBuffer.UV6Kind
  25033. * - VertexBuffer.ColorKind
  25034. * - VertexBuffer.MatricesIndicesKind
  25035. * - VertexBuffer.MatricesIndicesExtraKind
  25036. * - VertexBuffer.MatricesWeightsKind
  25037. * - VertexBuffer.MatricesWeightsExtraKind
  25038. * @returns a boolean
  25039. */
  25040. isVerticesDataPresent(kind: string): boolean;
  25041. /**
  25042. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25043. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25044. * - VertexBuffer.PositionKind
  25045. * - VertexBuffer.UVKind
  25046. * - VertexBuffer.UV2Kind
  25047. * - VertexBuffer.UV3Kind
  25048. * - VertexBuffer.UV4Kind
  25049. * - VertexBuffer.UV5Kind
  25050. * - VertexBuffer.UV6Kind
  25051. * - VertexBuffer.ColorKind
  25052. * - VertexBuffer.MatricesIndicesKind
  25053. * - VertexBuffer.MatricesIndicesExtraKind
  25054. * - VertexBuffer.MatricesWeightsKind
  25055. * - VertexBuffer.MatricesWeightsExtraKind
  25056. * @returns a boolean
  25057. */
  25058. isVertexBufferUpdatable(kind: string): boolean;
  25059. /**
  25060. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25061. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25062. * - VertexBuffer.PositionKind
  25063. * - VertexBuffer.NormalKind
  25064. * - VertexBuffer.UVKind
  25065. * - VertexBuffer.UV2Kind
  25066. * - VertexBuffer.UV3Kind
  25067. * - VertexBuffer.UV4Kind
  25068. * - VertexBuffer.UV5Kind
  25069. * - VertexBuffer.UV6Kind
  25070. * - VertexBuffer.ColorKind
  25071. * - VertexBuffer.MatricesIndicesKind
  25072. * - VertexBuffer.MatricesIndicesExtraKind
  25073. * - VertexBuffer.MatricesWeightsKind
  25074. * - VertexBuffer.MatricesWeightsExtraKind
  25075. * @returns an array of strings
  25076. */
  25077. getVerticesDataKinds(): string[];
  25078. /**
  25079. * Returns a positive integer : the total number of indices in this mesh geometry.
  25080. * @returns the numner of indices or zero if the mesh has no geometry.
  25081. */
  25082. getTotalIndices(): number;
  25083. /**
  25084. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25085. * @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.
  25086. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25087. * @returns the indices array or an empty array if the mesh has no geometry
  25088. */
  25089. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25090. get isBlocked(): boolean;
  25091. /**
  25092. * Determine if the current mesh is ready to be rendered
  25093. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25094. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25095. * @returns true if all associated assets are ready (material, textures, shaders)
  25096. */
  25097. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25098. /**
  25099. * 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.
  25100. */
  25101. get areNormalsFrozen(): boolean;
  25102. /**
  25103. * 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.
  25104. * @returns the current mesh
  25105. */
  25106. freezeNormals(): Mesh;
  25107. /**
  25108. * 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
  25109. * @returns the current mesh
  25110. */
  25111. unfreezeNormals(): Mesh;
  25112. /**
  25113. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25114. */
  25115. set overridenInstanceCount(count: number);
  25116. /** @hidden */
  25117. _preActivate(): Mesh;
  25118. /** @hidden */
  25119. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25120. /** @hidden */
  25121. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25122. /**
  25123. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25124. * This means the mesh underlying bounding box and sphere are recomputed.
  25125. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25126. * @returns the current mesh
  25127. */
  25128. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25129. /** @hidden */
  25130. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25131. /**
  25132. * This function will subdivide the mesh into multiple submeshes
  25133. * @param count defines the expected number of submeshes
  25134. */
  25135. subdivide(count: number): void;
  25136. /**
  25137. * Copy a FloatArray into a specific associated vertex buffer
  25138. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25139. * - VertexBuffer.PositionKind
  25140. * - VertexBuffer.UVKind
  25141. * - VertexBuffer.UV2Kind
  25142. * - VertexBuffer.UV3Kind
  25143. * - VertexBuffer.UV4Kind
  25144. * - VertexBuffer.UV5Kind
  25145. * - VertexBuffer.UV6Kind
  25146. * - VertexBuffer.ColorKind
  25147. * - VertexBuffer.MatricesIndicesKind
  25148. * - VertexBuffer.MatricesIndicesExtraKind
  25149. * - VertexBuffer.MatricesWeightsKind
  25150. * - VertexBuffer.MatricesWeightsExtraKind
  25151. * @param data defines the data source
  25152. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25153. * @param stride defines the data stride size (can be null)
  25154. * @returns the current mesh
  25155. */
  25156. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25157. /**
  25158. * Delete a vertex buffer associated with this mesh
  25159. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25160. * - VertexBuffer.PositionKind
  25161. * - VertexBuffer.UVKind
  25162. * - VertexBuffer.UV2Kind
  25163. * - VertexBuffer.UV3Kind
  25164. * - VertexBuffer.UV4Kind
  25165. * - VertexBuffer.UV5Kind
  25166. * - VertexBuffer.UV6Kind
  25167. * - VertexBuffer.ColorKind
  25168. * - VertexBuffer.MatricesIndicesKind
  25169. * - VertexBuffer.MatricesIndicesExtraKind
  25170. * - VertexBuffer.MatricesWeightsKind
  25171. * - VertexBuffer.MatricesWeightsExtraKind
  25172. */
  25173. removeVerticesData(kind: string): void;
  25174. /**
  25175. * Flags an associated vertex buffer as updatable
  25176. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25177. * - VertexBuffer.PositionKind
  25178. * - VertexBuffer.UVKind
  25179. * - VertexBuffer.UV2Kind
  25180. * - VertexBuffer.UV3Kind
  25181. * - VertexBuffer.UV4Kind
  25182. * - VertexBuffer.UV5Kind
  25183. * - VertexBuffer.UV6Kind
  25184. * - VertexBuffer.ColorKind
  25185. * - VertexBuffer.MatricesIndicesKind
  25186. * - VertexBuffer.MatricesIndicesExtraKind
  25187. * - VertexBuffer.MatricesWeightsKind
  25188. * - VertexBuffer.MatricesWeightsExtraKind
  25189. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25190. */
  25191. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25192. /**
  25193. * Sets the mesh global Vertex Buffer
  25194. * @param buffer defines the buffer to use
  25195. * @returns the current mesh
  25196. */
  25197. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25198. /**
  25199. * Update a specific associated vertex buffer
  25200. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25201. * - VertexBuffer.PositionKind
  25202. * - VertexBuffer.UVKind
  25203. * - VertexBuffer.UV2Kind
  25204. * - VertexBuffer.UV3Kind
  25205. * - VertexBuffer.UV4Kind
  25206. * - VertexBuffer.UV5Kind
  25207. * - VertexBuffer.UV6Kind
  25208. * - VertexBuffer.ColorKind
  25209. * - VertexBuffer.MatricesIndicesKind
  25210. * - VertexBuffer.MatricesIndicesExtraKind
  25211. * - VertexBuffer.MatricesWeightsKind
  25212. * - VertexBuffer.MatricesWeightsExtraKind
  25213. * @param data defines the data source
  25214. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25215. * @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)
  25216. * @returns the current mesh
  25217. */
  25218. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25219. /**
  25220. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25221. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25222. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25223. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25224. * @returns the current mesh
  25225. */
  25226. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25227. /**
  25228. * Creates a un-shared specific occurence of the geometry for the mesh.
  25229. * @returns the current mesh
  25230. */
  25231. makeGeometryUnique(): Mesh;
  25232. /**
  25233. * Set the index buffer of this mesh
  25234. * @param indices defines the source data
  25235. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25236. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25237. * @returns the current mesh
  25238. */
  25239. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25240. /**
  25241. * Update the current index buffer
  25242. * @param indices defines the source data
  25243. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25244. * @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)
  25245. * @returns the current mesh
  25246. */
  25247. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25248. /**
  25249. * Invert the geometry to move from a right handed system to a left handed one.
  25250. * @returns the current mesh
  25251. */
  25252. toLeftHanded(): Mesh;
  25253. /** @hidden */
  25254. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25255. /** @hidden */
  25256. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25257. /**
  25258. * Registers for this mesh a javascript function called just before the rendering process
  25259. * @param func defines the function to call before rendering this mesh
  25260. * @returns the current mesh
  25261. */
  25262. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25263. /**
  25264. * Disposes a previously registered javascript function called before the rendering
  25265. * @param func defines the function to remove
  25266. * @returns the current mesh
  25267. */
  25268. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25269. /**
  25270. * Registers for this mesh a javascript function called just after the rendering is complete
  25271. * @param func defines the function to call after rendering this mesh
  25272. * @returns the current mesh
  25273. */
  25274. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25275. /**
  25276. * Disposes a previously registered javascript function called after the rendering.
  25277. * @param func defines the function to remove
  25278. * @returns the current mesh
  25279. */
  25280. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25281. /** @hidden */
  25282. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25283. /** @hidden */
  25284. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25285. /** @hidden */
  25286. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25287. /** @hidden */
  25288. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25289. /** @hidden */
  25290. _rebuild(): void;
  25291. /** @hidden */
  25292. _freeze(): void;
  25293. /** @hidden */
  25294. _unFreeze(): void;
  25295. /**
  25296. * 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
  25297. * @param subMesh defines the subMesh to render
  25298. * @param enableAlphaMode defines if alpha mode can be changed
  25299. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25300. * @returns the current mesh
  25301. */
  25302. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25303. private _onBeforeDraw;
  25304. /**
  25305. * Renormalize the mesh and patch it up if there are no weights
  25306. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25307. * However in the case of zero weights then we set just a single influence to 1.
  25308. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25309. */
  25310. cleanMatrixWeights(): void;
  25311. private normalizeSkinFourWeights;
  25312. private normalizeSkinWeightsAndExtra;
  25313. /**
  25314. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25315. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25316. * the user know there was an issue with importing the mesh
  25317. * @returns a validation object with skinned, valid and report string
  25318. */
  25319. validateSkinning(): {
  25320. skinned: boolean;
  25321. valid: boolean;
  25322. report: string;
  25323. };
  25324. /** @hidden */
  25325. _checkDelayState(): Mesh;
  25326. private _queueLoad;
  25327. /**
  25328. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25329. * A mesh is in the frustum if its bounding box intersects the frustum
  25330. * @param frustumPlanes defines the frustum to test
  25331. * @returns true if the mesh is in the frustum planes
  25332. */
  25333. isInFrustum(frustumPlanes: Plane[]): boolean;
  25334. /**
  25335. * Sets the mesh material by the material or multiMaterial `id` property
  25336. * @param id is a string identifying the material or the multiMaterial
  25337. * @returns the current mesh
  25338. */
  25339. setMaterialByID(id: string): Mesh;
  25340. /**
  25341. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25342. * @returns an array of IAnimatable
  25343. */
  25344. getAnimatables(): IAnimatable[];
  25345. /**
  25346. * Modifies the mesh geometry according to the passed transformation matrix.
  25347. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25348. * The mesh normals are modified using the same transformation.
  25349. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25350. * @param transform defines the transform matrix to use
  25351. * @see http://doc.babylonjs.com/resources/baking_transformations
  25352. * @returns the current mesh
  25353. */
  25354. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25355. /**
  25356. * Modifies the mesh geometry according to its own current World Matrix.
  25357. * The mesh World Matrix is then reset.
  25358. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25359. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25360. * @see http://doc.babylonjs.com/resources/baking_transformations
  25361. * @returns the current mesh
  25362. */
  25363. bakeCurrentTransformIntoVertices(): Mesh;
  25364. /** @hidden */
  25365. get _positions(): Nullable<Vector3[]>;
  25366. /** @hidden */
  25367. _resetPointsArrayCache(): Mesh;
  25368. /** @hidden */
  25369. _generatePointsArray(): boolean;
  25370. /**
  25371. * Returns a new Mesh object generated from the current mesh properties.
  25372. * This method must not get confused with createInstance()
  25373. * @param name is a string, the name given to the new mesh
  25374. * @param newParent can be any Node object (default `null`)
  25375. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25376. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25377. * @returns a new mesh
  25378. */
  25379. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25380. /**
  25381. * Releases resources associated with this mesh.
  25382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25384. */
  25385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25386. /** @hidden */
  25387. _disposeInstanceSpecificData(): void;
  25388. /**
  25389. * Modifies the mesh geometry according to a displacement map.
  25390. * 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.
  25391. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25392. * @param url is a string, the URL from the image file is to be downloaded.
  25393. * @param minHeight is the lower limit of the displacement.
  25394. * @param maxHeight is the upper limit of the displacement.
  25395. * @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.
  25396. * @param uvOffset is an optional vector2 used to offset UV.
  25397. * @param uvScale is an optional vector2 used to scale UV.
  25398. * @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.
  25399. * @returns the Mesh.
  25400. */
  25401. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25402. /**
  25403. * Modifies the mesh geometry according to a displacementMap buffer.
  25404. * 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.
  25405. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25406. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25407. * @param heightMapWidth is the width of the buffer image.
  25408. * @param heightMapHeight is the height of the buffer image.
  25409. * @param minHeight is the lower limit of the displacement.
  25410. * @param maxHeight is the upper limit of the displacement.
  25411. * @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.
  25412. * @param uvOffset is an optional vector2 used to offset UV.
  25413. * @param uvScale is an optional vector2 used to scale UV.
  25414. * @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.
  25415. * @returns the Mesh.
  25416. */
  25417. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25418. /**
  25419. * Modify the mesh to get a flat shading rendering.
  25420. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25421. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25422. * @returns current mesh
  25423. */
  25424. convertToFlatShadedMesh(): Mesh;
  25425. /**
  25426. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25427. * In other words, more vertices, no more indices and a single bigger VBO.
  25428. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25429. * @returns current mesh
  25430. */
  25431. convertToUnIndexedMesh(): Mesh;
  25432. /**
  25433. * Inverses facet orientations.
  25434. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25435. * @param flipNormals will also inverts the normals
  25436. * @returns current mesh
  25437. */
  25438. flipFaces(flipNormals?: boolean): Mesh;
  25439. /**
  25440. * Increase the number of facets and hence vertices in a mesh
  25441. * Vertex normals are interpolated from existing vertex normals
  25442. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25443. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25444. */
  25445. increaseVertices(numberPerEdge: number): void;
  25446. /**
  25447. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25448. * This will undo any application of covertToFlatShadedMesh
  25449. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25450. */
  25451. forceSharedVertices(): void;
  25452. /** @hidden */
  25453. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25454. /** @hidden */
  25455. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25456. /**
  25457. * Creates a new InstancedMesh object from the mesh model.
  25458. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25459. * @param name defines the name of the new instance
  25460. * @returns a new InstancedMesh
  25461. */
  25462. createInstance(name: string): InstancedMesh;
  25463. /**
  25464. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25465. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25466. * @returns the current mesh
  25467. */
  25468. synchronizeInstances(): Mesh;
  25469. /**
  25470. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25471. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25472. * This should be used together with the simplification to avoid disappearing triangles.
  25473. * @param successCallback an optional success callback to be called after the optimization finished.
  25474. * @returns the current mesh
  25475. */
  25476. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25477. /**
  25478. * Serialize current mesh
  25479. * @param serializationObject defines the object which will receive the serialization data
  25480. */
  25481. serialize(serializationObject: any): void;
  25482. /** @hidden */
  25483. _syncGeometryWithMorphTargetManager(): void;
  25484. /** @hidden */
  25485. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25486. /**
  25487. * Returns a new Mesh object parsed from the source provided.
  25488. * @param parsedMesh is the source
  25489. * @param scene defines the hosting scene
  25490. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25491. * @returns a new Mesh
  25492. */
  25493. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25494. /**
  25495. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25496. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25497. * @param name defines the name of the mesh to create
  25498. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25499. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25500. * @param closePath creates a seam between the first and the last points of each path of the path array
  25501. * @param offset is taken in account only if the `pathArray` is containing a single path
  25502. * @param scene defines the hosting scene
  25503. * @param updatable defines if the mesh must be flagged as updatable
  25504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25505. * @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)
  25506. * @returns a new Mesh
  25507. */
  25508. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25509. /**
  25510. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25511. * @param name defines the name of the mesh to create
  25512. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25513. * @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
  25514. * @param scene defines the hosting scene
  25515. * @param updatable defines if the mesh must be flagged as updatable
  25516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25517. * @returns a new Mesh
  25518. */
  25519. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25520. /**
  25521. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25522. * @param name defines the name of the mesh to create
  25523. * @param size sets the size (float) of each box side (default 1)
  25524. * @param scene defines the hosting scene
  25525. * @param updatable defines if the mesh must be flagged as updatable
  25526. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25527. * @returns a new Mesh
  25528. */
  25529. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25530. /**
  25531. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25532. * @param name defines the name of the mesh to create
  25533. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25534. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25535. * @param scene defines the hosting scene
  25536. * @param updatable defines if the mesh must be flagged as updatable
  25537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25538. * @returns a new Mesh
  25539. */
  25540. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25541. /**
  25542. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25543. * @param name defines the name of the mesh to create
  25544. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25545. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25546. * @param scene defines the hosting scene
  25547. * @returns a new Mesh
  25548. */
  25549. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25550. /**
  25551. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25552. * @param name defines the name of the mesh to create
  25553. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25554. * @param diameterTop set the top cap diameter (floats, default 1)
  25555. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25556. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25557. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25558. * @param scene defines the hosting scene
  25559. * @param updatable defines if the mesh must be flagged as updatable
  25560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25561. * @returns a new Mesh
  25562. */
  25563. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25564. /**
  25565. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25566. * @param name defines the name of the mesh to create
  25567. * @param diameter sets the diameter size (float) of the torus (default 1)
  25568. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25569. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25570. * @param scene defines the hosting scene
  25571. * @param updatable defines if the mesh must be flagged as updatable
  25572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25573. * @returns a new Mesh
  25574. */
  25575. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25576. /**
  25577. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25578. * @param name defines the name of the mesh to create
  25579. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25580. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25581. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25582. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25583. * @param p the number of windings on X axis (positive integers, default 2)
  25584. * @param q the number of windings on Y axis (positive integers, default 3)
  25585. * @param scene defines the hosting scene
  25586. * @param updatable defines if the mesh must be flagged as updatable
  25587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25588. * @returns a new Mesh
  25589. */
  25590. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25591. /**
  25592. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25593. * @param name defines the name of the mesh to create
  25594. * @param points is an array successive Vector3
  25595. * @param scene defines the hosting scene
  25596. * @param updatable defines if the mesh must be flagged as updatable
  25597. * @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).
  25598. * @returns a new Mesh
  25599. */
  25600. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25601. /**
  25602. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25603. * @param name defines the name of the mesh to create
  25604. * @param points is an array successive Vector3
  25605. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25606. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25607. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25608. * @param scene defines the hosting scene
  25609. * @param updatable defines if the mesh must be flagged as updatable
  25610. * @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)
  25611. * @returns a new Mesh
  25612. */
  25613. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25614. /**
  25615. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25616. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25617. * 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.
  25618. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25619. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25620. * Remember you can only change the shape positions, not their number when updating a polygon.
  25621. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25622. * @param name defines the name of the mesh to create
  25623. * @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
  25624. * @param scene defines the hosting scene
  25625. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25626. * @param updatable defines if the mesh must be flagged as updatable
  25627. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25628. * @param earcutInjection can be used to inject your own earcut reference
  25629. * @returns a new Mesh
  25630. */
  25631. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25632. /**
  25633. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25634. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25635. * @param name defines the name of the mesh to create
  25636. * @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
  25637. * @param depth defines the height of extrusion
  25638. * @param scene defines the hosting scene
  25639. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25640. * @param updatable defines if the mesh must be flagged as updatable
  25641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25642. * @param earcutInjection can be used to inject your own earcut reference
  25643. * @returns a new Mesh
  25644. */
  25645. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25646. /**
  25647. * Creates an extruded shape mesh.
  25648. * 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
  25649. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25650. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25651. * @param name defines the name of the mesh to create
  25652. * @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
  25653. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25654. * @param scale is the value to scale the shape
  25655. * @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
  25656. * @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
  25657. * @param scene defines the hosting scene
  25658. * @param updatable defines if the mesh must be flagged as updatable
  25659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25660. * @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)
  25661. * @returns a new Mesh
  25662. */
  25663. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25664. /**
  25665. * Creates an custom extruded shape mesh.
  25666. * The custom extrusion is a parametric shape.
  25667. * It has no predefined shape. Its final shape will depend on the input parameters.
  25668. * Please consider using the same method from the MeshBuilder class instead
  25669. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25670. * @param name defines the name of the mesh to create
  25671. * @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
  25672. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25673. * @param scaleFunction is a custom Javascript function called on each path point
  25674. * @param rotationFunction is a custom Javascript function called on each path point
  25675. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25676. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25677. * @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
  25678. * @param scene defines the hosting scene
  25679. * @param updatable defines if the mesh must be flagged as updatable
  25680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25681. * @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)
  25682. * @returns a new Mesh
  25683. */
  25684. 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;
  25685. /**
  25686. * Creates lathe mesh.
  25687. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25688. * Please consider using the same method from the MeshBuilder class instead
  25689. * @param name defines the name of the mesh to create
  25690. * @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
  25691. * @param radius is the radius value of the lathe
  25692. * @param tessellation is the side number of the lathe.
  25693. * @param scene defines the hosting scene
  25694. * @param updatable defines if the mesh must be flagged as updatable
  25695. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25696. * @returns a new Mesh
  25697. */
  25698. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25699. /**
  25700. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25701. * @param name defines the name of the mesh to create
  25702. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25703. * @param scene defines the hosting scene
  25704. * @param updatable defines if the mesh must be flagged as updatable
  25705. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25706. * @returns a new Mesh
  25707. */
  25708. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25709. /**
  25710. * Creates a ground mesh.
  25711. * Please consider using the same method from the MeshBuilder class instead
  25712. * @param name defines the name of the mesh to create
  25713. * @param width set the width of the ground
  25714. * @param height set the height of the ground
  25715. * @param subdivisions sets the number of subdivisions per side
  25716. * @param scene defines the hosting scene
  25717. * @param updatable defines if the mesh must be flagged as updatable
  25718. * @returns a new Mesh
  25719. */
  25720. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25721. /**
  25722. * Creates a tiled ground mesh.
  25723. * Please consider using the same method from the MeshBuilder class instead
  25724. * @param name defines the name of the mesh to create
  25725. * @param xmin set the ground minimum X coordinate
  25726. * @param zmin set the ground minimum Y coordinate
  25727. * @param xmax set the ground maximum X coordinate
  25728. * @param zmax set the ground maximum Z coordinate
  25729. * @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
  25730. * @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
  25731. * @param scene defines the hosting scene
  25732. * @param updatable defines if the mesh must be flagged as updatable
  25733. * @returns a new Mesh
  25734. */
  25735. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25736. w: number;
  25737. h: number;
  25738. }, precision: {
  25739. w: number;
  25740. h: number;
  25741. }, scene: Scene, updatable?: boolean): Mesh;
  25742. /**
  25743. * Creates a ground mesh from a height map.
  25744. * Please consider using the same method from the MeshBuilder class instead
  25745. * @see http://doc.babylonjs.com/babylon101/height_map
  25746. * @param name defines the name of the mesh to create
  25747. * @param url sets the URL of the height map image resource
  25748. * @param width set the ground width size
  25749. * @param height set the ground height size
  25750. * @param subdivisions sets the number of subdivision per side
  25751. * @param minHeight is the minimum altitude on the ground
  25752. * @param maxHeight is the maximum altitude on the ground
  25753. * @param scene defines the hosting scene
  25754. * @param updatable defines if the mesh must be flagged as updatable
  25755. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25756. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25757. * @returns a new Mesh
  25758. */
  25759. 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;
  25760. /**
  25761. * Creates a tube mesh.
  25762. * The tube is a parametric shape.
  25763. * It has no predefined shape. Its final shape will depend on the input parameters.
  25764. * Please consider using the same method from the MeshBuilder class instead
  25765. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25766. * @param name defines the name of the mesh to create
  25767. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25768. * @param radius sets the tube radius size
  25769. * @param tessellation is the number of sides on the tubular surface
  25770. * @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
  25771. * @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
  25772. * @param scene defines the hosting scene
  25773. * @param updatable defines if the mesh must be flagged as updatable
  25774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25775. * @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)
  25776. * @returns a new Mesh
  25777. */
  25778. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25779. (i: number, distance: number): number;
  25780. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25781. /**
  25782. * Creates a polyhedron mesh.
  25783. * Please consider using the same method from the MeshBuilder class instead.
  25784. * * 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
  25785. * * The parameter `size` (positive float, default 1) sets the polygon size
  25786. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25787. * * 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`
  25788. * * 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
  25789. * * 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)`)
  25790. * * 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
  25791. * * 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
  25792. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25793. * * If you create a double-sided mesh, you can choose what parts of 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
  25794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25795. * @param name defines the name of the mesh to create
  25796. * @param options defines the options used to create the mesh
  25797. * @param scene defines the hosting scene
  25798. * @returns a new Mesh
  25799. */
  25800. static CreatePolyhedron(name: string, options: {
  25801. type?: number;
  25802. size?: number;
  25803. sizeX?: number;
  25804. sizeY?: number;
  25805. sizeZ?: number;
  25806. custom?: any;
  25807. faceUV?: Vector4[];
  25808. faceColors?: Color4[];
  25809. updatable?: boolean;
  25810. sideOrientation?: number;
  25811. }, scene: Scene): Mesh;
  25812. /**
  25813. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25814. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25815. * * 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`)
  25816. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25817. * * 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
  25818. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25819. * * If you create a double-sided mesh, you can choose what parts of 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
  25820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25821. * @param name defines the name of the mesh
  25822. * @param options defines the options used to create the mesh
  25823. * @param scene defines the hosting scene
  25824. * @returns a new Mesh
  25825. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25826. */
  25827. static CreateIcoSphere(name: string, options: {
  25828. radius?: number;
  25829. flat?: boolean;
  25830. subdivisions?: number;
  25831. sideOrientation?: number;
  25832. updatable?: boolean;
  25833. }, scene: Scene): Mesh;
  25834. /**
  25835. * Creates a decal mesh.
  25836. * Please consider using the same method from the MeshBuilder class instead.
  25837. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25838. * @param name defines the name of the mesh
  25839. * @param sourceMesh defines the mesh receiving the decal
  25840. * @param position sets the position of the decal in world coordinates
  25841. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25842. * @param size sets the decal scaling
  25843. * @param angle sets the angle to rotate the decal
  25844. * @returns a new Mesh
  25845. */
  25846. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25847. /**
  25848. * Prepare internal position array for software CPU skinning
  25849. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25850. */
  25851. setPositionsForCPUSkinning(): Float32Array;
  25852. /**
  25853. * Prepare internal normal array for software CPU skinning
  25854. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25855. */
  25856. setNormalsForCPUSkinning(): Float32Array;
  25857. /**
  25858. * Updates the vertex buffer by applying transformation from the bones
  25859. * @param skeleton defines the skeleton to apply to current mesh
  25860. * @returns the current mesh
  25861. */
  25862. applySkeleton(skeleton: Skeleton): Mesh;
  25863. /**
  25864. * 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
  25865. * @param meshes defines the list of meshes to scan
  25866. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25867. */
  25868. static MinMax(meshes: AbstractMesh[]): {
  25869. min: Vector3;
  25870. max: Vector3;
  25871. };
  25872. /**
  25873. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25874. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25875. * @returns a vector3
  25876. */
  25877. static Center(meshesOrMinMaxVector: {
  25878. min: Vector3;
  25879. max: Vector3;
  25880. } | AbstractMesh[]): Vector3;
  25881. /**
  25882. * Merge the array of meshes into a single mesh for performance reasons.
  25883. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25884. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25885. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25886. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25887. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25888. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25889. * @returns a new mesh
  25890. */
  25891. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25892. /** @hidden */
  25893. addInstance(instance: InstancedMesh): void;
  25894. /** @hidden */
  25895. removeInstance(instance: InstancedMesh): void;
  25896. }
  25897. }
  25898. declare module "babylonjs/Cameras/camera" {
  25899. import { SmartArray } from "babylonjs/Misc/smartArray";
  25900. import { Observable } from "babylonjs/Misc/observable";
  25901. import { Nullable } from "babylonjs/types";
  25902. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25903. import { Scene } from "babylonjs/scene";
  25904. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25905. import { Node } from "babylonjs/node";
  25906. import { Mesh } from "babylonjs/Meshes/mesh";
  25907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25908. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25909. import { Viewport } from "babylonjs/Maths/math.viewport";
  25910. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25911. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25912. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25913. import { Ray } from "babylonjs/Culling/ray";
  25914. /**
  25915. * This is the base class of all the camera used in the application.
  25916. * @see http://doc.babylonjs.com/features/cameras
  25917. */
  25918. export class Camera extends Node {
  25919. /** @hidden */
  25920. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25921. /**
  25922. * This is the default projection mode used by the cameras.
  25923. * It helps recreating a feeling of perspective and better appreciate depth.
  25924. * This is the best way to simulate real life cameras.
  25925. */
  25926. static readonly PERSPECTIVE_CAMERA: number;
  25927. /**
  25928. * This helps creating camera with an orthographic mode.
  25929. * 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.
  25930. */
  25931. static readonly ORTHOGRAPHIC_CAMERA: number;
  25932. /**
  25933. * This is the default FOV mode for perspective cameras.
  25934. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25935. */
  25936. static readonly FOVMODE_VERTICAL_FIXED: number;
  25937. /**
  25938. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25939. */
  25940. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25941. /**
  25942. * This specifies ther is no need for a camera rig.
  25943. * Basically only one eye is rendered corresponding to the camera.
  25944. */
  25945. static readonly RIG_MODE_NONE: number;
  25946. /**
  25947. * Simulates a camera Rig with one blue eye and one red eye.
  25948. * This can be use with 3d blue and red glasses.
  25949. */
  25950. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25951. /**
  25952. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25953. */
  25954. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25955. /**
  25956. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25957. */
  25958. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25959. /**
  25960. * Defines that both eyes of the camera will be rendered over under each other.
  25961. */
  25962. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25963. /**
  25964. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25965. */
  25966. static readonly RIG_MODE_VR: number;
  25967. /**
  25968. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25969. */
  25970. static readonly RIG_MODE_WEBVR: number;
  25971. /**
  25972. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25973. */
  25974. static readonly RIG_MODE_CUSTOM: number;
  25975. /**
  25976. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25977. */
  25978. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25979. /**
  25980. * Define the input manager associated with the camera.
  25981. */
  25982. inputs: CameraInputsManager<Camera>;
  25983. /** @hidden */
  25984. _position: Vector3;
  25985. /**
  25986. * Define the current local position of the camera in the scene
  25987. */
  25988. get position(): Vector3;
  25989. set position(newPosition: Vector3);
  25990. /**
  25991. * The vector the camera should consider as up.
  25992. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25993. */
  25994. upVector: Vector3;
  25995. /**
  25996. * Define the current limit on the left side for an orthographic camera
  25997. * In scene unit
  25998. */
  25999. orthoLeft: Nullable<number>;
  26000. /**
  26001. * Define the current limit on the right side for an orthographic camera
  26002. * In scene unit
  26003. */
  26004. orthoRight: Nullable<number>;
  26005. /**
  26006. * Define the current limit on the bottom side for an orthographic camera
  26007. * In scene unit
  26008. */
  26009. orthoBottom: Nullable<number>;
  26010. /**
  26011. * Define the current limit on the top side for an orthographic camera
  26012. * In scene unit
  26013. */
  26014. orthoTop: Nullable<number>;
  26015. /**
  26016. * Field Of View is set in Radians. (default is 0.8)
  26017. */
  26018. fov: number;
  26019. /**
  26020. * Define the minimum distance the camera can see from.
  26021. * This is important to note that the depth buffer are not infinite and the closer it starts
  26022. * the more your scene might encounter depth fighting issue.
  26023. */
  26024. minZ: number;
  26025. /**
  26026. * Define the maximum distance the camera can see to.
  26027. * This is important to note that the depth buffer are not infinite and the further it end
  26028. * the more your scene might encounter depth fighting issue.
  26029. */
  26030. maxZ: number;
  26031. /**
  26032. * Define the default inertia of the camera.
  26033. * This helps giving a smooth feeling to the camera movement.
  26034. */
  26035. inertia: number;
  26036. /**
  26037. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26038. */
  26039. mode: number;
  26040. /**
  26041. * Define wether the camera is intermediate.
  26042. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26043. */
  26044. isIntermediate: boolean;
  26045. /**
  26046. * Define the viewport of the camera.
  26047. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26048. */
  26049. viewport: Viewport;
  26050. /**
  26051. * Restricts the camera to viewing objects with the same layerMask.
  26052. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26053. */
  26054. layerMask: number;
  26055. /**
  26056. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26057. */
  26058. fovMode: number;
  26059. /**
  26060. * Rig mode of the camera.
  26061. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26062. * This is normally controlled byt the camera themselves as internal use.
  26063. */
  26064. cameraRigMode: number;
  26065. /**
  26066. * Defines the distance between both "eyes" in case of a RIG
  26067. */
  26068. interaxialDistance: number;
  26069. /**
  26070. * Defines if stereoscopic rendering is done side by side or over under.
  26071. */
  26072. isStereoscopicSideBySide: boolean;
  26073. /**
  26074. * 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
  26075. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26076. * else in the scene. (Eg. security camera)
  26077. *
  26078. * 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)
  26079. */
  26080. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26081. /**
  26082. * When set, the camera will render to this render target instead of the default canvas
  26083. *
  26084. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26085. */
  26086. outputRenderTarget: Nullable<RenderTargetTexture>;
  26087. /**
  26088. * Observable triggered when the camera view matrix has changed.
  26089. */
  26090. onViewMatrixChangedObservable: Observable<Camera>;
  26091. /**
  26092. * Observable triggered when the camera Projection matrix has changed.
  26093. */
  26094. onProjectionMatrixChangedObservable: Observable<Camera>;
  26095. /**
  26096. * Observable triggered when the inputs have been processed.
  26097. */
  26098. onAfterCheckInputsObservable: Observable<Camera>;
  26099. /**
  26100. * Observable triggered when reset has been called and applied to the camera.
  26101. */
  26102. onRestoreStateObservable: Observable<Camera>;
  26103. /** @hidden */
  26104. _cameraRigParams: any;
  26105. /** @hidden */
  26106. _rigCameras: Camera[];
  26107. /** @hidden */
  26108. _rigPostProcess: Nullable<PostProcess>;
  26109. protected _webvrViewMatrix: Matrix;
  26110. /** @hidden */
  26111. _skipRendering: boolean;
  26112. /** @hidden */
  26113. _projectionMatrix: Matrix;
  26114. /** @hidden */
  26115. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26116. /** @hidden */
  26117. _activeMeshes: SmartArray<AbstractMesh>;
  26118. protected _globalPosition: Vector3;
  26119. /** @hidden */
  26120. _computedViewMatrix: Matrix;
  26121. private _doNotComputeProjectionMatrix;
  26122. private _transformMatrix;
  26123. private _frustumPlanes;
  26124. private _refreshFrustumPlanes;
  26125. private _storedFov;
  26126. private _stateStored;
  26127. /**
  26128. * Instantiates a new camera object.
  26129. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26130. * @see http://doc.babylonjs.com/features/cameras
  26131. * @param name Defines the name of the camera in the scene
  26132. * @param position Defines the position of the camera
  26133. * @param scene Defines the scene the camera belongs too
  26134. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26135. */
  26136. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26137. /**
  26138. * Store current camera state (fov, position, etc..)
  26139. * @returns the camera
  26140. */
  26141. storeState(): Camera;
  26142. /**
  26143. * Restores the camera state values if it has been stored. You must call storeState() first
  26144. */
  26145. protected _restoreStateValues(): boolean;
  26146. /**
  26147. * Restored camera state. You must call storeState() first.
  26148. * @returns true if restored and false otherwise
  26149. */
  26150. restoreState(): boolean;
  26151. /**
  26152. * Gets the class name of the camera.
  26153. * @returns the class name
  26154. */
  26155. getClassName(): string;
  26156. /** @hidden */
  26157. readonly _isCamera: boolean;
  26158. /**
  26159. * Gets a string representation of the camera useful for debug purpose.
  26160. * @param fullDetails Defines that a more verboe level of logging is required
  26161. * @returns the string representation
  26162. */
  26163. toString(fullDetails?: boolean): string;
  26164. /**
  26165. * Gets the current world space position of the camera.
  26166. */
  26167. get globalPosition(): Vector3;
  26168. /**
  26169. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26170. * @returns the active meshe list
  26171. */
  26172. getActiveMeshes(): SmartArray<AbstractMesh>;
  26173. /**
  26174. * Check wether a mesh is part of the current active mesh list of the camera
  26175. * @param mesh Defines the mesh to check
  26176. * @returns true if active, false otherwise
  26177. */
  26178. isActiveMesh(mesh: Mesh): boolean;
  26179. /**
  26180. * Is this camera ready to be used/rendered
  26181. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26182. * @return true if the camera is ready
  26183. */
  26184. isReady(completeCheck?: boolean): boolean;
  26185. /** @hidden */
  26186. _initCache(): void;
  26187. /** @hidden */
  26188. _updateCache(ignoreParentClass?: boolean): void;
  26189. /** @hidden */
  26190. _isSynchronized(): boolean;
  26191. /** @hidden */
  26192. _isSynchronizedViewMatrix(): boolean;
  26193. /** @hidden */
  26194. _isSynchronizedProjectionMatrix(): boolean;
  26195. /**
  26196. * Attach the input controls to a specific dom element to get the input from.
  26197. * @param element Defines the element the controls should be listened from
  26198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26199. */
  26200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26201. /**
  26202. * Detach the current controls from the specified dom element.
  26203. * @param element Defines the element to stop listening the inputs from
  26204. */
  26205. detachControl(element: HTMLElement): void;
  26206. /**
  26207. * Update the camera state according to the different inputs gathered during the frame.
  26208. */
  26209. update(): void;
  26210. /** @hidden */
  26211. _checkInputs(): void;
  26212. /** @hidden */
  26213. get rigCameras(): Camera[];
  26214. /**
  26215. * Gets the post process used by the rig cameras
  26216. */
  26217. get rigPostProcess(): Nullable<PostProcess>;
  26218. /**
  26219. * Internal, gets the first post proces.
  26220. * @returns the first post process to be run on this camera.
  26221. */
  26222. _getFirstPostProcess(): Nullable<PostProcess>;
  26223. private _cascadePostProcessesToRigCams;
  26224. /**
  26225. * Attach a post process to the camera.
  26226. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26227. * @param postProcess The post process to attach to the camera
  26228. * @param insertAt The position of the post process in case several of them are in use in the scene
  26229. * @returns the position the post process has been inserted at
  26230. */
  26231. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26232. /**
  26233. * Detach a post process to the camera.
  26234. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26235. * @param postProcess The post process to detach from the camera
  26236. */
  26237. detachPostProcess(postProcess: PostProcess): void;
  26238. /**
  26239. * Gets the current world matrix of the camera
  26240. */
  26241. getWorldMatrix(): Matrix;
  26242. /** @hidden */
  26243. _getViewMatrix(): Matrix;
  26244. /**
  26245. * Gets the current view matrix of the camera.
  26246. * @param force forces the camera to recompute the matrix without looking at the cached state
  26247. * @returns the view matrix
  26248. */
  26249. getViewMatrix(force?: boolean): Matrix;
  26250. /**
  26251. * Freeze the projection matrix.
  26252. * It will prevent the cache check of the camera projection compute and can speed up perf
  26253. * if no parameter of the camera are meant to change
  26254. * @param projection Defines manually a projection if necessary
  26255. */
  26256. freezeProjectionMatrix(projection?: Matrix): void;
  26257. /**
  26258. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26259. */
  26260. unfreezeProjectionMatrix(): void;
  26261. /**
  26262. * Gets the current projection matrix of the camera.
  26263. * @param force forces the camera to recompute the matrix without looking at the cached state
  26264. * @returns the projection matrix
  26265. */
  26266. getProjectionMatrix(force?: boolean): Matrix;
  26267. /**
  26268. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26269. * @returns a Matrix
  26270. */
  26271. getTransformationMatrix(): Matrix;
  26272. private _updateFrustumPlanes;
  26273. /**
  26274. * Checks if a cullable object (mesh...) is in the camera frustum
  26275. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26276. * @param target The object to check
  26277. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26278. * @returns true if the object is in frustum otherwise false
  26279. */
  26280. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26281. /**
  26282. * Checks if a cullable object (mesh...) is in the camera frustum
  26283. * Unlike isInFrustum this cheks the full bounding box
  26284. * @param target The object to check
  26285. * @returns true if the object is in frustum otherwise false
  26286. */
  26287. isCompletelyInFrustum(target: ICullable): boolean;
  26288. /**
  26289. * Gets a ray in the forward direction from the camera.
  26290. * @param length Defines the length of the ray to create
  26291. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26292. * @param origin Defines the start point of the ray which defaults to the camera position
  26293. * @returns the forward ray
  26294. */
  26295. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26296. /**
  26297. * Releases resources associated with this node.
  26298. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26299. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26300. */
  26301. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26302. /** @hidden */
  26303. _isLeftCamera: boolean;
  26304. /**
  26305. * Gets the left camera of a rig setup in case of Rigged Camera
  26306. */
  26307. get isLeftCamera(): boolean;
  26308. /** @hidden */
  26309. _isRightCamera: boolean;
  26310. /**
  26311. * Gets the right camera of a rig setup in case of Rigged Camera
  26312. */
  26313. get isRightCamera(): boolean;
  26314. /**
  26315. * Gets the left camera of a rig setup in case of Rigged Camera
  26316. */
  26317. get leftCamera(): Nullable<FreeCamera>;
  26318. /**
  26319. * Gets the right camera of a rig setup in case of Rigged Camera
  26320. */
  26321. get rightCamera(): Nullable<FreeCamera>;
  26322. /**
  26323. * Gets the left camera target of a rig setup in case of Rigged Camera
  26324. * @returns the target position
  26325. */
  26326. getLeftTarget(): Nullable<Vector3>;
  26327. /**
  26328. * Gets the right camera target of a rig setup in case of Rigged Camera
  26329. * @returns the target position
  26330. */
  26331. getRightTarget(): Nullable<Vector3>;
  26332. /**
  26333. * @hidden
  26334. */
  26335. setCameraRigMode(mode: number, rigParams: any): void;
  26336. /** @hidden */
  26337. static _setStereoscopicRigMode(camera: Camera): void;
  26338. /** @hidden */
  26339. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26340. /** @hidden */
  26341. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26342. /** @hidden */
  26343. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26344. /** @hidden */
  26345. _getVRProjectionMatrix(): Matrix;
  26346. protected _updateCameraRotationMatrix(): void;
  26347. protected _updateWebVRCameraRotationMatrix(): void;
  26348. /**
  26349. * This function MUST be overwritten by the different WebVR cameras available.
  26350. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26351. * @hidden
  26352. */
  26353. _getWebVRProjectionMatrix(): Matrix;
  26354. /**
  26355. * This function MUST be overwritten by the different WebVR cameras available.
  26356. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26357. * @hidden
  26358. */
  26359. _getWebVRViewMatrix(): Matrix;
  26360. /** @hidden */
  26361. setCameraRigParameter(name: string, value: any): void;
  26362. /**
  26363. * needs to be overridden by children so sub has required properties to be copied
  26364. * @hidden
  26365. */
  26366. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26367. /**
  26368. * May need to be overridden by children
  26369. * @hidden
  26370. */
  26371. _updateRigCameras(): void;
  26372. /** @hidden */
  26373. _setupInputs(): void;
  26374. /**
  26375. * Serialiaze the camera setup to a json represention
  26376. * @returns the JSON representation
  26377. */
  26378. serialize(): any;
  26379. /**
  26380. * Clones the current camera.
  26381. * @param name The cloned camera name
  26382. * @returns the cloned camera
  26383. */
  26384. clone(name: string): Camera;
  26385. /**
  26386. * Gets the direction of the camera relative to a given local axis.
  26387. * @param localAxis Defines the reference axis to provide a relative direction.
  26388. * @return the direction
  26389. */
  26390. getDirection(localAxis: Vector3): Vector3;
  26391. /**
  26392. * Returns the current camera absolute rotation
  26393. */
  26394. get absoluteRotation(): Quaternion;
  26395. /**
  26396. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26397. * @param localAxis Defines the reference axis to provide a relative direction.
  26398. * @param result Defines the vector to store the result in
  26399. */
  26400. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26401. /**
  26402. * Gets a camera constructor for a given camera type
  26403. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26404. * @param name The name of the camera the result will be able to instantiate
  26405. * @param scene The scene the result will construct the camera in
  26406. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26407. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26408. * @returns a factory method to construc the camera
  26409. */
  26410. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26411. /**
  26412. * Compute the world matrix of the camera.
  26413. * @returns the camera world matrix
  26414. */
  26415. computeWorldMatrix(): Matrix;
  26416. /**
  26417. * Parse a JSON and creates the camera from the parsed information
  26418. * @param parsedCamera The JSON to parse
  26419. * @param scene The scene to instantiate the camera in
  26420. * @returns the newly constructed camera
  26421. */
  26422. static Parse(parsedCamera: any, scene: Scene): Camera;
  26423. }
  26424. }
  26425. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26426. import { Nullable } from "babylonjs/types";
  26427. import { Scene } from "babylonjs/scene";
  26428. import { Vector4 } from "babylonjs/Maths/math.vector";
  26429. import { Mesh } from "babylonjs/Meshes/mesh";
  26430. /**
  26431. * Class containing static functions to help procedurally build meshes
  26432. */
  26433. export class DiscBuilder {
  26434. /**
  26435. * Creates a plane polygonal mesh. By default, this is a disc
  26436. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26437. * * 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
  26438. * * 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
  26439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26442. * @param name defines the name of the mesh
  26443. * @param options defines the options used to create the mesh
  26444. * @param scene defines the hosting scene
  26445. * @returns the plane polygonal mesh
  26446. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26447. */
  26448. static CreateDisc(name: string, options: {
  26449. radius?: number;
  26450. tessellation?: number;
  26451. arc?: number;
  26452. updatable?: boolean;
  26453. sideOrientation?: number;
  26454. frontUVs?: Vector4;
  26455. backUVs?: Vector4;
  26456. }, scene?: Nullable<Scene>): Mesh;
  26457. }
  26458. }
  26459. declare module "babylonjs/Materials/fresnelParameters" {
  26460. import { Color3 } from "babylonjs/Maths/math.color";
  26461. /**
  26462. * This represents all the required information to add a fresnel effect on a material:
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26464. */
  26465. export class FresnelParameters {
  26466. private _isEnabled;
  26467. /**
  26468. * Define if the fresnel effect is enable or not.
  26469. */
  26470. get isEnabled(): boolean;
  26471. set isEnabled(value: boolean);
  26472. /**
  26473. * Define the color used on edges (grazing angle)
  26474. */
  26475. leftColor: Color3;
  26476. /**
  26477. * Define the color used on center
  26478. */
  26479. rightColor: Color3;
  26480. /**
  26481. * Define bias applied to computed fresnel term
  26482. */
  26483. bias: number;
  26484. /**
  26485. * Defined the power exponent applied to fresnel term
  26486. */
  26487. power: number;
  26488. /**
  26489. * Clones the current fresnel and its valuues
  26490. * @returns a clone fresnel configuration
  26491. */
  26492. clone(): FresnelParameters;
  26493. /**
  26494. * Serializes the current fresnel parameters to a JSON representation.
  26495. * @return the JSON serialization
  26496. */
  26497. serialize(): any;
  26498. /**
  26499. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26500. * @param parsedFresnelParameters Define the JSON representation
  26501. * @returns the parsed parameters
  26502. */
  26503. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26504. }
  26505. }
  26506. declare module "babylonjs/Materials/pushMaterial" {
  26507. import { Nullable } from "babylonjs/types";
  26508. import { Scene } from "babylonjs/scene";
  26509. import { Matrix } from "babylonjs/Maths/math.vector";
  26510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26511. import { Mesh } from "babylonjs/Meshes/mesh";
  26512. import { Material } from "babylonjs/Materials/material";
  26513. import { Effect } from "babylonjs/Materials/effect";
  26514. /**
  26515. * Base class of materials working in push mode in babylon JS
  26516. * @hidden
  26517. */
  26518. export class PushMaterial extends Material {
  26519. protected _activeEffect: Effect;
  26520. protected _normalMatrix: Matrix;
  26521. /**
  26522. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26523. * This means that the material can keep using a previous shader while a new one is being compiled.
  26524. * This is mostly used when shader parallel compilation is supported (true by default)
  26525. */
  26526. allowShaderHotSwapping: boolean;
  26527. constructor(name: string, scene: Scene);
  26528. getEffect(): Effect;
  26529. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26530. /**
  26531. * Binds the given world matrix to the active effect
  26532. *
  26533. * @param world the matrix to bind
  26534. */
  26535. bindOnlyWorldMatrix(world: Matrix): void;
  26536. /**
  26537. * Binds the given normal matrix to the active effect
  26538. *
  26539. * @param normalMatrix the matrix to bind
  26540. */
  26541. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26542. bind(world: Matrix, mesh?: Mesh): void;
  26543. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26544. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26545. }
  26546. }
  26547. declare module "babylonjs/Materials/materialFlags" {
  26548. /**
  26549. * This groups all the flags used to control the materials channel.
  26550. */
  26551. export class MaterialFlags {
  26552. private static _DiffuseTextureEnabled;
  26553. /**
  26554. * Are diffuse textures enabled in the application.
  26555. */
  26556. static get DiffuseTextureEnabled(): boolean;
  26557. static set DiffuseTextureEnabled(value: boolean);
  26558. private static _AmbientTextureEnabled;
  26559. /**
  26560. * Are ambient textures enabled in the application.
  26561. */
  26562. static get AmbientTextureEnabled(): boolean;
  26563. static set AmbientTextureEnabled(value: boolean);
  26564. private static _OpacityTextureEnabled;
  26565. /**
  26566. * Are opacity textures enabled in the application.
  26567. */
  26568. static get OpacityTextureEnabled(): boolean;
  26569. static set OpacityTextureEnabled(value: boolean);
  26570. private static _ReflectionTextureEnabled;
  26571. /**
  26572. * Are reflection textures enabled in the application.
  26573. */
  26574. static get ReflectionTextureEnabled(): boolean;
  26575. static set ReflectionTextureEnabled(value: boolean);
  26576. private static _EmissiveTextureEnabled;
  26577. /**
  26578. * Are emissive textures enabled in the application.
  26579. */
  26580. static get EmissiveTextureEnabled(): boolean;
  26581. static set EmissiveTextureEnabled(value: boolean);
  26582. private static _SpecularTextureEnabled;
  26583. /**
  26584. * Are specular textures enabled in the application.
  26585. */
  26586. static get SpecularTextureEnabled(): boolean;
  26587. static set SpecularTextureEnabled(value: boolean);
  26588. private static _BumpTextureEnabled;
  26589. /**
  26590. * Are bump textures enabled in the application.
  26591. */
  26592. static get BumpTextureEnabled(): boolean;
  26593. static set BumpTextureEnabled(value: boolean);
  26594. private static _LightmapTextureEnabled;
  26595. /**
  26596. * Are lightmap textures enabled in the application.
  26597. */
  26598. static get LightmapTextureEnabled(): boolean;
  26599. static set LightmapTextureEnabled(value: boolean);
  26600. private static _RefractionTextureEnabled;
  26601. /**
  26602. * Are refraction textures enabled in the application.
  26603. */
  26604. static get RefractionTextureEnabled(): boolean;
  26605. static set RefractionTextureEnabled(value: boolean);
  26606. private static _ColorGradingTextureEnabled;
  26607. /**
  26608. * Are color grading textures enabled in the application.
  26609. */
  26610. static get ColorGradingTextureEnabled(): boolean;
  26611. static set ColorGradingTextureEnabled(value: boolean);
  26612. private static _FresnelEnabled;
  26613. /**
  26614. * Are fresnels enabled in the application.
  26615. */
  26616. static get FresnelEnabled(): boolean;
  26617. static set FresnelEnabled(value: boolean);
  26618. private static _ClearCoatTextureEnabled;
  26619. /**
  26620. * Are clear coat textures enabled in the application.
  26621. */
  26622. static get ClearCoatTextureEnabled(): boolean;
  26623. static set ClearCoatTextureEnabled(value: boolean);
  26624. private static _ClearCoatBumpTextureEnabled;
  26625. /**
  26626. * Are clear coat bump textures enabled in the application.
  26627. */
  26628. static get ClearCoatBumpTextureEnabled(): boolean;
  26629. static set ClearCoatBumpTextureEnabled(value: boolean);
  26630. private static _ClearCoatTintTextureEnabled;
  26631. /**
  26632. * Are clear coat tint textures enabled in the application.
  26633. */
  26634. static get ClearCoatTintTextureEnabled(): boolean;
  26635. static set ClearCoatTintTextureEnabled(value: boolean);
  26636. private static _SheenTextureEnabled;
  26637. /**
  26638. * Are sheen textures enabled in the application.
  26639. */
  26640. static get SheenTextureEnabled(): boolean;
  26641. static set SheenTextureEnabled(value: boolean);
  26642. private static _AnisotropicTextureEnabled;
  26643. /**
  26644. * Are anisotropic textures enabled in the application.
  26645. */
  26646. static get AnisotropicTextureEnabled(): boolean;
  26647. static set AnisotropicTextureEnabled(value: boolean);
  26648. private static _ThicknessTextureEnabled;
  26649. /**
  26650. * Are thickness textures enabled in the application.
  26651. */
  26652. static get ThicknessTextureEnabled(): boolean;
  26653. static set ThicknessTextureEnabled(value: boolean);
  26654. }
  26655. }
  26656. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26657. /** @hidden */
  26658. export var defaultFragmentDeclaration: {
  26659. name: string;
  26660. shader: string;
  26661. };
  26662. }
  26663. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26664. /** @hidden */
  26665. export var defaultUboDeclaration: {
  26666. name: string;
  26667. shader: string;
  26668. };
  26669. }
  26670. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26671. /** @hidden */
  26672. export var lightFragmentDeclaration: {
  26673. name: string;
  26674. shader: string;
  26675. };
  26676. }
  26677. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26678. /** @hidden */
  26679. export var lightUboDeclaration: {
  26680. name: string;
  26681. shader: string;
  26682. };
  26683. }
  26684. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26685. /** @hidden */
  26686. export var lightsFragmentFunctions: {
  26687. name: string;
  26688. shader: string;
  26689. };
  26690. }
  26691. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26692. /** @hidden */
  26693. export var shadowsFragmentFunctions: {
  26694. name: string;
  26695. shader: string;
  26696. };
  26697. }
  26698. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26699. /** @hidden */
  26700. export var fresnelFunction: {
  26701. name: string;
  26702. shader: string;
  26703. };
  26704. }
  26705. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26706. /** @hidden */
  26707. export var reflectionFunction: {
  26708. name: string;
  26709. shader: string;
  26710. };
  26711. }
  26712. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26713. /** @hidden */
  26714. export var bumpFragmentFunctions: {
  26715. name: string;
  26716. shader: string;
  26717. };
  26718. }
  26719. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26720. /** @hidden */
  26721. export var logDepthDeclaration: {
  26722. name: string;
  26723. shader: string;
  26724. };
  26725. }
  26726. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26727. /** @hidden */
  26728. export var bumpFragment: {
  26729. name: string;
  26730. shader: string;
  26731. };
  26732. }
  26733. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26734. /** @hidden */
  26735. export var depthPrePass: {
  26736. name: string;
  26737. shader: string;
  26738. };
  26739. }
  26740. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26741. /** @hidden */
  26742. export var lightFragment: {
  26743. name: string;
  26744. shader: string;
  26745. };
  26746. }
  26747. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26748. /** @hidden */
  26749. export var logDepthFragment: {
  26750. name: string;
  26751. shader: string;
  26752. };
  26753. }
  26754. declare module "babylonjs/Shaders/default.fragment" {
  26755. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26756. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26757. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26758. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26759. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26760. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26761. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26762. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26763. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26764. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26765. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26766. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26767. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26768. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26769. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26770. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26771. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26772. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26773. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26774. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26775. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26776. /** @hidden */
  26777. export var defaultPixelShader: {
  26778. name: string;
  26779. shader: string;
  26780. };
  26781. }
  26782. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26783. /** @hidden */
  26784. export var defaultVertexDeclaration: {
  26785. name: string;
  26786. shader: string;
  26787. };
  26788. }
  26789. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26790. /** @hidden */
  26791. export var bumpVertexDeclaration: {
  26792. name: string;
  26793. shader: string;
  26794. };
  26795. }
  26796. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26797. /** @hidden */
  26798. export var bumpVertex: {
  26799. name: string;
  26800. shader: string;
  26801. };
  26802. }
  26803. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26804. /** @hidden */
  26805. export var fogVertex: {
  26806. name: string;
  26807. shader: string;
  26808. };
  26809. }
  26810. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26811. /** @hidden */
  26812. export var shadowsVertex: {
  26813. name: string;
  26814. shader: string;
  26815. };
  26816. }
  26817. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26818. /** @hidden */
  26819. export var pointCloudVertex: {
  26820. name: string;
  26821. shader: string;
  26822. };
  26823. }
  26824. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26825. /** @hidden */
  26826. export var logDepthVertex: {
  26827. name: string;
  26828. shader: string;
  26829. };
  26830. }
  26831. declare module "babylonjs/Shaders/default.vertex" {
  26832. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26833. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26834. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26835. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26837. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26838. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26839. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26840. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26841. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26844. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26846. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26847. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26848. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26849. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26850. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26851. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26852. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26853. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26854. /** @hidden */
  26855. export var defaultVertexShader: {
  26856. name: string;
  26857. shader: string;
  26858. };
  26859. }
  26860. declare module "babylonjs/Materials/standardMaterial" {
  26861. import { SmartArray } from "babylonjs/Misc/smartArray";
  26862. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26863. import { Nullable } from "babylonjs/types";
  26864. import { Scene } from "babylonjs/scene";
  26865. import { Matrix } from "babylonjs/Maths/math.vector";
  26866. import { Color3 } from "babylonjs/Maths/math.color";
  26867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26869. import { Mesh } from "babylonjs/Meshes/mesh";
  26870. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26871. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26872. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26873. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26874. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26875. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26877. import "babylonjs/Shaders/default.fragment";
  26878. import "babylonjs/Shaders/default.vertex";
  26879. /** @hidden */
  26880. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26881. MAINUV1: boolean;
  26882. MAINUV2: boolean;
  26883. DIFFUSE: boolean;
  26884. DIFFUSEDIRECTUV: number;
  26885. AMBIENT: boolean;
  26886. AMBIENTDIRECTUV: number;
  26887. OPACITY: boolean;
  26888. OPACITYDIRECTUV: number;
  26889. OPACITYRGB: boolean;
  26890. REFLECTION: boolean;
  26891. EMISSIVE: boolean;
  26892. EMISSIVEDIRECTUV: number;
  26893. SPECULAR: boolean;
  26894. SPECULARDIRECTUV: number;
  26895. BUMP: boolean;
  26896. BUMPDIRECTUV: number;
  26897. PARALLAX: boolean;
  26898. PARALLAXOCCLUSION: boolean;
  26899. SPECULAROVERALPHA: boolean;
  26900. CLIPPLANE: boolean;
  26901. CLIPPLANE2: boolean;
  26902. CLIPPLANE3: boolean;
  26903. CLIPPLANE4: boolean;
  26904. CLIPPLANE5: boolean;
  26905. CLIPPLANE6: boolean;
  26906. ALPHATEST: boolean;
  26907. DEPTHPREPASS: boolean;
  26908. ALPHAFROMDIFFUSE: boolean;
  26909. POINTSIZE: boolean;
  26910. FOG: boolean;
  26911. SPECULARTERM: boolean;
  26912. DIFFUSEFRESNEL: boolean;
  26913. OPACITYFRESNEL: boolean;
  26914. REFLECTIONFRESNEL: boolean;
  26915. REFRACTIONFRESNEL: boolean;
  26916. EMISSIVEFRESNEL: boolean;
  26917. FRESNEL: boolean;
  26918. NORMAL: boolean;
  26919. UV1: boolean;
  26920. UV2: boolean;
  26921. VERTEXCOLOR: boolean;
  26922. VERTEXALPHA: boolean;
  26923. NUM_BONE_INFLUENCERS: number;
  26924. BonesPerMesh: number;
  26925. BONETEXTURE: boolean;
  26926. INSTANCES: boolean;
  26927. GLOSSINESS: boolean;
  26928. ROUGHNESS: boolean;
  26929. EMISSIVEASILLUMINATION: boolean;
  26930. LINKEMISSIVEWITHDIFFUSE: boolean;
  26931. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26932. LIGHTMAP: boolean;
  26933. LIGHTMAPDIRECTUV: number;
  26934. OBJECTSPACE_NORMALMAP: boolean;
  26935. USELIGHTMAPASSHADOWMAP: boolean;
  26936. REFLECTIONMAP_3D: boolean;
  26937. REFLECTIONMAP_SPHERICAL: boolean;
  26938. REFLECTIONMAP_PLANAR: boolean;
  26939. REFLECTIONMAP_CUBIC: boolean;
  26940. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26941. REFLECTIONMAP_PROJECTION: boolean;
  26942. REFLECTIONMAP_SKYBOX: boolean;
  26943. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26944. REFLECTIONMAP_EXPLICIT: boolean;
  26945. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26946. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26947. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26948. INVERTCUBICMAP: boolean;
  26949. LOGARITHMICDEPTH: boolean;
  26950. REFRACTION: boolean;
  26951. REFRACTIONMAP_3D: boolean;
  26952. REFLECTIONOVERALPHA: boolean;
  26953. TWOSIDEDLIGHTING: boolean;
  26954. SHADOWFLOAT: boolean;
  26955. MORPHTARGETS: boolean;
  26956. MORPHTARGETS_NORMAL: boolean;
  26957. MORPHTARGETS_TANGENT: boolean;
  26958. MORPHTARGETS_UV: boolean;
  26959. NUM_MORPH_INFLUENCERS: number;
  26960. NONUNIFORMSCALING: boolean;
  26961. PREMULTIPLYALPHA: boolean;
  26962. IMAGEPROCESSING: boolean;
  26963. VIGNETTE: boolean;
  26964. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26965. VIGNETTEBLENDMODEOPAQUE: boolean;
  26966. TONEMAPPING: boolean;
  26967. TONEMAPPING_ACES: boolean;
  26968. CONTRAST: boolean;
  26969. COLORCURVES: boolean;
  26970. COLORGRADING: boolean;
  26971. COLORGRADING3D: boolean;
  26972. SAMPLER3DGREENDEPTH: boolean;
  26973. SAMPLER3DBGRMAP: boolean;
  26974. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26975. MULTIVIEW: boolean;
  26976. /**
  26977. * If the reflection texture on this material is in linear color space
  26978. * @hidden
  26979. */
  26980. IS_REFLECTION_LINEAR: boolean;
  26981. /**
  26982. * If the refraction texture on this material is in linear color space
  26983. * @hidden
  26984. */
  26985. IS_REFRACTION_LINEAR: boolean;
  26986. EXPOSURE: boolean;
  26987. constructor();
  26988. setReflectionMode(modeToEnable: string): void;
  26989. }
  26990. /**
  26991. * This is the default material used in Babylon. It is the best trade off between quality
  26992. * and performances.
  26993. * @see http://doc.babylonjs.com/babylon101/materials
  26994. */
  26995. export class StandardMaterial extends PushMaterial {
  26996. private _diffuseTexture;
  26997. /**
  26998. * The basic texture of the material as viewed under a light.
  26999. */
  27000. diffuseTexture: Nullable<BaseTexture>;
  27001. private _ambientTexture;
  27002. /**
  27003. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27004. */
  27005. ambientTexture: Nullable<BaseTexture>;
  27006. private _opacityTexture;
  27007. /**
  27008. * Define the transparency of the material from a texture.
  27009. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27010. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27011. */
  27012. opacityTexture: Nullable<BaseTexture>;
  27013. private _reflectionTexture;
  27014. /**
  27015. * Define the texture used to display the reflection.
  27016. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27017. */
  27018. reflectionTexture: Nullable<BaseTexture>;
  27019. private _emissiveTexture;
  27020. /**
  27021. * Define texture of the material as if self lit.
  27022. * This will be mixed in the final result even in the absence of light.
  27023. */
  27024. emissiveTexture: Nullable<BaseTexture>;
  27025. private _specularTexture;
  27026. /**
  27027. * Define how the color and intensity of the highlight given by the light in the material.
  27028. */
  27029. specularTexture: Nullable<BaseTexture>;
  27030. private _bumpTexture;
  27031. /**
  27032. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27033. * 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.
  27034. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27035. */
  27036. bumpTexture: Nullable<BaseTexture>;
  27037. private _lightmapTexture;
  27038. /**
  27039. * Complex lighting can be computationally expensive to compute at runtime.
  27040. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27041. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27042. */
  27043. lightmapTexture: Nullable<BaseTexture>;
  27044. private _refractionTexture;
  27045. /**
  27046. * Define the texture used to display the refraction.
  27047. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27048. */
  27049. refractionTexture: Nullable<BaseTexture>;
  27050. /**
  27051. * The color of the material lit by the environmental background lighting.
  27052. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27053. */
  27054. ambientColor: Color3;
  27055. /**
  27056. * The basic color of the material as viewed under a light.
  27057. */
  27058. diffuseColor: Color3;
  27059. /**
  27060. * Define how the color and intensity of the highlight given by the light in the material.
  27061. */
  27062. specularColor: Color3;
  27063. /**
  27064. * Define the color of the material as if self lit.
  27065. * This will be mixed in the final result even in the absence of light.
  27066. */
  27067. emissiveColor: Color3;
  27068. /**
  27069. * Defines how sharp are the highlights in the material.
  27070. * The bigger the value the sharper giving a more glossy feeling to the result.
  27071. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27072. */
  27073. specularPower: number;
  27074. private _useAlphaFromDiffuseTexture;
  27075. /**
  27076. * Does the transparency come from the diffuse texture alpha channel.
  27077. */
  27078. useAlphaFromDiffuseTexture: boolean;
  27079. private _useEmissiveAsIllumination;
  27080. /**
  27081. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27082. */
  27083. useEmissiveAsIllumination: boolean;
  27084. private _linkEmissiveWithDiffuse;
  27085. /**
  27086. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27087. * the emissive level when the final color is close to one.
  27088. */
  27089. linkEmissiveWithDiffuse: boolean;
  27090. private _useSpecularOverAlpha;
  27091. /**
  27092. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27093. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27094. */
  27095. useSpecularOverAlpha: boolean;
  27096. private _useReflectionOverAlpha;
  27097. /**
  27098. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27099. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27100. */
  27101. useReflectionOverAlpha: boolean;
  27102. private _disableLighting;
  27103. /**
  27104. * Does lights from the scene impacts this material.
  27105. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27106. */
  27107. disableLighting: boolean;
  27108. private _useObjectSpaceNormalMap;
  27109. /**
  27110. * Allows using an object space normal map (instead of tangent space).
  27111. */
  27112. useObjectSpaceNormalMap: boolean;
  27113. private _useParallax;
  27114. /**
  27115. * Is parallax enabled or not.
  27116. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27117. */
  27118. useParallax: boolean;
  27119. private _useParallaxOcclusion;
  27120. /**
  27121. * Is parallax occlusion enabled or not.
  27122. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27123. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27124. */
  27125. useParallaxOcclusion: boolean;
  27126. /**
  27127. * 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.
  27128. */
  27129. parallaxScaleBias: number;
  27130. private _roughness;
  27131. /**
  27132. * Helps to define how blurry the reflections should appears in the material.
  27133. */
  27134. roughness: number;
  27135. /**
  27136. * In case of refraction, define the value of the index of refraction.
  27137. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27138. */
  27139. indexOfRefraction: number;
  27140. /**
  27141. * Invert the refraction texture alongside the y axis.
  27142. * It can be useful with procedural textures or probe for instance.
  27143. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27144. */
  27145. invertRefractionY: boolean;
  27146. /**
  27147. * Defines the alpha limits in alpha test mode.
  27148. */
  27149. alphaCutOff: number;
  27150. private _useLightmapAsShadowmap;
  27151. /**
  27152. * In case of light mapping, define whether the map contains light or shadow informations.
  27153. */
  27154. useLightmapAsShadowmap: boolean;
  27155. private _diffuseFresnelParameters;
  27156. /**
  27157. * Define the diffuse fresnel parameters of the material.
  27158. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27159. */
  27160. diffuseFresnelParameters: FresnelParameters;
  27161. private _opacityFresnelParameters;
  27162. /**
  27163. * Define the opacity fresnel parameters of the material.
  27164. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27165. */
  27166. opacityFresnelParameters: FresnelParameters;
  27167. private _reflectionFresnelParameters;
  27168. /**
  27169. * Define the reflection fresnel parameters of the material.
  27170. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27171. */
  27172. reflectionFresnelParameters: FresnelParameters;
  27173. private _refractionFresnelParameters;
  27174. /**
  27175. * Define the refraction fresnel parameters of the material.
  27176. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27177. */
  27178. refractionFresnelParameters: FresnelParameters;
  27179. private _emissiveFresnelParameters;
  27180. /**
  27181. * Define the emissive fresnel parameters of the material.
  27182. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27183. */
  27184. emissiveFresnelParameters: FresnelParameters;
  27185. private _useReflectionFresnelFromSpecular;
  27186. /**
  27187. * If true automatically deducts the fresnels values from the material specularity.
  27188. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27189. */
  27190. useReflectionFresnelFromSpecular: boolean;
  27191. private _useGlossinessFromSpecularMapAlpha;
  27192. /**
  27193. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27194. */
  27195. useGlossinessFromSpecularMapAlpha: boolean;
  27196. private _maxSimultaneousLights;
  27197. /**
  27198. * Defines the maximum number of lights that can be used in the material
  27199. */
  27200. maxSimultaneousLights: number;
  27201. private _invertNormalMapX;
  27202. /**
  27203. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27204. */
  27205. invertNormalMapX: boolean;
  27206. private _invertNormalMapY;
  27207. /**
  27208. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27209. */
  27210. invertNormalMapY: boolean;
  27211. private _twoSidedLighting;
  27212. /**
  27213. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27214. */
  27215. twoSidedLighting: boolean;
  27216. /**
  27217. * Default configuration related to image processing available in the standard Material.
  27218. */
  27219. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27220. /**
  27221. * Gets the image processing configuration used either in this material.
  27222. */
  27223. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27224. /**
  27225. * Sets the Default image processing configuration used either in the this material.
  27226. *
  27227. * If sets to null, the scene one is in use.
  27228. */
  27229. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27230. /**
  27231. * Keep track of the image processing observer to allow dispose and replace.
  27232. */
  27233. private _imageProcessingObserver;
  27234. /**
  27235. * Attaches a new image processing configuration to the Standard Material.
  27236. * @param configuration
  27237. */
  27238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27239. /**
  27240. * Gets wether the color curves effect is enabled.
  27241. */
  27242. get cameraColorCurvesEnabled(): boolean;
  27243. /**
  27244. * Sets wether the color curves effect is enabled.
  27245. */
  27246. set cameraColorCurvesEnabled(value: boolean);
  27247. /**
  27248. * Gets wether the color grading effect is enabled.
  27249. */
  27250. get cameraColorGradingEnabled(): boolean;
  27251. /**
  27252. * Gets wether the color grading effect is enabled.
  27253. */
  27254. set cameraColorGradingEnabled(value: boolean);
  27255. /**
  27256. * Gets wether tonemapping is enabled or not.
  27257. */
  27258. get cameraToneMappingEnabled(): boolean;
  27259. /**
  27260. * Sets wether tonemapping is enabled or not
  27261. */
  27262. set cameraToneMappingEnabled(value: boolean);
  27263. /**
  27264. * The camera exposure used on this material.
  27265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27266. * This corresponds to a photographic exposure.
  27267. */
  27268. get cameraExposure(): number;
  27269. /**
  27270. * The camera exposure used on this material.
  27271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27272. * This corresponds to a photographic exposure.
  27273. */
  27274. set cameraExposure(value: number);
  27275. /**
  27276. * Gets The camera contrast used on this material.
  27277. */
  27278. get cameraContrast(): number;
  27279. /**
  27280. * Sets The camera contrast used on this material.
  27281. */
  27282. set cameraContrast(value: number);
  27283. /**
  27284. * Gets the Color Grading 2D Lookup Texture.
  27285. */
  27286. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27287. /**
  27288. * Sets the Color Grading 2D Lookup Texture.
  27289. */
  27290. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27291. /**
  27292. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27293. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27294. * 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;
  27295. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27296. */
  27297. get cameraColorCurves(): Nullable<ColorCurves>;
  27298. /**
  27299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27301. * 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;
  27302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27303. */
  27304. set cameraColorCurves(value: Nullable<ColorCurves>);
  27305. /**
  27306. * Custom callback helping to override the default shader used in the material.
  27307. */
  27308. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27309. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27310. protected _worldViewProjectionMatrix: Matrix;
  27311. protected _globalAmbientColor: Color3;
  27312. protected _useLogarithmicDepth: boolean;
  27313. protected _rebuildInParallel: boolean;
  27314. /**
  27315. * Instantiates a new standard material.
  27316. * This is the default material used in Babylon. It is the best trade off between quality
  27317. * and performances.
  27318. * @see http://doc.babylonjs.com/babylon101/materials
  27319. * @param name Define the name of the material in the scene
  27320. * @param scene Define the scene the material belong to
  27321. */
  27322. constructor(name: string, scene: Scene);
  27323. /**
  27324. * Gets a boolean indicating that current material needs to register RTT
  27325. */
  27326. get hasRenderTargetTextures(): boolean;
  27327. /**
  27328. * Gets the current class name of the material e.g. "StandardMaterial"
  27329. * Mainly use in serialization.
  27330. * @returns the class name
  27331. */
  27332. getClassName(): string;
  27333. /**
  27334. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27335. * You can try switching to logarithmic depth.
  27336. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27337. */
  27338. get useLogarithmicDepth(): boolean;
  27339. set useLogarithmicDepth(value: boolean);
  27340. /**
  27341. * Specifies if the material will require alpha blending
  27342. * @returns a boolean specifying if alpha blending is needed
  27343. */
  27344. needAlphaBlending(): boolean;
  27345. /**
  27346. * Specifies if this material should be rendered in alpha test mode
  27347. * @returns a boolean specifying if an alpha test is needed.
  27348. */
  27349. needAlphaTesting(): boolean;
  27350. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27351. /**
  27352. * Get the texture used for alpha test purpose.
  27353. * @returns the diffuse texture in case of the standard material.
  27354. */
  27355. getAlphaTestTexture(): Nullable<BaseTexture>;
  27356. /**
  27357. * Get if the submesh is ready to be used and all its information available.
  27358. * Child classes can use it to update shaders
  27359. * @param mesh defines the mesh to check
  27360. * @param subMesh defines which submesh to check
  27361. * @param useInstances specifies that instances should be used
  27362. * @returns a boolean indicating that the submesh is ready or not
  27363. */
  27364. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27365. /**
  27366. * Builds the material UBO layouts.
  27367. * Used internally during the effect preparation.
  27368. */
  27369. buildUniformLayout(): void;
  27370. /**
  27371. * Unbinds the material from the mesh
  27372. */
  27373. unbind(): void;
  27374. /**
  27375. * Binds the submesh to this material by preparing the effect and shader to draw
  27376. * @param world defines the world transformation matrix
  27377. * @param mesh defines the mesh containing the submesh
  27378. * @param subMesh defines the submesh to bind the material to
  27379. */
  27380. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27381. /**
  27382. * Get the list of animatables in the material.
  27383. * @returns the list of animatables object used in the material
  27384. */
  27385. getAnimatables(): IAnimatable[];
  27386. /**
  27387. * Gets the active textures from the material
  27388. * @returns an array of textures
  27389. */
  27390. getActiveTextures(): BaseTexture[];
  27391. /**
  27392. * Specifies if the material uses a texture
  27393. * @param texture defines the texture to check against the material
  27394. * @returns a boolean specifying if the material uses the texture
  27395. */
  27396. hasTexture(texture: BaseTexture): boolean;
  27397. /**
  27398. * Disposes the material
  27399. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27400. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27401. */
  27402. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27403. /**
  27404. * Makes a duplicate of the material, and gives it a new name
  27405. * @param name defines the new name for the duplicated material
  27406. * @returns the cloned material
  27407. */
  27408. clone(name: string): StandardMaterial;
  27409. /**
  27410. * Serializes this material in a JSON representation
  27411. * @returns the serialized material object
  27412. */
  27413. serialize(): any;
  27414. /**
  27415. * Creates a standard material from parsed material data
  27416. * @param source defines the JSON representation of the material
  27417. * @param scene defines the hosting scene
  27418. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27419. * @returns a new standard material
  27420. */
  27421. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27422. /**
  27423. * Are diffuse textures enabled in the application.
  27424. */
  27425. static get DiffuseTextureEnabled(): boolean;
  27426. static set DiffuseTextureEnabled(value: boolean);
  27427. /**
  27428. * Are ambient textures enabled in the application.
  27429. */
  27430. static get AmbientTextureEnabled(): boolean;
  27431. static set AmbientTextureEnabled(value: boolean);
  27432. /**
  27433. * Are opacity textures enabled in the application.
  27434. */
  27435. static get OpacityTextureEnabled(): boolean;
  27436. static set OpacityTextureEnabled(value: boolean);
  27437. /**
  27438. * Are reflection textures enabled in the application.
  27439. */
  27440. static get ReflectionTextureEnabled(): boolean;
  27441. static set ReflectionTextureEnabled(value: boolean);
  27442. /**
  27443. * Are emissive textures enabled in the application.
  27444. */
  27445. static get EmissiveTextureEnabled(): boolean;
  27446. static set EmissiveTextureEnabled(value: boolean);
  27447. /**
  27448. * Are specular textures enabled in the application.
  27449. */
  27450. static get SpecularTextureEnabled(): boolean;
  27451. static set SpecularTextureEnabled(value: boolean);
  27452. /**
  27453. * Are bump textures enabled in the application.
  27454. */
  27455. static get BumpTextureEnabled(): boolean;
  27456. static set BumpTextureEnabled(value: boolean);
  27457. /**
  27458. * Are lightmap textures enabled in the application.
  27459. */
  27460. static get LightmapTextureEnabled(): boolean;
  27461. static set LightmapTextureEnabled(value: boolean);
  27462. /**
  27463. * Are refraction textures enabled in the application.
  27464. */
  27465. static get RefractionTextureEnabled(): boolean;
  27466. static set RefractionTextureEnabled(value: boolean);
  27467. /**
  27468. * Are color grading textures enabled in the application.
  27469. */
  27470. static get ColorGradingTextureEnabled(): boolean;
  27471. static set ColorGradingTextureEnabled(value: boolean);
  27472. /**
  27473. * Are fresnels enabled in the application.
  27474. */
  27475. static get FresnelEnabled(): boolean;
  27476. static set FresnelEnabled(value: boolean);
  27477. }
  27478. }
  27479. declare module "babylonjs/Particles/solidParticleSystem" {
  27480. import { Nullable } from "babylonjs/types";
  27481. import { Vector3 } from "babylonjs/Maths/math.vector";
  27482. import { Mesh } from "babylonjs/Meshes/mesh";
  27483. import { Scene, IDisposable } from "babylonjs/scene";
  27484. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27485. import { Material } from "babylonjs/Materials/material";
  27486. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27487. /**
  27488. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27489. *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.
  27490. * The SPS is also a particle system. It provides some methods to manage the particles.
  27491. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27492. *
  27493. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27494. */
  27495. export class SolidParticleSystem implements IDisposable {
  27496. /**
  27497. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27498. * Example : var p = SPS.particles[i];
  27499. */
  27500. particles: SolidParticle[];
  27501. /**
  27502. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27503. */
  27504. nbParticles: number;
  27505. /**
  27506. * If the particles must ever face the camera (default false). Useful for planar particles.
  27507. */
  27508. billboard: boolean;
  27509. /**
  27510. * Recompute normals when adding a shape
  27511. */
  27512. recomputeNormals: boolean;
  27513. /**
  27514. * This a counter ofr your own usage. It's not set by any SPS functions.
  27515. */
  27516. counter: number;
  27517. /**
  27518. * The SPS name. This name is also given to the underlying mesh.
  27519. */
  27520. name: string;
  27521. /**
  27522. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27523. */
  27524. mesh: Mesh;
  27525. /**
  27526. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27527. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27528. */
  27529. vars: any;
  27530. /**
  27531. * This array is populated when the SPS is set as 'pickable'.
  27532. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27533. * Each element of this array is an object `{idx: int, faceId: int}`.
  27534. * `idx` is the picked particle index in the `SPS.particles` array
  27535. * `faceId` is the picked face index counted within this particle.
  27536. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27537. */
  27538. pickedParticles: {
  27539. idx: number;
  27540. faceId: number;
  27541. }[];
  27542. /**
  27543. * This array is populated when `enableDepthSort` is set to true.
  27544. * Each element of this array is an instance of the class DepthSortedParticle.
  27545. */
  27546. depthSortedParticles: DepthSortedParticle[];
  27547. /**
  27548. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27549. * @hidden
  27550. */
  27551. _bSphereOnly: boolean;
  27552. /**
  27553. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27554. * @hidden
  27555. */
  27556. _bSphereRadiusFactor: number;
  27557. private _scene;
  27558. private _positions;
  27559. private _indices;
  27560. private _normals;
  27561. private _colors;
  27562. private _uvs;
  27563. private _indices32;
  27564. private _positions32;
  27565. private _normals32;
  27566. private _fixedNormal32;
  27567. private _colors32;
  27568. private _uvs32;
  27569. private _index;
  27570. private _updatable;
  27571. private _pickable;
  27572. private _isVisibilityBoxLocked;
  27573. private _alwaysVisible;
  27574. private _depthSort;
  27575. private _expandable;
  27576. private _shapeCounter;
  27577. private _copy;
  27578. private _color;
  27579. private _computeParticleColor;
  27580. private _computeParticleTexture;
  27581. private _computeParticleRotation;
  27582. private _computeParticleVertex;
  27583. private _computeBoundingBox;
  27584. private _depthSortParticles;
  27585. private _camera;
  27586. private _mustUnrotateFixedNormals;
  27587. private _particlesIntersect;
  27588. private _needs32Bits;
  27589. private _isNotBuilt;
  27590. private _lastParticleId;
  27591. private _idxOfId;
  27592. private _multimaterialEnabled;
  27593. private _useModelMaterial;
  27594. private _indicesByMaterial;
  27595. private _materialIndexes;
  27596. private _depthSortFunction;
  27597. private _materialSortFunction;
  27598. private _materials;
  27599. private _multimaterial;
  27600. private _materialIndexesById;
  27601. private _defaultMaterial;
  27602. private _autoUpdateSubMeshes;
  27603. /**
  27604. * Creates a SPS (Solid Particle System) object.
  27605. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27606. * @param scene (Scene) is the scene in which the SPS is added.
  27607. * @param options defines the options of the sps e.g.
  27608. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27609. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27610. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27611. * * 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.
  27612. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27613. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27614. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27615. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27616. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27617. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27618. */
  27619. constructor(name: string, scene: Scene, options?: {
  27620. updatable?: boolean;
  27621. isPickable?: boolean;
  27622. enableDepthSort?: boolean;
  27623. particleIntersection?: boolean;
  27624. boundingSphereOnly?: boolean;
  27625. bSphereRadiusFactor?: number;
  27626. expandable?: boolean;
  27627. useModelMaterial?: boolean;
  27628. enableMultiMaterial?: boolean;
  27629. });
  27630. /**
  27631. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27632. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27633. * @returns the created mesh
  27634. */
  27635. buildMesh(): Mesh;
  27636. /**
  27637. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27638. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27639. * Thus the particles generated from `digest()` have their property `position` set yet.
  27640. * @param mesh ( Mesh ) is the mesh to be digested
  27641. * @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
  27642. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27643. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27644. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27645. * @returns the current SPS
  27646. */
  27647. digest(mesh: Mesh, options?: {
  27648. facetNb?: number;
  27649. number?: number;
  27650. delta?: number;
  27651. storage?: [];
  27652. }): SolidParticleSystem;
  27653. /**
  27654. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27655. * @hidden
  27656. */
  27657. private _unrotateFixedNormals;
  27658. /**
  27659. * Resets the temporary working copy particle
  27660. * @hidden
  27661. */
  27662. private _resetCopy;
  27663. /**
  27664. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27665. * @param p the current index in the positions array to be updated
  27666. * @param ind the current index in the indices array
  27667. * @param shape a Vector3 array, the shape geometry
  27668. * @param positions the positions array to be updated
  27669. * @param meshInd the shape indices array
  27670. * @param indices the indices array to be updated
  27671. * @param meshUV the shape uv array
  27672. * @param uvs the uv array to be updated
  27673. * @param meshCol the shape color array
  27674. * @param colors the color array to be updated
  27675. * @param meshNor the shape normals array
  27676. * @param normals the normals array to be updated
  27677. * @param idx the particle index
  27678. * @param idxInShape the particle index in its shape
  27679. * @param options the addShape() method passed options
  27680. * @model the particle model
  27681. * @hidden
  27682. */
  27683. private _meshBuilder;
  27684. /**
  27685. * Returns a shape Vector3 array from positions float array
  27686. * @param positions float array
  27687. * @returns a vector3 array
  27688. * @hidden
  27689. */
  27690. private _posToShape;
  27691. /**
  27692. * Returns a shapeUV array from a float uvs (array deep copy)
  27693. * @param uvs as a float array
  27694. * @returns a shapeUV array
  27695. * @hidden
  27696. */
  27697. private _uvsToShapeUV;
  27698. /**
  27699. * Adds a new particle object in the particles array
  27700. * @param idx particle index in particles array
  27701. * @param id particle id
  27702. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27703. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27704. * @param model particle ModelShape object
  27705. * @param shapeId model shape identifier
  27706. * @param idxInShape index of the particle in the current model
  27707. * @param bInfo model bounding info object
  27708. * @param storage target storage array, if any
  27709. * @hidden
  27710. */
  27711. private _addParticle;
  27712. /**
  27713. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27714. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27715. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27716. * @param nb (positive integer) the number of particles to be created from this model
  27717. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27718. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27719. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27720. * @returns the number of shapes in the system
  27721. */
  27722. addShape(mesh: Mesh, nb: number, options?: {
  27723. positionFunction?: any;
  27724. vertexFunction?: any;
  27725. storage?: [];
  27726. }): number;
  27727. /**
  27728. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27729. * @hidden
  27730. */
  27731. private _rebuildParticle;
  27732. /**
  27733. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27734. * @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.
  27735. * @returns the SPS.
  27736. */
  27737. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27738. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27739. * Returns an array with the removed particles.
  27740. * 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.
  27741. * The SPS can't be empty so at least one particle needs to remain in place.
  27742. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27743. * @param start index of the first particle to remove
  27744. * @param end index of the last particle to remove (included)
  27745. * @returns an array populated with the removed particles
  27746. */
  27747. removeParticles(start: number, end: number): SolidParticle[];
  27748. /**
  27749. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27750. * @param solidParticleArray an array populated with Solid Particles objects
  27751. * @returns the SPS
  27752. */
  27753. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27754. /**
  27755. * Creates a new particle and modifies the SPS mesh geometry :
  27756. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27757. * - calls _addParticle() to populate the particle array
  27758. * factorized code from addShape() and insertParticlesFromArray()
  27759. * @param idx particle index in the particles array
  27760. * @param i particle index in its shape
  27761. * @param modelShape particle ModelShape object
  27762. * @param shape shape vertex array
  27763. * @param meshInd shape indices array
  27764. * @param meshUV shape uv array
  27765. * @param meshCol shape color array
  27766. * @param meshNor shape normals array
  27767. * @param bbInfo shape bounding info
  27768. * @param storage target particle storage
  27769. * @options addShape() passed options
  27770. * @hidden
  27771. */
  27772. private _insertNewParticle;
  27773. /**
  27774. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27775. * This method calls `updateParticle()` for each particle of the SPS.
  27776. * For an animated SPS, it is usually called within the render loop.
  27777. * 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.
  27778. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27779. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27780. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27781. * @returns the SPS.
  27782. */
  27783. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27784. /**
  27785. * Disposes the SPS.
  27786. */
  27787. dispose(): void;
  27788. /**
  27789. * Returns a SolidParticle object from its identifier : particle.id
  27790. * @param id (integer) the particle Id
  27791. * @returns the searched particle or null if not found in the SPS.
  27792. */
  27793. getParticleById(id: number): Nullable<SolidParticle>;
  27794. /**
  27795. * Returns a new array populated with the particles having the passed shapeId.
  27796. * @param shapeId (integer) the shape identifier
  27797. * @returns a new solid particle array
  27798. */
  27799. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27800. /**
  27801. * Populates the passed array "ref" with the particles having the passed shapeId.
  27802. * @param shapeId the shape identifier
  27803. * @returns the SPS
  27804. * @param ref
  27805. */
  27806. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27807. /**
  27808. * Computes the required SubMeshes according the materials assigned to the particles.
  27809. * @returns the solid particle system.
  27810. * Does nothing if called before the SPS mesh is built.
  27811. */
  27812. computeSubMeshes(): SolidParticleSystem;
  27813. /**
  27814. * Sorts the solid particles by material when MultiMaterial is enabled.
  27815. * Updates the indices32 array.
  27816. * Updates the indicesByMaterial array.
  27817. * Updates the mesh indices array.
  27818. * @returns the SPS
  27819. * @hidden
  27820. */
  27821. private _sortParticlesByMaterial;
  27822. /**
  27823. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27824. * @hidden
  27825. */
  27826. private _setMaterialIndexesById;
  27827. /**
  27828. * Returns an array with unique values of Materials from the passed array
  27829. * @param array the material array to be checked and filtered
  27830. * @hidden
  27831. */
  27832. private _filterUniqueMaterialId;
  27833. /**
  27834. * Sets a new Standard Material as _defaultMaterial if not already set.
  27835. * @hidden
  27836. */
  27837. private _setDefaultMaterial;
  27838. /**
  27839. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27840. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27841. * @returns the SPS.
  27842. */
  27843. refreshVisibleSize(): SolidParticleSystem;
  27844. /**
  27845. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27846. * @param size the size (float) of the visibility box
  27847. * note : this doesn't lock the SPS mesh bounding box.
  27848. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27849. */
  27850. setVisibilityBox(size: number): void;
  27851. /**
  27852. * Gets whether the SPS as always visible or not
  27853. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27854. */
  27855. get isAlwaysVisible(): boolean;
  27856. /**
  27857. * Sets the SPS as always visible or not
  27858. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27859. */
  27860. set isAlwaysVisible(val: boolean);
  27861. /**
  27862. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27863. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27864. */
  27865. set isVisibilityBoxLocked(val: boolean);
  27866. /**
  27867. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27868. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27869. */
  27870. get isVisibilityBoxLocked(): boolean;
  27871. /**
  27872. * Tells to `setParticles()` to compute the particle rotations or not.
  27873. * Default value : true. The SPS is faster when it's set to false.
  27874. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27875. */
  27876. set computeParticleRotation(val: boolean);
  27877. /**
  27878. * Tells to `setParticles()` to compute the particle colors or not.
  27879. * Default value : true. The SPS is faster when it's set to false.
  27880. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27881. */
  27882. set computeParticleColor(val: boolean);
  27883. set computeParticleTexture(val: boolean);
  27884. /**
  27885. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27886. * Default value : false. The SPS is faster when it's set to false.
  27887. * Note : the particle custom vertex positions aren't stored values.
  27888. */
  27889. set computeParticleVertex(val: boolean);
  27890. /**
  27891. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27892. */
  27893. set computeBoundingBox(val: boolean);
  27894. /**
  27895. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27896. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27897. * Default : `true`
  27898. */
  27899. set depthSortParticles(val: boolean);
  27900. /**
  27901. * Gets if `setParticles()` computes the particle rotations or not.
  27902. * Default value : true. The SPS is faster when it's set to false.
  27903. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27904. */
  27905. get computeParticleRotation(): boolean;
  27906. /**
  27907. * Gets if `setParticles()` computes the particle colors or not.
  27908. * Default value : true. The SPS is faster when it's set to false.
  27909. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27910. */
  27911. get computeParticleColor(): boolean;
  27912. /**
  27913. * Gets if `setParticles()` computes the particle textures or not.
  27914. * Default value : true. The SPS is faster when it's set to false.
  27915. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27916. */
  27917. get computeParticleTexture(): boolean;
  27918. /**
  27919. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27920. * Default value : false. The SPS is faster when it's set to false.
  27921. * Note : the particle custom vertex positions aren't stored values.
  27922. */
  27923. get computeParticleVertex(): boolean;
  27924. /**
  27925. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27926. */
  27927. get computeBoundingBox(): boolean;
  27928. /**
  27929. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27930. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27931. * Default : `true`
  27932. */
  27933. get depthSortParticles(): boolean;
  27934. /**
  27935. * Gets if the SPS is created as expandable at construction time.
  27936. * Default : `false`
  27937. */
  27938. get expandable(): boolean;
  27939. /**
  27940. * Gets if the SPS supports the Multi Materials
  27941. */
  27942. get multimaterialEnabled(): boolean;
  27943. /**
  27944. * Gets if the SPS uses the model materials for its own multimaterial.
  27945. */
  27946. get useModelMaterial(): boolean;
  27947. /**
  27948. * The SPS used material array.
  27949. */
  27950. get materials(): Material[];
  27951. /**
  27952. * Sets the SPS MultiMaterial from the passed materials.
  27953. * Note : the passed array is internally copied and not used then by reference.
  27954. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27955. */
  27956. setMultiMaterial(materials: Material[]): void;
  27957. /**
  27958. * The SPS computed multimaterial object
  27959. */
  27960. get multimaterial(): MultiMaterial;
  27961. set multimaterial(mm: MultiMaterial);
  27962. /**
  27963. * If the subMeshes must be updated on the next call to setParticles()
  27964. */
  27965. get autoUpdateSubMeshes(): boolean;
  27966. set autoUpdateSubMeshes(val: boolean);
  27967. /**
  27968. * This function does nothing. It may be overwritten to set all the particle first values.
  27969. * The SPS doesn't call this function, you may have to call it by your own.
  27970. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27971. */
  27972. initParticles(): void;
  27973. /**
  27974. * This function does nothing. It may be overwritten to recycle a particle.
  27975. * The SPS doesn't call this function, you may have to call it by your own.
  27976. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27977. * @param particle The particle to recycle
  27978. * @returns the recycled particle
  27979. */
  27980. recycleParticle(particle: SolidParticle): SolidParticle;
  27981. /**
  27982. * Updates a particle : this function should be overwritten by the user.
  27983. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27984. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27985. * @example : just set a particle position or velocity and recycle conditions
  27986. * @param particle The particle to update
  27987. * @returns the updated particle
  27988. */
  27989. updateParticle(particle: SolidParticle): SolidParticle;
  27990. /**
  27991. * Updates a vertex of a particle : it can be overwritten by the user.
  27992. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27993. * @param particle the current particle
  27994. * @param vertex the current index of the current particle
  27995. * @param pt the index of the current vertex in the particle shape
  27996. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27997. * @example : just set a vertex particle position
  27998. * @returns the updated vertex
  27999. */
  28000. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28001. /**
  28002. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28003. * This does nothing and may be overwritten by the user.
  28004. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28005. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28006. * @param update the boolean update value actually passed to setParticles()
  28007. */
  28008. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28009. /**
  28010. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28011. * This will be passed three parameters.
  28012. * This does nothing and may be overwritten by the user.
  28013. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28014. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28015. * @param update the boolean update value actually passed to setParticles()
  28016. */
  28017. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28018. }
  28019. }
  28020. declare module "babylonjs/Particles/solidParticle" {
  28021. import { Nullable } from "babylonjs/types";
  28022. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28023. import { Color4 } from "babylonjs/Maths/math.color";
  28024. import { Mesh } from "babylonjs/Meshes/mesh";
  28025. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28026. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28027. import { Plane } from "babylonjs/Maths/math.plane";
  28028. import { Material } from "babylonjs/Materials/material";
  28029. /**
  28030. * Represents one particle of a solid particle system.
  28031. */
  28032. export class SolidParticle {
  28033. /**
  28034. * particle global index
  28035. */
  28036. idx: number;
  28037. /**
  28038. * particle identifier
  28039. */
  28040. id: number;
  28041. /**
  28042. * The color of the particle
  28043. */
  28044. color: Nullable<Color4>;
  28045. /**
  28046. * The world space position of the particle.
  28047. */
  28048. position: Vector3;
  28049. /**
  28050. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28051. */
  28052. rotation: Vector3;
  28053. /**
  28054. * The world space rotation quaternion of the particle.
  28055. */
  28056. rotationQuaternion: Nullable<Quaternion>;
  28057. /**
  28058. * The scaling of the particle.
  28059. */
  28060. scaling: Vector3;
  28061. /**
  28062. * The uvs of the particle.
  28063. */
  28064. uvs: Vector4;
  28065. /**
  28066. * The current speed of the particle.
  28067. */
  28068. velocity: Vector3;
  28069. /**
  28070. * The pivot point in the particle local space.
  28071. */
  28072. pivot: Vector3;
  28073. /**
  28074. * Must the particle be translated from its pivot point in its local space ?
  28075. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28076. * Default : false
  28077. */
  28078. translateFromPivot: boolean;
  28079. /**
  28080. * Is the particle active or not ?
  28081. */
  28082. alive: boolean;
  28083. /**
  28084. * Is the particle visible or not ?
  28085. */
  28086. isVisible: boolean;
  28087. /**
  28088. * Index of this particle in the global "positions" array (Internal use)
  28089. * @hidden
  28090. */
  28091. _pos: number;
  28092. /**
  28093. * @hidden Index of this particle in the global "indices" array (Internal use)
  28094. */
  28095. _ind: number;
  28096. /**
  28097. * @hidden ModelShape of this particle (Internal use)
  28098. */
  28099. _model: ModelShape;
  28100. /**
  28101. * ModelShape id of this particle
  28102. */
  28103. shapeId: number;
  28104. /**
  28105. * Index of the particle in its shape id
  28106. */
  28107. idxInShape: number;
  28108. /**
  28109. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28110. */
  28111. _modelBoundingInfo: BoundingInfo;
  28112. /**
  28113. * @hidden Particle BoundingInfo object (Internal use)
  28114. */
  28115. _boundingInfo: BoundingInfo;
  28116. /**
  28117. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28118. */
  28119. _sps: SolidParticleSystem;
  28120. /**
  28121. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28122. */
  28123. _stillInvisible: boolean;
  28124. /**
  28125. * @hidden Last computed particle rotation matrix
  28126. */
  28127. _rotationMatrix: number[];
  28128. /**
  28129. * Parent particle Id, if any.
  28130. * Default null.
  28131. */
  28132. parentId: Nullable<number>;
  28133. /**
  28134. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28135. */
  28136. materialIndex: Nullable<number>;
  28137. /**
  28138. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28139. * The possible values are :
  28140. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28141. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28142. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28143. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28144. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28145. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28146. * */
  28147. cullingStrategy: number;
  28148. /**
  28149. * @hidden Internal global position in the SPS.
  28150. */
  28151. _globalPosition: Vector3;
  28152. /**
  28153. * Creates a Solid Particle object.
  28154. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28155. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28156. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28157. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28158. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28159. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28160. * @param shapeId (integer) is the model shape identifier in the SPS.
  28161. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28162. * @param sps defines the sps it is associated to
  28163. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28164. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28165. */
  28166. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28167. /**
  28168. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28169. * @param target the particle target
  28170. * @returns the current particle
  28171. */
  28172. copyToRef(target: SolidParticle): SolidParticle;
  28173. /**
  28174. * Legacy support, changed scale to scaling
  28175. */
  28176. get scale(): Vector3;
  28177. /**
  28178. * Legacy support, changed scale to scaling
  28179. */
  28180. set scale(scale: Vector3);
  28181. /**
  28182. * Legacy support, changed quaternion to rotationQuaternion
  28183. */
  28184. get quaternion(): Nullable<Quaternion>;
  28185. /**
  28186. * Legacy support, changed quaternion to rotationQuaternion
  28187. */
  28188. set quaternion(q: Nullable<Quaternion>);
  28189. /**
  28190. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28191. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28192. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28193. * @returns true if it intersects
  28194. */
  28195. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28196. /**
  28197. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28198. * A particle is in the frustum if its bounding box intersects the frustum
  28199. * @param frustumPlanes defines the frustum to test
  28200. * @returns true if the particle is in the frustum planes
  28201. */
  28202. isInFrustum(frustumPlanes: Plane[]): boolean;
  28203. /**
  28204. * get the rotation matrix of the particle
  28205. * @hidden
  28206. */
  28207. getRotationMatrix(m: Matrix): void;
  28208. }
  28209. /**
  28210. * Represents the shape of the model used by one particle of a solid particle system.
  28211. * SPS internal tool, don't use it manually.
  28212. */
  28213. export class ModelShape {
  28214. /**
  28215. * The shape id
  28216. * @hidden
  28217. */
  28218. shapeID: number;
  28219. /**
  28220. * flat array of model positions (internal use)
  28221. * @hidden
  28222. */
  28223. _shape: Vector3[];
  28224. /**
  28225. * flat array of model UVs (internal use)
  28226. * @hidden
  28227. */
  28228. _shapeUV: number[];
  28229. /**
  28230. * color array of the model
  28231. * @hidden
  28232. */
  28233. _shapeColors: number[];
  28234. /**
  28235. * indices array of the model
  28236. * @hidden
  28237. */
  28238. _indices: number[];
  28239. /**
  28240. * normals array of the model
  28241. * @hidden
  28242. */
  28243. _normals: number[];
  28244. /**
  28245. * length of the shape in the model indices array (internal use)
  28246. * @hidden
  28247. */
  28248. _indicesLength: number;
  28249. /**
  28250. * Custom position function (internal use)
  28251. * @hidden
  28252. */
  28253. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28254. /**
  28255. * Custom vertex function (internal use)
  28256. * @hidden
  28257. */
  28258. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28259. /**
  28260. * Model material (internal use)
  28261. * @hidden
  28262. */
  28263. _material: Nullable<Material>;
  28264. /**
  28265. * 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.
  28266. * SPS internal tool, don't use it manually.
  28267. * @hidden
  28268. */
  28269. 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>);
  28270. }
  28271. /**
  28272. * Represents a Depth Sorted Particle in the solid particle system.
  28273. * @hidden
  28274. */
  28275. export class DepthSortedParticle {
  28276. /**
  28277. * Index of the particle in the "indices" array
  28278. */
  28279. ind: number;
  28280. /**
  28281. * Length of the particle shape in the "indices" array
  28282. */
  28283. indicesLength: number;
  28284. /**
  28285. * Squared distance from the particle to the camera
  28286. */
  28287. sqDistance: number;
  28288. /**
  28289. * Material index when used with MultiMaterials
  28290. */
  28291. materialIndex: number;
  28292. /**
  28293. * Creates a new sorted particle
  28294. * @param materialIndex
  28295. */
  28296. constructor(ind: number, indLength: number, materialIndex: number);
  28297. }
  28298. }
  28299. declare module "babylonjs/Collisions/meshCollisionData" {
  28300. import { Collider } from "babylonjs/Collisions/collider";
  28301. import { Vector3 } from "babylonjs/Maths/math.vector";
  28302. import { Nullable } from "babylonjs/types";
  28303. import { Observer } from "babylonjs/Misc/observable";
  28304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28305. /**
  28306. * @hidden
  28307. */
  28308. export class _MeshCollisionData {
  28309. _checkCollisions: boolean;
  28310. _collisionMask: number;
  28311. _collisionGroup: number;
  28312. _collider: Nullable<Collider>;
  28313. _oldPositionForCollisions: Vector3;
  28314. _diffPositionForCollisions: Vector3;
  28315. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28316. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28317. }
  28318. }
  28319. declare module "babylonjs/Meshes/abstractMesh" {
  28320. import { Observable } from "babylonjs/Misc/observable";
  28321. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28322. import { Camera } from "babylonjs/Cameras/camera";
  28323. import { Scene, IDisposable } from "babylonjs/scene";
  28324. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28325. import { Node } from "babylonjs/node";
  28326. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28327. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28329. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28330. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28331. import { Material } from "babylonjs/Materials/material";
  28332. import { Light } from "babylonjs/Lights/light";
  28333. import { Skeleton } from "babylonjs/Bones/skeleton";
  28334. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28335. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28336. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28337. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28338. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28339. import { Plane } from "babylonjs/Maths/math.plane";
  28340. import { Ray } from "babylonjs/Culling/ray";
  28341. import { Collider } from "babylonjs/Collisions/collider";
  28342. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28343. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28344. /** @hidden */
  28345. class _FacetDataStorage {
  28346. facetPositions: Vector3[];
  28347. facetNormals: Vector3[];
  28348. facetPartitioning: number[][];
  28349. facetNb: number;
  28350. partitioningSubdivisions: number;
  28351. partitioningBBoxRatio: number;
  28352. facetDataEnabled: boolean;
  28353. facetParameters: any;
  28354. bbSize: Vector3;
  28355. subDiv: {
  28356. max: number;
  28357. X: number;
  28358. Y: number;
  28359. Z: number;
  28360. };
  28361. facetDepthSort: boolean;
  28362. facetDepthSortEnabled: boolean;
  28363. depthSortedIndices: IndicesArray;
  28364. depthSortedFacets: {
  28365. ind: number;
  28366. sqDistance: number;
  28367. }[];
  28368. facetDepthSortFunction: (f1: {
  28369. ind: number;
  28370. sqDistance: number;
  28371. }, f2: {
  28372. ind: number;
  28373. sqDistance: number;
  28374. }) => number;
  28375. facetDepthSortFrom: Vector3;
  28376. facetDepthSortOrigin: Vector3;
  28377. invertedMatrix: Matrix;
  28378. }
  28379. /**
  28380. * @hidden
  28381. **/
  28382. class _InternalAbstractMeshDataInfo {
  28383. _hasVertexAlpha: boolean;
  28384. _useVertexColors: boolean;
  28385. _numBoneInfluencers: number;
  28386. _applyFog: boolean;
  28387. _receiveShadows: boolean;
  28388. _facetData: _FacetDataStorage;
  28389. _visibility: number;
  28390. _skeleton: Nullable<Skeleton>;
  28391. _layerMask: number;
  28392. _computeBonesUsingShaders: boolean;
  28393. _isActive: boolean;
  28394. _onlyForInstances: boolean;
  28395. _isActiveIntermediate: boolean;
  28396. _onlyForInstancesIntermediate: boolean;
  28397. _actAsRegularMesh: boolean;
  28398. }
  28399. /**
  28400. * Class used to store all common mesh properties
  28401. */
  28402. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28403. /** No occlusion */
  28404. static OCCLUSION_TYPE_NONE: number;
  28405. /** Occlusion set to optimisitic */
  28406. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28407. /** Occlusion set to strict */
  28408. static OCCLUSION_TYPE_STRICT: number;
  28409. /** Use an accurante occlusion algorithm */
  28410. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28411. /** Use a conservative occlusion algorithm */
  28412. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28413. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28414. * Test order :
  28415. * Is the bounding sphere outside the frustum ?
  28416. * If not, are the bounding box vertices outside the frustum ?
  28417. * It not, then the cullable object is in the frustum.
  28418. */
  28419. static readonly CULLINGSTRATEGY_STANDARD: number;
  28420. /** Culling strategy : Bounding Sphere Only.
  28421. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28422. * It's also less accurate than the standard because some not visible objects can still be selected.
  28423. * Test : is the bounding sphere outside the frustum ?
  28424. * If not, then the cullable object is in the frustum.
  28425. */
  28426. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28427. /** Culling strategy : Optimistic Inclusion.
  28428. * This in an inclusion test first, then the standard exclusion test.
  28429. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28430. * 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.
  28431. * Anyway, it's as accurate as the standard strategy.
  28432. * Test :
  28433. * Is the cullable object bounding sphere center in the frustum ?
  28434. * If not, apply the default culling strategy.
  28435. */
  28436. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28437. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28438. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28439. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28440. * 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.
  28441. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28442. * Test :
  28443. * Is the cullable object bounding sphere center in the frustum ?
  28444. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28445. */
  28446. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28447. /**
  28448. * No billboard
  28449. */
  28450. static get BILLBOARDMODE_NONE(): number;
  28451. /** Billboard on X axis */
  28452. static get BILLBOARDMODE_X(): number;
  28453. /** Billboard on Y axis */
  28454. static get BILLBOARDMODE_Y(): number;
  28455. /** Billboard on Z axis */
  28456. static get BILLBOARDMODE_Z(): number;
  28457. /** Billboard on all axes */
  28458. static get BILLBOARDMODE_ALL(): number;
  28459. /** Billboard on using position instead of orientation */
  28460. static get BILLBOARDMODE_USE_POSITION(): number;
  28461. /** @hidden */
  28462. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28463. /**
  28464. * The culling strategy to use to check whether the mesh must be rendered or not.
  28465. * This value can be changed at any time and will be used on the next render mesh selection.
  28466. * The possible values are :
  28467. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28468. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28469. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28470. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28471. * Please read each static variable documentation to get details about the culling process.
  28472. * */
  28473. cullingStrategy: number;
  28474. /**
  28475. * Gets the number of facets in the mesh
  28476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28477. */
  28478. get facetNb(): number;
  28479. /**
  28480. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28482. */
  28483. get partitioningSubdivisions(): number;
  28484. set partitioningSubdivisions(nb: number);
  28485. /**
  28486. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28487. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28489. */
  28490. get partitioningBBoxRatio(): number;
  28491. set partitioningBBoxRatio(ratio: number);
  28492. /**
  28493. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28494. * Works only for updatable meshes.
  28495. * Doesn't work with multi-materials
  28496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28497. */
  28498. get mustDepthSortFacets(): boolean;
  28499. set mustDepthSortFacets(sort: boolean);
  28500. /**
  28501. * The location (Vector3) where the facet depth sort must be computed from.
  28502. * By default, the active camera position.
  28503. * Used only when facet depth sort is enabled
  28504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28505. */
  28506. get facetDepthSortFrom(): Vector3;
  28507. set facetDepthSortFrom(location: Vector3);
  28508. /**
  28509. * gets a boolean indicating if facetData is enabled
  28510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28511. */
  28512. get isFacetDataEnabled(): boolean;
  28513. /** @hidden */
  28514. _updateNonUniformScalingState(value: boolean): boolean;
  28515. /**
  28516. * An event triggered when this mesh collides with another one
  28517. */
  28518. onCollideObservable: Observable<AbstractMesh>;
  28519. /** Set a function to call when this mesh collides with another one */
  28520. set onCollide(callback: () => void);
  28521. /**
  28522. * An event triggered when the collision's position changes
  28523. */
  28524. onCollisionPositionChangeObservable: Observable<Vector3>;
  28525. /** Set a function to call when the collision's position changes */
  28526. set onCollisionPositionChange(callback: () => void);
  28527. /**
  28528. * An event triggered when material is changed
  28529. */
  28530. onMaterialChangedObservable: Observable<AbstractMesh>;
  28531. /**
  28532. * Gets or sets the orientation for POV movement & rotation
  28533. */
  28534. definedFacingForward: boolean;
  28535. /** @hidden */
  28536. _occlusionQuery: Nullable<WebGLQuery>;
  28537. /** @hidden */
  28538. _renderingGroup: Nullable<RenderingGroup>;
  28539. /**
  28540. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28541. */
  28542. get visibility(): number;
  28543. /**
  28544. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28545. */
  28546. set visibility(value: number);
  28547. /** Gets or sets the alpha index used to sort transparent meshes
  28548. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28549. */
  28550. alphaIndex: number;
  28551. /**
  28552. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28553. */
  28554. isVisible: boolean;
  28555. /**
  28556. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28557. */
  28558. isPickable: boolean;
  28559. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28560. showSubMeshesBoundingBox: boolean;
  28561. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28562. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28563. */
  28564. isBlocker: boolean;
  28565. /**
  28566. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28567. */
  28568. enablePointerMoveEvents: boolean;
  28569. /**
  28570. * Specifies the rendering group id for this mesh (0 by default)
  28571. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28572. */
  28573. renderingGroupId: number;
  28574. private _material;
  28575. /** Gets or sets current material */
  28576. get material(): Nullable<Material>;
  28577. set material(value: Nullable<Material>);
  28578. /**
  28579. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28580. * @see http://doc.babylonjs.com/babylon101/shadows
  28581. */
  28582. get receiveShadows(): boolean;
  28583. set receiveShadows(value: boolean);
  28584. /** Defines color to use when rendering outline */
  28585. outlineColor: Color3;
  28586. /** Define width to use when rendering outline */
  28587. outlineWidth: number;
  28588. /** Defines color to use when rendering overlay */
  28589. overlayColor: Color3;
  28590. /** Defines alpha to use when rendering overlay */
  28591. overlayAlpha: number;
  28592. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28593. get hasVertexAlpha(): boolean;
  28594. set hasVertexAlpha(value: boolean);
  28595. /** 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) */
  28596. get useVertexColors(): boolean;
  28597. set useVertexColors(value: boolean);
  28598. /**
  28599. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28600. */
  28601. get computeBonesUsingShaders(): boolean;
  28602. set computeBonesUsingShaders(value: boolean);
  28603. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28604. get numBoneInfluencers(): number;
  28605. set numBoneInfluencers(value: number);
  28606. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28607. get applyFog(): boolean;
  28608. set applyFog(value: boolean);
  28609. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28610. useOctreeForRenderingSelection: boolean;
  28611. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28612. useOctreeForPicking: boolean;
  28613. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28614. useOctreeForCollisions: boolean;
  28615. /**
  28616. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28617. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28618. */
  28619. get layerMask(): number;
  28620. set layerMask(value: number);
  28621. /**
  28622. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28623. */
  28624. alwaysSelectAsActiveMesh: boolean;
  28625. /**
  28626. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28627. */
  28628. doNotSyncBoundingInfo: boolean;
  28629. /**
  28630. * Gets or sets the current action manager
  28631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28632. */
  28633. actionManager: Nullable<AbstractActionManager>;
  28634. private _meshCollisionData;
  28635. /**
  28636. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28638. */
  28639. ellipsoid: Vector3;
  28640. /**
  28641. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28642. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28643. */
  28644. ellipsoidOffset: Vector3;
  28645. /**
  28646. * Gets or sets a collision mask used to mask collisions (default is -1).
  28647. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28648. */
  28649. get collisionMask(): number;
  28650. set collisionMask(mask: number);
  28651. /**
  28652. * Gets or sets the current collision group mask (-1 by default).
  28653. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28654. */
  28655. get collisionGroup(): number;
  28656. set collisionGroup(mask: number);
  28657. /**
  28658. * Defines edge width used when edgesRenderer is enabled
  28659. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28660. */
  28661. edgesWidth: number;
  28662. /**
  28663. * Defines edge color used when edgesRenderer is enabled
  28664. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28665. */
  28666. edgesColor: Color4;
  28667. /** @hidden */
  28668. _edgesRenderer: Nullable<IEdgesRenderer>;
  28669. /** @hidden */
  28670. _masterMesh: Nullable<AbstractMesh>;
  28671. /** @hidden */
  28672. _boundingInfo: Nullable<BoundingInfo>;
  28673. /** @hidden */
  28674. _renderId: number;
  28675. /**
  28676. * Gets or sets the list of subMeshes
  28677. * @see http://doc.babylonjs.com/how_to/multi_materials
  28678. */
  28679. subMeshes: SubMesh[];
  28680. /** @hidden */
  28681. _intersectionsInProgress: AbstractMesh[];
  28682. /** @hidden */
  28683. _unIndexed: boolean;
  28684. /** @hidden */
  28685. _lightSources: Light[];
  28686. /** Gets the list of lights affecting that mesh */
  28687. get lightSources(): Light[];
  28688. /** @hidden */
  28689. get _positions(): Nullable<Vector3[]>;
  28690. /** @hidden */
  28691. _waitingData: {
  28692. lods: Nullable<any>;
  28693. actions: Nullable<any>;
  28694. freezeWorldMatrix: Nullable<boolean>;
  28695. };
  28696. /** @hidden */
  28697. _bonesTransformMatrices: Nullable<Float32Array>;
  28698. /** @hidden */
  28699. _transformMatrixTexture: Nullable<RawTexture>;
  28700. /**
  28701. * Gets or sets a skeleton to apply skining transformations
  28702. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28703. */
  28704. set skeleton(value: Nullable<Skeleton>);
  28705. get skeleton(): Nullable<Skeleton>;
  28706. /**
  28707. * An event triggered when the mesh is rebuilt.
  28708. */
  28709. onRebuildObservable: Observable<AbstractMesh>;
  28710. /**
  28711. * Creates a new AbstractMesh
  28712. * @param name defines the name of the mesh
  28713. * @param scene defines the hosting scene
  28714. */
  28715. constructor(name: string, scene?: Nullable<Scene>);
  28716. /**
  28717. * Returns the string "AbstractMesh"
  28718. * @returns "AbstractMesh"
  28719. */
  28720. getClassName(): string;
  28721. /**
  28722. * Gets a string representation of the current mesh
  28723. * @param fullDetails defines a boolean indicating if full details must be included
  28724. * @returns a string representation of the current mesh
  28725. */
  28726. toString(fullDetails?: boolean): string;
  28727. /**
  28728. * @hidden
  28729. */
  28730. protected _getEffectiveParent(): Nullable<Node>;
  28731. /** @hidden */
  28732. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28733. /** @hidden */
  28734. _rebuild(): void;
  28735. /** @hidden */
  28736. _resyncLightSources(): void;
  28737. /** @hidden */
  28738. _resyncLightSource(light: Light): void;
  28739. /** @hidden */
  28740. _unBindEffect(): void;
  28741. /** @hidden */
  28742. _removeLightSource(light: Light, dispose: boolean): void;
  28743. private _markSubMeshesAsDirty;
  28744. /** @hidden */
  28745. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28746. /** @hidden */
  28747. _markSubMeshesAsAttributesDirty(): void;
  28748. /** @hidden */
  28749. _markSubMeshesAsMiscDirty(): void;
  28750. /**
  28751. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28752. */
  28753. get scaling(): Vector3;
  28754. set scaling(newScaling: Vector3);
  28755. /**
  28756. * Returns true if the mesh is blocked. Implemented by child classes
  28757. */
  28758. get isBlocked(): boolean;
  28759. /**
  28760. * Returns the mesh itself by default. Implemented by child classes
  28761. * @param camera defines the camera to use to pick the right LOD level
  28762. * @returns the currentAbstractMesh
  28763. */
  28764. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28765. /**
  28766. * Returns 0 by default. Implemented by child classes
  28767. * @returns an integer
  28768. */
  28769. getTotalVertices(): number;
  28770. /**
  28771. * Returns a positive integer : the total number of indices in this mesh geometry.
  28772. * @returns the numner of indices or zero if the mesh has no geometry.
  28773. */
  28774. getTotalIndices(): number;
  28775. /**
  28776. * Returns null by default. Implemented by child classes
  28777. * @returns null
  28778. */
  28779. getIndices(): Nullable<IndicesArray>;
  28780. /**
  28781. * Returns the array of the requested vertex data kind. Implemented by child classes
  28782. * @param kind defines the vertex data kind to use
  28783. * @returns null
  28784. */
  28785. getVerticesData(kind: string): Nullable<FloatArray>;
  28786. /**
  28787. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28788. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28789. * Note that a new underlying VertexBuffer object is created each call.
  28790. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28791. * @param kind defines vertex data kind:
  28792. * * VertexBuffer.PositionKind
  28793. * * VertexBuffer.UVKind
  28794. * * VertexBuffer.UV2Kind
  28795. * * VertexBuffer.UV3Kind
  28796. * * VertexBuffer.UV4Kind
  28797. * * VertexBuffer.UV5Kind
  28798. * * VertexBuffer.UV6Kind
  28799. * * VertexBuffer.ColorKind
  28800. * * VertexBuffer.MatricesIndicesKind
  28801. * * VertexBuffer.MatricesIndicesExtraKind
  28802. * * VertexBuffer.MatricesWeightsKind
  28803. * * VertexBuffer.MatricesWeightsExtraKind
  28804. * @param data defines the data source
  28805. * @param updatable defines if the data must be flagged as updatable (or static)
  28806. * @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
  28807. * @returns the current mesh
  28808. */
  28809. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28810. /**
  28811. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28812. * If the mesh has no geometry, it is simply returned as it is.
  28813. * @param kind defines vertex data kind:
  28814. * * VertexBuffer.PositionKind
  28815. * * VertexBuffer.UVKind
  28816. * * VertexBuffer.UV2Kind
  28817. * * VertexBuffer.UV3Kind
  28818. * * VertexBuffer.UV4Kind
  28819. * * VertexBuffer.UV5Kind
  28820. * * VertexBuffer.UV6Kind
  28821. * * VertexBuffer.ColorKind
  28822. * * VertexBuffer.MatricesIndicesKind
  28823. * * VertexBuffer.MatricesIndicesExtraKind
  28824. * * VertexBuffer.MatricesWeightsKind
  28825. * * VertexBuffer.MatricesWeightsExtraKind
  28826. * @param data defines the data source
  28827. * @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
  28828. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28829. * @returns the current mesh
  28830. */
  28831. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28832. /**
  28833. * Sets the mesh indices,
  28834. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28835. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28836. * @param totalVertices Defines the total number of vertices
  28837. * @returns the current mesh
  28838. */
  28839. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28840. /**
  28841. * Gets a boolean indicating if specific vertex data is present
  28842. * @param kind defines the vertex data kind to use
  28843. * @returns true is data kind is present
  28844. */
  28845. isVerticesDataPresent(kind: string): boolean;
  28846. /**
  28847. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28848. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28849. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28850. * @returns a BoundingInfo
  28851. */
  28852. getBoundingInfo(): BoundingInfo;
  28853. /**
  28854. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28855. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28856. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28857. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28858. * @returns the current mesh
  28859. */
  28860. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28861. /**
  28862. * Overwrite the current bounding info
  28863. * @param boundingInfo defines the new bounding info
  28864. * @returns the current mesh
  28865. */
  28866. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28867. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28868. get useBones(): boolean;
  28869. /** @hidden */
  28870. _preActivate(): void;
  28871. /** @hidden */
  28872. _preActivateForIntermediateRendering(renderId: number): void;
  28873. /** @hidden */
  28874. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28875. /** @hidden */
  28876. _postActivate(): void;
  28877. /** @hidden */
  28878. _freeze(): void;
  28879. /** @hidden */
  28880. _unFreeze(): void;
  28881. /**
  28882. * Gets the current world matrix
  28883. * @returns a Matrix
  28884. */
  28885. getWorldMatrix(): Matrix;
  28886. /** @hidden */
  28887. _getWorldMatrixDeterminant(): number;
  28888. /**
  28889. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28890. */
  28891. get isAnInstance(): boolean;
  28892. /**
  28893. * Gets a boolean indicating if this mesh has instances
  28894. */
  28895. get hasInstances(): boolean;
  28896. /**
  28897. * Perform relative position change from the point of view of behind the front of the mesh.
  28898. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28899. * Supports definition of mesh facing forward or backward
  28900. * @param amountRight defines the distance on the right axis
  28901. * @param amountUp defines the distance on the up axis
  28902. * @param amountForward defines the distance on the forward axis
  28903. * @returns the current mesh
  28904. */
  28905. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28906. /**
  28907. * Calculate relative position change from the point of view of behind the front of the mesh.
  28908. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28909. * Supports definition of mesh facing forward or backward
  28910. * @param amountRight defines the distance on the right axis
  28911. * @param amountUp defines the distance on the up axis
  28912. * @param amountForward defines the distance on the forward axis
  28913. * @returns the new displacement vector
  28914. */
  28915. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28916. /**
  28917. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28918. * Supports definition of mesh facing forward or backward
  28919. * @param flipBack defines the flip
  28920. * @param twirlClockwise defines the twirl
  28921. * @param tiltRight defines the tilt
  28922. * @returns the current mesh
  28923. */
  28924. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28925. /**
  28926. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28927. * Supports definition of mesh facing forward or backward.
  28928. * @param flipBack defines the flip
  28929. * @param twirlClockwise defines the twirl
  28930. * @param tiltRight defines the tilt
  28931. * @returns the new rotation vector
  28932. */
  28933. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28934. /**
  28935. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28936. * This means the mesh underlying bounding box and sphere are recomputed.
  28937. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28938. * @returns the current mesh
  28939. */
  28940. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28941. /** @hidden */
  28942. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28943. /** @hidden */
  28944. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28945. /** @hidden */
  28946. _updateBoundingInfo(): AbstractMesh;
  28947. /** @hidden */
  28948. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28949. /** @hidden */
  28950. protected _afterComputeWorldMatrix(): void;
  28951. /** @hidden */
  28952. get _effectiveMesh(): AbstractMesh;
  28953. /**
  28954. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28955. * A mesh is in the frustum if its bounding box intersects the frustum
  28956. * @param frustumPlanes defines the frustum to test
  28957. * @returns true if the mesh is in the frustum planes
  28958. */
  28959. isInFrustum(frustumPlanes: Plane[]): boolean;
  28960. /**
  28961. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28962. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28963. * @param frustumPlanes defines the frustum to test
  28964. * @returns true if the mesh is completely in the frustum planes
  28965. */
  28966. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28967. /**
  28968. * True if the mesh intersects another mesh or a SolidParticle object
  28969. * @param mesh defines a target mesh or SolidParticle to test
  28970. * @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)
  28971. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28972. * @returns true if there is an intersection
  28973. */
  28974. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28975. /**
  28976. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28977. * @param point defines the point to test
  28978. * @returns true if there is an intersection
  28979. */
  28980. intersectsPoint(point: Vector3): boolean;
  28981. /**
  28982. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28983. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28984. */
  28985. get checkCollisions(): boolean;
  28986. set checkCollisions(collisionEnabled: boolean);
  28987. /**
  28988. * Gets Collider object used to compute collisions (not physics)
  28989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28990. */
  28991. get collider(): Nullable<Collider>;
  28992. /**
  28993. * Move the mesh using collision engine
  28994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28995. * @param displacement defines the requested displacement vector
  28996. * @returns the current mesh
  28997. */
  28998. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28999. private _onCollisionPositionChange;
  29000. /** @hidden */
  29001. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29002. /** @hidden */
  29003. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29004. /** @hidden */
  29005. _checkCollision(collider: Collider): AbstractMesh;
  29006. /** @hidden */
  29007. _generatePointsArray(): boolean;
  29008. /**
  29009. * Checks if the passed Ray intersects with the mesh
  29010. * @param ray defines the ray to use
  29011. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29012. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29013. * @returns the picking info
  29014. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29015. */
  29016. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29017. /**
  29018. * Clones the current mesh
  29019. * @param name defines the mesh name
  29020. * @param newParent defines the new mesh parent
  29021. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29022. * @returns the new mesh
  29023. */
  29024. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29025. /**
  29026. * Disposes all the submeshes of the current meshnp
  29027. * @returns the current mesh
  29028. */
  29029. releaseSubMeshes(): AbstractMesh;
  29030. /**
  29031. * Releases resources associated with this abstract mesh.
  29032. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29033. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29034. */
  29035. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29036. /**
  29037. * Adds the passed mesh as a child to the current mesh
  29038. * @param mesh defines the child mesh
  29039. * @returns the current mesh
  29040. */
  29041. addChild(mesh: AbstractMesh): AbstractMesh;
  29042. /**
  29043. * Removes the passed mesh from the current mesh children list
  29044. * @param mesh defines the child mesh
  29045. * @returns the current mesh
  29046. */
  29047. removeChild(mesh: AbstractMesh): AbstractMesh;
  29048. /** @hidden */
  29049. private _initFacetData;
  29050. /**
  29051. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29052. * This method can be called within the render loop.
  29053. * 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
  29054. * @returns the current mesh
  29055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29056. */
  29057. updateFacetData(): AbstractMesh;
  29058. /**
  29059. * Returns the facetLocalNormals array.
  29060. * The normals are expressed in the mesh local spac
  29061. * @returns an array of Vector3
  29062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29063. */
  29064. getFacetLocalNormals(): Vector3[];
  29065. /**
  29066. * Returns the facetLocalPositions array.
  29067. * The facet positions are expressed in the mesh local space
  29068. * @returns an array of Vector3
  29069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29070. */
  29071. getFacetLocalPositions(): Vector3[];
  29072. /**
  29073. * Returns the facetLocalPartioning array
  29074. * @returns an array of array of numbers
  29075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29076. */
  29077. getFacetLocalPartitioning(): number[][];
  29078. /**
  29079. * Returns the i-th facet position in the world system.
  29080. * This method allocates a new Vector3 per call
  29081. * @param i defines the facet index
  29082. * @returns a new Vector3
  29083. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29084. */
  29085. getFacetPosition(i: number): Vector3;
  29086. /**
  29087. * Sets the reference Vector3 with the i-th facet position in the world system
  29088. * @param i defines the facet index
  29089. * @param ref defines the target vector
  29090. * @returns the current mesh
  29091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29092. */
  29093. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29094. /**
  29095. * Returns the i-th facet normal in the world system.
  29096. * This method allocates a new Vector3 per call
  29097. * @param i defines the facet index
  29098. * @returns a new Vector3
  29099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29100. */
  29101. getFacetNormal(i: number): Vector3;
  29102. /**
  29103. * Sets the reference Vector3 with the i-th facet normal in the world system
  29104. * @param i defines the facet index
  29105. * @param ref defines the target vector
  29106. * @returns the current mesh
  29107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29108. */
  29109. getFacetNormalToRef(i: number, ref: Vector3): this;
  29110. /**
  29111. * 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)
  29112. * @param x defines x coordinate
  29113. * @param y defines y coordinate
  29114. * @param z defines z coordinate
  29115. * @returns the array of facet indexes
  29116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29117. */
  29118. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29119. /**
  29120. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29121. * @param projected sets as the (x,y,z) world projection on the facet
  29122. * @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
  29123. * @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
  29124. * @param x defines x coordinate
  29125. * @param y defines y coordinate
  29126. * @param z defines z coordinate
  29127. * @returns the face index if found (or null instead)
  29128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29129. */
  29130. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29131. /**
  29132. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29133. * @param projected sets as the (x,y,z) local projection on the facet
  29134. * @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
  29135. * @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
  29136. * @param x defines x coordinate
  29137. * @param y defines y coordinate
  29138. * @param z defines z coordinate
  29139. * @returns the face index if found (or null instead)
  29140. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29141. */
  29142. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29143. /**
  29144. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29145. * @returns the parameters
  29146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29147. */
  29148. getFacetDataParameters(): any;
  29149. /**
  29150. * Disables the feature FacetData and frees the related memory
  29151. * @returns the current mesh
  29152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29153. */
  29154. disableFacetData(): AbstractMesh;
  29155. /**
  29156. * Updates the AbstractMesh indices array
  29157. * @param indices defines the data source
  29158. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29159. * @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)
  29160. * @returns the current mesh
  29161. */
  29162. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29163. /**
  29164. * Creates new normals data for the mesh
  29165. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29166. * @returns the current mesh
  29167. */
  29168. createNormals(updatable: boolean): AbstractMesh;
  29169. /**
  29170. * Align the mesh with a normal
  29171. * @param normal defines the normal to use
  29172. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29173. * @returns the current mesh
  29174. */
  29175. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29176. /** @hidden */
  29177. _checkOcclusionQuery(): boolean;
  29178. /**
  29179. * Disables the mesh edge rendering mode
  29180. * @returns the currentAbstractMesh
  29181. */
  29182. disableEdgesRendering(): AbstractMesh;
  29183. /**
  29184. * Enables the edge rendering mode on the mesh.
  29185. * This mode makes the mesh edges visible
  29186. * @param epsilon defines the maximal distance between two angles to detect a face
  29187. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29188. * @returns the currentAbstractMesh
  29189. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29190. */
  29191. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29192. }
  29193. }
  29194. declare module "babylonjs/Actions/actionEvent" {
  29195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29196. import { Nullable } from "babylonjs/types";
  29197. import { Sprite } from "babylonjs/Sprites/sprite";
  29198. import { Scene } from "babylonjs/scene";
  29199. import { Vector2 } from "babylonjs/Maths/math.vector";
  29200. /**
  29201. * Interface used to define ActionEvent
  29202. */
  29203. export interface IActionEvent {
  29204. /** The mesh or sprite that triggered the action */
  29205. source: any;
  29206. /** The X mouse cursor position at the time of the event */
  29207. pointerX: number;
  29208. /** The Y mouse cursor position at the time of the event */
  29209. pointerY: number;
  29210. /** The mesh that is currently pointed at (can be null) */
  29211. meshUnderPointer: Nullable<AbstractMesh>;
  29212. /** the original (browser) event that triggered the ActionEvent */
  29213. sourceEvent?: any;
  29214. /** additional data for the event */
  29215. additionalData?: any;
  29216. }
  29217. /**
  29218. * ActionEvent is the event being sent when an action is triggered.
  29219. */
  29220. export class ActionEvent implements IActionEvent {
  29221. /** The mesh or sprite that triggered the action */
  29222. source: any;
  29223. /** The X mouse cursor position at the time of the event */
  29224. pointerX: number;
  29225. /** The Y mouse cursor position at the time of the event */
  29226. pointerY: number;
  29227. /** The mesh that is currently pointed at (can be null) */
  29228. meshUnderPointer: Nullable<AbstractMesh>;
  29229. /** the original (browser) event that triggered the ActionEvent */
  29230. sourceEvent?: any;
  29231. /** additional data for the event */
  29232. additionalData?: any;
  29233. /**
  29234. * Creates a new ActionEvent
  29235. * @param source The mesh or sprite that triggered the action
  29236. * @param pointerX The X mouse cursor position at the time of the event
  29237. * @param pointerY The Y mouse cursor position at the time of the event
  29238. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29239. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29240. * @param additionalData additional data for the event
  29241. */
  29242. constructor(
  29243. /** The mesh or sprite that triggered the action */
  29244. source: any,
  29245. /** The X mouse cursor position at the time of the event */
  29246. pointerX: number,
  29247. /** The Y mouse cursor position at the time of the event */
  29248. pointerY: number,
  29249. /** The mesh that is currently pointed at (can be null) */
  29250. meshUnderPointer: Nullable<AbstractMesh>,
  29251. /** the original (browser) event that triggered the ActionEvent */
  29252. sourceEvent?: any,
  29253. /** additional data for the event */
  29254. additionalData?: any);
  29255. /**
  29256. * Helper function to auto-create an ActionEvent from a source mesh.
  29257. * @param source The source mesh that triggered the event
  29258. * @param evt The original (browser) event
  29259. * @param additionalData additional data for the event
  29260. * @returns the new ActionEvent
  29261. */
  29262. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29263. /**
  29264. * Helper function to auto-create an ActionEvent from a source sprite
  29265. * @param source The source sprite that triggered the event
  29266. * @param scene Scene associated with the sprite
  29267. * @param evt The original (browser) event
  29268. * @param additionalData additional data for the event
  29269. * @returns the new ActionEvent
  29270. */
  29271. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29272. /**
  29273. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29274. * @param scene the scene where the event occurred
  29275. * @param evt The original (browser) event
  29276. * @returns the new ActionEvent
  29277. */
  29278. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29279. /**
  29280. * Helper function to auto-create an ActionEvent from a primitive
  29281. * @param prim defines the target primitive
  29282. * @param pointerPos defines the pointer position
  29283. * @param evt The original (browser) event
  29284. * @param additionalData additional data for the event
  29285. * @returns the new ActionEvent
  29286. */
  29287. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29288. }
  29289. }
  29290. declare module "babylonjs/Actions/abstractActionManager" {
  29291. import { IDisposable } from "babylonjs/scene";
  29292. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29293. import { IAction } from "babylonjs/Actions/action";
  29294. import { Nullable } from "babylonjs/types";
  29295. /**
  29296. * Abstract class used to decouple action Manager from scene and meshes.
  29297. * Do not instantiate.
  29298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29299. */
  29300. export abstract class AbstractActionManager implements IDisposable {
  29301. /** Gets the list of active triggers */
  29302. static Triggers: {
  29303. [key: string]: number;
  29304. };
  29305. /** Gets the cursor to use when hovering items */
  29306. hoverCursor: string;
  29307. /** Gets the list of actions */
  29308. actions: IAction[];
  29309. /**
  29310. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29311. */
  29312. isRecursive: boolean;
  29313. /**
  29314. * Releases all associated resources
  29315. */
  29316. abstract dispose(): void;
  29317. /**
  29318. * Does this action manager has pointer triggers
  29319. */
  29320. abstract get hasPointerTriggers(): boolean;
  29321. /**
  29322. * Does this action manager has pick triggers
  29323. */
  29324. abstract get hasPickTriggers(): boolean;
  29325. /**
  29326. * Process a specific trigger
  29327. * @param trigger defines the trigger to process
  29328. * @param evt defines the event details to be processed
  29329. */
  29330. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29331. /**
  29332. * Does this action manager handles actions of any of the given triggers
  29333. * @param triggers defines the triggers to be tested
  29334. * @return a boolean indicating whether one (or more) of the triggers is handled
  29335. */
  29336. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29337. /**
  29338. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29339. * speed.
  29340. * @param triggerA defines the trigger to be tested
  29341. * @param triggerB defines the trigger to be tested
  29342. * @return a boolean indicating whether one (or more) of the triggers is handled
  29343. */
  29344. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29345. /**
  29346. * Does this action manager handles actions of a given trigger
  29347. * @param trigger defines the trigger to be tested
  29348. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29349. * @return whether the trigger is handled
  29350. */
  29351. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29352. /**
  29353. * Serialize this manager to a JSON object
  29354. * @param name defines the property name to store this manager
  29355. * @returns a JSON representation of this manager
  29356. */
  29357. abstract serialize(name: string): any;
  29358. /**
  29359. * Registers an action to this action manager
  29360. * @param action defines the action to be registered
  29361. * @return the action amended (prepared) after registration
  29362. */
  29363. abstract registerAction(action: IAction): Nullable<IAction>;
  29364. /**
  29365. * Unregisters an action to this action manager
  29366. * @param action defines the action to be unregistered
  29367. * @return a boolean indicating whether the action has been unregistered
  29368. */
  29369. abstract unregisterAction(action: IAction): Boolean;
  29370. /**
  29371. * Does exist one action manager with at least one trigger
  29372. **/
  29373. static get HasTriggers(): boolean;
  29374. /**
  29375. * Does exist one action manager with at least one pick trigger
  29376. **/
  29377. static get HasPickTriggers(): boolean;
  29378. /**
  29379. * Does exist one action manager that handles actions of a given trigger
  29380. * @param trigger defines the trigger to be tested
  29381. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29382. **/
  29383. static HasSpecificTrigger(trigger: number): boolean;
  29384. }
  29385. }
  29386. declare module "babylonjs/node" {
  29387. import { Scene } from "babylonjs/scene";
  29388. import { Nullable } from "babylonjs/types";
  29389. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29390. import { Engine } from "babylonjs/Engines/engine";
  29391. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29392. import { Observable } from "babylonjs/Misc/observable";
  29393. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29394. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29395. import { Animatable } from "babylonjs/Animations/animatable";
  29396. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29397. import { Animation } from "babylonjs/Animations/animation";
  29398. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29400. /**
  29401. * Defines how a node can be built from a string name.
  29402. */
  29403. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29404. /**
  29405. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29406. */
  29407. export class Node implements IBehaviorAware<Node> {
  29408. /** @hidden */
  29409. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29410. private static _NodeConstructors;
  29411. /**
  29412. * Add a new node constructor
  29413. * @param type defines the type name of the node to construct
  29414. * @param constructorFunc defines the constructor function
  29415. */
  29416. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29417. /**
  29418. * Returns a node constructor based on type name
  29419. * @param type defines the type name
  29420. * @param name defines the new node name
  29421. * @param scene defines the hosting scene
  29422. * @param options defines optional options to transmit to constructors
  29423. * @returns the new constructor or null
  29424. */
  29425. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29426. /**
  29427. * Gets or sets the name of the node
  29428. */
  29429. name: string;
  29430. /**
  29431. * Gets or sets the id of the node
  29432. */
  29433. id: string;
  29434. /**
  29435. * Gets or sets the unique id of the node
  29436. */
  29437. uniqueId: number;
  29438. /**
  29439. * Gets or sets a string used to store user defined state for the node
  29440. */
  29441. state: string;
  29442. /**
  29443. * Gets or sets an object used to store user defined information for the node
  29444. */
  29445. metadata: any;
  29446. /**
  29447. * For internal use only. Please do not use.
  29448. */
  29449. reservedDataStore: any;
  29450. /**
  29451. * List of inspectable custom properties (used by the Inspector)
  29452. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29453. */
  29454. inspectableCustomProperties: IInspectable[];
  29455. private _doNotSerialize;
  29456. /**
  29457. * Gets or sets a boolean used to define if the node must be serialized
  29458. */
  29459. get doNotSerialize(): boolean;
  29460. set doNotSerialize(value: boolean);
  29461. /** @hidden */
  29462. _isDisposed: boolean;
  29463. /**
  29464. * Gets a list of Animations associated with the node
  29465. */
  29466. animations: import("babylonjs/Animations/animation").Animation[];
  29467. protected _ranges: {
  29468. [name: string]: Nullable<AnimationRange>;
  29469. };
  29470. /**
  29471. * Callback raised when the node is ready to be used
  29472. */
  29473. onReady: Nullable<(node: Node) => void>;
  29474. private _isEnabled;
  29475. private _isParentEnabled;
  29476. private _isReady;
  29477. /** @hidden */
  29478. _currentRenderId: number;
  29479. private _parentUpdateId;
  29480. /** @hidden */
  29481. _childUpdateId: number;
  29482. /** @hidden */
  29483. _waitingParentId: Nullable<string>;
  29484. /** @hidden */
  29485. _scene: Scene;
  29486. /** @hidden */
  29487. _cache: any;
  29488. private _parentNode;
  29489. private _children;
  29490. /** @hidden */
  29491. _worldMatrix: Matrix;
  29492. /** @hidden */
  29493. _worldMatrixDeterminant: number;
  29494. /** @hidden */
  29495. _worldMatrixDeterminantIsDirty: boolean;
  29496. /** @hidden */
  29497. private _sceneRootNodesIndex;
  29498. /**
  29499. * Gets a boolean indicating if the node has been disposed
  29500. * @returns true if the node was disposed
  29501. */
  29502. isDisposed(): boolean;
  29503. /**
  29504. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29505. * @see https://doc.babylonjs.com/how_to/parenting
  29506. */
  29507. set parent(parent: Nullable<Node>);
  29508. get parent(): Nullable<Node>;
  29509. /** @hidden */
  29510. _addToSceneRootNodes(): void;
  29511. /** @hidden */
  29512. _removeFromSceneRootNodes(): void;
  29513. private _animationPropertiesOverride;
  29514. /**
  29515. * Gets or sets the animation properties override
  29516. */
  29517. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29518. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29519. /**
  29520. * Gets a string idenfifying the name of the class
  29521. * @returns "Node" string
  29522. */
  29523. getClassName(): string;
  29524. /** @hidden */
  29525. readonly _isNode: boolean;
  29526. /**
  29527. * An event triggered when the mesh is disposed
  29528. */
  29529. onDisposeObservable: Observable<Node>;
  29530. private _onDisposeObserver;
  29531. /**
  29532. * Sets a callback that will be raised when the node will be disposed
  29533. */
  29534. set onDispose(callback: () => void);
  29535. /**
  29536. * Creates a new Node
  29537. * @param name the name and id to be given to this node
  29538. * @param scene the scene this node will be added to
  29539. */
  29540. constructor(name: string, scene?: Nullable<Scene>);
  29541. /**
  29542. * Gets the scene of the node
  29543. * @returns a scene
  29544. */
  29545. getScene(): Scene;
  29546. /**
  29547. * Gets the engine of the node
  29548. * @returns a Engine
  29549. */
  29550. getEngine(): Engine;
  29551. private _behaviors;
  29552. /**
  29553. * Attach a behavior to the node
  29554. * @see http://doc.babylonjs.com/features/behaviour
  29555. * @param behavior defines the behavior to attach
  29556. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29557. * @returns the current Node
  29558. */
  29559. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29560. /**
  29561. * Remove an attached behavior
  29562. * @see http://doc.babylonjs.com/features/behaviour
  29563. * @param behavior defines the behavior to attach
  29564. * @returns the current Node
  29565. */
  29566. removeBehavior(behavior: Behavior<Node>): Node;
  29567. /**
  29568. * Gets the list of attached behaviors
  29569. * @see http://doc.babylonjs.com/features/behaviour
  29570. */
  29571. get behaviors(): Behavior<Node>[];
  29572. /**
  29573. * Gets an attached behavior by name
  29574. * @param name defines the name of the behavior to look for
  29575. * @see http://doc.babylonjs.com/features/behaviour
  29576. * @returns null if behavior was not found else the requested behavior
  29577. */
  29578. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29579. /**
  29580. * Returns the latest update of the World matrix
  29581. * @returns a Matrix
  29582. */
  29583. getWorldMatrix(): Matrix;
  29584. /** @hidden */
  29585. _getWorldMatrixDeterminant(): number;
  29586. /**
  29587. * Returns directly the latest state of the mesh World matrix.
  29588. * A Matrix is returned.
  29589. */
  29590. get worldMatrixFromCache(): Matrix;
  29591. /** @hidden */
  29592. _initCache(): void;
  29593. /** @hidden */
  29594. updateCache(force?: boolean): void;
  29595. /** @hidden */
  29596. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29597. /** @hidden */
  29598. _updateCache(ignoreParentClass?: boolean): void;
  29599. /** @hidden */
  29600. _isSynchronized(): boolean;
  29601. /** @hidden */
  29602. _markSyncedWithParent(): void;
  29603. /** @hidden */
  29604. isSynchronizedWithParent(): boolean;
  29605. /** @hidden */
  29606. isSynchronized(): boolean;
  29607. /**
  29608. * Is this node ready to be used/rendered
  29609. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29610. * @return true if the node is ready
  29611. */
  29612. isReady(completeCheck?: boolean): boolean;
  29613. /**
  29614. * Is this node enabled?
  29615. * 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
  29616. * @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
  29617. * @return whether this node (and its parent) is enabled
  29618. */
  29619. isEnabled(checkAncestors?: boolean): boolean;
  29620. /** @hidden */
  29621. protected _syncParentEnabledState(): void;
  29622. /**
  29623. * Set the enabled state of this node
  29624. * @param value defines the new enabled state
  29625. */
  29626. setEnabled(value: boolean): void;
  29627. /**
  29628. * Is this node a descendant of the given node?
  29629. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29630. * @param ancestor defines the parent node to inspect
  29631. * @returns a boolean indicating if this node is a descendant of the given node
  29632. */
  29633. isDescendantOf(ancestor: Node): boolean;
  29634. /** @hidden */
  29635. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29636. /**
  29637. * Will return all nodes that have this node as ascendant
  29638. * @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
  29639. * @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
  29640. * @return all children nodes of all types
  29641. */
  29642. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29643. /**
  29644. * Get all child-meshes of this node
  29645. * @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)
  29646. * @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
  29647. * @returns an array of AbstractMesh
  29648. */
  29649. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29650. /**
  29651. * Get all direct children of this node
  29652. * @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
  29653. * @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)
  29654. * @returns an array of Node
  29655. */
  29656. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29657. /** @hidden */
  29658. _setReady(state: boolean): void;
  29659. /**
  29660. * Get an animation by name
  29661. * @param name defines the name of the animation to look for
  29662. * @returns null if not found else the requested animation
  29663. */
  29664. getAnimationByName(name: string): Nullable<Animation>;
  29665. /**
  29666. * Creates an animation range for this node
  29667. * @param name defines the name of the range
  29668. * @param from defines the starting key
  29669. * @param to defines the end key
  29670. */
  29671. createAnimationRange(name: string, from: number, to: number): void;
  29672. /**
  29673. * Delete a specific animation range
  29674. * @param name defines the name of the range to delete
  29675. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29676. */
  29677. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29678. /**
  29679. * Get an animation range by name
  29680. * @param name defines the name of the animation range to look for
  29681. * @returns null if not found else the requested animation range
  29682. */
  29683. getAnimationRange(name: string): Nullable<AnimationRange>;
  29684. /**
  29685. * Gets the list of all animation ranges defined on this node
  29686. * @returns an array
  29687. */
  29688. getAnimationRanges(): Nullable<AnimationRange>[];
  29689. /**
  29690. * Will start the animation sequence
  29691. * @param name defines the range frames for animation sequence
  29692. * @param loop defines if the animation should loop (false by default)
  29693. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29694. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29695. * @returns the object created for this animation. If range does not exist, it will return null
  29696. */
  29697. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29698. /**
  29699. * Serialize animation ranges into a JSON compatible object
  29700. * @returns serialization object
  29701. */
  29702. serializeAnimationRanges(): any;
  29703. /**
  29704. * Computes the world matrix of the node
  29705. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29706. * @returns the world matrix
  29707. */
  29708. computeWorldMatrix(force?: boolean): Matrix;
  29709. /**
  29710. * Releases resources associated with this node.
  29711. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29712. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29713. */
  29714. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29715. /**
  29716. * Parse animation range data from a serialization object and store them into a given node
  29717. * @param node defines where to store the animation ranges
  29718. * @param parsedNode defines the serialization object to read data from
  29719. * @param scene defines the hosting scene
  29720. */
  29721. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29722. /**
  29723. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29724. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29725. * @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
  29726. * @returns the new bounding vectors
  29727. */
  29728. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29729. min: Vector3;
  29730. max: Vector3;
  29731. };
  29732. }
  29733. }
  29734. declare module "babylonjs/Animations/animation" {
  29735. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29736. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29737. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29738. import { Nullable } from "babylonjs/types";
  29739. import { Scene } from "babylonjs/scene";
  29740. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29741. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29742. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29743. import { Node } from "babylonjs/node";
  29744. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29745. import { Size } from "babylonjs/Maths/math.size";
  29746. import { Animatable } from "babylonjs/Animations/animatable";
  29747. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29748. /**
  29749. * @hidden
  29750. */
  29751. export class _IAnimationState {
  29752. key: number;
  29753. repeatCount: number;
  29754. workValue?: any;
  29755. loopMode?: number;
  29756. offsetValue?: any;
  29757. highLimitValue?: any;
  29758. }
  29759. /**
  29760. * Class used to store any kind of animation
  29761. */
  29762. export class Animation {
  29763. /**Name of the animation */
  29764. name: string;
  29765. /**Property to animate */
  29766. targetProperty: string;
  29767. /**The frames per second of the animation */
  29768. framePerSecond: number;
  29769. /**The data type of the animation */
  29770. dataType: number;
  29771. /**The loop mode of the animation */
  29772. loopMode?: number | undefined;
  29773. /**Specifies if blending should be enabled */
  29774. enableBlending?: boolean | undefined;
  29775. /**
  29776. * Use matrix interpolation instead of using direct key value when animating matrices
  29777. */
  29778. static AllowMatricesInterpolation: boolean;
  29779. /**
  29780. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29781. */
  29782. static AllowMatrixDecomposeForInterpolation: boolean;
  29783. /**
  29784. * Stores the key frames of the animation
  29785. */
  29786. private _keys;
  29787. /**
  29788. * Stores the easing function of the animation
  29789. */
  29790. private _easingFunction;
  29791. /**
  29792. * @hidden Internal use only
  29793. */
  29794. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29795. /**
  29796. * The set of event that will be linked to this animation
  29797. */
  29798. private _events;
  29799. /**
  29800. * Stores an array of target property paths
  29801. */
  29802. targetPropertyPath: string[];
  29803. /**
  29804. * Stores the blending speed of the animation
  29805. */
  29806. blendingSpeed: number;
  29807. /**
  29808. * Stores the animation ranges for the animation
  29809. */
  29810. private _ranges;
  29811. /**
  29812. * @hidden Internal use
  29813. */
  29814. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29815. /**
  29816. * Sets up an animation
  29817. * @param property The property to animate
  29818. * @param animationType The animation type to apply
  29819. * @param framePerSecond The frames per second of the animation
  29820. * @param easingFunction The easing function used in the animation
  29821. * @returns The created animation
  29822. */
  29823. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29824. /**
  29825. * Create and start an animation on a node
  29826. * @param name defines the name of the global animation that will be run on all nodes
  29827. * @param node defines the root node where the animation will take place
  29828. * @param targetProperty defines property to animate
  29829. * @param framePerSecond defines the number of frame per second yo use
  29830. * @param totalFrame defines the number of frames in total
  29831. * @param from defines the initial value
  29832. * @param to defines the final value
  29833. * @param loopMode defines which loop mode you want to use (off by default)
  29834. * @param easingFunction defines the easing function to use (linear by default)
  29835. * @param onAnimationEnd defines the callback to call when animation end
  29836. * @returns the animatable created for this animation
  29837. */
  29838. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29839. /**
  29840. * Create and start an animation on a node and its descendants
  29841. * @param name defines the name of the global animation that will be run on all nodes
  29842. * @param node defines the root node where the animation will take place
  29843. * @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
  29844. * @param targetProperty defines property to animate
  29845. * @param framePerSecond defines the number of frame per second to use
  29846. * @param totalFrame defines the number of frames in total
  29847. * @param from defines the initial value
  29848. * @param to defines the final value
  29849. * @param loopMode defines which loop mode you want to use (off by default)
  29850. * @param easingFunction defines the easing function to use (linear by default)
  29851. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29852. * @returns the list of animatables created for all nodes
  29853. * @example https://www.babylonjs-playground.com/#MH0VLI
  29854. */
  29855. 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[]>;
  29856. /**
  29857. * Creates a new animation, merges it with the existing animations and starts it
  29858. * @param name Name of the animation
  29859. * @param node Node which contains the scene that begins the animations
  29860. * @param targetProperty Specifies which property to animate
  29861. * @param framePerSecond The frames per second of the animation
  29862. * @param totalFrame The total number of frames
  29863. * @param from The frame at the beginning of the animation
  29864. * @param to The frame at the end of the animation
  29865. * @param loopMode Specifies the loop mode of the animation
  29866. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29867. * @param onAnimationEnd Callback to run once the animation is complete
  29868. * @returns Nullable animation
  29869. */
  29870. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29871. /**
  29872. * Transition property of an host to the target Value
  29873. * @param property The property to transition
  29874. * @param targetValue The target Value of the property
  29875. * @param host The object where the property to animate belongs
  29876. * @param scene Scene used to run the animation
  29877. * @param frameRate Framerate (in frame/s) to use
  29878. * @param transition The transition type we want to use
  29879. * @param duration The duration of the animation, in milliseconds
  29880. * @param onAnimationEnd Callback trigger at the end of the animation
  29881. * @returns Nullable animation
  29882. */
  29883. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29884. /**
  29885. * Return the array of runtime animations currently using this animation
  29886. */
  29887. get runtimeAnimations(): RuntimeAnimation[];
  29888. /**
  29889. * Specifies if any of the runtime animations are currently running
  29890. */
  29891. get hasRunningRuntimeAnimations(): boolean;
  29892. /**
  29893. * Initializes the animation
  29894. * @param name Name of the animation
  29895. * @param targetProperty Property to animate
  29896. * @param framePerSecond The frames per second of the animation
  29897. * @param dataType The data type of the animation
  29898. * @param loopMode The loop mode of the animation
  29899. * @param enableBlending Specifies if blending should be enabled
  29900. */
  29901. constructor(
  29902. /**Name of the animation */
  29903. name: string,
  29904. /**Property to animate */
  29905. targetProperty: string,
  29906. /**The frames per second of the animation */
  29907. framePerSecond: number,
  29908. /**The data type of the animation */
  29909. dataType: number,
  29910. /**The loop mode of the animation */
  29911. loopMode?: number | undefined,
  29912. /**Specifies if blending should be enabled */
  29913. enableBlending?: boolean | undefined);
  29914. /**
  29915. * Converts the animation to a string
  29916. * @param fullDetails support for multiple levels of logging within scene loading
  29917. * @returns String form of the animation
  29918. */
  29919. toString(fullDetails?: boolean): string;
  29920. /**
  29921. * Add an event to this animation
  29922. * @param event Event to add
  29923. */
  29924. addEvent(event: AnimationEvent): void;
  29925. /**
  29926. * Remove all events found at the given frame
  29927. * @param frame The frame to remove events from
  29928. */
  29929. removeEvents(frame: number): void;
  29930. /**
  29931. * Retrieves all the events from the animation
  29932. * @returns Events from the animation
  29933. */
  29934. getEvents(): AnimationEvent[];
  29935. /**
  29936. * Creates an animation range
  29937. * @param name Name of the animation range
  29938. * @param from Starting frame of the animation range
  29939. * @param to Ending frame of the animation
  29940. */
  29941. createRange(name: string, from: number, to: number): void;
  29942. /**
  29943. * Deletes an animation range by name
  29944. * @param name Name of the animation range to delete
  29945. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29946. */
  29947. deleteRange(name: string, deleteFrames?: boolean): void;
  29948. /**
  29949. * Gets the animation range by name, or null if not defined
  29950. * @param name Name of the animation range
  29951. * @returns Nullable animation range
  29952. */
  29953. getRange(name: string): Nullable<AnimationRange>;
  29954. /**
  29955. * Gets the key frames from the animation
  29956. * @returns The key frames of the animation
  29957. */
  29958. getKeys(): Array<IAnimationKey>;
  29959. /**
  29960. * Gets the highest frame rate of the animation
  29961. * @returns Highest frame rate of the animation
  29962. */
  29963. getHighestFrame(): number;
  29964. /**
  29965. * Gets the easing function of the animation
  29966. * @returns Easing function of the animation
  29967. */
  29968. getEasingFunction(): IEasingFunction;
  29969. /**
  29970. * Sets the easing function of the animation
  29971. * @param easingFunction A custom mathematical formula for animation
  29972. */
  29973. setEasingFunction(easingFunction: EasingFunction): void;
  29974. /**
  29975. * Interpolates a scalar linearly
  29976. * @param startValue Start value of the animation curve
  29977. * @param endValue End value of the animation curve
  29978. * @param gradient Scalar amount to interpolate
  29979. * @returns Interpolated scalar value
  29980. */
  29981. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29982. /**
  29983. * Interpolates a scalar cubically
  29984. * @param startValue Start value of the animation curve
  29985. * @param outTangent End tangent of the animation
  29986. * @param endValue End value of the animation curve
  29987. * @param inTangent Start tangent of the animation curve
  29988. * @param gradient Scalar amount to interpolate
  29989. * @returns Interpolated scalar value
  29990. */
  29991. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29992. /**
  29993. * Interpolates a quaternion using a spherical linear interpolation
  29994. * @param startValue Start value of the animation curve
  29995. * @param endValue End value of the animation curve
  29996. * @param gradient Scalar amount to interpolate
  29997. * @returns Interpolated quaternion value
  29998. */
  29999. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30000. /**
  30001. * Interpolates a quaternion cubically
  30002. * @param startValue Start value of the animation curve
  30003. * @param outTangent End tangent of the animation curve
  30004. * @param endValue End value of the animation curve
  30005. * @param inTangent Start tangent of the animation curve
  30006. * @param gradient Scalar amount to interpolate
  30007. * @returns Interpolated quaternion value
  30008. */
  30009. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30010. /**
  30011. * Interpolates a Vector3 linearl
  30012. * @param startValue Start value of the animation curve
  30013. * @param endValue End value of the animation curve
  30014. * @param gradient Scalar amount to interpolate
  30015. * @returns Interpolated scalar value
  30016. */
  30017. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30018. /**
  30019. * Interpolates a Vector3 cubically
  30020. * @param startValue Start value of the animation curve
  30021. * @param outTangent End tangent of the animation
  30022. * @param endValue End value of the animation curve
  30023. * @param inTangent Start tangent of the animation curve
  30024. * @param gradient Scalar amount to interpolate
  30025. * @returns InterpolatedVector3 value
  30026. */
  30027. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30028. /**
  30029. * Interpolates a Vector2 linearly
  30030. * @param startValue Start value of the animation curve
  30031. * @param endValue End value of the animation curve
  30032. * @param gradient Scalar amount to interpolate
  30033. * @returns Interpolated Vector2 value
  30034. */
  30035. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30036. /**
  30037. * Interpolates a Vector2 cubically
  30038. * @param startValue Start value of the animation curve
  30039. * @param outTangent End tangent of the animation
  30040. * @param endValue End value of the animation curve
  30041. * @param inTangent Start tangent of the animation curve
  30042. * @param gradient Scalar amount to interpolate
  30043. * @returns Interpolated Vector2 value
  30044. */
  30045. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30046. /**
  30047. * Interpolates a size linearly
  30048. * @param startValue Start value of the animation curve
  30049. * @param endValue End value of the animation curve
  30050. * @param gradient Scalar amount to interpolate
  30051. * @returns Interpolated Size value
  30052. */
  30053. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30054. /**
  30055. * Interpolates a Color3 linearly
  30056. * @param startValue Start value of the animation curve
  30057. * @param endValue End value of the animation curve
  30058. * @param gradient Scalar amount to interpolate
  30059. * @returns Interpolated Color3 value
  30060. */
  30061. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30062. /**
  30063. * Interpolates a Color4 linearly
  30064. * @param startValue Start value of the animation curve
  30065. * @param endValue End value of the animation curve
  30066. * @param gradient Scalar amount to interpolate
  30067. * @returns Interpolated Color3 value
  30068. */
  30069. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30070. /**
  30071. * @hidden Internal use only
  30072. */
  30073. _getKeyValue(value: any): any;
  30074. /**
  30075. * @hidden Internal use only
  30076. */
  30077. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30078. /**
  30079. * Defines the function to use to interpolate matrices
  30080. * @param startValue defines the start matrix
  30081. * @param endValue defines the end matrix
  30082. * @param gradient defines the gradient between both matrices
  30083. * @param result defines an optional target matrix where to store the interpolation
  30084. * @returns the interpolated matrix
  30085. */
  30086. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30087. /**
  30088. * Makes a copy of the animation
  30089. * @returns Cloned animation
  30090. */
  30091. clone(): Animation;
  30092. /**
  30093. * Sets the key frames of the animation
  30094. * @param values The animation key frames to set
  30095. */
  30096. setKeys(values: Array<IAnimationKey>): void;
  30097. /**
  30098. * Serializes the animation to an object
  30099. * @returns Serialized object
  30100. */
  30101. serialize(): any;
  30102. /**
  30103. * Float animation type
  30104. */
  30105. static readonly ANIMATIONTYPE_FLOAT: number;
  30106. /**
  30107. * Vector3 animation type
  30108. */
  30109. static readonly ANIMATIONTYPE_VECTOR3: number;
  30110. /**
  30111. * Quaternion animation type
  30112. */
  30113. static readonly ANIMATIONTYPE_QUATERNION: number;
  30114. /**
  30115. * Matrix animation type
  30116. */
  30117. static readonly ANIMATIONTYPE_MATRIX: number;
  30118. /**
  30119. * Color3 animation type
  30120. */
  30121. static readonly ANIMATIONTYPE_COLOR3: number;
  30122. /**
  30123. * Color3 animation type
  30124. */
  30125. static readonly ANIMATIONTYPE_COLOR4: number;
  30126. /**
  30127. * Vector2 animation type
  30128. */
  30129. static readonly ANIMATIONTYPE_VECTOR2: number;
  30130. /**
  30131. * Size animation type
  30132. */
  30133. static readonly ANIMATIONTYPE_SIZE: number;
  30134. /**
  30135. * Relative Loop Mode
  30136. */
  30137. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30138. /**
  30139. * Cycle Loop Mode
  30140. */
  30141. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30142. /**
  30143. * Constant Loop Mode
  30144. */
  30145. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30146. /** @hidden */
  30147. static _UniversalLerp(left: any, right: any, amount: number): any;
  30148. /**
  30149. * Parses an animation object and creates an animation
  30150. * @param parsedAnimation Parsed animation object
  30151. * @returns Animation object
  30152. */
  30153. static Parse(parsedAnimation: any): Animation;
  30154. /**
  30155. * Appends the serialized animations from the source animations
  30156. * @param source Source containing the animations
  30157. * @param destination Target to store the animations
  30158. */
  30159. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30160. }
  30161. }
  30162. declare module "babylonjs/Animations/animatable.interface" {
  30163. import { Nullable } from "babylonjs/types";
  30164. import { Animation } from "babylonjs/Animations/animation";
  30165. /**
  30166. * Interface containing an array of animations
  30167. */
  30168. export interface IAnimatable {
  30169. /**
  30170. * Array of animations
  30171. */
  30172. animations: Nullable<Array<Animation>>;
  30173. }
  30174. }
  30175. declare module "babylonjs/Misc/decorators" {
  30176. import { Nullable } from "babylonjs/types";
  30177. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30178. import { Scene } from "babylonjs/scene";
  30179. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30180. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30181. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30182. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30183. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30184. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30185. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30186. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30187. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30188. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30189. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30190. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30191. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30192. /**
  30193. * Decorator used to define property that can be serialized as reference to a camera
  30194. * @param sourceName defines the name of the property to decorate
  30195. */
  30196. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30197. /**
  30198. * Class used to help serialization objects
  30199. */
  30200. export class SerializationHelper {
  30201. /** @hidden */
  30202. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30203. /** @hidden */
  30204. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30205. /** @hidden */
  30206. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30207. /** @hidden */
  30208. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30209. /**
  30210. * Appends the serialized animations from the source animations
  30211. * @param source Source containing the animations
  30212. * @param destination Target to store the animations
  30213. */
  30214. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30215. /**
  30216. * Static function used to serialized a specific entity
  30217. * @param entity defines the entity to serialize
  30218. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30219. * @returns a JSON compatible object representing the serialization of the entity
  30220. */
  30221. static Serialize<T>(entity: T, serializationObject?: any): any;
  30222. /**
  30223. * Creates a new entity from a serialization data object
  30224. * @param creationFunction defines a function used to instanciated the new entity
  30225. * @param source defines the source serialization data
  30226. * @param scene defines the hosting scene
  30227. * @param rootUrl defines the root url for resources
  30228. * @returns a new entity
  30229. */
  30230. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30231. /**
  30232. * Clones an object
  30233. * @param creationFunction defines the function used to instanciate the new object
  30234. * @param source defines the source object
  30235. * @returns the cloned object
  30236. */
  30237. static Clone<T>(creationFunction: () => T, source: T): T;
  30238. /**
  30239. * Instanciates a new object based on a source one (some data will be shared between both object)
  30240. * @param creationFunction defines the function used to instanciate the new object
  30241. * @param source defines the source object
  30242. * @returns the new object
  30243. */
  30244. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30245. }
  30246. }
  30247. declare module "babylonjs/Misc/guid" {
  30248. /**
  30249. * Class used to manipulate GUIDs
  30250. */
  30251. export class GUID {
  30252. /**
  30253. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30254. * Be aware Math.random() could cause collisions, but:
  30255. * "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"
  30256. * @returns a pseudo random id
  30257. */
  30258. static RandomId(): string;
  30259. }
  30260. }
  30261. declare module "babylonjs/Materials/Textures/baseTexture" {
  30262. import { Observable } from "babylonjs/Misc/observable";
  30263. import { Nullable } from "babylonjs/types";
  30264. import { Scene } from "babylonjs/scene";
  30265. import { Matrix } from "babylonjs/Maths/math.vector";
  30266. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30267. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30268. import { ISize } from "babylonjs/Maths/math.size";
  30269. import "babylonjs/Misc/fileTools";
  30270. /**
  30271. * Base class of all the textures in babylon.
  30272. * It groups all the common properties the materials, post process, lights... might need
  30273. * in order to make a correct use of the texture.
  30274. */
  30275. export class BaseTexture implements IAnimatable {
  30276. /**
  30277. * Default anisotropic filtering level for the application.
  30278. * It is set to 4 as a good tradeoff between perf and quality.
  30279. */
  30280. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30281. /**
  30282. * Gets or sets the unique id of the texture
  30283. */
  30284. uniqueId: number;
  30285. /**
  30286. * Define the name of the texture.
  30287. */
  30288. name: string;
  30289. /**
  30290. * Gets or sets an object used to store user defined information.
  30291. */
  30292. metadata: any;
  30293. /**
  30294. * For internal use only. Please do not use.
  30295. */
  30296. reservedDataStore: any;
  30297. private _hasAlpha;
  30298. /**
  30299. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30300. */
  30301. set hasAlpha(value: boolean);
  30302. get hasAlpha(): boolean;
  30303. /**
  30304. * Defines if the alpha value should be determined via the rgb values.
  30305. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30306. */
  30307. getAlphaFromRGB: boolean;
  30308. /**
  30309. * Intensity or strength of the texture.
  30310. * It is commonly used by materials to fine tune the intensity of the texture
  30311. */
  30312. level: number;
  30313. /**
  30314. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30315. * This is part of the texture as textures usually maps to one uv set.
  30316. */
  30317. coordinatesIndex: number;
  30318. private _coordinatesMode;
  30319. /**
  30320. * How a texture is mapped.
  30321. *
  30322. * | Value | Type | Description |
  30323. * | ----- | ----------------------------------- | ----------- |
  30324. * | 0 | EXPLICIT_MODE | |
  30325. * | 1 | SPHERICAL_MODE | |
  30326. * | 2 | PLANAR_MODE | |
  30327. * | 3 | CUBIC_MODE | |
  30328. * | 4 | PROJECTION_MODE | |
  30329. * | 5 | SKYBOX_MODE | |
  30330. * | 6 | INVCUBIC_MODE | |
  30331. * | 7 | EQUIRECTANGULAR_MODE | |
  30332. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30333. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30334. */
  30335. set coordinatesMode(value: number);
  30336. get coordinatesMode(): number;
  30337. /**
  30338. * | Value | Type | Description |
  30339. * | ----- | ------------------ | ----------- |
  30340. * | 0 | CLAMP_ADDRESSMODE | |
  30341. * | 1 | WRAP_ADDRESSMODE | |
  30342. * | 2 | MIRROR_ADDRESSMODE | |
  30343. */
  30344. wrapU: number;
  30345. /**
  30346. * | Value | Type | Description |
  30347. * | ----- | ------------------ | ----------- |
  30348. * | 0 | CLAMP_ADDRESSMODE | |
  30349. * | 1 | WRAP_ADDRESSMODE | |
  30350. * | 2 | MIRROR_ADDRESSMODE | |
  30351. */
  30352. wrapV: number;
  30353. /**
  30354. * | Value | Type | Description |
  30355. * | ----- | ------------------ | ----------- |
  30356. * | 0 | CLAMP_ADDRESSMODE | |
  30357. * | 1 | WRAP_ADDRESSMODE | |
  30358. * | 2 | MIRROR_ADDRESSMODE | |
  30359. */
  30360. wrapR: number;
  30361. /**
  30362. * With compliant hardware and browser (supporting anisotropic filtering)
  30363. * this defines the level of anisotropic filtering in the texture.
  30364. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30365. */
  30366. anisotropicFilteringLevel: number;
  30367. /**
  30368. * Define if the texture is a cube texture or if false a 2d texture.
  30369. */
  30370. get isCube(): boolean;
  30371. set isCube(value: boolean);
  30372. /**
  30373. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30374. */
  30375. get is3D(): boolean;
  30376. set is3D(value: boolean);
  30377. /**
  30378. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30379. */
  30380. get is2DArray(): boolean;
  30381. set is2DArray(value: boolean);
  30382. /**
  30383. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30384. * HDR texture are usually stored in linear space.
  30385. * This only impacts the PBR and Background materials
  30386. */
  30387. gammaSpace: boolean;
  30388. /**
  30389. * Gets or sets whether or not the texture contains RGBD data.
  30390. */
  30391. get isRGBD(): boolean;
  30392. set isRGBD(value: boolean);
  30393. /**
  30394. * Is Z inverted in the texture (useful in a cube texture).
  30395. */
  30396. invertZ: boolean;
  30397. /**
  30398. * Are mip maps generated for this texture or not.
  30399. */
  30400. get noMipmap(): boolean;
  30401. /**
  30402. * @hidden
  30403. */
  30404. lodLevelInAlpha: boolean;
  30405. /**
  30406. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30407. */
  30408. get lodGenerationOffset(): number;
  30409. set lodGenerationOffset(value: number);
  30410. /**
  30411. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30412. */
  30413. get lodGenerationScale(): number;
  30414. set lodGenerationScale(value: number);
  30415. /**
  30416. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30417. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30418. * average roughness values.
  30419. */
  30420. get linearSpecularLOD(): boolean;
  30421. set linearSpecularLOD(value: boolean);
  30422. /**
  30423. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30424. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30425. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30426. */
  30427. get irradianceTexture(): Nullable<BaseTexture>;
  30428. set irradianceTexture(value: Nullable<BaseTexture>);
  30429. /**
  30430. * Define if the texture is a render target.
  30431. */
  30432. isRenderTarget: boolean;
  30433. /**
  30434. * Define the unique id of the texture in the scene.
  30435. */
  30436. get uid(): string;
  30437. /**
  30438. * Return a string representation of the texture.
  30439. * @returns the texture as a string
  30440. */
  30441. toString(): string;
  30442. /**
  30443. * Get the class name of the texture.
  30444. * @returns "BaseTexture"
  30445. */
  30446. getClassName(): string;
  30447. /**
  30448. * Define the list of animation attached to the texture.
  30449. */
  30450. animations: import("babylonjs/Animations/animation").Animation[];
  30451. /**
  30452. * An event triggered when the texture is disposed.
  30453. */
  30454. onDisposeObservable: Observable<BaseTexture>;
  30455. private _onDisposeObserver;
  30456. /**
  30457. * Callback triggered when the texture has been disposed.
  30458. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30459. */
  30460. set onDispose(callback: () => void);
  30461. /**
  30462. * Define the current state of the loading sequence when in delayed load mode.
  30463. */
  30464. delayLoadState: number;
  30465. private _scene;
  30466. /** @hidden */
  30467. _texture: Nullable<InternalTexture>;
  30468. private _uid;
  30469. /**
  30470. * Define if the texture is preventinga material to render or not.
  30471. * If not and the texture is not ready, the engine will use a default black texture instead.
  30472. */
  30473. get isBlocking(): boolean;
  30474. /**
  30475. * Instantiates a new BaseTexture.
  30476. * Base class of all the textures in babylon.
  30477. * It groups all the common properties the materials, post process, lights... might need
  30478. * in order to make a correct use of the texture.
  30479. * @param scene Define the scene the texture blongs to
  30480. */
  30481. constructor(scene: Nullable<Scene>);
  30482. /**
  30483. * Get the scene the texture belongs to.
  30484. * @returns the scene or null if undefined
  30485. */
  30486. getScene(): Nullable<Scene>;
  30487. /**
  30488. * Get the texture transform matrix used to offset tile the texture for istance.
  30489. * @returns the transformation matrix
  30490. */
  30491. getTextureMatrix(): Matrix;
  30492. /**
  30493. * Get the texture reflection matrix used to rotate/transform the reflection.
  30494. * @returns the reflection matrix
  30495. */
  30496. getReflectionTextureMatrix(): Matrix;
  30497. /**
  30498. * Get the underlying lower level texture from Babylon.
  30499. * @returns the insternal texture
  30500. */
  30501. getInternalTexture(): Nullable<InternalTexture>;
  30502. /**
  30503. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30504. * @returns true if ready or not blocking
  30505. */
  30506. isReadyOrNotBlocking(): boolean;
  30507. /**
  30508. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30509. * @returns true if fully ready
  30510. */
  30511. isReady(): boolean;
  30512. private _cachedSize;
  30513. /**
  30514. * Get the size of the texture.
  30515. * @returns the texture size.
  30516. */
  30517. getSize(): ISize;
  30518. /**
  30519. * Get the base size of the texture.
  30520. * It can be different from the size if the texture has been resized for POT for instance
  30521. * @returns the base size
  30522. */
  30523. getBaseSize(): ISize;
  30524. /**
  30525. * Update the sampling mode of the texture.
  30526. * Default is Trilinear mode.
  30527. *
  30528. * | Value | Type | Description |
  30529. * | ----- | ------------------ | ----------- |
  30530. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30531. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30532. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30533. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30534. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30535. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30536. * | 7 | NEAREST_LINEAR | |
  30537. * | 8 | NEAREST_NEAREST | |
  30538. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30539. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30540. * | 11 | LINEAR_LINEAR | |
  30541. * | 12 | LINEAR_NEAREST | |
  30542. *
  30543. * > _mag_: magnification filter (close to the viewer)
  30544. * > _min_: minification filter (far from the viewer)
  30545. * > _mip_: filter used between mip map levels
  30546. *@param samplingMode Define the new sampling mode of the texture
  30547. */
  30548. updateSamplingMode(samplingMode: number): void;
  30549. /**
  30550. * Scales the texture if is `canRescale()`
  30551. * @param ratio the resize factor we want to use to rescale
  30552. */
  30553. scale(ratio: number): void;
  30554. /**
  30555. * Get if the texture can rescale.
  30556. */
  30557. get canRescale(): boolean;
  30558. /** @hidden */
  30559. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30560. /** @hidden */
  30561. _rebuild(): void;
  30562. /**
  30563. * Triggers the load sequence in delayed load mode.
  30564. */
  30565. delayLoad(): void;
  30566. /**
  30567. * Clones the texture.
  30568. * @returns the cloned texture
  30569. */
  30570. clone(): Nullable<BaseTexture>;
  30571. /**
  30572. * Get the texture underlying type (INT, FLOAT...)
  30573. */
  30574. get textureType(): number;
  30575. /**
  30576. * Get the texture underlying format (RGB, RGBA...)
  30577. */
  30578. get textureFormat(): number;
  30579. /**
  30580. * Indicates that textures need to be re-calculated for all materials
  30581. */
  30582. protected _markAllSubMeshesAsTexturesDirty(): void;
  30583. /**
  30584. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30585. * This will returns an RGBA array buffer containing either in values (0-255) or
  30586. * float values (0-1) depending of the underlying buffer type.
  30587. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30588. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30589. * @param buffer defines a user defined buffer to fill with data (can be null)
  30590. * @returns The Array buffer containing the pixels data.
  30591. */
  30592. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30593. /**
  30594. * Release and destroy the underlying lower level texture aka internalTexture.
  30595. */
  30596. releaseInternalTexture(): void;
  30597. /** @hidden */
  30598. get _lodTextureHigh(): Nullable<BaseTexture>;
  30599. /** @hidden */
  30600. get _lodTextureMid(): Nullable<BaseTexture>;
  30601. /** @hidden */
  30602. get _lodTextureLow(): Nullable<BaseTexture>;
  30603. /**
  30604. * Dispose the texture and release its associated resources.
  30605. */
  30606. dispose(): void;
  30607. /**
  30608. * Serialize the texture into a JSON representation that can be parsed later on.
  30609. * @returns the JSON representation of the texture
  30610. */
  30611. serialize(): any;
  30612. /**
  30613. * Helper function to be called back once a list of texture contains only ready textures.
  30614. * @param textures Define the list of textures to wait for
  30615. * @param callback Define the callback triggered once the entire list will be ready
  30616. */
  30617. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30618. }
  30619. }
  30620. declare module "babylonjs/Materials/effect" {
  30621. import { Observable } from "babylonjs/Misc/observable";
  30622. import { Nullable } from "babylonjs/types";
  30623. import { IDisposable } from "babylonjs/scene";
  30624. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30625. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30626. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30627. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30628. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30629. import { Engine } from "babylonjs/Engines/engine";
  30630. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30631. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30632. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30633. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30634. /**
  30635. * Options to be used when creating an effect.
  30636. */
  30637. export interface IEffectCreationOptions {
  30638. /**
  30639. * Atrributes that will be used in the shader.
  30640. */
  30641. attributes: string[];
  30642. /**
  30643. * Uniform varible names that will be set in the shader.
  30644. */
  30645. uniformsNames: string[];
  30646. /**
  30647. * Uniform buffer variable names that will be set in the shader.
  30648. */
  30649. uniformBuffersNames: string[];
  30650. /**
  30651. * Sampler texture variable names that will be set in the shader.
  30652. */
  30653. samplers: string[];
  30654. /**
  30655. * Define statements that will be set in the shader.
  30656. */
  30657. defines: any;
  30658. /**
  30659. * Possible fallbacks for this effect to improve performance when needed.
  30660. */
  30661. fallbacks: Nullable<IEffectFallbacks>;
  30662. /**
  30663. * Callback that will be called when the shader is compiled.
  30664. */
  30665. onCompiled: Nullable<(effect: Effect) => void>;
  30666. /**
  30667. * Callback that will be called if an error occurs during shader compilation.
  30668. */
  30669. onError: Nullable<(effect: Effect, errors: string) => void>;
  30670. /**
  30671. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30672. */
  30673. indexParameters?: any;
  30674. /**
  30675. * Max number of lights that can be used in the shader.
  30676. */
  30677. maxSimultaneousLights?: number;
  30678. /**
  30679. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30680. */
  30681. transformFeedbackVaryings?: Nullable<string[]>;
  30682. }
  30683. /**
  30684. * Effect containing vertex and fragment shader that can be executed on an object.
  30685. */
  30686. export class Effect implements IDisposable {
  30687. /**
  30688. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30689. */
  30690. static ShadersRepository: string;
  30691. /**
  30692. * Name of the effect.
  30693. */
  30694. name: any;
  30695. /**
  30696. * String container all the define statements that should be set on the shader.
  30697. */
  30698. defines: string;
  30699. /**
  30700. * Callback that will be called when the shader is compiled.
  30701. */
  30702. onCompiled: Nullable<(effect: Effect) => void>;
  30703. /**
  30704. * Callback that will be called if an error occurs during shader compilation.
  30705. */
  30706. onError: Nullable<(effect: Effect, errors: string) => void>;
  30707. /**
  30708. * Callback that will be called when effect is bound.
  30709. */
  30710. onBind: Nullable<(effect: Effect) => void>;
  30711. /**
  30712. * Unique ID of the effect.
  30713. */
  30714. uniqueId: number;
  30715. /**
  30716. * Observable that will be called when the shader is compiled.
  30717. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30718. */
  30719. onCompileObservable: Observable<Effect>;
  30720. /**
  30721. * Observable that will be called if an error occurs during shader compilation.
  30722. */
  30723. onErrorObservable: Observable<Effect>;
  30724. /** @hidden */
  30725. _onBindObservable: Nullable<Observable<Effect>>;
  30726. /**
  30727. * @hidden
  30728. * Specifies if the effect was previously ready
  30729. */
  30730. _wasPreviouslyReady: boolean;
  30731. /**
  30732. * Observable that will be called when effect is bound.
  30733. */
  30734. get onBindObservable(): Observable<Effect>;
  30735. /** @hidden */
  30736. _bonesComputationForcedToCPU: boolean;
  30737. private static _uniqueIdSeed;
  30738. private _engine;
  30739. private _uniformBuffersNames;
  30740. private _uniformsNames;
  30741. private _samplerList;
  30742. private _samplers;
  30743. private _isReady;
  30744. private _compilationError;
  30745. private _allFallbacksProcessed;
  30746. private _attributesNames;
  30747. private _attributes;
  30748. private _attributeLocationByName;
  30749. private _uniforms;
  30750. /**
  30751. * Key for the effect.
  30752. * @hidden
  30753. */
  30754. _key: string;
  30755. private _indexParameters;
  30756. private _fallbacks;
  30757. private _vertexSourceCode;
  30758. private _fragmentSourceCode;
  30759. private _vertexSourceCodeOverride;
  30760. private _fragmentSourceCodeOverride;
  30761. private _transformFeedbackVaryings;
  30762. /**
  30763. * Compiled shader to webGL program.
  30764. * @hidden
  30765. */
  30766. _pipelineContext: Nullable<IPipelineContext>;
  30767. private _valueCache;
  30768. private static _baseCache;
  30769. /**
  30770. * Instantiates an effect.
  30771. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30772. * @param baseName Name of the effect.
  30773. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30774. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30775. * @param samplers List of sampler variables that will be passed to the shader.
  30776. * @param engine Engine to be used to render the effect
  30777. * @param defines Define statements to be added to the shader.
  30778. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30779. * @param onCompiled Callback that will be called when the shader is compiled.
  30780. * @param onError Callback that will be called if an error occurs during shader compilation.
  30781. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30782. */
  30783. 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);
  30784. private _useFinalCode;
  30785. /**
  30786. * Unique key for this effect
  30787. */
  30788. get key(): string;
  30789. /**
  30790. * If the effect has been compiled and prepared.
  30791. * @returns if the effect is compiled and prepared.
  30792. */
  30793. isReady(): boolean;
  30794. private _isReadyInternal;
  30795. /**
  30796. * The engine the effect was initialized with.
  30797. * @returns the engine.
  30798. */
  30799. getEngine(): Engine;
  30800. /**
  30801. * The pipeline context for this effect
  30802. * @returns the associated pipeline context
  30803. */
  30804. getPipelineContext(): Nullable<IPipelineContext>;
  30805. /**
  30806. * The set of names of attribute variables for the shader.
  30807. * @returns An array of attribute names.
  30808. */
  30809. getAttributesNames(): string[];
  30810. /**
  30811. * Returns the attribute at the given index.
  30812. * @param index The index of the attribute.
  30813. * @returns The location of the attribute.
  30814. */
  30815. getAttributeLocation(index: number): number;
  30816. /**
  30817. * Returns the attribute based on the name of the variable.
  30818. * @param name of the attribute to look up.
  30819. * @returns the attribute location.
  30820. */
  30821. getAttributeLocationByName(name: string): number;
  30822. /**
  30823. * The number of attributes.
  30824. * @returns the numnber of attributes.
  30825. */
  30826. getAttributesCount(): number;
  30827. /**
  30828. * Gets the index of a uniform variable.
  30829. * @param uniformName of the uniform to look up.
  30830. * @returns the index.
  30831. */
  30832. getUniformIndex(uniformName: string): number;
  30833. /**
  30834. * Returns the attribute based on the name of the variable.
  30835. * @param uniformName of the uniform to look up.
  30836. * @returns the location of the uniform.
  30837. */
  30838. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30839. /**
  30840. * Returns an array of sampler variable names
  30841. * @returns The array of sampler variable neames.
  30842. */
  30843. getSamplers(): string[];
  30844. /**
  30845. * The error from the last compilation.
  30846. * @returns the error string.
  30847. */
  30848. getCompilationError(): string;
  30849. /**
  30850. * Gets a boolean indicating that all fallbacks were used during compilation
  30851. * @returns true if all fallbacks were used
  30852. */
  30853. allFallbacksProcessed(): boolean;
  30854. /**
  30855. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30856. * @param func The callback to be used.
  30857. */
  30858. executeWhenCompiled(func: (effect: Effect) => void): void;
  30859. private _checkIsReady;
  30860. private _loadShader;
  30861. /**
  30862. * Recompiles the webGL program
  30863. * @param vertexSourceCode The source code for the vertex shader.
  30864. * @param fragmentSourceCode The source code for the fragment shader.
  30865. * @param onCompiled Callback called when completed.
  30866. * @param onError Callback called on error.
  30867. * @hidden
  30868. */
  30869. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30870. /**
  30871. * Prepares the effect
  30872. * @hidden
  30873. */
  30874. _prepareEffect(): void;
  30875. private _processCompilationErrors;
  30876. /**
  30877. * Checks if the effect is supported. (Must be called after compilation)
  30878. */
  30879. get isSupported(): boolean;
  30880. /**
  30881. * Binds a texture to the engine to be used as output of the shader.
  30882. * @param channel Name of the output variable.
  30883. * @param texture Texture to bind.
  30884. * @hidden
  30885. */
  30886. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30887. /**
  30888. * Sets a texture on the engine to be used in the shader.
  30889. * @param channel Name of the sampler variable.
  30890. * @param texture Texture to set.
  30891. */
  30892. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30893. /**
  30894. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30895. * @param channel Name of the sampler variable.
  30896. * @param texture Texture to set.
  30897. */
  30898. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30899. /**
  30900. * Sets an array of textures on the engine to be used in the shader.
  30901. * @param channel Name of the variable.
  30902. * @param textures Textures to set.
  30903. */
  30904. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30905. /**
  30906. * 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)
  30907. * @param channel Name of the sampler variable.
  30908. * @param postProcess Post process to get the input texture from.
  30909. */
  30910. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30911. /**
  30912. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30913. * 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)
  30914. * @param channel Name of the sampler variable.
  30915. * @param postProcess Post process to get the output texture from.
  30916. */
  30917. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30918. /** @hidden */
  30919. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30920. /** @hidden */
  30921. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30922. /** @hidden */
  30923. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30924. /** @hidden */
  30925. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30926. /**
  30927. * Binds a buffer to a uniform.
  30928. * @param buffer Buffer to bind.
  30929. * @param name Name of the uniform variable to bind to.
  30930. */
  30931. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30932. /**
  30933. * Binds block to a uniform.
  30934. * @param blockName Name of the block to bind.
  30935. * @param index Index to bind.
  30936. */
  30937. bindUniformBlock(blockName: string, index: number): void;
  30938. /**
  30939. * Sets an interger value on a uniform variable.
  30940. * @param uniformName Name of the variable.
  30941. * @param value Value to be set.
  30942. * @returns this effect.
  30943. */
  30944. setInt(uniformName: string, value: number): Effect;
  30945. /**
  30946. * Sets an int array on a uniform variable.
  30947. * @param uniformName Name of the variable.
  30948. * @param array array to be set.
  30949. * @returns this effect.
  30950. */
  30951. setIntArray(uniformName: string, array: Int32Array): Effect;
  30952. /**
  30953. * 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)
  30954. * @param uniformName Name of the variable.
  30955. * @param array array to be set.
  30956. * @returns this effect.
  30957. */
  30958. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30959. /**
  30960. * 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)
  30961. * @param uniformName Name of the variable.
  30962. * @param array array to be set.
  30963. * @returns this effect.
  30964. */
  30965. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30966. /**
  30967. * 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)
  30968. * @param uniformName Name of the variable.
  30969. * @param array array to be set.
  30970. * @returns this effect.
  30971. */
  30972. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30973. /**
  30974. * Sets an float array on a uniform variable.
  30975. * @param uniformName Name of the variable.
  30976. * @param array array to be set.
  30977. * @returns this effect.
  30978. */
  30979. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30980. /**
  30981. * 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)
  30982. * @param uniformName Name of the variable.
  30983. * @param array array to be set.
  30984. * @returns this effect.
  30985. */
  30986. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30987. /**
  30988. * 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)
  30989. * @param uniformName Name of the variable.
  30990. * @param array array to be set.
  30991. * @returns this effect.
  30992. */
  30993. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30994. /**
  30995. * 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)
  30996. * @param uniformName Name of the variable.
  30997. * @param array array to be set.
  30998. * @returns this effect.
  30999. */
  31000. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31001. /**
  31002. * Sets an array on a uniform variable.
  31003. * @param uniformName Name of the variable.
  31004. * @param array array to be set.
  31005. * @returns this effect.
  31006. */
  31007. setArray(uniformName: string, array: number[]): Effect;
  31008. /**
  31009. * 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)
  31010. * @param uniformName Name of the variable.
  31011. * @param array array to be set.
  31012. * @returns this effect.
  31013. */
  31014. setArray2(uniformName: string, array: number[]): Effect;
  31015. /**
  31016. * 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)
  31017. * @param uniformName Name of the variable.
  31018. * @param array array to be set.
  31019. * @returns this effect.
  31020. */
  31021. setArray3(uniformName: string, array: number[]): Effect;
  31022. /**
  31023. * 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)
  31024. * @param uniformName Name of the variable.
  31025. * @param array array to be set.
  31026. * @returns this effect.
  31027. */
  31028. setArray4(uniformName: string, array: number[]): Effect;
  31029. /**
  31030. * Sets matrices on a uniform variable.
  31031. * @param uniformName Name of the variable.
  31032. * @param matrices matrices to be set.
  31033. * @returns this effect.
  31034. */
  31035. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31036. /**
  31037. * Sets matrix on a uniform variable.
  31038. * @param uniformName Name of the variable.
  31039. * @param matrix matrix to be set.
  31040. * @returns this effect.
  31041. */
  31042. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31043. /**
  31044. * 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)
  31045. * @param uniformName Name of the variable.
  31046. * @param matrix matrix to be set.
  31047. * @returns this effect.
  31048. */
  31049. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31050. /**
  31051. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31052. * @param uniformName Name of the variable.
  31053. * @param matrix matrix to be set.
  31054. * @returns this effect.
  31055. */
  31056. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31057. /**
  31058. * Sets a float on a uniform variable.
  31059. * @param uniformName Name of the variable.
  31060. * @param value value to be set.
  31061. * @returns this effect.
  31062. */
  31063. setFloat(uniformName: string, value: number): Effect;
  31064. /**
  31065. * Sets a boolean on a uniform variable.
  31066. * @param uniformName Name of the variable.
  31067. * @param bool value to be set.
  31068. * @returns this effect.
  31069. */
  31070. setBool(uniformName: string, bool: boolean): Effect;
  31071. /**
  31072. * Sets a Vector2 on a uniform variable.
  31073. * @param uniformName Name of the variable.
  31074. * @param vector2 vector2 to be set.
  31075. * @returns this effect.
  31076. */
  31077. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31078. /**
  31079. * Sets a float2 on a uniform variable.
  31080. * @param uniformName Name of the variable.
  31081. * @param x First float in float2.
  31082. * @param y Second float in float2.
  31083. * @returns this effect.
  31084. */
  31085. setFloat2(uniformName: string, x: number, y: number): Effect;
  31086. /**
  31087. * Sets a Vector3 on a uniform variable.
  31088. * @param uniformName Name of the variable.
  31089. * @param vector3 Value to be set.
  31090. * @returns this effect.
  31091. */
  31092. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31093. /**
  31094. * Sets a float3 on a uniform variable.
  31095. * @param uniformName Name of the variable.
  31096. * @param x First float in float3.
  31097. * @param y Second float in float3.
  31098. * @param z Third float in float3.
  31099. * @returns this effect.
  31100. */
  31101. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31102. /**
  31103. * Sets a Vector4 on a uniform variable.
  31104. * @param uniformName Name of the variable.
  31105. * @param vector4 Value to be set.
  31106. * @returns this effect.
  31107. */
  31108. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31109. /**
  31110. * Sets a float4 on a uniform variable.
  31111. * @param uniformName Name of the variable.
  31112. * @param x First float in float4.
  31113. * @param y Second float in float4.
  31114. * @param z Third float in float4.
  31115. * @param w Fourth float in float4.
  31116. * @returns this effect.
  31117. */
  31118. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31119. /**
  31120. * Sets a Color3 on a uniform variable.
  31121. * @param uniformName Name of the variable.
  31122. * @param color3 Value to be set.
  31123. * @returns this effect.
  31124. */
  31125. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31126. /**
  31127. * Sets a Color4 on a uniform variable.
  31128. * @param uniformName Name of the variable.
  31129. * @param color3 Value to be set.
  31130. * @param alpha Alpha value to be set.
  31131. * @returns this effect.
  31132. */
  31133. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31134. /**
  31135. * Sets a Color4 on a uniform variable
  31136. * @param uniformName defines the name of the variable
  31137. * @param color4 defines the value to be set
  31138. * @returns this effect.
  31139. */
  31140. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31141. /** Release all associated resources */
  31142. dispose(): void;
  31143. /**
  31144. * This function will add a new shader to the shader store
  31145. * @param name the name of the shader
  31146. * @param pixelShader optional pixel shader content
  31147. * @param vertexShader optional vertex shader content
  31148. */
  31149. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31150. /**
  31151. * Store of each shader (The can be looked up using effect.key)
  31152. */
  31153. static ShadersStore: {
  31154. [key: string]: string;
  31155. };
  31156. /**
  31157. * Store of each included file for a shader (The can be looked up using effect.key)
  31158. */
  31159. static IncludesShadersStore: {
  31160. [key: string]: string;
  31161. };
  31162. /**
  31163. * Resets the cache of effects.
  31164. */
  31165. static ResetCache(): void;
  31166. }
  31167. }
  31168. declare module "babylonjs/Engines/engineCapabilities" {
  31169. /**
  31170. * Interface used to describe the capabilities of the engine relatively to the current browser
  31171. */
  31172. export interface EngineCapabilities {
  31173. /** Maximum textures units per fragment shader */
  31174. maxTexturesImageUnits: number;
  31175. /** Maximum texture units per vertex shader */
  31176. maxVertexTextureImageUnits: number;
  31177. /** Maximum textures units in the entire pipeline */
  31178. maxCombinedTexturesImageUnits: number;
  31179. /** Maximum texture size */
  31180. maxTextureSize: number;
  31181. /** Maximum texture samples */
  31182. maxSamples?: number;
  31183. /** Maximum cube texture size */
  31184. maxCubemapTextureSize: number;
  31185. /** Maximum render texture size */
  31186. maxRenderTextureSize: number;
  31187. /** Maximum number of vertex attributes */
  31188. maxVertexAttribs: number;
  31189. /** Maximum number of varyings */
  31190. maxVaryingVectors: number;
  31191. /** Maximum number of uniforms per vertex shader */
  31192. maxVertexUniformVectors: number;
  31193. /** Maximum number of uniforms per fragment shader */
  31194. maxFragmentUniformVectors: number;
  31195. /** Defines if standard derivates (dx/dy) are supported */
  31196. standardDerivatives: boolean;
  31197. /** Defines if s3tc texture compression is supported */
  31198. s3tc?: WEBGL_compressed_texture_s3tc;
  31199. /** Defines if pvrtc texture compression is supported */
  31200. pvrtc: any;
  31201. /** Defines if etc1 texture compression is supported */
  31202. etc1: any;
  31203. /** Defines if etc2 texture compression is supported */
  31204. etc2: any;
  31205. /** Defines if astc texture compression is supported */
  31206. astc: any;
  31207. /** Defines if float textures are supported */
  31208. textureFloat: boolean;
  31209. /** Defines if vertex array objects are supported */
  31210. vertexArrayObject: boolean;
  31211. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31212. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31213. /** Gets the maximum level of anisotropy supported */
  31214. maxAnisotropy: number;
  31215. /** Defines if instancing is supported */
  31216. instancedArrays: boolean;
  31217. /** Defines if 32 bits indices are supported */
  31218. uintIndices: boolean;
  31219. /** Defines if high precision shaders are supported */
  31220. highPrecisionShaderSupported: boolean;
  31221. /** Defines if depth reading in the fragment shader is supported */
  31222. fragmentDepthSupported: boolean;
  31223. /** Defines if float texture linear filtering is supported*/
  31224. textureFloatLinearFiltering: boolean;
  31225. /** Defines if rendering to float textures is supported */
  31226. textureFloatRender: boolean;
  31227. /** Defines if half float textures are supported*/
  31228. textureHalfFloat: boolean;
  31229. /** Defines if half float texture linear filtering is supported*/
  31230. textureHalfFloatLinearFiltering: boolean;
  31231. /** Defines if rendering to half float textures is supported */
  31232. textureHalfFloatRender: boolean;
  31233. /** Defines if textureLOD shader command is supported */
  31234. textureLOD: boolean;
  31235. /** Defines if draw buffers extension is supported */
  31236. drawBuffersExtension: boolean;
  31237. /** Defines if depth textures are supported */
  31238. depthTextureExtension: boolean;
  31239. /** Defines if float color buffer are supported */
  31240. colorBufferFloat: boolean;
  31241. /** Gets disjoint timer query extension (null if not supported) */
  31242. timerQuery?: EXT_disjoint_timer_query;
  31243. /** Defines if timestamp can be used with timer query */
  31244. canUseTimestampForTimerQuery: boolean;
  31245. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31246. multiview?: any;
  31247. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31248. oculusMultiview?: any;
  31249. /** Function used to let the system compiles shaders in background */
  31250. parallelShaderCompile?: {
  31251. COMPLETION_STATUS_KHR: number;
  31252. };
  31253. /** Max number of texture samples for MSAA */
  31254. maxMSAASamples: number;
  31255. /** Defines if the blend min max extension is supported */
  31256. blendMinMax: boolean;
  31257. }
  31258. }
  31259. declare module "babylonjs/States/depthCullingState" {
  31260. import { Nullable } from "babylonjs/types";
  31261. /**
  31262. * @hidden
  31263. **/
  31264. export class DepthCullingState {
  31265. private _isDepthTestDirty;
  31266. private _isDepthMaskDirty;
  31267. private _isDepthFuncDirty;
  31268. private _isCullFaceDirty;
  31269. private _isCullDirty;
  31270. private _isZOffsetDirty;
  31271. private _isFrontFaceDirty;
  31272. private _depthTest;
  31273. private _depthMask;
  31274. private _depthFunc;
  31275. private _cull;
  31276. private _cullFace;
  31277. private _zOffset;
  31278. private _frontFace;
  31279. /**
  31280. * Initializes the state.
  31281. */
  31282. constructor();
  31283. get isDirty(): boolean;
  31284. get zOffset(): number;
  31285. set zOffset(value: number);
  31286. get cullFace(): Nullable<number>;
  31287. set cullFace(value: Nullable<number>);
  31288. get cull(): Nullable<boolean>;
  31289. set cull(value: Nullable<boolean>);
  31290. get depthFunc(): Nullable<number>;
  31291. set depthFunc(value: Nullable<number>);
  31292. get depthMask(): boolean;
  31293. set depthMask(value: boolean);
  31294. get depthTest(): boolean;
  31295. set depthTest(value: boolean);
  31296. get frontFace(): Nullable<number>;
  31297. set frontFace(value: Nullable<number>);
  31298. reset(): void;
  31299. apply(gl: WebGLRenderingContext): void;
  31300. }
  31301. }
  31302. declare module "babylonjs/States/stencilState" {
  31303. /**
  31304. * @hidden
  31305. **/
  31306. export class StencilState {
  31307. /** 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 */
  31308. static readonly ALWAYS: number;
  31309. /** Passed to stencilOperation to specify that stencil value must be kept */
  31310. static readonly KEEP: number;
  31311. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31312. static readonly REPLACE: number;
  31313. private _isStencilTestDirty;
  31314. private _isStencilMaskDirty;
  31315. private _isStencilFuncDirty;
  31316. private _isStencilOpDirty;
  31317. private _stencilTest;
  31318. private _stencilMask;
  31319. private _stencilFunc;
  31320. private _stencilFuncRef;
  31321. private _stencilFuncMask;
  31322. private _stencilOpStencilFail;
  31323. private _stencilOpDepthFail;
  31324. private _stencilOpStencilDepthPass;
  31325. get isDirty(): boolean;
  31326. get stencilFunc(): number;
  31327. set stencilFunc(value: number);
  31328. get stencilFuncRef(): number;
  31329. set stencilFuncRef(value: number);
  31330. get stencilFuncMask(): number;
  31331. set stencilFuncMask(value: number);
  31332. get stencilOpStencilFail(): number;
  31333. set stencilOpStencilFail(value: number);
  31334. get stencilOpDepthFail(): number;
  31335. set stencilOpDepthFail(value: number);
  31336. get stencilOpStencilDepthPass(): number;
  31337. set stencilOpStencilDepthPass(value: number);
  31338. get stencilMask(): number;
  31339. set stencilMask(value: number);
  31340. get stencilTest(): boolean;
  31341. set stencilTest(value: boolean);
  31342. constructor();
  31343. reset(): void;
  31344. apply(gl: WebGLRenderingContext): void;
  31345. }
  31346. }
  31347. declare module "babylonjs/States/alphaCullingState" {
  31348. /**
  31349. * @hidden
  31350. **/
  31351. export class AlphaState {
  31352. private _isAlphaBlendDirty;
  31353. private _isBlendFunctionParametersDirty;
  31354. private _isBlendEquationParametersDirty;
  31355. private _isBlendConstantsDirty;
  31356. private _alphaBlend;
  31357. private _blendFunctionParameters;
  31358. private _blendEquationParameters;
  31359. private _blendConstants;
  31360. /**
  31361. * Initializes the state.
  31362. */
  31363. constructor();
  31364. get isDirty(): boolean;
  31365. get alphaBlend(): boolean;
  31366. set alphaBlend(value: boolean);
  31367. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31368. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31369. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31370. reset(): void;
  31371. apply(gl: WebGLRenderingContext): void;
  31372. }
  31373. }
  31374. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31375. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31376. /** @hidden */
  31377. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31378. attributeProcessor(attribute: string): string;
  31379. varyingProcessor(varying: string, isFragment: boolean): string;
  31380. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31381. }
  31382. }
  31383. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31384. /**
  31385. * Interface for attribute information associated with buffer instanciation
  31386. */
  31387. export interface InstancingAttributeInfo {
  31388. /**
  31389. * Name of the GLSL attribute
  31390. * if attribute index is not specified, this is used to retrieve the index from the effect
  31391. */
  31392. attributeName: string;
  31393. /**
  31394. * Index/offset of the attribute in the vertex shader
  31395. * if not specified, this will be computes from the name.
  31396. */
  31397. index?: number;
  31398. /**
  31399. * size of the attribute, 1, 2, 3 or 4
  31400. */
  31401. attributeSize: number;
  31402. /**
  31403. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31404. */
  31405. offset: number;
  31406. /**
  31407. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31408. * default to 1
  31409. */
  31410. divisor?: number;
  31411. /**
  31412. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31413. * default is FLOAT
  31414. */
  31415. attributeType?: number;
  31416. /**
  31417. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31418. */
  31419. normalized?: boolean;
  31420. }
  31421. }
  31422. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31424. import { Nullable } from "babylonjs/types";
  31425. module "babylonjs/Engines/thinEngine" {
  31426. interface ThinEngine {
  31427. /**
  31428. * Update a video texture
  31429. * @param texture defines the texture to update
  31430. * @param video defines the video element to use
  31431. * @param invertY defines if data must be stored with Y axis inverted
  31432. */
  31433. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31434. }
  31435. }
  31436. }
  31437. declare module "babylonjs/Materials/Textures/videoTexture" {
  31438. import { Observable } from "babylonjs/Misc/observable";
  31439. import { Nullable } from "babylonjs/types";
  31440. import { Scene } from "babylonjs/scene";
  31441. import { Texture } from "babylonjs/Materials/Textures/texture";
  31442. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31443. /**
  31444. * Settings for finer control over video usage
  31445. */
  31446. export interface VideoTextureSettings {
  31447. /**
  31448. * Applies `autoplay` to video, if specified
  31449. */
  31450. autoPlay?: boolean;
  31451. /**
  31452. * Applies `loop` to video, if specified
  31453. */
  31454. loop?: boolean;
  31455. /**
  31456. * Automatically updates internal texture from video at every frame in the render loop
  31457. */
  31458. autoUpdateTexture: boolean;
  31459. /**
  31460. * Image src displayed during the video loading or until the user interacts with the video.
  31461. */
  31462. poster?: string;
  31463. }
  31464. /**
  31465. * If you want to display a video in your scene, this is the special texture for that.
  31466. * This special texture works similar to other textures, with the exception of a few parameters.
  31467. * @see https://doc.babylonjs.com/how_to/video_texture
  31468. */
  31469. export class VideoTexture extends Texture {
  31470. /**
  31471. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31472. */
  31473. readonly autoUpdateTexture: boolean;
  31474. /**
  31475. * The video instance used by the texture internally
  31476. */
  31477. readonly video: HTMLVideoElement;
  31478. private _onUserActionRequestedObservable;
  31479. /**
  31480. * Event triggerd when a dom action is required by the user to play the video.
  31481. * This happens due to recent changes in browser policies preventing video to auto start.
  31482. */
  31483. get onUserActionRequestedObservable(): Observable<Texture>;
  31484. private _generateMipMaps;
  31485. private _engine;
  31486. private _stillImageCaptured;
  31487. private _displayingPosterTexture;
  31488. private _settings;
  31489. private _createInternalTextureOnEvent;
  31490. private _frameId;
  31491. /**
  31492. * Creates a video texture.
  31493. * If you want to display a video in your scene, this is the special texture for that.
  31494. * This special texture works similar to other textures, with the exception of a few parameters.
  31495. * @see https://doc.babylonjs.com/how_to/video_texture
  31496. * @param name optional name, will detect from video source, if not defined
  31497. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31498. * @param scene is obviously the current scene.
  31499. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31500. * @param invertY is false by default but can be used to invert video on Y axis
  31501. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31502. * @param settings allows finer control over video usage
  31503. */
  31504. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31505. private _getName;
  31506. private _getVideo;
  31507. private _createInternalTexture;
  31508. private reset;
  31509. /**
  31510. * @hidden Internal method to initiate `update`.
  31511. */
  31512. _rebuild(): void;
  31513. /**
  31514. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31515. */
  31516. update(): void;
  31517. /**
  31518. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31519. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31520. */
  31521. updateTexture(isVisible: boolean): void;
  31522. protected _updateInternalTexture: () => void;
  31523. /**
  31524. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31525. * @param url New url.
  31526. */
  31527. updateURL(url: string): void;
  31528. /**
  31529. * Dispose the texture and release its associated resources.
  31530. */
  31531. dispose(): void;
  31532. /**
  31533. * Creates a video texture straight from a stream.
  31534. * @param scene Define the scene the texture should be created in
  31535. * @param stream Define the stream the texture should be created from
  31536. * @returns The created video texture as a promise
  31537. */
  31538. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31539. /**
  31540. * Creates a video texture straight from your WebCam video feed.
  31541. * @param scene Define the scene the texture should be created in
  31542. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31543. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31544. * @returns The created video texture as a promise
  31545. */
  31546. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31547. minWidth: number;
  31548. maxWidth: number;
  31549. minHeight: number;
  31550. maxHeight: number;
  31551. deviceId: string;
  31552. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31553. /**
  31554. * Creates a video texture straight from your WebCam video feed.
  31555. * @param scene Define the scene the texture should be created in
  31556. * @param onReady Define a callback to triggered once the texture will be ready
  31557. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31558. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31559. */
  31560. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31561. minWidth: number;
  31562. maxWidth: number;
  31563. minHeight: number;
  31564. maxHeight: number;
  31565. deviceId: string;
  31566. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31567. }
  31568. }
  31569. declare module "babylonjs/Engines/thinEngine" {
  31570. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31571. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31572. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31573. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31574. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31575. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31576. import { Observable } from "babylonjs/Misc/observable";
  31577. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31578. import { StencilState } from "babylonjs/States/stencilState";
  31579. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31580. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31581. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31582. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31583. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31584. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31585. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31586. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31587. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31588. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31589. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31590. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31591. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31592. import { WebRequest } from "babylonjs/Misc/webRequest";
  31593. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31594. /**
  31595. * Defines the interface used by objects working like Scene
  31596. * @hidden
  31597. */
  31598. interface ISceneLike {
  31599. _addPendingData(data: any): void;
  31600. _removePendingData(data: any): void;
  31601. offlineProvider: IOfflineProvider;
  31602. }
  31603. /** Interface defining initialization parameters for Engine class */
  31604. export interface EngineOptions extends WebGLContextAttributes {
  31605. /**
  31606. * Defines if the engine should no exceed a specified device ratio
  31607. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31608. */
  31609. limitDeviceRatio?: number;
  31610. /**
  31611. * Defines if webvr should be enabled automatically
  31612. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31613. */
  31614. autoEnableWebVR?: boolean;
  31615. /**
  31616. * Defines if webgl2 should be turned off even if supported
  31617. * @see http://doc.babylonjs.com/features/webgl2
  31618. */
  31619. disableWebGL2Support?: boolean;
  31620. /**
  31621. * Defines if webaudio should be initialized as well
  31622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31623. */
  31624. audioEngine?: boolean;
  31625. /**
  31626. * Defines if animations should run using a deterministic lock step
  31627. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31628. */
  31629. deterministicLockstep?: boolean;
  31630. /** Defines the maximum steps to use with deterministic lock step mode */
  31631. lockstepMaxSteps?: number;
  31632. /** Defines the seconds between each deterministic lock step */
  31633. timeStep?: number;
  31634. /**
  31635. * Defines that engine should ignore context lost events
  31636. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31637. */
  31638. doNotHandleContextLost?: boolean;
  31639. /**
  31640. * Defines that engine should ignore modifying touch action attribute and style
  31641. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31642. */
  31643. doNotHandleTouchAction?: boolean;
  31644. /**
  31645. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31646. */
  31647. useHighPrecisionFloats?: boolean;
  31648. }
  31649. /**
  31650. * The base engine class (root of all engines)
  31651. */
  31652. export class ThinEngine {
  31653. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31654. static ExceptionList: ({
  31655. key: string;
  31656. capture: string;
  31657. captureConstraint: number;
  31658. targets: string[];
  31659. } | {
  31660. key: string;
  31661. capture: null;
  31662. captureConstraint: null;
  31663. targets: string[];
  31664. })[];
  31665. /** @hidden */
  31666. static _TextureLoaders: IInternalTextureLoader[];
  31667. /**
  31668. * Returns the current npm package of the sdk
  31669. */
  31670. static get NpmPackage(): string;
  31671. /**
  31672. * Returns the current version of the framework
  31673. */
  31674. static get Version(): string;
  31675. /**
  31676. * Returns a string describing the current engine
  31677. */
  31678. get description(): string;
  31679. /**
  31680. * Gets or sets the epsilon value used by collision engine
  31681. */
  31682. static CollisionsEpsilon: number;
  31683. /**
  31684. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31685. */
  31686. static get ShadersRepository(): string;
  31687. static set ShadersRepository(value: string);
  31688. /**
  31689. * Gets or sets the textures that the engine should not attempt to load as compressed
  31690. */
  31691. protected _excludedCompressedTextures: string[];
  31692. /**
  31693. * Filters the compressed texture formats to only include
  31694. * files that are not included in the skippable list
  31695. *
  31696. * @param url the current extension
  31697. * @param textureFormatInUse the current compressed texture format
  31698. * @returns "format" string
  31699. */
  31700. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31701. /** @hidden */
  31702. _shaderProcessor: IShaderProcessor;
  31703. /**
  31704. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31705. */
  31706. forcePOTTextures: boolean;
  31707. /**
  31708. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31709. */
  31710. isFullscreen: boolean;
  31711. /**
  31712. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31713. */
  31714. cullBackFaces: boolean;
  31715. /**
  31716. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31717. */
  31718. renderEvenInBackground: boolean;
  31719. /**
  31720. * Gets or sets a boolean indicating that cache can be kept between frames
  31721. */
  31722. preventCacheWipeBetweenFrames: boolean;
  31723. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31724. validateShaderPrograms: boolean;
  31725. /**
  31726. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31727. * This can provide greater z depth for distant objects.
  31728. */
  31729. useReverseDepthBuffer: boolean;
  31730. /**
  31731. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31732. */
  31733. disableUniformBuffers: boolean;
  31734. /** @hidden */
  31735. _uniformBuffers: UniformBuffer[];
  31736. /**
  31737. * Gets a boolean indicating that the engine supports uniform buffers
  31738. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31739. */
  31740. get supportsUniformBuffers(): boolean;
  31741. /** @hidden */
  31742. _gl: WebGLRenderingContext;
  31743. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31744. protected _windowIsBackground: boolean;
  31745. protected _webGLVersion: number;
  31746. protected _creationOptions: EngineOptions;
  31747. protected _highPrecisionShadersAllowed: boolean;
  31748. /** @hidden */
  31749. get _shouldUseHighPrecisionShader(): boolean;
  31750. /**
  31751. * Gets a boolean indicating that only power of 2 textures are supported
  31752. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31753. */
  31754. get needPOTTextures(): boolean;
  31755. /** @hidden */
  31756. _badOS: boolean;
  31757. /** @hidden */
  31758. _badDesktopOS: boolean;
  31759. private _hardwareScalingLevel;
  31760. /** @hidden */
  31761. _caps: EngineCapabilities;
  31762. private _isStencilEnable;
  31763. private _glVersion;
  31764. private _glRenderer;
  31765. private _glVendor;
  31766. /** @hidden */
  31767. _videoTextureSupported: boolean;
  31768. protected _renderingQueueLaunched: boolean;
  31769. protected _activeRenderLoops: (() => void)[];
  31770. /**
  31771. * Observable signaled when a context lost event is raised
  31772. */
  31773. onContextLostObservable: Observable<ThinEngine>;
  31774. /**
  31775. * Observable signaled when a context restored event is raised
  31776. */
  31777. onContextRestoredObservable: Observable<ThinEngine>;
  31778. private _onContextLost;
  31779. private _onContextRestored;
  31780. protected _contextWasLost: boolean;
  31781. /** @hidden */
  31782. _doNotHandleContextLost: boolean;
  31783. /**
  31784. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31786. */
  31787. get doNotHandleContextLost(): boolean;
  31788. set doNotHandleContextLost(value: boolean);
  31789. /**
  31790. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31791. */
  31792. disableVertexArrayObjects: boolean;
  31793. /** @hidden */
  31794. protected _colorWrite: boolean;
  31795. /** @hidden */
  31796. protected _colorWriteChanged: boolean;
  31797. /** @hidden */
  31798. protected _depthCullingState: DepthCullingState;
  31799. /** @hidden */
  31800. protected _stencilState: StencilState;
  31801. /** @hidden */
  31802. _alphaState: AlphaState;
  31803. /** @hidden */
  31804. _alphaMode: number;
  31805. /** @hidden */
  31806. _alphaEquation: number;
  31807. /** @hidden */
  31808. _internalTexturesCache: InternalTexture[];
  31809. /** @hidden */
  31810. protected _activeChannel: number;
  31811. private _currentTextureChannel;
  31812. /** @hidden */
  31813. protected _boundTexturesCache: {
  31814. [key: string]: Nullable<InternalTexture>;
  31815. };
  31816. /** @hidden */
  31817. protected _currentEffect: Nullable<Effect>;
  31818. /** @hidden */
  31819. protected _currentProgram: Nullable<WebGLProgram>;
  31820. private _compiledEffects;
  31821. private _vertexAttribArraysEnabled;
  31822. /** @hidden */
  31823. protected _cachedViewport: Nullable<IViewportLike>;
  31824. private _cachedVertexArrayObject;
  31825. /** @hidden */
  31826. protected _cachedVertexBuffers: any;
  31827. /** @hidden */
  31828. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31829. /** @hidden */
  31830. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31831. /** @hidden */
  31832. _currentRenderTarget: Nullable<InternalTexture>;
  31833. private _uintIndicesCurrentlySet;
  31834. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31835. /** @hidden */
  31836. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31837. private _currentBufferPointers;
  31838. private _currentInstanceLocations;
  31839. private _currentInstanceBuffers;
  31840. private _textureUnits;
  31841. /** @hidden */
  31842. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31843. /** @hidden */
  31844. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31845. /** @hidden */
  31846. _boundRenderFunction: any;
  31847. private _vaoRecordInProgress;
  31848. private _mustWipeVertexAttributes;
  31849. private _emptyTexture;
  31850. private _emptyCubeTexture;
  31851. private _emptyTexture3D;
  31852. private _emptyTexture2DArray;
  31853. /** @hidden */
  31854. _frameHandler: number;
  31855. private _nextFreeTextureSlots;
  31856. private _maxSimultaneousTextures;
  31857. private _activeRequests;
  31858. protected _texturesSupported: string[];
  31859. /** @hidden */
  31860. _textureFormatInUse: Nullable<string>;
  31861. protected get _supportsHardwareTextureRescaling(): boolean;
  31862. /**
  31863. * Gets the list of texture formats supported
  31864. */
  31865. get texturesSupported(): Array<string>;
  31866. /**
  31867. * Gets the list of texture formats in use
  31868. */
  31869. get textureFormatInUse(): Nullable<string>;
  31870. /**
  31871. * Gets the current viewport
  31872. */
  31873. get currentViewport(): Nullable<IViewportLike>;
  31874. /**
  31875. * Gets the default empty texture
  31876. */
  31877. get emptyTexture(): InternalTexture;
  31878. /**
  31879. * Gets the default empty 3D texture
  31880. */
  31881. get emptyTexture3D(): InternalTexture;
  31882. /**
  31883. * Gets the default empty 2D array texture
  31884. */
  31885. get emptyTexture2DArray(): InternalTexture;
  31886. /**
  31887. * Gets the default empty cube texture
  31888. */
  31889. get emptyCubeTexture(): InternalTexture;
  31890. /**
  31891. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31892. */
  31893. readonly premultipliedAlpha: boolean;
  31894. /**
  31895. * Observable event triggered before each texture is initialized
  31896. */
  31897. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31898. /**
  31899. * Creates a new engine
  31900. * @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
  31901. * @param antialias defines enable antialiasing (default: false)
  31902. * @param options defines further options to be sent to the getContext() function
  31903. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31904. */
  31905. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31906. private _rebuildInternalTextures;
  31907. private _rebuildEffects;
  31908. /**
  31909. * Gets a boolean indicating if all created effects are ready
  31910. * @returns true if all effects are ready
  31911. */
  31912. areAllEffectsReady(): boolean;
  31913. protected _rebuildBuffers(): void;
  31914. private _initGLContext;
  31915. /**
  31916. * Gets version of the current webGL context
  31917. */
  31918. get webGLVersion(): number;
  31919. /**
  31920. * Gets a string idenfifying the name of the class
  31921. * @returns "Engine" string
  31922. */
  31923. getClassName(): string;
  31924. /**
  31925. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31926. */
  31927. get isStencilEnable(): boolean;
  31928. /** @hidden */
  31929. _prepareWorkingCanvas(): void;
  31930. /**
  31931. * Reset the texture cache to empty state
  31932. */
  31933. resetTextureCache(): void;
  31934. /**
  31935. * Gets an object containing information about the current webGL context
  31936. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31937. */
  31938. getGlInfo(): {
  31939. vendor: string;
  31940. renderer: string;
  31941. version: string;
  31942. };
  31943. /**
  31944. * Defines the hardware scaling level.
  31945. * By default the hardware scaling level is computed from the window device ratio.
  31946. * 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.
  31947. * @param level defines the level to use
  31948. */
  31949. setHardwareScalingLevel(level: number): void;
  31950. /**
  31951. * Gets the current hardware scaling level.
  31952. * By default the hardware scaling level is computed from the window device ratio.
  31953. * 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.
  31954. * @returns a number indicating the current hardware scaling level
  31955. */
  31956. getHardwareScalingLevel(): number;
  31957. /**
  31958. * Gets the list of loaded textures
  31959. * @returns an array containing all loaded textures
  31960. */
  31961. getLoadedTexturesCache(): InternalTexture[];
  31962. /**
  31963. * Gets the object containing all engine capabilities
  31964. * @returns the EngineCapabilities object
  31965. */
  31966. getCaps(): EngineCapabilities;
  31967. /**
  31968. * stop executing a render loop function and remove it from the execution array
  31969. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31970. */
  31971. stopRenderLoop(renderFunction?: () => void): void;
  31972. /** @hidden */
  31973. _renderLoop(): void;
  31974. /**
  31975. * Gets the HTML canvas attached with the current webGL context
  31976. * @returns a HTML canvas
  31977. */
  31978. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31979. /**
  31980. * Gets host window
  31981. * @returns the host window object
  31982. */
  31983. getHostWindow(): Nullable<Window>;
  31984. /**
  31985. * Gets the current render width
  31986. * @param useScreen defines if screen size must be used (or the current render target if any)
  31987. * @returns a number defining the current render width
  31988. */
  31989. getRenderWidth(useScreen?: boolean): number;
  31990. /**
  31991. * Gets the current render height
  31992. * @param useScreen defines if screen size must be used (or the current render target if any)
  31993. * @returns a number defining the current render height
  31994. */
  31995. getRenderHeight(useScreen?: boolean): number;
  31996. /**
  31997. * Can be used to override the current requestAnimationFrame requester.
  31998. * @hidden
  31999. */
  32000. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32001. /**
  32002. * Register and execute a render loop. The engine can have more than one render function
  32003. * @param renderFunction defines the function to continuously execute
  32004. */
  32005. runRenderLoop(renderFunction: () => void): void;
  32006. /**
  32007. * Clear the current render buffer or the current render target (if any is set up)
  32008. * @param color defines the color to use
  32009. * @param backBuffer defines if the back buffer must be cleared
  32010. * @param depth defines if the depth buffer must be cleared
  32011. * @param stencil defines if the stencil buffer must be cleared
  32012. */
  32013. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32014. private _viewportCached;
  32015. /** @hidden */
  32016. _viewport(x: number, y: number, width: number, height: number): void;
  32017. /**
  32018. * Set the WebGL's viewport
  32019. * @param viewport defines the viewport element to be used
  32020. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32021. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32022. */
  32023. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32024. /**
  32025. * Begin a new frame
  32026. */
  32027. beginFrame(): void;
  32028. /**
  32029. * Enf the current frame
  32030. */
  32031. endFrame(): void;
  32032. /**
  32033. * Resize the view according to the canvas' size
  32034. */
  32035. resize(): void;
  32036. /**
  32037. * Force a specific size of the canvas
  32038. * @param width defines the new canvas' width
  32039. * @param height defines the new canvas' height
  32040. */
  32041. setSize(width: number, height: number): void;
  32042. /**
  32043. * Binds the frame buffer to the specified texture.
  32044. * @param texture The texture to render to or null for the default canvas
  32045. * @param faceIndex The face of the texture to render to in case of cube texture
  32046. * @param requiredWidth The width of the target to render to
  32047. * @param requiredHeight The height of the target to render to
  32048. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32049. * @param depthStencilTexture The depth stencil texture to use to render
  32050. * @param lodLevel defines le lod level to bind to the frame buffer
  32051. */
  32052. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  32053. /** @hidden */
  32054. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32055. /**
  32056. * Unbind the current render target texture from the webGL context
  32057. * @param texture defines the render target texture to unbind
  32058. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32059. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32060. */
  32061. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32062. /**
  32063. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32064. */
  32065. flushFramebuffer(): void;
  32066. /**
  32067. * Unbind the current render target and bind the default framebuffer
  32068. */
  32069. restoreDefaultFramebuffer(): void;
  32070. /** @hidden */
  32071. protected _resetVertexBufferBinding(): void;
  32072. /**
  32073. * Creates a vertex buffer
  32074. * @param data the data for the vertex buffer
  32075. * @returns the new WebGL static buffer
  32076. */
  32077. createVertexBuffer(data: DataArray): DataBuffer;
  32078. private _createVertexBuffer;
  32079. /**
  32080. * Creates a dynamic vertex buffer
  32081. * @param data the data for the dynamic vertex buffer
  32082. * @returns the new WebGL dynamic buffer
  32083. */
  32084. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32085. protected _resetIndexBufferBinding(): void;
  32086. /**
  32087. * Creates a new index buffer
  32088. * @param indices defines the content of the index buffer
  32089. * @param updatable defines if the index buffer must be updatable
  32090. * @returns a new webGL buffer
  32091. */
  32092. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32093. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32094. /**
  32095. * Bind a webGL buffer to the webGL context
  32096. * @param buffer defines the buffer to bind
  32097. */
  32098. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32099. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32100. private bindBuffer;
  32101. /**
  32102. * update the bound buffer with the given data
  32103. * @param data defines the data to update
  32104. */
  32105. updateArrayBuffer(data: Float32Array): void;
  32106. private _vertexAttribPointer;
  32107. private _bindIndexBufferWithCache;
  32108. private _bindVertexBuffersAttributes;
  32109. /**
  32110. * Records a vertex array object
  32111. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32112. * @param vertexBuffers defines the list of vertex buffers to store
  32113. * @param indexBuffer defines the index buffer to store
  32114. * @param effect defines the effect to store
  32115. * @returns the new vertex array object
  32116. */
  32117. recordVertexArrayObject(vertexBuffers: {
  32118. [key: string]: VertexBuffer;
  32119. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32120. /**
  32121. * Bind a specific vertex array object
  32122. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32123. * @param vertexArrayObject defines the vertex array object to bind
  32124. * @param indexBuffer defines the index buffer to bind
  32125. */
  32126. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32127. /**
  32128. * Bind webGl buffers directly to the webGL context
  32129. * @param vertexBuffer defines the vertex buffer to bind
  32130. * @param indexBuffer defines the index buffer to bind
  32131. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32132. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32133. * @param effect defines the effect associated with the vertex buffer
  32134. */
  32135. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32136. private _unbindVertexArrayObject;
  32137. /**
  32138. * Bind a list of vertex buffers to the webGL context
  32139. * @param vertexBuffers defines the list of vertex buffers to bind
  32140. * @param indexBuffer defines the index buffer to bind
  32141. * @param effect defines the effect associated with the vertex buffers
  32142. */
  32143. bindBuffers(vertexBuffers: {
  32144. [key: string]: Nullable<VertexBuffer>;
  32145. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32146. /**
  32147. * Unbind all instance attributes
  32148. */
  32149. unbindInstanceAttributes(): void;
  32150. /**
  32151. * Release and free the memory of a vertex array object
  32152. * @param vao defines the vertex array object to delete
  32153. */
  32154. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32155. /** @hidden */
  32156. _releaseBuffer(buffer: DataBuffer): boolean;
  32157. protected _deleteBuffer(buffer: DataBuffer): void;
  32158. /**
  32159. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32160. * @param instancesBuffer defines the webGL buffer to update and bind
  32161. * @param data defines the data to store in the buffer
  32162. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32163. */
  32164. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32165. /**
  32166. * Bind the content of a webGL buffer used with instanciation
  32167. * @param instancesBuffer defines the webGL buffer to bind
  32168. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32169. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32170. */
  32171. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32172. /**
  32173. * Disable the instance attribute corresponding to the name in parameter
  32174. * @param name defines the name of the attribute to disable
  32175. */
  32176. disableInstanceAttributeByName(name: string): void;
  32177. /**
  32178. * Disable the instance attribute corresponding to the location in parameter
  32179. * @param attributeLocation defines the attribute location of the attribute to disable
  32180. */
  32181. disableInstanceAttribute(attributeLocation: number): void;
  32182. /**
  32183. * Disable the attribute corresponding to the location in parameter
  32184. * @param attributeLocation defines the attribute location of the attribute to disable
  32185. */
  32186. disableAttributeByIndex(attributeLocation: number): void;
  32187. /**
  32188. * Send a draw order
  32189. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32190. * @param indexStart defines the starting index
  32191. * @param indexCount defines the number of index to draw
  32192. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32193. */
  32194. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32195. /**
  32196. * Draw a list of points
  32197. * @param verticesStart defines the index of first vertex to draw
  32198. * @param verticesCount defines the count of vertices to draw
  32199. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32200. */
  32201. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32202. /**
  32203. * Draw a list of unindexed primitives
  32204. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32205. * @param verticesStart defines the index of first vertex to draw
  32206. * @param verticesCount defines the count of vertices to draw
  32207. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32208. */
  32209. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32210. /**
  32211. * Draw a list of indexed primitives
  32212. * @param fillMode defines the primitive to use
  32213. * @param indexStart defines the starting index
  32214. * @param indexCount defines the number of index to draw
  32215. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32216. */
  32217. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32218. /**
  32219. * Draw a list of unindexed primitives
  32220. * @param fillMode defines the primitive to use
  32221. * @param verticesStart defines the index of first vertex to draw
  32222. * @param verticesCount defines the count of vertices to draw
  32223. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32224. */
  32225. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32226. private _drawMode;
  32227. /** @hidden */
  32228. protected _reportDrawCall(): void;
  32229. /** @hidden */
  32230. _releaseEffect(effect: Effect): void;
  32231. /** @hidden */
  32232. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32233. /**
  32234. * Create a new effect (used to store vertex/fragment shaders)
  32235. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32236. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32237. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32238. * @param samplers defines an array of string used to represent textures
  32239. * @param defines defines the string containing the defines to use to compile the shaders
  32240. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32241. * @param onCompiled defines a function to call when the effect creation is successful
  32242. * @param onError defines a function to call when the effect creation has failed
  32243. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32244. * @returns the new Effect
  32245. */
  32246. 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;
  32247. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32248. private _compileShader;
  32249. private _compileRawShader;
  32250. /**
  32251. * Directly creates a webGL program
  32252. * @param pipelineContext defines the pipeline context to attach to
  32253. * @param vertexCode defines the vertex shader code to use
  32254. * @param fragmentCode defines the fragment shader code to use
  32255. * @param context defines the webGL context to use (if not set, the current one will be used)
  32256. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32257. * @returns the new webGL program
  32258. */
  32259. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32260. /**
  32261. * Creates a webGL program
  32262. * @param pipelineContext defines the pipeline context to attach to
  32263. * @param vertexCode defines the vertex shader code to use
  32264. * @param fragmentCode defines the fragment shader code to use
  32265. * @param defines defines the string containing the defines to use to compile the shaders
  32266. * @param context defines the webGL context to use (if not set, the current one will be used)
  32267. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32268. * @returns the new webGL program
  32269. */
  32270. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32271. /**
  32272. * Creates a new pipeline context
  32273. * @returns the new pipeline
  32274. */
  32275. createPipelineContext(): IPipelineContext;
  32276. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32277. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32278. /** @hidden */
  32279. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32280. /** @hidden */
  32281. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32282. /** @hidden */
  32283. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32284. /**
  32285. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32286. * @param pipelineContext defines the pipeline context to use
  32287. * @param uniformsNames defines the list of uniform names
  32288. * @returns an array of webGL uniform locations
  32289. */
  32290. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32291. /**
  32292. * Gets the lsit of active attributes for a given webGL program
  32293. * @param pipelineContext defines the pipeline context to use
  32294. * @param attributesNames defines the list of attribute names to get
  32295. * @returns an array of indices indicating the offset of each attribute
  32296. */
  32297. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32298. /**
  32299. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32300. * @param effect defines the effect to activate
  32301. */
  32302. enableEffect(effect: Nullable<Effect>): void;
  32303. /**
  32304. * Set the value of an uniform to a number (int)
  32305. * @param uniform defines the webGL uniform location where to store the value
  32306. * @param value defines the int number to store
  32307. */
  32308. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32309. /**
  32310. * Set the value of an uniform to an array of int32
  32311. * @param uniform defines the webGL uniform location where to store the value
  32312. * @param array defines the array of int32 to store
  32313. */
  32314. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32315. /**
  32316. * Set the value of an uniform to an array of int32 (stored as vec2)
  32317. * @param uniform defines the webGL uniform location where to store the value
  32318. * @param array defines the array of int32 to store
  32319. */
  32320. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32321. /**
  32322. * Set the value of an uniform to an array of int32 (stored as vec3)
  32323. * @param uniform defines the webGL uniform location where to store the value
  32324. * @param array defines the array of int32 to store
  32325. */
  32326. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32327. /**
  32328. * Set the value of an uniform to an array of int32 (stored as vec4)
  32329. * @param uniform defines the webGL uniform location where to store the value
  32330. * @param array defines the array of int32 to store
  32331. */
  32332. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32333. /**
  32334. * Set the value of an uniform to an array of number
  32335. * @param uniform defines the webGL uniform location where to store the value
  32336. * @param array defines the array of number to store
  32337. */
  32338. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32339. /**
  32340. * Set the value of an uniform to an array of number (stored as vec2)
  32341. * @param uniform defines the webGL uniform location where to store the value
  32342. * @param array defines the array of number to store
  32343. */
  32344. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32345. /**
  32346. * Set the value of an uniform to an array of number (stored as vec3)
  32347. * @param uniform defines the webGL uniform location where to store the value
  32348. * @param array defines the array of number to store
  32349. */
  32350. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32351. /**
  32352. * Set the value of an uniform to an array of number (stored as vec4)
  32353. * @param uniform defines the webGL uniform location where to store the value
  32354. * @param array defines the array of number to store
  32355. */
  32356. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32357. /**
  32358. * Set the value of an uniform to an array of float32 (stored as matrices)
  32359. * @param uniform defines the webGL uniform location where to store the value
  32360. * @param matrices defines the array of float32 to store
  32361. */
  32362. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32363. /**
  32364. * Set the value of an uniform to a matrix (3x3)
  32365. * @param uniform defines the webGL uniform location where to store the value
  32366. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32367. */
  32368. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32369. /**
  32370. * Set the value of an uniform to a matrix (2x2)
  32371. * @param uniform defines the webGL uniform location where to store the value
  32372. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32373. */
  32374. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32375. /**
  32376. * Set the value of an uniform to a number (float)
  32377. * @param uniform defines the webGL uniform location where to store the value
  32378. * @param value defines the float number to store
  32379. */
  32380. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32381. /**
  32382. * Set the value of an uniform to a vec2
  32383. * @param uniform defines the webGL uniform location where to store the value
  32384. * @param x defines the 1st component of the value
  32385. * @param y defines the 2nd component of the value
  32386. */
  32387. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32388. /**
  32389. * Set the value of an uniform to a vec3
  32390. * @param uniform defines the webGL uniform location where to store the value
  32391. * @param x defines the 1st component of the value
  32392. * @param y defines the 2nd component of the value
  32393. * @param z defines the 3rd component of the value
  32394. */
  32395. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32396. /**
  32397. * Set the value of an uniform to a vec4
  32398. * @param uniform defines the webGL uniform location where to store the value
  32399. * @param x defines the 1st component of the value
  32400. * @param y defines the 2nd component of the value
  32401. * @param z defines the 3rd component of the value
  32402. * @param w defines the 4th component of the value
  32403. */
  32404. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32405. /**
  32406. * Apply all cached states (depth, culling, stencil and alpha)
  32407. */
  32408. applyStates(): void;
  32409. /**
  32410. * Enable or disable color writing
  32411. * @param enable defines the state to set
  32412. */
  32413. setColorWrite(enable: boolean): void;
  32414. /**
  32415. * Gets a boolean indicating if color writing is enabled
  32416. * @returns the current color writing state
  32417. */
  32418. getColorWrite(): boolean;
  32419. /**
  32420. * Gets the depth culling state manager
  32421. */
  32422. get depthCullingState(): DepthCullingState;
  32423. /**
  32424. * Gets the alpha state manager
  32425. */
  32426. get alphaState(): AlphaState;
  32427. /**
  32428. * Gets the stencil state manager
  32429. */
  32430. get stencilState(): StencilState;
  32431. /**
  32432. * Clears the list of texture accessible through engine.
  32433. * This can help preventing texture load conflict due to name collision.
  32434. */
  32435. clearInternalTexturesCache(): void;
  32436. /**
  32437. * Force the entire cache to be cleared
  32438. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32439. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32440. */
  32441. wipeCaches(bruteForce?: boolean): void;
  32442. /** @hidden */
  32443. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32444. min: number;
  32445. mag: number;
  32446. };
  32447. /** @hidden */
  32448. _createTexture(): WebGLTexture;
  32449. /**
  32450. * Usually called from Texture.ts.
  32451. * Passed information to create a WebGLTexture
  32452. * @param urlArg defines a value which contains one of the following:
  32453. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32454. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32455. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32456. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32457. * @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)
  32458. * @param scene needed for loading to the correct scene
  32459. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32460. * @param onLoad optional callback to be called upon successful completion
  32461. * @param onError optional callback to be called upon failure
  32462. * @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
  32463. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32464. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32465. * @param forcedExtension defines the extension to use to pick the right loader
  32466. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32467. * @param mimeType defines an optional mime type
  32468. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32469. */
  32470. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32471. /**
  32472. * Loads an image as an HTMLImageElement.
  32473. * @param input url string, ArrayBuffer, or Blob to load
  32474. * @param onLoad callback called when the image successfully loads
  32475. * @param onError callback called when the image fails to load
  32476. * @param offlineProvider offline provider for caching
  32477. * @param mimeType optional mime type
  32478. * @returns the HTMLImageElement of the loaded image
  32479. * @hidden
  32480. */
  32481. 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>;
  32482. /**
  32483. * @hidden
  32484. */
  32485. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32486. /**
  32487. * Creates a raw texture
  32488. * @param data defines the data to store in the texture
  32489. * @param width defines the width of the texture
  32490. * @param height defines the height of the texture
  32491. * @param format defines the format of the data
  32492. * @param generateMipMaps defines if the engine should generate the mip levels
  32493. * @param invertY defines if data must be stored with Y axis inverted
  32494. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32495. * @param compression defines the compression used (null by default)
  32496. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32497. * @returns the raw texture inside an InternalTexture
  32498. */
  32499. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32500. /**
  32501. * Creates a new raw cube texture
  32502. * @param data defines the array of data to use to create each face
  32503. * @param size defines the size of the textures
  32504. * @param format defines the format of the data
  32505. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32506. * @param generateMipMaps defines if the engine should generate the mip levels
  32507. * @param invertY defines if data must be stored with Y axis inverted
  32508. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32509. * @param compression defines the compression used (null by default)
  32510. * @returns the cube texture as an InternalTexture
  32511. */
  32512. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32513. /**
  32514. * Creates a new raw 3D texture
  32515. * @param data defines the data used to create the texture
  32516. * @param width defines the width of the texture
  32517. * @param height defines the height of the texture
  32518. * @param depth defines the depth of the texture
  32519. * @param format defines the format of the texture
  32520. * @param generateMipMaps defines if the engine must generate mip levels
  32521. * @param invertY defines if data must be stored with Y axis inverted
  32522. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32523. * @param compression defines the compressed used (can be null)
  32524. * @param textureType defines the compressed used (can be null)
  32525. * @returns a new raw 3D texture (stored in an InternalTexture)
  32526. */
  32527. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32528. /**
  32529. * Creates a new raw 2D array texture
  32530. * @param data defines the data used to create the texture
  32531. * @param width defines the width of the texture
  32532. * @param height defines the height of the texture
  32533. * @param depth defines the number of layers of the texture
  32534. * @param format defines the format of the texture
  32535. * @param generateMipMaps defines if the engine must generate mip levels
  32536. * @param invertY defines if data must be stored with Y axis inverted
  32537. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32538. * @param compression defines the compressed used (can be null)
  32539. * @param textureType defines the compressed used (can be null)
  32540. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32541. */
  32542. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32543. private _unpackFlipYCached;
  32544. /**
  32545. * In case you are sharing the context with other applications, it might
  32546. * be interested to not cache the unpack flip y state to ensure a consistent
  32547. * value would be set.
  32548. */
  32549. enableUnpackFlipYCached: boolean;
  32550. /** @hidden */
  32551. _unpackFlipY(value: boolean): void;
  32552. /** @hidden */
  32553. _getUnpackAlignement(): number;
  32554. private _getTextureTarget;
  32555. /**
  32556. * Update the sampling mode of a given texture
  32557. * @param samplingMode defines the required sampling mode
  32558. * @param texture defines the texture to update
  32559. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32560. */
  32561. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32562. /**
  32563. * Update the sampling mode of a given texture
  32564. * @param texture defines the texture to update
  32565. * @param wrapU defines the texture wrap mode of the u coordinates
  32566. * @param wrapV defines the texture wrap mode of the v coordinates
  32567. * @param wrapR defines the texture wrap mode of the r coordinates
  32568. */
  32569. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32570. /** @hidden */
  32571. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32572. width: number;
  32573. height: number;
  32574. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32575. /** @hidden */
  32576. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32577. /** @hidden */
  32578. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32579. /** @hidden */
  32580. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32581. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32582. private _prepareWebGLTexture;
  32583. /** @hidden */
  32584. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32585. private _getDepthStencilBuffer;
  32586. /** @hidden */
  32587. _releaseFramebufferObjects(texture: InternalTexture): void;
  32588. /** @hidden */
  32589. _releaseTexture(texture: InternalTexture): void;
  32590. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32591. protected _setProgram(program: WebGLProgram): void;
  32592. protected _boundUniforms: {
  32593. [key: number]: WebGLUniformLocation;
  32594. };
  32595. /**
  32596. * Binds an effect to the webGL context
  32597. * @param effect defines the effect to bind
  32598. */
  32599. bindSamplers(effect: Effect): void;
  32600. private _activateCurrentTexture;
  32601. /** @hidden */
  32602. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32603. /** @hidden */
  32604. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32605. /**
  32606. * Unbind all textures from the webGL context
  32607. */
  32608. unbindAllTextures(): void;
  32609. /**
  32610. * Sets a texture to the according uniform.
  32611. * @param channel The texture channel
  32612. * @param uniform The uniform to set
  32613. * @param texture The texture to apply
  32614. */
  32615. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32616. private _bindSamplerUniformToChannel;
  32617. private _getTextureWrapMode;
  32618. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32619. /**
  32620. * Sets an array of texture to the webGL context
  32621. * @param channel defines the channel where the texture array must be set
  32622. * @param uniform defines the associated uniform location
  32623. * @param textures defines the array of textures to bind
  32624. */
  32625. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32626. /** @hidden */
  32627. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32628. private _setTextureParameterFloat;
  32629. private _setTextureParameterInteger;
  32630. /**
  32631. * Unbind all vertex attributes from the webGL context
  32632. */
  32633. unbindAllAttributes(): void;
  32634. /**
  32635. * 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
  32636. */
  32637. releaseEffects(): void;
  32638. /**
  32639. * Dispose and release all associated resources
  32640. */
  32641. dispose(): void;
  32642. /**
  32643. * Attach a new callback raised when context lost event is fired
  32644. * @param callback defines the callback to call
  32645. */
  32646. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32647. /**
  32648. * Attach a new callback raised when context restored event is fired
  32649. * @param callback defines the callback to call
  32650. */
  32651. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32652. /**
  32653. * Get the current error code of the webGL context
  32654. * @returns the error code
  32655. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32656. */
  32657. getError(): number;
  32658. private _canRenderToFloatFramebuffer;
  32659. private _canRenderToHalfFloatFramebuffer;
  32660. private _canRenderToFramebuffer;
  32661. /** @hidden */
  32662. _getWebGLTextureType(type: number): number;
  32663. /** @hidden */
  32664. _getInternalFormat(format: number): number;
  32665. /** @hidden */
  32666. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32667. /** @hidden */
  32668. _getRGBAMultiSampleBufferFormat(type: number): number;
  32669. /** @hidden */
  32670. _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;
  32671. /**
  32672. * Loads a file from a url
  32673. * @param url url to load
  32674. * @param onSuccess callback called when the file successfully loads
  32675. * @param onProgress callback called while file is loading (if the server supports this mode)
  32676. * @param offlineProvider defines the offline provider for caching
  32677. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32678. * @param onError callback called when the file fails to load
  32679. * @returns a file request object
  32680. * @hidden
  32681. */
  32682. 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;
  32683. /**
  32684. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32685. * @param x defines the x coordinate of the rectangle where pixels must be read
  32686. * @param y defines the y coordinate of the rectangle where pixels must be read
  32687. * @param width defines the width of the rectangle where pixels must be read
  32688. * @param height defines the height of the rectangle where pixels must be read
  32689. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32690. * @returns a Uint8Array containing RGBA colors
  32691. */
  32692. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32693. private static _isSupported;
  32694. /**
  32695. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32696. * @returns true if the engine can be created
  32697. * @ignorenaming
  32698. */
  32699. static isSupported(): boolean;
  32700. /**
  32701. * Find the next highest power of two.
  32702. * @param x Number to start search from.
  32703. * @return Next highest power of two.
  32704. */
  32705. static CeilingPOT(x: number): number;
  32706. /**
  32707. * Find the next lowest power of two.
  32708. * @param x Number to start search from.
  32709. * @return Next lowest power of two.
  32710. */
  32711. static FloorPOT(x: number): number;
  32712. /**
  32713. * Find the nearest power of two.
  32714. * @param x Number to start search from.
  32715. * @return Next nearest power of two.
  32716. */
  32717. static NearestPOT(x: number): number;
  32718. /**
  32719. * Get the closest exponent of two
  32720. * @param value defines the value to approximate
  32721. * @param max defines the maximum value to return
  32722. * @param mode defines how to define the closest value
  32723. * @returns closest exponent of two of the given value
  32724. */
  32725. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32726. /**
  32727. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32728. * @param func - the function to be called
  32729. * @param requester - the object that will request the next frame. Falls back to window.
  32730. * @returns frame number
  32731. */
  32732. static QueueNewFrame(func: () => void, requester?: any): number;
  32733. /**
  32734. * Gets host document
  32735. * @returns the host document object
  32736. */
  32737. getHostDocument(): Nullable<Document>;
  32738. }
  32739. }
  32740. declare module "babylonjs/Maths/sphericalPolynomial" {
  32741. import { Vector3 } from "babylonjs/Maths/math.vector";
  32742. import { Color3 } from "babylonjs/Maths/math.color";
  32743. /**
  32744. * Class representing spherical harmonics coefficients to the 3rd degree
  32745. */
  32746. export class SphericalHarmonics {
  32747. /**
  32748. * Defines whether or not the harmonics have been prescaled for rendering.
  32749. */
  32750. preScaled: boolean;
  32751. /**
  32752. * The l0,0 coefficients of the spherical harmonics
  32753. */
  32754. l00: Vector3;
  32755. /**
  32756. * The l1,-1 coefficients of the spherical harmonics
  32757. */
  32758. l1_1: Vector3;
  32759. /**
  32760. * The l1,0 coefficients of the spherical harmonics
  32761. */
  32762. l10: Vector3;
  32763. /**
  32764. * The l1,1 coefficients of the spherical harmonics
  32765. */
  32766. l11: Vector3;
  32767. /**
  32768. * The l2,-2 coefficients of the spherical harmonics
  32769. */
  32770. l2_2: Vector3;
  32771. /**
  32772. * The l2,-1 coefficients of the spherical harmonics
  32773. */
  32774. l2_1: Vector3;
  32775. /**
  32776. * The l2,0 coefficients of the spherical harmonics
  32777. */
  32778. l20: Vector3;
  32779. /**
  32780. * The l2,1 coefficients of the spherical harmonics
  32781. */
  32782. l21: Vector3;
  32783. /**
  32784. * The l2,2 coefficients of the spherical harmonics
  32785. */
  32786. l22: Vector3;
  32787. /**
  32788. * Adds a light to the spherical harmonics
  32789. * @param direction the direction of the light
  32790. * @param color the color of the light
  32791. * @param deltaSolidAngle the delta solid angle of the light
  32792. */
  32793. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32794. /**
  32795. * Scales the spherical harmonics by the given amount
  32796. * @param scale the amount to scale
  32797. */
  32798. scaleInPlace(scale: number): void;
  32799. /**
  32800. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32801. *
  32802. * ```
  32803. * E_lm = A_l * L_lm
  32804. * ```
  32805. *
  32806. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32807. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32808. * the scaling factors are given in equation 9.
  32809. */
  32810. convertIncidentRadianceToIrradiance(): void;
  32811. /**
  32812. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32813. *
  32814. * ```
  32815. * L = (1/pi) * E * rho
  32816. * ```
  32817. *
  32818. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32819. */
  32820. convertIrradianceToLambertianRadiance(): void;
  32821. /**
  32822. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32823. * required operations at run time.
  32824. *
  32825. * This is simply done by scaling back the SH with Ylm constants parameter.
  32826. * The trigonometric part being applied by the shader at run time.
  32827. */
  32828. preScaleForRendering(): void;
  32829. /**
  32830. * Constructs a spherical harmonics from an array.
  32831. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32832. * @returns the spherical harmonics
  32833. */
  32834. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32835. /**
  32836. * Gets the spherical harmonics from polynomial
  32837. * @param polynomial the spherical polynomial
  32838. * @returns the spherical harmonics
  32839. */
  32840. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32841. }
  32842. /**
  32843. * Class representing spherical polynomial coefficients to the 3rd degree
  32844. */
  32845. export class SphericalPolynomial {
  32846. private _harmonics;
  32847. /**
  32848. * The spherical harmonics used to create the polynomials.
  32849. */
  32850. get preScaledHarmonics(): SphericalHarmonics;
  32851. /**
  32852. * The x coefficients of the spherical polynomial
  32853. */
  32854. x: Vector3;
  32855. /**
  32856. * The y coefficients of the spherical polynomial
  32857. */
  32858. y: Vector3;
  32859. /**
  32860. * The z coefficients of the spherical polynomial
  32861. */
  32862. z: Vector3;
  32863. /**
  32864. * The xx coefficients of the spherical polynomial
  32865. */
  32866. xx: Vector3;
  32867. /**
  32868. * The yy coefficients of the spherical polynomial
  32869. */
  32870. yy: Vector3;
  32871. /**
  32872. * The zz coefficients of the spherical polynomial
  32873. */
  32874. zz: Vector3;
  32875. /**
  32876. * The xy coefficients of the spherical polynomial
  32877. */
  32878. xy: Vector3;
  32879. /**
  32880. * The yz coefficients of the spherical polynomial
  32881. */
  32882. yz: Vector3;
  32883. /**
  32884. * The zx coefficients of the spherical polynomial
  32885. */
  32886. zx: Vector3;
  32887. /**
  32888. * Adds an ambient color to the spherical polynomial
  32889. * @param color the color to add
  32890. */
  32891. addAmbient(color: Color3): void;
  32892. /**
  32893. * Scales the spherical polynomial by the given amount
  32894. * @param scale the amount to scale
  32895. */
  32896. scaleInPlace(scale: number): void;
  32897. /**
  32898. * Gets the spherical polynomial from harmonics
  32899. * @param harmonics the spherical harmonics
  32900. * @returns the spherical polynomial
  32901. */
  32902. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32903. /**
  32904. * Constructs a spherical polynomial from an array.
  32905. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32906. * @returns the spherical polynomial
  32907. */
  32908. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32909. }
  32910. }
  32911. declare module "babylonjs/Materials/Textures/internalTexture" {
  32912. import { Observable } from "babylonjs/Misc/observable";
  32913. import { Nullable, int } from "babylonjs/types";
  32914. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32916. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32917. /**
  32918. * Defines the source of the internal texture
  32919. */
  32920. export enum InternalTextureSource {
  32921. /**
  32922. * The source of the texture data is unknown
  32923. */
  32924. Unknown = 0,
  32925. /**
  32926. * Texture data comes from an URL
  32927. */
  32928. Url = 1,
  32929. /**
  32930. * Texture data is only used for temporary storage
  32931. */
  32932. Temp = 2,
  32933. /**
  32934. * Texture data comes from raw data (ArrayBuffer)
  32935. */
  32936. Raw = 3,
  32937. /**
  32938. * Texture content is dynamic (video or dynamic texture)
  32939. */
  32940. Dynamic = 4,
  32941. /**
  32942. * Texture content is generated by rendering to it
  32943. */
  32944. RenderTarget = 5,
  32945. /**
  32946. * Texture content is part of a multi render target process
  32947. */
  32948. MultiRenderTarget = 6,
  32949. /**
  32950. * Texture data comes from a cube data file
  32951. */
  32952. Cube = 7,
  32953. /**
  32954. * Texture data comes from a raw cube data
  32955. */
  32956. CubeRaw = 8,
  32957. /**
  32958. * Texture data come from a prefiltered cube data file
  32959. */
  32960. CubePrefiltered = 9,
  32961. /**
  32962. * Texture content is raw 3D data
  32963. */
  32964. Raw3D = 10,
  32965. /**
  32966. * Texture content is raw 2D array data
  32967. */
  32968. Raw2DArray = 11,
  32969. /**
  32970. * Texture content is a depth texture
  32971. */
  32972. Depth = 12,
  32973. /**
  32974. * Texture data comes from a raw cube data encoded with RGBD
  32975. */
  32976. CubeRawRGBD = 13
  32977. }
  32978. /**
  32979. * Class used to store data associated with WebGL texture data for the engine
  32980. * This class should not be used directly
  32981. */
  32982. export class InternalTexture {
  32983. /** @hidden */
  32984. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32985. /**
  32986. * Defines if the texture is ready
  32987. */
  32988. isReady: boolean;
  32989. /**
  32990. * Defines if the texture is a cube texture
  32991. */
  32992. isCube: boolean;
  32993. /**
  32994. * Defines if the texture contains 3D data
  32995. */
  32996. is3D: boolean;
  32997. /**
  32998. * Defines if the texture contains 2D array data
  32999. */
  33000. is2DArray: boolean;
  33001. /**
  33002. * Defines if the texture contains multiview data
  33003. */
  33004. isMultiview: boolean;
  33005. /**
  33006. * Gets the URL used to load this texture
  33007. */
  33008. url: string;
  33009. /**
  33010. * Gets the sampling mode of the texture
  33011. */
  33012. samplingMode: number;
  33013. /**
  33014. * Gets a boolean indicating if the texture needs mipmaps generation
  33015. */
  33016. generateMipMaps: boolean;
  33017. /**
  33018. * Gets the number of samples used by the texture (WebGL2+ only)
  33019. */
  33020. samples: number;
  33021. /**
  33022. * Gets the type of the texture (int, float...)
  33023. */
  33024. type: number;
  33025. /**
  33026. * Gets the format of the texture (RGB, RGBA...)
  33027. */
  33028. format: number;
  33029. /**
  33030. * Observable called when the texture is loaded
  33031. */
  33032. onLoadedObservable: Observable<InternalTexture>;
  33033. /**
  33034. * Gets the width of the texture
  33035. */
  33036. width: number;
  33037. /**
  33038. * Gets the height of the texture
  33039. */
  33040. height: number;
  33041. /**
  33042. * Gets the depth of the texture
  33043. */
  33044. depth: number;
  33045. /**
  33046. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33047. */
  33048. baseWidth: number;
  33049. /**
  33050. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33051. */
  33052. baseHeight: number;
  33053. /**
  33054. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33055. */
  33056. baseDepth: number;
  33057. /**
  33058. * Gets a boolean indicating if the texture is inverted on Y axis
  33059. */
  33060. invertY: boolean;
  33061. /** @hidden */
  33062. _invertVScale: boolean;
  33063. /** @hidden */
  33064. _associatedChannel: number;
  33065. /** @hidden */
  33066. _source: InternalTextureSource;
  33067. /** @hidden */
  33068. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33069. /** @hidden */
  33070. _bufferView: Nullable<ArrayBufferView>;
  33071. /** @hidden */
  33072. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33073. /** @hidden */
  33074. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33075. /** @hidden */
  33076. _size: number;
  33077. /** @hidden */
  33078. _extension: string;
  33079. /** @hidden */
  33080. _files: Nullable<string[]>;
  33081. /** @hidden */
  33082. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33083. /** @hidden */
  33084. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33085. /** @hidden */
  33086. _framebuffer: Nullable<WebGLFramebuffer>;
  33087. /** @hidden */
  33088. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33089. /** @hidden */
  33090. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33091. /** @hidden */
  33092. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33093. /** @hidden */
  33094. _attachments: Nullable<number[]>;
  33095. /** @hidden */
  33096. _cachedCoordinatesMode: Nullable<number>;
  33097. /** @hidden */
  33098. _cachedWrapU: Nullable<number>;
  33099. /** @hidden */
  33100. _cachedWrapV: Nullable<number>;
  33101. /** @hidden */
  33102. _cachedWrapR: Nullable<number>;
  33103. /** @hidden */
  33104. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33105. /** @hidden */
  33106. _isDisabled: boolean;
  33107. /** @hidden */
  33108. _compression: Nullable<string>;
  33109. /** @hidden */
  33110. _generateStencilBuffer: boolean;
  33111. /** @hidden */
  33112. _generateDepthBuffer: boolean;
  33113. /** @hidden */
  33114. _comparisonFunction: number;
  33115. /** @hidden */
  33116. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33117. /** @hidden */
  33118. _lodGenerationScale: number;
  33119. /** @hidden */
  33120. _lodGenerationOffset: number;
  33121. /** @hidden */
  33122. _colorTextureArray: Nullable<WebGLTexture>;
  33123. /** @hidden */
  33124. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33125. /** @hidden */
  33126. _lodTextureHigh: Nullable<BaseTexture>;
  33127. /** @hidden */
  33128. _lodTextureMid: Nullable<BaseTexture>;
  33129. /** @hidden */
  33130. _lodTextureLow: Nullable<BaseTexture>;
  33131. /** @hidden */
  33132. _isRGBD: boolean;
  33133. /** @hidden */
  33134. _linearSpecularLOD: boolean;
  33135. /** @hidden */
  33136. _irradianceTexture: Nullable<BaseTexture>;
  33137. /** @hidden */
  33138. _webGLTexture: Nullable<WebGLTexture>;
  33139. /** @hidden */
  33140. _references: number;
  33141. private _engine;
  33142. /**
  33143. * Gets the Engine the texture belongs to.
  33144. * @returns The babylon engine
  33145. */
  33146. getEngine(): ThinEngine;
  33147. /**
  33148. * Gets the data source type of the texture
  33149. */
  33150. get source(): InternalTextureSource;
  33151. /**
  33152. * Creates a new InternalTexture
  33153. * @param engine defines the engine to use
  33154. * @param source defines the type of data that will be used
  33155. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33156. */
  33157. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33158. /**
  33159. * Increments the number of references (ie. the number of Texture that point to it)
  33160. */
  33161. incrementReferences(): void;
  33162. /**
  33163. * Change the size of the texture (not the size of the content)
  33164. * @param width defines the new width
  33165. * @param height defines the new height
  33166. * @param depth defines the new depth (1 by default)
  33167. */
  33168. updateSize(width: int, height: int, depth?: int): void;
  33169. /** @hidden */
  33170. _rebuild(): void;
  33171. /** @hidden */
  33172. _swapAndDie(target: InternalTexture): void;
  33173. /**
  33174. * Dispose the current allocated resources
  33175. */
  33176. dispose(): void;
  33177. }
  33178. }
  33179. declare module "babylonjs/Audio/analyser" {
  33180. import { Scene } from "babylonjs/scene";
  33181. /**
  33182. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33184. */
  33185. export class Analyser {
  33186. /**
  33187. * Gets or sets the smoothing
  33188. * @ignorenaming
  33189. */
  33190. SMOOTHING: number;
  33191. /**
  33192. * Gets or sets the FFT table size
  33193. * @ignorenaming
  33194. */
  33195. FFT_SIZE: number;
  33196. /**
  33197. * Gets or sets the bar graph amplitude
  33198. * @ignorenaming
  33199. */
  33200. BARGRAPHAMPLITUDE: number;
  33201. /**
  33202. * Gets or sets the position of the debug canvas
  33203. * @ignorenaming
  33204. */
  33205. DEBUGCANVASPOS: {
  33206. x: number;
  33207. y: number;
  33208. };
  33209. /**
  33210. * Gets or sets the debug canvas size
  33211. * @ignorenaming
  33212. */
  33213. DEBUGCANVASSIZE: {
  33214. width: number;
  33215. height: number;
  33216. };
  33217. private _byteFreqs;
  33218. private _byteTime;
  33219. private _floatFreqs;
  33220. private _webAudioAnalyser;
  33221. private _debugCanvas;
  33222. private _debugCanvasContext;
  33223. private _scene;
  33224. private _registerFunc;
  33225. private _audioEngine;
  33226. /**
  33227. * Creates a new analyser
  33228. * @param scene defines hosting scene
  33229. */
  33230. constructor(scene: Scene);
  33231. /**
  33232. * Get the number of data values you will have to play with for the visualization
  33233. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33234. * @returns a number
  33235. */
  33236. getFrequencyBinCount(): number;
  33237. /**
  33238. * Gets the current frequency data as a byte array
  33239. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33240. * @returns a Uint8Array
  33241. */
  33242. getByteFrequencyData(): Uint8Array;
  33243. /**
  33244. * Gets the current waveform as a byte array
  33245. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33246. * @returns a Uint8Array
  33247. */
  33248. getByteTimeDomainData(): Uint8Array;
  33249. /**
  33250. * Gets the current frequency data as a float array
  33251. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33252. * @returns a Float32Array
  33253. */
  33254. getFloatFrequencyData(): Float32Array;
  33255. /**
  33256. * Renders the debug canvas
  33257. */
  33258. drawDebugCanvas(): void;
  33259. /**
  33260. * Stops rendering the debug canvas and removes it
  33261. */
  33262. stopDebugCanvas(): void;
  33263. /**
  33264. * Connects two audio nodes
  33265. * @param inputAudioNode defines first node to connect
  33266. * @param outputAudioNode defines second node to connect
  33267. */
  33268. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33269. /**
  33270. * Releases all associated resources
  33271. */
  33272. dispose(): void;
  33273. }
  33274. }
  33275. declare module "babylonjs/Audio/audioEngine" {
  33276. import { IDisposable } from "babylonjs/scene";
  33277. import { Analyser } from "babylonjs/Audio/analyser";
  33278. import { Nullable } from "babylonjs/types";
  33279. import { Observable } from "babylonjs/Misc/observable";
  33280. /**
  33281. * This represents an audio engine and it is responsible
  33282. * to play, synchronize and analyse sounds throughout the application.
  33283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33284. */
  33285. export interface IAudioEngine extends IDisposable {
  33286. /**
  33287. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33288. */
  33289. readonly canUseWebAudio: boolean;
  33290. /**
  33291. * Gets the current AudioContext if available.
  33292. */
  33293. readonly audioContext: Nullable<AudioContext>;
  33294. /**
  33295. * The master gain node defines the global audio volume of your audio engine.
  33296. */
  33297. readonly masterGain: GainNode;
  33298. /**
  33299. * Gets whether or not mp3 are supported by your browser.
  33300. */
  33301. readonly isMP3supported: boolean;
  33302. /**
  33303. * Gets whether or not ogg are supported by your browser.
  33304. */
  33305. readonly isOGGsupported: boolean;
  33306. /**
  33307. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33308. * @ignoreNaming
  33309. */
  33310. WarnedWebAudioUnsupported: boolean;
  33311. /**
  33312. * Defines if the audio engine relies on a custom unlocked button.
  33313. * In this case, the embedded button will not be displayed.
  33314. */
  33315. useCustomUnlockedButton: boolean;
  33316. /**
  33317. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33318. */
  33319. readonly unlocked: boolean;
  33320. /**
  33321. * Event raised when audio has been unlocked on the browser.
  33322. */
  33323. onAudioUnlockedObservable: Observable<AudioEngine>;
  33324. /**
  33325. * Event raised when audio has been locked on the browser.
  33326. */
  33327. onAudioLockedObservable: Observable<AudioEngine>;
  33328. /**
  33329. * Flags the audio engine in Locked state.
  33330. * This happens due to new browser policies preventing audio to autoplay.
  33331. */
  33332. lock(): void;
  33333. /**
  33334. * Unlocks the audio engine once a user action has been done on the dom.
  33335. * This is helpful to resume play once browser policies have been satisfied.
  33336. */
  33337. unlock(): void;
  33338. }
  33339. /**
  33340. * This represents the default audio engine used in babylon.
  33341. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33343. */
  33344. export class AudioEngine implements IAudioEngine {
  33345. private _audioContext;
  33346. private _audioContextInitialized;
  33347. private _muteButton;
  33348. private _hostElement;
  33349. /**
  33350. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33351. */
  33352. canUseWebAudio: boolean;
  33353. /**
  33354. * The master gain node defines the global audio volume of your audio engine.
  33355. */
  33356. masterGain: GainNode;
  33357. /**
  33358. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33359. * @ignoreNaming
  33360. */
  33361. WarnedWebAudioUnsupported: boolean;
  33362. /**
  33363. * Gets whether or not mp3 are supported by your browser.
  33364. */
  33365. isMP3supported: boolean;
  33366. /**
  33367. * Gets whether or not ogg are supported by your browser.
  33368. */
  33369. isOGGsupported: boolean;
  33370. /**
  33371. * Gets whether audio has been unlocked on the device.
  33372. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33373. * a user interaction has happened.
  33374. */
  33375. unlocked: boolean;
  33376. /**
  33377. * Defines if the audio engine relies on a custom unlocked button.
  33378. * In this case, the embedded button will not be displayed.
  33379. */
  33380. useCustomUnlockedButton: boolean;
  33381. /**
  33382. * Event raised when audio has been unlocked on the browser.
  33383. */
  33384. onAudioUnlockedObservable: Observable<AudioEngine>;
  33385. /**
  33386. * Event raised when audio has been locked on the browser.
  33387. */
  33388. onAudioLockedObservable: Observable<AudioEngine>;
  33389. /**
  33390. * Gets the current AudioContext if available.
  33391. */
  33392. get audioContext(): Nullable<AudioContext>;
  33393. private _connectedAnalyser;
  33394. /**
  33395. * Instantiates a new audio engine.
  33396. *
  33397. * There should be only one per page as some browsers restrict the number
  33398. * of audio contexts you can create.
  33399. * @param hostElement defines the host element where to display the mute icon if necessary
  33400. */
  33401. constructor(hostElement?: Nullable<HTMLElement>);
  33402. /**
  33403. * Flags the audio engine in Locked state.
  33404. * This happens due to new browser policies preventing audio to autoplay.
  33405. */
  33406. lock(): void;
  33407. /**
  33408. * Unlocks the audio engine once a user action has been done on the dom.
  33409. * This is helpful to resume play once browser policies have been satisfied.
  33410. */
  33411. unlock(): void;
  33412. private _resumeAudioContext;
  33413. private _initializeAudioContext;
  33414. private _tryToRun;
  33415. private _triggerRunningState;
  33416. private _triggerSuspendedState;
  33417. private _displayMuteButton;
  33418. private _moveButtonToTopLeft;
  33419. private _onResize;
  33420. private _hideMuteButton;
  33421. /**
  33422. * Destroy and release the resources associated with the audio ccontext.
  33423. */
  33424. dispose(): void;
  33425. /**
  33426. * Gets the global volume sets on the master gain.
  33427. * @returns the global volume if set or -1 otherwise
  33428. */
  33429. getGlobalVolume(): number;
  33430. /**
  33431. * Sets the global volume of your experience (sets on the master gain).
  33432. * @param newVolume Defines the new global volume of the application
  33433. */
  33434. setGlobalVolume(newVolume: number): void;
  33435. /**
  33436. * Connect the audio engine to an audio analyser allowing some amazing
  33437. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33439. * @param analyser The analyser to connect to the engine
  33440. */
  33441. connectToAnalyser(analyser: Analyser): void;
  33442. }
  33443. }
  33444. declare module "babylonjs/Loading/loadingScreen" {
  33445. /**
  33446. * Interface used to present a loading screen while loading a scene
  33447. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33448. */
  33449. export interface ILoadingScreen {
  33450. /**
  33451. * Function called to display the loading screen
  33452. */
  33453. displayLoadingUI: () => void;
  33454. /**
  33455. * Function called to hide the loading screen
  33456. */
  33457. hideLoadingUI: () => void;
  33458. /**
  33459. * Gets or sets the color to use for the background
  33460. */
  33461. loadingUIBackgroundColor: string;
  33462. /**
  33463. * Gets or sets the text to display while loading
  33464. */
  33465. loadingUIText: string;
  33466. }
  33467. /**
  33468. * Class used for the default loading screen
  33469. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33470. */
  33471. export class DefaultLoadingScreen implements ILoadingScreen {
  33472. private _renderingCanvas;
  33473. private _loadingText;
  33474. private _loadingDivBackgroundColor;
  33475. private _loadingDiv;
  33476. private _loadingTextDiv;
  33477. /** Gets or sets the logo url to use for the default loading screen */
  33478. static DefaultLogoUrl: string;
  33479. /** Gets or sets the spinner url to use for the default loading screen */
  33480. static DefaultSpinnerUrl: string;
  33481. /**
  33482. * Creates a new default loading screen
  33483. * @param _renderingCanvas defines the canvas used to render the scene
  33484. * @param _loadingText defines the default text to display
  33485. * @param _loadingDivBackgroundColor defines the default background color
  33486. */
  33487. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33488. /**
  33489. * Function called to display the loading screen
  33490. */
  33491. displayLoadingUI(): void;
  33492. /**
  33493. * Function called to hide the loading screen
  33494. */
  33495. hideLoadingUI(): void;
  33496. /**
  33497. * Gets or sets the text to display while loading
  33498. */
  33499. set loadingUIText(text: string);
  33500. get loadingUIText(): string;
  33501. /**
  33502. * Gets or sets the color to use for the background
  33503. */
  33504. get loadingUIBackgroundColor(): string;
  33505. set loadingUIBackgroundColor(color: string);
  33506. private _resizeLoadingUI;
  33507. }
  33508. }
  33509. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33510. /**
  33511. * Interface for any object that can request an animation frame
  33512. */
  33513. export interface ICustomAnimationFrameRequester {
  33514. /**
  33515. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33516. */
  33517. renderFunction?: Function;
  33518. /**
  33519. * Called to request the next frame to render to
  33520. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33521. */
  33522. requestAnimationFrame: Function;
  33523. /**
  33524. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33525. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33526. */
  33527. requestID?: number;
  33528. }
  33529. }
  33530. declare module "babylonjs/Misc/performanceMonitor" {
  33531. /**
  33532. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33533. */
  33534. export class PerformanceMonitor {
  33535. private _enabled;
  33536. private _rollingFrameTime;
  33537. private _lastFrameTimeMs;
  33538. /**
  33539. * constructor
  33540. * @param frameSampleSize The number of samples required to saturate the sliding window
  33541. */
  33542. constructor(frameSampleSize?: number);
  33543. /**
  33544. * Samples current frame
  33545. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33546. */
  33547. sampleFrame(timeMs?: number): void;
  33548. /**
  33549. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33550. */
  33551. get averageFrameTime(): number;
  33552. /**
  33553. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33554. */
  33555. get averageFrameTimeVariance(): number;
  33556. /**
  33557. * Returns the frame time of the most recent frame
  33558. */
  33559. get instantaneousFrameTime(): number;
  33560. /**
  33561. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33562. */
  33563. get averageFPS(): number;
  33564. /**
  33565. * Returns the average framerate in frames per second using the most recent frame time
  33566. */
  33567. get instantaneousFPS(): number;
  33568. /**
  33569. * Returns true if enough samples have been taken to completely fill the sliding window
  33570. */
  33571. get isSaturated(): boolean;
  33572. /**
  33573. * Enables contributions to the sliding window sample set
  33574. */
  33575. enable(): void;
  33576. /**
  33577. * Disables contributions to the sliding window sample set
  33578. * Samples will not be interpolated over the disabled period
  33579. */
  33580. disable(): void;
  33581. /**
  33582. * Returns true if sampling is enabled
  33583. */
  33584. get isEnabled(): boolean;
  33585. /**
  33586. * Resets performance monitor
  33587. */
  33588. reset(): void;
  33589. }
  33590. /**
  33591. * RollingAverage
  33592. *
  33593. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33594. */
  33595. export class RollingAverage {
  33596. /**
  33597. * Current average
  33598. */
  33599. average: number;
  33600. /**
  33601. * Current variance
  33602. */
  33603. variance: number;
  33604. protected _samples: Array<number>;
  33605. protected _sampleCount: number;
  33606. protected _pos: number;
  33607. protected _m2: number;
  33608. /**
  33609. * constructor
  33610. * @param length The number of samples required to saturate the sliding window
  33611. */
  33612. constructor(length: number);
  33613. /**
  33614. * Adds a sample to the sample set
  33615. * @param v The sample value
  33616. */
  33617. add(v: number): void;
  33618. /**
  33619. * Returns previously added values or null if outside of history or outside the sliding window domain
  33620. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33621. * @return Value previously recorded with add() or null if outside of range
  33622. */
  33623. history(i: number): number;
  33624. /**
  33625. * Returns true if enough samples have been taken to completely fill the sliding window
  33626. * @return true if sample-set saturated
  33627. */
  33628. isSaturated(): boolean;
  33629. /**
  33630. * Resets the rolling average (equivalent to 0 samples taken so far)
  33631. */
  33632. reset(): void;
  33633. /**
  33634. * Wraps a value around the sample range boundaries
  33635. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33636. * @return Wrapped position in sample range
  33637. */
  33638. protected _wrapPosition(i: number): number;
  33639. }
  33640. }
  33641. declare module "babylonjs/Misc/perfCounter" {
  33642. /**
  33643. * This class is used to track a performance counter which is number based.
  33644. * The user has access to many properties which give statistics of different nature.
  33645. *
  33646. * The implementer can track two kinds of Performance Counter: time and count.
  33647. * 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.
  33648. * 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.
  33649. */
  33650. export class PerfCounter {
  33651. /**
  33652. * Gets or sets a global boolean to turn on and off all the counters
  33653. */
  33654. static Enabled: boolean;
  33655. /**
  33656. * Returns the smallest value ever
  33657. */
  33658. get min(): number;
  33659. /**
  33660. * Returns the biggest value ever
  33661. */
  33662. get max(): number;
  33663. /**
  33664. * Returns the average value since the performance counter is running
  33665. */
  33666. get average(): number;
  33667. /**
  33668. * Returns the average value of the last second the counter was monitored
  33669. */
  33670. get lastSecAverage(): number;
  33671. /**
  33672. * Returns the current value
  33673. */
  33674. get current(): number;
  33675. /**
  33676. * Gets the accumulated total
  33677. */
  33678. get total(): number;
  33679. /**
  33680. * Gets the total value count
  33681. */
  33682. get count(): number;
  33683. /**
  33684. * Creates a new counter
  33685. */
  33686. constructor();
  33687. /**
  33688. * Call this method to start monitoring a new frame.
  33689. * 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.
  33690. */
  33691. fetchNewFrame(): void;
  33692. /**
  33693. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33694. * @param newCount the count value to add to the monitored count
  33695. * @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.
  33696. */
  33697. addCount(newCount: number, fetchResult: boolean): void;
  33698. /**
  33699. * Start monitoring this performance counter
  33700. */
  33701. beginMonitoring(): void;
  33702. /**
  33703. * Compute the time lapsed since the previous beginMonitoring() call.
  33704. * @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
  33705. */
  33706. endMonitoring(newFrame?: boolean): void;
  33707. private _fetchResult;
  33708. private _startMonitoringTime;
  33709. private _min;
  33710. private _max;
  33711. private _average;
  33712. private _current;
  33713. private _totalValueCount;
  33714. private _totalAccumulated;
  33715. private _lastSecAverage;
  33716. private _lastSecAccumulated;
  33717. private _lastSecTime;
  33718. private _lastSecValueCount;
  33719. }
  33720. }
  33721. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33722. module "babylonjs/Engines/thinEngine" {
  33723. interface ThinEngine {
  33724. /**
  33725. * Sets alpha constants used by some alpha blending modes
  33726. * @param r defines the red component
  33727. * @param g defines the green component
  33728. * @param b defines the blue component
  33729. * @param a defines the alpha component
  33730. */
  33731. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33732. /**
  33733. * Sets the current alpha mode
  33734. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33735. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33736. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33737. */
  33738. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33739. /**
  33740. * Gets the current alpha mode
  33741. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33742. * @returns the current alpha mode
  33743. */
  33744. getAlphaMode(): number;
  33745. /**
  33746. * Sets the current alpha equation
  33747. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33748. */
  33749. setAlphaEquation(equation: number): void;
  33750. /**
  33751. * Gets the current alpha equation.
  33752. * @returns the current alpha equation
  33753. */
  33754. getAlphaEquation(): number;
  33755. }
  33756. }
  33757. }
  33758. declare module "babylonjs/Engines/engine" {
  33759. import { Observable } from "babylonjs/Misc/observable";
  33760. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33761. import { Scene } from "babylonjs/scene";
  33762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33763. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33764. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33765. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33766. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33767. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33768. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33769. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33770. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33771. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33772. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33773. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33774. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33775. import "babylonjs/Engines/Extensions/engine.alpha";
  33776. import { Material } from "babylonjs/Materials/material";
  33777. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33778. /**
  33779. * Defines the interface used by display changed events
  33780. */
  33781. export interface IDisplayChangedEventArgs {
  33782. /** Gets the vrDisplay object (if any) */
  33783. vrDisplay: Nullable<any>;
  33784. /** Gets a boolean indicating if webVR is supported */
  33785. vrSupported: boolean;
  33786. }
  33787. /**
  33788. * Defines the interface used by objects containing a viewport (like a camera)
  33789. */
  33790. interface IViewportOwnerLike {
  33791. /**
  33792. * Gets or sets the viewport
  33793. */
  33794. viewport: IViewportLike;
  33795. }
  33796. /**
  33797. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33798. */
  33799. export class Engine extends ThinEngine {
  33800. /** Defines that alpha blending is disabled */
  33801. static readonly ALPHA_DISABLE: number;
  33802. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33803. static readonly ALPHA_ADD: number;
  33804. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33805. static readonly ALPHA_COMBINE: number;
  33806. /** Defines that alpha blending to DEST - SRC * DEST */
  33807. static readonly ALPHA_SUBTRACT: number;
  33808. /** Defines that alpha blending to SRC * DEST */
  33809. static readonly ALPHA_MULTIPLY: number;
  33810. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33811. static readonly ALPHA_MAXIMIZED: number;
  33812. /** Defines that alpha blending to SRC + DEST */
  33813. static readonly ALPHA_ONEONE: number;
  33814. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33815. static readonly ALPHA_PREMULTIPLIED: number;
  33816. /**
  33817. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33818. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33819. */
  33820. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33821. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33822. static readonly ALPHA_INTERPOLATE: number;
  33823. /**
  33824. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33825. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33826. */
  33827. static readonly ALPHA_SCREENMODE: number;
  33828. /** Defines that the ressource is not delayed*/
  33829. static readonly DELAYLOADSTATE_NONE: number;
  33830. /** Defines that the ressource was successfully delay loaded */
  33831. static readonly DELAYLOADSTATE_LOADED: number;
  33832. /** Defines that the ressource is currently delay loading */
  33833. static readonly DELAYLOADSTATE_LOADING: number;
  33834. /** Defines that the ressource is delayed and has not started loading */
  33835. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33836. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33837. static readonly NEVER: number;
  33838. /** 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 */
  33839. static readonly ALWAYS: number;
  33840. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33841. static readonly LESS: number;
  33842. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33843. static readonly EQUAL: number;
  33844. /** 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 */
  33845. static readonly LEQUAL: number;
  33846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33847. static readonly GREATER: number;
  33848. /** 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 */
  33849. static readonly GEQUAL: number;
  33850. /** 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 */
  33851. static readonly NOTEQUAL: number;
  33852. /** Passed to stencilOperation to specify that stencil value must be kept */
  33853. static readonly KEEP: number;
  33854. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33855. static readonly REPLACE: number;
  33856. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33857. static readonly INCR: number;
  33858. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33859. static readonly DECR: number;
  33860. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33861. static readonly INVERT: number;
  33862. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33863. static readonly INCR_WRAP: number;
  33864. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33865. static readonly DECR_WRAP: number;
  33866. /** Texture is not repeating outside of 0..1 UVs */
  33867. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33868. /** Texture is repeating outside of 0..1 UVs */
  33869. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33870. /** Texture is repeating and mirrored */
  33871. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33872. /** ALPHA */
  33873. static readonly TEXTUREFORMAT_ALPHA: number;
  33874. /** LUMINANCE */
  33875. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33876. /** LUMINANCE_ALPHA */
  33877. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33878. /** RGB */
  33879. static readonly TEXTUREFORMAT_RGB: number;
  33880. /** RGBA */
  33881. static readonly TEXTUREFORMAT_RGBA: number;
  33882. /** RED */
  33883. static readonly TEXTUREFORMAT_RED: number;
  33884. /** RED (2nd reference) */
  33885. static readonly TEXTUREFORMAT_R: number;
  33886. /** RG */
  33887. static readonly TEXTUREFORMAT_RG: number;
  33888. /** RED_INTEGER */
  33889. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33890. /** RED_INTEGER (2nd reference) */
  33891. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33892. /** RG_INTEGER */
  33893. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33894. /** RGB_INTEGER */
  33895. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33896. /** RGBA_INTEGER */
  33897. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33898. /** UNSIGNED_BYTE */
  33899. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33900. /** UNSIGNED_BYTE (2nd reference) */
  33901. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33902. /** FLOAT */
  33903. static readonly TEXTURETYPE_FLOAT: number;
  33904. /** HALF_FLOAT */
  33905. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33906. /** BYTE */
  33907. static readonly TEXTURETYPE_BYTE: number;
  33908. /** SHORT */
  33909. static readonly TEXTURETYPE_SHORT: number;
  33910. /** UNSIGNED_SHORT */
  33911. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33912. /** INT */
  33913. static readonly TEXTURETYPE_INT: number;
  33914. /** UNSIGNED_INT */
  33915. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33916. /** UNSIGNED_SHORT_4_4_4_4 */
  33917. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33918. /** UNSIGNED_SHORT_5_5_5_1 */
  33919. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33920. /** UNSIGNED_SHORT_5_6_5 */
  33921. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33922. /** UNSIGNED_INT_2_10_10_10_REV */
  33923. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33924. /** UNSIGNED_INT_24_8 */
  33925. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33926. /** UNSIGNED_INT_10F_11F_11F_REV */
  33927. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33928. /** UNSIGNED_INT_5_9_9_9_REV */
  33929. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33930. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33931. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33932. /** nearest is mag = nearest and min = nearest and mip = linear */
  33933. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33934. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33935. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33936. /** Trilinear is mag = linear and min = linear and mip = linear */
  33937. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33938. /** nearest is mag = nearest and min = nearest and mip = linear */
  33939. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33940. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33941. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33942. /** Trilinear is mag = linear and min = linear and mip = linear */
  33943. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33944. /** mag = nearest and min = nearest and mip = nearest */
  33945. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33946. /** mag = nearest and min = linear and mip = nearest */
  33947. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33948. /** mag = nearest and min = linear and mip = linear */
  33949. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33950. /** mag = nearest and min = linear and mip = none */
  33951. static readonly TEXTURE_NEAREST_LINEAR: number;
  33952. /** mag = nearest and min = nearest and mip = none */
  33953. static readonly TEXTURE_NEAREST_NEAREST: number;
  33954. /** mag = linear and min = nearest and mip = nearest */
  33955. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33956. /** mag = linear and min = nearest and mip = linear */
  33957. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33958. /** mag = linear and min = linear and mip = none */
  33959. static readonly TEXTURE_LINEAR_LINEAR: number;
  33960. /** mag = linear and min = nearest and mip = none */
  33961. static readonly TEXTURE_LINEAR_NEAREST: number;
  33962. /** Explicit coordinates mode */
  33963. static readonly TEXTURE_EXPLICIT_MODE: number;
  33964. /** Spherical coordinates mode */
  33965. static readonly TEXTURE_SPHERICAL_MODE: number;
  33966. /** Planar coordinates mode */
  33967. static readonly TEXTURE_PLANAR_MODE: number;
  33968. /** Cubic coordinates mode */
  33969. static readonly TEXTURE_CUBIC_MODE: number;
  33970. /** Projection coordinates mode */
  33971. static readonly TEXTURE_PROJECTION_MODE: number;
  33972. /** Skybox coordinates mode */
  33973. static readonly TEXTURE_SKYBOX_MODE: number;
  33974. /** Inverse Cubic coordinates mode */
  33975. static readonly TEXTURE_INVCUBIC_MODE: number;
  33976. /** Equirectangular coordinates mode */
  33977. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33978. /** Equirectangular Fixed coordinates mode */
  33979. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33980. /** Equirectangular Fixed Mirrored coordinates mode */
  33981. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33982. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33983. static readonly SCALEMODE_FLOOR: number;
  33984. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33985. static readonly SCALEMODE_NEAREST: number;
  33986. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33987. static readonly SCALEMODE_CEILING: number;
  33988. /**
  33989. * Returns the current npm package of the sdk
  33990. */
  33991. static get NpmPackage(): string;
  33992. /**
  33993. * Returns the current version of the framework
  33994. */
  33995. static get Version(): string;
  33996. /** Gets the list of created engines */
  33997. static get Instances(): Engine[];
  33998. /**
  33999. * Gets the latest created engine
  34000. */
  34001. static get LastCreatedEngine(): Nullable<Engine>;
  34002. /**
  34003. * Gets the latest created scene
  34004. */
  34005. static get LastCreatedScene(): Nullable<Scene>;
  34006. /**
  34007. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34008. * @param flag defines which part of the materials must be marked as dirty
  34009. * @param predicate defines a predicate used to filter which materials should be affected
  34010. */
  34011. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34012. /**
  34013. * Method called to create the default loading screen.
  34014. * This can be overriden in your own app.
  34015. * @param canvas The rendering canvas element
  34016. * @returns The loading screen
  34017. */
  34018. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34019. /**
  34020. * Method called to create the default rescale post process on each engine.
  34021. */
  34022. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34023. /**
  34024. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34025. **/
  34026. enableOfflineSupport: boolean;
  34027. /**
  34028. * 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)
  34029. **/
  34030. disableManifestCheck: boolean;
  34031. /**
  34032. * Gets the list of created scenes
  34033. */
  34034. scenes: Scene[];
  34035. /**
  34036. * Event raised when a new scene is created
  34037. */
  34038. onNewSceneAddedObservable: Observable<Scene>;
  34039. /**
  34040. * Gets the list of created postprocesses
  34041. */
  34042. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34043. /**
  34044. * Gets a boolean indicating if the pointer is currently locked
  34045. */
  34046. isPointerLock: boolean;
  34047. /**
  34048. * Observable event triggered each time the rendering canvas is resized
  34049. */
  34050. onResizeObservable: Observable<Engine>;
  34051. /**
  34052. * Observable event triggered each time the canvas loses focus
  34053. */
  34054. onCanvasBlurObservable: Observable<Engine>;
  34055. /**
  34056. * Observable event triggered each time the canvas gains focus
  34057. */
  34058. onCanvasFocusObservable: Observable<Engine>;
  34059. /**
  34060. * Observable event triggered each time the canvas receives pointerout event
  34061. */
  34062. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34063. /**
  34064. * Observable raised when the engine begins a new frame
  34065. */
  34066. onBeginFrameObservable: Observable<Engine>;
  34067. /**
  34068. * If set, will be used to request the next animation frame for the render loop
  34069. */
  34070. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34071. /**
  34072. * Observable raised when the engine ends the current frame
  34073. */
  34074. onEndFrameObservable: Observable<Engine>;
  34075. /**
  34076. * Observable raised when the engine is about to compile a shader
  34077. */
  34078. onBeforeShaderCompilationObservable: Observable<Engine>;
  34079. /**
  34080. * Observable raised when the engine has jsut compiled a shader
  34081. */
  34082. onAfterShaderCompilationObservable: Observable<Engine>;
  34083. /**
  34084. * Gets the audio engine
  34085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34086. * @ignorenaming
  34087. */
  34088. static audioEngine: IAudioEngine;
  34089. /**
  34090. * Default AudioEngine factory responsible of creating the Audio Engine.
  34091. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34092. */
  34093. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34094. /**
  34095. * Default offline support factory responsible of creating a tool used to store data locally.
  34096. * By default, this will create a Database object if the workload has been embedded.
  34097. */
  34098. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34099. private _loadingScreen;
  34100. private _pointerLockRequested;
  34101. private _dummyFramebuffer;
  34102. private _rescalePostProcess;
  34103. private _deterministicLockstep;
  34104. private _lockstepMaxSteps;
  34105. private _timeStep;
  34106. protected get _supportsHardwareTextureRescaling(): boolean;
  34107. private _fps;
  34108. private _deltaTime;
  34109. /** @hidden */
  34110. _drawCalls: PerfCounter;
  34111. /**
  34112. * Turn this value on if you want to pause FPS computation when in background
  34113. */
  34114. disablePerformanceMonitorInBackground: boolean;
  34115. private _performanceMonitor;
  34116. /**
  34117. * Gets the performance monitor attached to this engine
  34118. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34119. */
  34120. get performanceMonitor(): PerformanceMonitor;
  34121. private _onFocus;
  34122. private _onBlur;
  34123. private _onCanvasPointerOut;
  34124. private _onCanvasBlur;
  34125. private _onCanvasFocus;
  34126. private _onFullscreenChange;
  34127. private _onPointerLockChange;
  34128. /**
  34129. * Gets the HTML element used to attach event listeners
  34130. * @returns a HTML element
  34131. */
  34132. getInputElement(): Nullable<HTMLElement>;
  34133. /**
  34134. * Creates a new engine
  34135. * @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
  34136. * @param antialias defines enable antialiasing (default: false)
  34137. * @param options defines further options to be sent to the getContext() function
  34138. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34139. */
  34140. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34141. /**
  34142. * Gets current aspect ratio
  34143. * @param viewportOwner defines the camera to use to get the aspect ratio
  34144. * @param useScreen defines if screen size must be used (or the current render target if any)
  34145. * @returns a number defining the aspect ratio
  34146. */
  34147. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34148. /**
  34149. * Gets current screen aspect ratio
  34150. * @returns a number defining the aspect ratio
  34151. */
  34152. getScreenAspectRatio(): number;
  34153. /**
  34154. * Gets the client rect of the HTML canvas attached with the current webGL context
  34155. * @returns a client rectanglee
  34156. */
  34157. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34158. /**
  34159. * Gets the client rect of the HTML element used for events
  34160. * @returns a client rectanglee
  34161. */
  34162. getInputElementClientRect(): Nullable<ClientRect>;
  34163. /**
  34164. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34166. * @returns true if engine is in deterministic lock step mode
  34167. */
  34168. isDeterministicLockStep(): boolean;
  34169. /**
  34170. * Gets the max steps when engine is running in deterministic lock step
  34171. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34172. * @returns the max steps
  34173. */
  34174. getLockstepMaxSteps(): number;
  34175. /**
  34176. * Returns the time in ms between steps when using deterministic lock step.
  34177. * @returns time step in (ms)
  34178. */
  34179. getTimeStep(): number;
  34180. /**
  34181. * Force the mipmap generation for the given render target texture
  34182. * @param texture defines the render target texture to use
  34183. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34184. */
  34185. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34186. /** States */
  34187. /**
  34188. * Set various states to the webGL context
  34189. * @param culling defines backface culling state
  34190. * @param zOffset defines the value to apply to zOffset (0 by default)
  34191. * @param force defines if states must be applied even if cache is up to date
  34192. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34193. */
  34194. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34195. /**
  34196. * Set the z offset to apply to current rendering
  34197. * @param value defines the offset to apply
  34198. */
  34199. setZOffset(value: number): void;
  34200. /**
  34201. * Gets the current value of the zOffset
  34202. * @returns the current zOffset state
  34203. */
  34204. getZOffset(): number;
  34205. /**
  34206. * Enable or disable depth buffering
  34207. * @param enable defines the state to set
  34208. */
  34209. setDepthBuffer(enable: boolean): void;
  34210. /**
  34211. * Gets a boolean indicating if depth writing is enabled
  34212. * @returns the current depth writing state
  34213. */
  34214. getDepthWrite(): boolean;
  34215. /**
  34216. * Enable or disable depth writing
  34217. * @param enable defines the state to set
  34218. */
  34219. setDepthWrite(enable: boolean): void;
  34220. /**
  34221. * Gets a boolean indicating if stencil buffer is enabled
  34222. * @returns the current stencil buffer state
  34223. */
  34224. getStencilBuffer(): boolean;
  34225. /**
  34226. * Enable or disable the stencil buffer
  34227. * @param enable defines if the stencil buffer must be enabled or disabled
  34228. */
  34229. setStencilBuffer(enable: boolean): void;
  34230. /**
  34231. * Gets the current stencil mask
  34232. * @returns a number defining the new stencil mask to use
  34233. */
  34234. getStencilMask(): number;
  34235. /**
  34236. * Sets the current stencil mask
  34237. * @param mask defines the new stencil mask to use
  34238. */
  34239. setStencilMask(mask: number): void;
  34240. /**
  34241. * Gets the current stencil function
  34242. * @returns a number defining the stencil function to use
  34243. */
  34244. getStencilFunction(): number;
  34245. /**
  34246. * Gets the current stencil reference value
  34247. * @returns a number defining the stencil reference value to use
  34248. */
  34249. getStencilFunctionReference(): number;
  34250. /**
  34251. * Gets the current stencil mask
  34252. * @returns a number defining the stencil mask to use
  34253. */
  34254. getStencilFunctionMask(): number;
  34255. /**
  34256. * Sets the current stencil function
  34257. * @param stencilFunc defines the new stencil function to use
  34258. */
  34259. setStencilFunction(stencilFunc: number): void;
  34260. /**
  34261. * Sets the current stencil reference
  34262. * @param reference defines the new stencil reference to use
  34263. */
  34264. setStencilFunctionReference(reference: number): void;
  34265. /**
  34266. * Sets the current stencil mask
  34267. * @param mask defines the new stencil mask to use
  34268. */
  34269. setStencilFunctionMask(mask: number): void;
  34270. /**
  34271. * Gets the current stencil operation when stencil fails
  34272. * @returns a number defining stencil operation to use when stencil fails
  34273. */
  34274. getStencilOperationFail(): number;
  34275. /**
  34276. * Gets the current stencil operation when depth fails
  34277. * @returns a number defining stencil operation to use when depth fails
  34278. */
  34279. getStencilOperationDepthFail(): number;
  34280. /**
  34281. * Gets the current stencil operation when stencil passes
  34282. * @returns a number defining stencil operation to use when stencil passes
  34283. */
  34284. getStencilOperationPass(): number;
  34285. /**
  34286. * Sets the stencil operation to use when stencil fails
  34287. * @param operation defines the stencil operation to use when stencil fails
  34288. */
  34289. setStencilOperationFail(operation: number): void;
  34290. /**
  34291. * Sets the stencil operation to use when depth fails
  34292. * @param operation defines the stencil operation to use when depth fails
  34293. */
  34294. setStencilOperationDepthFail(operation: number): void;
  34295. /**
  34296. * Sets the stencil operation to use when stencil passes
  34297. * @param operation defines the stencil operation to use when stencil passes
  34298. */
  34299. setStencilOperationPass(operation: number): void;
  34300. /**
  34301. * Sets a boolean indicating if the dithering state is enabled or disabled
  34302. * @param value defines the dithering state
  34303. */
  34304. setDitheringState(value: boolean): void;
  34305. /**
  34306. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34307. * @param value defines the rasterizer state
  34308. */
  34309. setRasterizerState(value: boolean): void;
  34310. /**
  34311. * Gets the current depth function
  34312. * @returns a number defining the depth function
  34313. */
  34314. getDepthFunction(): Nullable<number>;
  34315. /**
  34316. * Sets the current depth function
  34317. * @param depthFunc defines the function to use
  34318. */
  34319. setDepthFunction(depthFunc: number): void;
  34320. /**
  34321. * Sets the current depth function to GREATER
  34322. */
  34323. setDepthFunctionToGreater(): void;
  34324. /**
  34325. * Sets the current depth function to GEQUAL
  34326. */
  34327. setDepthFunctionToGreaterOrEqual(): void;
  34328. /**
  34329. * Sets the current depth function to LESS
  34330. */
  34331. setDepthFunctionToLess(): void;
  34332. /**
  34333. * Sets the current depth function to LEQUAL
  34334. */
  34335. setDepthFunctionToLessOrEqual(): void;
  34336. private _cachedStencilBuffer;
  34337. private _cachedStencilFunction;
  34338. private _cachedStencilMask;
  34339. private _cachedStencilOperationPass;
  34340. private _cachedStencilOperationFail;
  34341. private _cachedStencilOperationDepthFail;
  34342. private _cachedStencilReference;
  34343. /**
  34344. * Caches the the state of the stencil buffer
  34345. */
  34346. cacheStencilState(): void;
  34347. /**
  34348. * Restores the state of the stencil buffer
  34349. */
  34350. restoreStencilState(): void;
  34351. /**
  34352. * Directly set the WebGL Viewport
  34353. * @param x defines the x coordinate of the viewport (in screen space)
  34354. * @param y defines the y coordinate of the viewport (in screen space)
  34355. * @param width defines the width of the viewport (in screen space)
  34356. * @param height defines the height of the viewport (in screen space)
  34357. * @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
  34358. */
  34359. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34360. /**
  34361. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34362. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34363. * @param y defines the y-coordinate of the corner of the clear rectangle
  34364. * @param width defines the width of the clear rectangle
  34365. * @param height defines the height of the clear rectangle
  34366. * @param clearColor defines the clear color
  34367. */
  34368. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34369. /**
  34370. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34371. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34372. * @param y defines the y-coordinate of the corner of the clear rectangle
  34373. * @param width defines the width of the clear rectangle
  34374. * @param height defines the height of the clear rectangle
  34375. */
  34376. enableScissor(x: number, y: number, width: number, height: number): void;
  34377. /**
  34378. * Disable previously set scissor test rectangle
  34379. */
  34380. disableScissor(): void;
  34381. protected _reportDrawCall(): void;
  34382. /**
  34383. * Initializes a webVR display and starts listening to display change events
  34384. * The onVRDisplayChangedObservable will be notified upon these changes
  34385. * @returns The onVRDisplayChangedObservable
  34386. */
  34387. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34388. /** @hidden */
  34389. _prepareVRComponent(): void;
  34390. /** @hidden */
  34391. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34392. /** @hidden */
  34393. _submitVRFrame(): void;
  34394. /**
  34395. * Call this function to leave webVR mode
  34396. * Will do nothing if webVR is not supported or if there is no webVR device
  34397. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34398. */
  34399. disableVR(): void;
  34400. /**
  34401. * Gets a boolean indicating that the system is in VR mode and is presenting
  34402. * @returns true if VR mode is engaged
  34403. */
  34404. isVRPresenting(): boolean;
  34405. /** @hidden */
  34406. _requestVRFrame(): void;
  34407. /** @hidden */
  34408. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34409. /**
  34410. * Gets the source code of the vertex shader associated with a specific webGL program
  34411. * @param program defines the program to use
  34412. * @returns a string containing the source code of the vertex shader associated with the program
  34413. */
  34414. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34415. /**
  34416. * Gets the source code of the fragment shader associated with a specific webGL program
  34417. * @param program defines the program to use
  34418. * @returns a string containing the source code of the fragment shader associated with the program
  34419. */
  34420. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34421. /**
  34422. * Sets a depth stencil texture from a render target to the according uniform.
  34423. * @param channel The texture channel
  34424. * @param uniform The uniform to set
  34425. * @param texture The render target texture containing the depth stencil texture to apply
  34426. */
  34427. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34428. /**
  34429. * Sets a texture to the webGL context from a postprocess
  34430. * @param channel defines the channel to use
  34431. * @param postProcess defines the source postprocess
  34432. */
  34433. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34434. /**
  34435. * Binds the output of the passed in post process to the texture channel specified
  34436. * @param channel The channel the texture should be bound to
  34437. * @param postProcess The post process which's output should be bound
  34438. */
  34439. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34440. /** @hidden */
  34441. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34442. protected _rebuildBuffers(): void;
  34443. /** @hidden */
  34444. _renderFrame(): void;
  34445. _renderLoop(): void;
  34446. /** @hidden */
  34447. _renderViews(): boolean;
  34448. /**
  34449. * Toggle full screen mode
  34450. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34451. */
  34452. switchFullscreen(requestPointerLock: boolean): void;
  34453. /**
  34454. * Enters full screen mode
  34455. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34456. */
  34457. enterFullscreen(requestPointerLock: boolean): void;
  34458. /**
  34459. * Exits full screen mode
  34460. */
  34461. exitFullscreen(): void;
  34462. /**
  34463. * Enters Pointerlock mode
  34464. */
  34465. enterPointerlock(): void;
  34466. /**
  34467. * Exits Pointerlock mode
  34468. */
  34469. exitPointerlock(): void;
  34470. /**
  34471. * Begin a new frame
  34472. */
  34473. beginFrame(): void;
  34474. /**
  34475. * Enf the current frame
  34476. */
  34477. endFrame(): void;
  34478. resize(): void;
  34479. /**
  34480. * Set the compressed texture format to use, based on the formats you have, and the formats
  34481. * supported by the hardware / browser.
  34482. *
  34483. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34484. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34485. * to API arguments needed to compressed textures. This puts the burden on the container
  34486. * generator to house the arcane code for determining these for current & future formats.
  34487. *
  34488. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34489. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34490. *
  34491. * Note: The result of this call is not taken into account when a texture is base64.
  34492. *
  34493. * @param formatsAvailable defines the list of those format families you have created
  34494. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34495. *
  34496. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34497. * @returns The extension selected.
  34498. */
  34499. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34500. /**
  34501. * Set the compressed texture extensions or file names to skip.
  34502. *
  34503. * @param skippedFiles defines the list of those texture files you want to skip
  34504. * Example: [".dds", ".env", "myfile.png"]
  34505. */
  34506. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34507. /**
  34508. * Force a specific size of the canvas
  34509. * @param width defines the new canvas' width
  34510. * @param height defines the new canvas' height
  34511. */
  34512. setSize(width: number, height: number): void;
  34513. /**
  34514. * Updates a dynamic vertex buffer.
  34515. * @param vertexBuffer the vertex buffer to update
  34516. * @param data the data used to update the vertex buffer
  34517. * @param byteOffset the byte offset of the data
  34518. * @param byteLength the byte length of the data
  34519. */
  34520. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34521. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34522. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34523. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34524. _releaseTexture(texture: InternalTexture): void;
  34525. /**
  34526. * @hidden
  34527. * Rescales a texture
  34528. * @param source input texutre
  34529. * @param destination destination texture
  34530. * @param scene scene to use to render the resize
  34531. * @param internalFormat format to use when resizing
  34532. * @param onComplete callback to be called when resize has completed
  34533. */
  34534. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34535. /**
  34536. * Gets the current framerate
  34537. * @returns a number representing the framerate
  34538. */
  34539. getFps(): number;
  34540. /**
  34541. * Gets the time spent between current and previous frame
  34542. * @returns a number representing the delta time in ms
  34543. */
  34544. getDeltaTime(): number;
  34545. private _measureFps;
  34546. /** @hidden */
  34547. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34548. /**
  34549. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34550. * @param renderTarget The render target to set the frame buffer for
  34551. */
  34552. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34553. /**
  34554. * Update a dynamic index buffer
  34555. * @param indexBuffer defines the target index buffer
  34556. * @param indices defines the data to update
  34557. * @param offset defines the offset in the target index buffer where update should start
  34558. */
  34559. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34560. /**
  34561. * Updates the sample count of a render target texture
  34562. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34563. * @param texture defines the texture to update
  34564. * @param samples defines the sample count to set
  34565. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34566. */
  34567. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34568. /**
  34569. * Updates a depth texture Comparison Mode and Function.
  34570. * If the comparison Function is equal to 0, the mode will be set to none.
  34571. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34572. * @param texture The texture to set the comparison function for
  34573. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34574. */
  34575. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34576. /**
  34577. * Creates a webGL buffer to use with instanciation
  34578. * @param capacity defines the size of the buffer
  34579. * @returns the webGL buffer
  34580. */
  34581. createInstancesBuffer(capacity: number): DataBuffer;
  34582. /**
  34583. * Delete a webGL buffer used with instanciation
  34584. * @param buffer defines the webGL buffer to delete
  34585. */
  34586. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34587. /** @hidden */
  34588. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34589. dispose(): void;
  34590. private _disableTouchAction;
  34591. /**
  34592. * Display the loading screen
  34593. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34594. */
  34595. displayLoadingUI(): void;
  34596. /**
  34597. * Hide the loading screen
  34598. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34599. */
  34600. hideLoadingUI(): void;
  34601. /**
  34602. * Gets the current loading screen object
  34603. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34604. */
  34605. get loadingScreen(): ILoadingScreen;
  34606. /**
  34607. * Sets the current loading screen object
  34608. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34609. */
  34610. set loadingScreen(loadingScreen: ILoadingScreen);
  34611. /**
  34612. * Sets the current loading screen text
  34613. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34614. */
  34615. set loadingUIText(text: string);
  34616. /**
  34617. * Sets the current loading screen background color
  34618. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34619. */
  34620. set loadingUIBackgroundColor(color: string);
  34621. /** Pointerlock and fullscreen */
  34622. /**
  34623. * Ask the browser to promote the current element to pointerlock mode
  34624. * @param element defines the DOM element to promote
  34625. */
  34626. static _RequestPointerlock(element: HTMLElement): void;
  34627. /**
  34628. * Asks the browser to exit pointerlock mode
  34629. */
  34630. static _ExitPointerlock(): void;
  34631. /**
  34632. * Ask the browser to promote the current element to fullscreen rendering mode
  34633. * @param element defines the DOM element to promote
  34634. */
  34635. static _RequestFullscreen(element: HTMLElement): void;
  34636. /**
  34637. * Asks the browser to exit fullscreen mode
  34638. */
  34639. static _ExitFullscreen(): void;
  34640. }
  34641. }
  34642. declare module "babylonjs/Engines/engineStore" {
  34643. import { Nullable } from "babylonjs/types";
  34644. import { Engine } from "babylonjs/Engines/engine";
  34645. import { Scene } from "babylonjs/scene";
  34646. /**
  34647. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34648. * during the life time of the application.
  34649. */
  34650. export class EngineStore {
  34651. /** Gets the list of created engines */
  34652. static Instances: import("babylonjs/Engines/engine").Engine[];
  34653. /** @hidden */
  34654. static _LastCreatedScene: Nullable<Scene>;
  34655. /**
  34656. * Gets the latest created engine
  34657. */
  34658. static get LastCreatedEngine(): Nullable<Engine>;
  34659. /**
  34660. * Gets the latest created scene
  34661. */
  34662. static get LastCreatedScene(): Nullable<Scene>;
  34663. /**
  34664. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34665. * @ignorenaming
  34666. */
  34667. static UseFallbackTexture: boolean;
  34668. /**
  34669. * Texture content used if a texture cannot loaded
  34670. * @ignorenaming
  34671. */
  34672. static FallbackTexture: string;
  34673. }
  34674. }
  34675. declare module "babylonjs/Misc/promise" {
  34676. /**
  34677. * Helper class that provides a small promise polyfill
  34678. */
  34679. export class PromisePolyfill {
  34680. /**
  34681. * Static function used to check if the polyfill is required
  34682. * If this is the case then the function will inject the polyfill to window.Promise
  34683. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34684. */
  34685. static Apply(force?: boolean): void;
  34686. }
  34687. }
  34688. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34689. /**
  34690. * Interface for screenshot methods with describe argument called `size` as object with options
  34691. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34692. */
  34693. export interface IScreenshotSize {
  34694. /**
  34695. * number in pixels for canvas height
  34696. */
  34697. height?: number;
  34698. /**
  34699. * multiplier allowing render at a higher or lower resolution
  34700. * If value is defined then height and width will be ignored and taken from camera
  34701. */
  34702. precision?: number;
  34703. /**
  34704. * number in pixels for canvas width
  34705. */
  34706. width?: number;
  34707. }
  34708. }
  34709. declare module "babylonjs/Misc/tools" {
  34710. import { Nullable, float } from "babylonjs/types";
  34711. import { DomManagement } from "babylonjs/Misc/domManagement";
  34712. import { WebRequest } from "babylonjs/Misc/webRequest";
  34713. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34714. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34715. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34716. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34717. import { Camera } from "babylonjs/Cameras/camera";
  34718. import { Engine } from "babylonjs/Engines/engine";
  34719. interface IColor4Like {
  34720. r: float;
  34721. g: float;
  34722. b: float;
  34723. a: float;
  34724. }
  34725. /**
  34726. * Class containing a set of static utilities functions
  34727. */
  34728. export class Tools {
  34729. /**
  34730. * Gets or sets the base URL to use to load assets
  34731. */
  34732. static get BaseUrl(): string;
  34733. static set BaseUrl(value: string);
  34734. /**
  34735. * Enable/Disable Custom HTTP Request Headers globally.
  34736. * default = false
  34737. * @see CustomRequestHeaders
  34738. */
  34739. static UseCustomRequestHeaders: boolean;
  34740. /**
  34741. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34742. * i.e. when loading files, where the server/service expects an Authorization header
  34743. */
  34744. static CustomRequestHeaders: {
  34745. [key: string]: string;
  34746. };
  34747. /**
  34748. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34749. */
  34750. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34751. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34752. /**
  34753. * Default behaviour for cors in the application.
  34754. * It can be a string if the expected behavior is identical in the entire app.
  34755. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34756. */
  34757. static CorsBehavior: string | ((url: string | string[]) => string);
  34758. /**
  34759. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34760. * @ignorenaming
  34761. */
  34762. static get UseFallbackTexture(): boolean;
  34763. static set UseFallbackTexture(value: boolean);
  34764. /**
  34765. * Use this object to register external classes like custom textures or material
  34766. * to allow the laoders to instantiate them
  34767. */
  34768. static get RegisteredExternalClasses(): {
  34769. [key: string]: Object;
  34770. };
  34771. static set RegisteredExternalClasses(classes: {
  34772. [key: string]: Object;
  34773. });
  34774. /**
  34775. * Texture content used if a texture cannot loaded
  34776. * @ignorenaming
  34777. */
  34778. static get fallbackTexture(): string;
  34779. static set fallbackTexture(value: string);
  34780. /**
  34781. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34782. * @param u defines the coordinate on X axis
  34783. * @param v defines the coordinate on Y axis
  34784. * @param width defines the width of the source data
  34785. * @param height defines the height of the source data
  34786. * @param pixels defines the source byte array
  34787. * @param color defines the output color
  34788. */
  34789. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34790. /**
  34791. * Interpolates between a and b via alpha
  34792. * @param a The lower value (returned when alpha = 0)
  34793. * @param b The upper value (returned when alpha = 1)
  34794. * @param alpha The interpolation-factor
  34795. * @return The mixed value
  34796. */
  34797. static Mix(a: number, b: number, alpha: number): number;
  34798. /**
  34799. * Tries to instantiate a new object from a given class name
  34800. * @param className defines the class name to instantiate
  34801. * @returns the new object or null if the system was not able to do the instantiation
  34802. */
  34803. static Instantiate(className: string): any;
  34804. /**
  34805. * Provides a slice function that will work even on IE
  34806. * @param data defines the array to slice
  34807. * @param start defines the start of the data (optional)
  34808. * @param end defines the end of the data (optional)
  34809. * @returns the new sliced array
  34810. */
  34811. static Slice<T>(data: T, start?: number, end?: number): T;
  34812. /**
  34813. * Polyfill for setImmediate
  34814. * @param action defines the action to execute after the current execution block
  34815. */
  34816. static SetImmediate(action: () => void): void;
  34817. /**
  34818. * Function indicating if a number is an exponent of 2
  34819. * @param value defines the value to test
  34820. * @returns true if the value is an exponent of 2
  34821. */
  34822. static IsExponentOfTwo(value: number): boolean;
  34823. private static _tmpFloatArray;
  34824. /**
  34825. * Returns the nearest 32-bit single precision float representation of a Number
  34826. * @param value A Number. If the parameter is of a different type, it will get converted
  34827. * to a number or to NaN if it cannot be converted
  34828. * @returns number
  34829. */
  34830. static FloatRound(value: number): number;
  34831. /**
  34832. * Extracts the filename from a path
  34833. * @param path defines the path to use
  34834. * @returns the filename
  34835. */
  34836. static GetFilename(path: string): string;
  34837. /**
  34838. * Extracts the "folder" part of a path (everything before the filename).
  34839. * @param uri The URI to extract the info from
  34840. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34841. * @returns The "folder" part of the path
  34842. */
  34843. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34844. /**
  34845. * Extracts text content from a DOM element hierarchy
  34846. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34847. */
  34848. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34849. /**
  34850. * Convert an angle in radians to degrees
  34851. * @param angle defines the angle to convert
  34852. * @returns the angle in degrees
  34853. */
  34854. static ToDegrees(angle: number): number;
  34855. /**
  34856. * Convert an angle in degrees to radians
  34857. * @param angle defines the angle to convert
  34858. * @returns the angle in radians
  34859. */
  34860. static ToRadians(angle: number): number;
  34861. /**
  34862. * Returns an array if obj is not an array
  34863. * @param obj defines the object to evaluate as an array
  34864. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34865. * @returns either obj directly if obj is an array or a new array containing obj
  34866. */
  34867. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34868. /**
  34869. * Gets the pointer prefix to use
  34870. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34871. */
  34872. static GetPointerPrefix(): string;
  34873. /**
  34874. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34875. * @param url define the url we are trying
  34876. * @param element define the dom element where to configure the cors policy
  34877. */
  34878. static SetCorsBehavior(url: string | string[], element: {
  34879. crossOrigin: string | null;
  34880. }): void;
  34881. /**
  34882. * Removes unwanted characters from an url
  34883. * @param url defines the url to clean
  34884. * @returns the cleaned url
  34885. */
  34886. static CleanUrl(url: string): string;
  34887. /**
  34888. * Gets or sets a function used to pre-process url before using them to load assets
  34889. */
  34890. static get PreprocessUrl(): (url: string) => string;
  34891. static set PreprocessUrl(processor: (url: string) => string);
  34892. /**
  34893. * Loads an image as an HTMLImageElement.
  34894. * @param input url string, ArrayBuffer, or Blob to load
  34895. * @param onLoad callback called when the image successfully loads
  34896. * @param onError callback called when the image fails to load
  34897. * @param offlineProvider offline provider for caching
  34898. * @param mimeType optional mime type
  34899. * @returns the HTMLImageElement of the loaded image
  34900. */
  34901. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34902. /**
  34903. * Loads a file from a url
  34904. * @param url url string, ArrayBuffer, or Blob to load
  34905. * @param onSuccess callback called when the file successfully loads
  34906. * @param onProgress callback called while file is loading (if the server supports this mode)
  34907. * @param offlineProvider defines the offline provider for caching
  34908. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34909. * @param onError callback called when the file fails to load
  34910. * @returns a file request object
  34911. */
  34912. 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;
  34913. /**
  34914. * Loads a file from a url
  34915. * @param url the file url to load
  34916. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34917. */
  34918. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34919. /**
  34920. * Load a script (identified by an url). When the url returns, the
  34921. * content of this file is added into a new script element, attached to the DOM (body element)
  34922. * @param scriptUrl defines the url of the script to laod
  34923. * @param onSuccess defines the callback called when the script is loaded
  34924. * @param onError defines the callback to call if an error occurs
  34925. * @param scriptId defines the id of the script element
  34926. */
  34927. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34928. /**
  34929. * Load an asynchronous script (identified by an url). When the url returns, the
  34930. * content of this file is added into a new script element, attached to the DOM (body element)
  34931. * @param scriptUrl defines the url of the script to laod
  34932. * @param scriptId defines the id of the script element
  34933. * @returns a promise request object
  34934. */
  34935. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34936. /**
  34937. * Loads a file from a blob
  34938. * @param fileToLoad defines the blob to use
  34939. * @param callback defines the callback to call when data is loaded
  34940. * @param progressCallback defines the callback to call during loading process
  34941. * @returns a file request object
  34942. */
  34943. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34944. /**
  34945. * Reads a file from a File object
  34946. * @param file defines the file to load
  34947. * @param onSuccess defines the callback to call when data is loaded
  34948. * @param onProgress defines the callback to call during loading process
  34949. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34950. * @param onError defines the callback to call when an error occurs
  34951. * @returns a file request object
  34952. */
  34953. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34954. /**
  34955. * Creates a data url from a given string content
  34956. * @param content defines the content to convert
  34957. * @returns the new data url link
  34958. */
  34959. static FileAsURL(content: string): string;
  34960. /**
  34961. * Format the given number to a specific decimal format
  34962. * @param value defines the number to format
  34963. * @param decimals defines the number of decimals to use
  34964. * @returns the formatted string
  34965. */
  34966. static Format(value: number, decimals?: number): string;
  34967. /**
  34968. * Tries to copy an object by duplicating every property
  34969. * @param source defines the source object
  34970. * @param destination defines the target object
  34971. * @param doNotCopyList defines a list of properties to avoid
  34972. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34973. */
  34974. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34975. /**
  34976. * Gets a boolean indicating if the given object has no own property
  34977. * @param obj defines the object to test
  34978. * @returns true if object has no own property
  34979. */
  34980. static IsEmpty(obj: any): boolean;
  34981. /**
  34982. * Function used to register events at window level
  34983. * @param windowElement defines the Window object to use
  34984. * @param events defines the events to register
  34985. */
  34986. static RegisterTopRootEvents(windowElement: Window, events: {
  34987. name: string;
  34988. handler: Nullable<(e: FocusEvent) => any>;
  34989. }[]): void;
  34990. /**
  34991. * Function used to unregister events from window level
  34992. * @param windowElement defines the Window object to use
  34993. * @param events defines the events to unregister
  34994. */
  34995. static UnregisterTopRootEvents(windowElement: Window, events: {
  34996. name: string;
  34997. handler: Nullable<(e: FocusEvent) => any>;
  34998. }[]): void;
  34999. /**
  35000. * @ignore
  35001. */
  35002. static _ScreenshotCanvas: HTMLCanvasElement;
  35003. /**
  35004. * Dumps the current bound framebuffer
  35005. * @param width defines the rendering width
  35006. * @param height defines the rendering height
  35007. * @param engine defines the hosting engine
  35008. * @param successCallback defines the callback triggered once the data are available
  35009. * @param mimeType defines the mime type of the result
  35010. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35011. */
  35012. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35013. /**
  35014. * Converts the canvas data to blob.
  35015. * This acts as a polyfill for browsers not supporting the to blob function.
  35016. * @param canvas Defines the canvas to extract the data from
  35017. * @param successCallback Defines the callback triggered once the data are available
  35018. * @param mimeType Defines the mime type of the result
  35019. */
  35020. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35021. /**
  35022. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35023. * @param successCallback defines the callback triggered once the data are available
  35024. * @param mimeType defines the mime type of the result
  35025. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35026. */
  35027. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35028. /**
  35029. * Downloads a blob in the browser
  35030. * @param blob defines the blob to download
  35031. * @param fileName defines the name of the downloaded file
  35032. */
  35033. static Download(blob: Blob, fileName: string): void;
  35034. /**
  35035. * Captures a screenshot of the current rendering
  35036. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35037. * @param engine defines the rendering engine
  35038. * @param camera defines the source camera
  35039. * @param size This parameter can be set to a single number or to an object with the
  35040. * following (optional) properties: precision, width, height. If a single number is passed,
  35041. * it will be used for both width and height. If an object is passed, the screenshot size
  35042. * will be derived from the parameters. The precision property is a multiplier allowing
  35043. * rendering at a higher or lower resolution
  35044. * @param successCallback defines the callback receives a single parameter which contains the
  35045. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35046. * src parameter of an <img> to display it
  35047. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35048. * Check your browser for supported MIME types
  35049. */
  35050. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35051. /**
  35052. * Captures a screenshot of the current rendering
  35053. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35054. * @param engine defines the rendering engine
  35055. * @param camera defines the source camera
  35056. * @param size This parameter can be set to a single number or to an object with the
  35057. * following (optional) properties: precision, width, height. If a single number is passed,
  35058. * it will be used for both width and height. If an object is passed, the screenshot size
  35059. * will be derived from the parameters. The precision property is a multiplier allowing
  35060. * rendering at a higher or lower resolution
  35061. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35062. * Check your browser for supported MIME types
  35063. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35064. * to the src parameter of an <img> to display it
  35065. */
  35066. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35067. /**
  35068. * Generates an image screenshot from the specified camera.
  35069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35070. * @param engine The engine to use for rendering
  35071. * @param camera The camera to use for rendering
  35072. * @param size This parameter can be set to a single number or to an object with the
  35073. * following (optional) properties: precision, width, height. If a single number is passed,
  35074. * it will be used for both width and height. If an object is passed, the screenshot size
  35075. * will be derived from the parameters. The precision property is a multiplier allowing
  35076. * rendering at a higher or lower resolution
  35077. * @param successCallback The callback receives a single parameter which contains the
  35078. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35079. * src parameter of an <img> to display it
  35080. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35081. * Check your browser for supported MIME types
  35082. * @param samples Texture samples (default: 1)
  35083. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35084. * @param fileName A name for for the downloaded file.
  35085. */
  35086. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35087. /**
  35088. * Generates an image screenshot from the specified camera.
  35089. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35090. * @param engine The engine to use for rendering
  35091. * @param camera The camera to use for rendering
  35092. * @param size This parameter can be set to a single number or to an object with the
  35093. * following (optional) properties: precision, width, height. If a single number is passed,
  35094. * it will be used for both width and height. If an object is passed, the screenshot size
  35095. * will be derived from the parameters. The precision property is a multiplier allowing
  35096. * rendering at a higher or lower resolution
  35097. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35098. * Check your browser for supported MIME types
  35099. * @param samples Texture samples (default: 1)
  35100. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35101. * @param fileName A name for for the downloaded file.
  35102. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35103. * to the src parameter of an <img> to display it
  35104. */
  35105. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35106. /**
  35107. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35108. * Be aware Math.random() could cause collisions, but:
  35109. * "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"
  35110. * @returns a pseudo random id
  35111. */
  35112. static RandomId(): string;
  35113. /**
  35114. * Test if the given uri is a base64 string
  35115. * @param uri The uri to test
  35116. * @return True if the uri is a base64 string or false otherwise
  35117. */
  35118. static IsBase64(uri: string): boolean;
  35119. /**
  35120. * Decode the given base64 uri.
  35121. * @param uri The uri to decode
  35122. * @return The decoded base64 data.
  35123. */
  35124. static DecodeBase64(uri: string): ArrayBuffer;
  35125. /**
  35126. * Gets the absolute url.
  35127. * @param url the input url
  35128. * @return the absolute url
  35129. */
  35130. static GetAbsoluteUrl(url: string): string;
  35131. /**
  35132. * No log
  35133. */
  35134. static readonly NoneLogLevel: number;
  35135. /**
  35136. * Only message logs
  35137. */
  35138. static readonly MessageLogLevel: number;
  35139. /**
  35140. * Only warning logs
  35141. */
  35142. static readonly WarningLogLevel: number;
  35143. /**
  35144. * Only error logs
  35145. */
  35146. static readonly ErrorLogLevel: number;
  35147. /**
  35148. * All logs
  35149. */
  35150. static readonly AllLogLevel: number;
  35151. /**
  35152. * Gets a value indicating the number of loading errors
  35153. * @ignorenaming
  35154. */
  35155. static get errorsCount(): number;
  35156. /**
  35157. * Callback called when a new log is added
  35158. */
  35159. static OnNewCacheEntry: (entry: string) => void;
  35160. /**
  35161. * Log a message to the console
  35162. * @param message defines the message to log
  35163. */
  35164. static Log(message: string): void;
  35165. /**
  35166. * Write a warning message to the console
  35167. * @param message defines the message to log
  35168. */
  35169. static Warn(message: string): void;
  35170. /**
  35171. * Write an error message to the console
  35172. * @param message defines the message to log
  35173. */
  35174. static Error(message: string): void;
  35175. /**
  35176. * Gets current log cache (list of logs)
  35177. */
  35178. static get LogCache(): string;
  35179. /**
  35180. * Clears the log cache
  35181. */
  35182. static ClearLogCache(): void;
  35183. /**
  35184. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35185. */
  35186. static set LogLevels(level: number);
  35187. /**
  35188. * Checks if the window object exists
  35189. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35190. */
  35191. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35192. /**
  35193. * No performance log
  35194. */
  35195. static readonly PerformanceNoneLogLevel: number;
  35196. /**
  35197. * Use user marks to log performance
  35198. */
  35199. static readonly PerformanceUserMarkLogLevel: number;
  35200. /**
  35201. * Log performance to the console
  35202. */
  35203. static readonly PerformanceConsoleLogLevel: number;
  35204. private static _performance;
  35205. /**
  35206. * Sets the current performance log level
  35207. */
  35208. static set PerformanceLogLevel(level: number);
  35209. private static _StartPerformanceCounterDisabled;
  35210. private static _EndPerformanceCounterDisabled;
  35211. private static _StartUserMark;
  35212. private static _EndUserMark;
  35213. private static _StartPerformanceConsole;
  35214. private static _EndPerformanceConsole;
  35215. /**
  35216. * Starts a performance counter
  35217. */
  35218. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35219. /**
  35220. * Ends a specific performance coutner
  35221. */
  35222. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35223. /**
  35224. * Gets either window.performance.now() if supported or Date.now() else
  35225. */
  35226. static get Now(): number;
  35227. /**
  35228. * This method will return the name of the class used to create the instance of the given object.
  35229. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35230. * @param object the object to get the class name from
  35231. * @param isType defines if the object is actually a type
  35232. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35233. */
  35234. static GetClassName(object: any, isType?: boolean): string;
  35235. /**
  35236. * Gets the first element of an array satisfying a given predicate
  35237. * @param array defines the array to browse
  35238. * @param predicate defines the predicate to use
  35239. * @returns null if not found or the element
  35240. */
  35241. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35242. /**
  35243. * This method will return the name of the full name of the class, including its owning module (if any).
  35244. * 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).
  35245. * @param object the object to get the class name from
  35246. * @param isType defines if the object is actually a type
  35247. * @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.
  35248. * @ignorenaming
  35249. */
  35250. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35251. /**
  35252. * Returns a promise that resolves after the given amount of time.
  35253. * @param delay Number of milliseconds to delay
  35254. * @returns Promise that resolves after the given amount of time
  35255. */
  35256. static DelayAsync(delay: number): Promise<void>;
  35257. /**
  35258. * Utility function to detect if the current user agent is Safari
  35259. * @returns whether or not the current user agent is safari
  35260. */
  35261. static IsSafari(): boolean;
  35262. }
  35263. /**
  35264. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35265. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35266. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35267. * @param name The name of the class, case should be preserved
  35268. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35269. */
  35270. export function className(name: string, module?: string): (target: Object) => void;
  35271. /**
  35272. * An implementation of a loop for asynchronous functions.
  35273. */
  35274. export class AsyncLoop {
  35275. /**
  35276. * Defines the number of iterations for the loop
  35277. */
  35278. iterations: number;
  35279. /**
  35280. * Defines the current index of the loop.
  35281. */
  35282. index: number;
  35283. private _done;
  35284. private _fn;
  35285. private _successCallback;
  35286. /**
  35287. * Constructor.
  35288. * @param iterations the number of iterations.
  35289. * @param func the function to run each iteration
  35290. * @param successCallback the callback that will be called upon succesful execution
  35291. * @param offset starting offset.
  35292. */
  35293. constructor(
  35294. /**
  35295. * Defines the number of iterations for the loop
  35296. */
  35297. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35298. /**
  35299. * Execute the next iteration. Must be called after the last iteration was finished.
  35300. */
  35301. executeNext(): void;
  35302. /**
  35303. * Break the loop and run the success callback.
  35304. */
  35305. breakLoop(): void;
  35306. /**
  35307. * Create and run an async loop.
  35308. * @param iterations the number of iterations.
  35309. * @param fn the function to run each iteration
  35310. * @param successCallback the callback that will be called upon succesful execution
  35311. * @param offset starting offset.
  35312. * @returns the created async loop object
  35313. */
  35314. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35315. /**
  35316. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35317. * @param iterations total number of iterations
  35318. * @param syncedIterations number of synchronous iterations in each async iteration.
  35319. * @param fn the function to call each iteration.
  35320. * @param callback a success call back that will be called when iterating stops.
  35321. * @param breakFunction a break condition (optional)
  35322. * @param timeout timeout settings for the setTimeout function. default - 0.
  35323. * @returns the created async loop object
  35324. */
  35325. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35326. }
  35327. }
  35328. declare module "babylonjs/Misc/stringDictionary" {
  35329. import { Nullable } from "babylonjs/types";
  35330. /**
  35331. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35332. * The underlying implementation relies on an associative array to ensure the best performances.
  35333. * The value can be anything including 'null' but except 'undefined'
  35334. */
  35335. export class StringDictionary<T> {
  35336. /**
  35337. * This will clear this dictionary and copy the content from the 'source' one.
  35338. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35339. * @param source the dictionary to take the content from and copy to this dictionary
  35340. */
  35341. copyFrom(source: StringDictionary<T>): void;
  35342. /**
  35343. * Get a value based from its key
  35344. * @param key the given key to get the matching value from
  35345. * @return the value if found, otherwise undefined is returned
  35346. */
  35347. get(key: string): T | undefined;
  35348. /**
  35349. * Get a value from its key or add it if it doesn't exist.
  35350. * This method will ensure you that a given key/data will be present in the dictionary.
  35351. * @param key the given key to get the matching value from
  35352. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35353. * The factory will only be invoked if there's no data for the given key.
  35354. * @return the value corresponding to the key.
  35355. */
  35356. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35357. /**
  35358. * Get a value from its key if present in the dictionary otherwise add it
  35359. * @param key the key to get the value from
  35360. * @param val if there's no such key/value pair in the dictionary add it with this value
  35361. * @return the value corresponding to the key
  35362. */
  35363. getOrAdd(key: string, val: T): T;
  35364. /**
  35365. * Check if there's a given key in the dictionary
  35366. * @param key the key to check for
  35367. * @return true if the key is present, false otherwise
  35368. */
  35369. contains(key: string): boolean;
  35370. /**
  35371. * Add a new key and its corresponding value
  35372. * @param key the key to add
  35373. * @param value the value corresponding to the key
  35374. * @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
  35375. */
  35376. add(key: string, value: T): boolean;
  35377. /**
  35378. * Update a specific value associated to a key
  35379. * @param key defines the key to use
  35380. * @param value defines the value to store
  35381. * @returns true if the value was updated (or false if the key was not found)
  35382. */
  35383. set(key: string, value: T): boolean;
  35384. /**
  35385. * Get the element of the given key and remove it from the dictionary
  35386. * @param key defines the key to search
  35387. * @returns the value associated with the key or null if not found
  35388. */
  35389. getAndRemove(key: string): Nullable<T>;
  35390. /**
  35391. * Remove a key/value from the dictionary.
  35392. * @param key the key to remove
  35393. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35394. */
  35395. remove(key: string): boolean;
  35396. /**
  35397. * Clear the whole content of the dictionary
  35398. */
  35399. clear(): void;
  35400. /**
  35401. * Gets the current count
  35402. */
  35403. get count(): number;
  35404. /**
  35405. * Execute a callback on each key/val of the dictionary.
  35406. * Note that you can remove any element in this dictionary in the callback implementation
  35407. * @param callback the callback to execute on a given key/value pair
  35408. */
  35409. forEach(callback: (key: string, val: T) => void): void;
  35410. /**
  35411. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35412. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35413. * Note that you can remove any element in this dictionary in the callback implementation
  35414. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35415. * @returns the first item
  35416. */
  35417. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35418. private _count;
  35419. private _data;
  35420. }
  35421. }
  35422. declare module "babylonjs/Collisions/collisionCoordinator" {
  35423. import { Nullable } from "babylonjs/types";
  35424. import { Scene } from "babylonjs/scene";
  35425. import { Vector3 } from "babylonjs/Maths/math.vector";
  35426. import { Collider } from "babylonjs/Collisions/collider";
  35427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35428. /** @hidden */
  35429. export interface ICollisionCoordinator {
  35430. createCollider(): Collider;
  35431. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35432. init(scene: Scene): void;
  35433. }
  35434. /** @hidden */
  35435. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35436. private _scene;
  35437. private _scaledPosition;
  35438. private _scaledVelocity;
  35439. private _finalPosition;
  35440. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35441. createCollider(): Collider;
  35442. init(scene: Scene): void;
  35443. private _collideWithWorld;
  35444. }
  35445. }
  35446. declare module "babylonjs/Inputs/scene.inputManager" {
  35447. import { Nullable } from "babylonjs/types";
  35448. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35449. import { Vector2 } from "babylonjs/Maths/math.vector";
  35450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35451. import { Scene } from "babylonjs/scene";
  35452. /**
  35453. * Class used to manage all inputs for the scene.
  35454. */
  35455. export class InputManager {
  35456. /** The distance in pixel that you have to move to prevent some events */
  35457. static DragMovementThreshold: number;
  35458. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35459. static LongPressDelay: number;
  35460. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35461. static DoubleClickDelay: number;
  35462. /** If you need to check double click without raising a single click at first click, enable this flag */
  35463. static ExclusiveDoubleClickMode: boolean;
  35464. private _wheelEventName;
  35465. private _onPointerMove;
  35466. private _onPointerDown;
  35467. private _onPointerUp;
  35468. private _initClickEvent;
  35469. private _initActionManager;
  35470. private _delayedSimpleClick;
  35471. private _delayedSimpleClickTimeout;
  35472. private _previousDelayedSimpleClickTimeout;
  35473. private _meshPickProceed;
  35474. private _previousButtonPressed;
  35475. private _currentPickResult;
  35476. private _previousPickResult;
  35477. private _totalPointersPressed;
  35478. private _doubleClickOccured;
  35479. private _pointerOverMesh;
  35480. private _pickedDownMesh;
  35481. private _pickedUpMesh;
  35482. private _pointerX;
  35483. private _pointerY;
  35484. private _unTranslatedPointerX;
  35485. private _unTranslatedPointerY;
  35486. private _startingPointerPosition;
  35487. private _previousStartingPointerPosition;
  35488. private _startingPointerTime;
  35489. private _previousStartingPointerTime;
  35490. private _pointerCaptures;
  35491. private _onKeyDown;
  35492. private _onKeyUp;
  35493. private _onCanvasFocusObserver;
  35494. private _onCanvasBlurObserver;
  35495. private _scene;
  35496. /**
  35497. * Creates a new InputManager
  35498. * @param scene defines the hosting scene
  35499. */
  35500. constructor(scene: Scene);
  35501. /**
  35502. * Gets the mesh that is currently under the pointer
  35503. */
  35504. get meshUnderPointer(): Nullable<AbstractMesh>;
  35505. /**
  35506. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35507. */
  35508. get unTranslatedPointer(): Vector2;
  35509. /**
  35510. * Gets or sets the current on-screen X position of the pointer
  35511. */
  35512. get pointerX(): number;
  35513. set pointerX(value: number);
  35514. /**
  35515. * Gets or sets the current on-screen Y position of the pointer
  35516. */
  35517. get pointerY(): number;
  35518. set pointerY(value: number);
  35519. private _updatePointerPosition;
  35520. private _processPointerMove;
  35521. private _setRayOnPointerInfo;
  35522. private _checkPrePointerObservable;
  35523. /**
  35524. * Use this method to simulate a pointer move on a mesh
  35525. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35526. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35527. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35528. */
  35529. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35530. /**
  35531. * Use this method to simulate a pointer down on a mesh
  35532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35535. */
  35536. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35537. private _processPointerDown;
  35538. /** @hidden */
  35539. _isPointerSwiping(): boolean;
  35540. /**
  35541. * Use this method to simulate a pointer up on a mesh
  35542. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35543. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35544. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35545. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35546. */
  35547. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35548. private _processPointerUp;
  35549. /**
  35550. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35551. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35552. * @returns true if the pointer was captured
  35553. */
  35554. isPointerCaptured(pointerId?: number): boolean;
  35555. /**
  35556. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35557. * @param attachUp defines if you want to attach events to pointerup
  35558. * @param attachDown defines if you want to attach events to pointerdown
  35559. * @param attachMove defines if you want to attach events to pointermove
  35560. */
  35561. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35562. /**
  35563. * Detaches all event handlers
  35564. */
  35565. detachControl(): void;
  35566. /**
  35567. * Force the value of meshUnderPointer
  35568. * @param mesh defines the mesh to use
  35569. */
  35570. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35571. /**
  35572. * Gets the mesh under the pointer
  35573. * @returns a Mesh or null if no mesh is under the pointer
  35574. */
  35575. getPointerOverMesh(): Nullable<AbstractMesh>;
  35576. }
  35577. }
  35578. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35579. /**
  35580. * Helper class used to generate session unique ID
  35581. */
  35582. export class UniqueIdGenerator {
  35583. private static _UniqueIdCounter;
  35584. /**
  35585. * Gets an unique (relatively to the current scene) Id
  35586. */
  35587. static get UniqueId(): number;
  35588. }
  35589. }
  35590. declare module "babylonjs/Animations/animationGroup" {
  35591. import { Animatable } from "babylonjs/Animations/animatable";
  35592. import { Animation } from "babylonjs/Animations/animation";
  35593. import { Scene, IDisposable } from "babylonjs/scene";
  35594. import { Observable } from "babylonjs/Misc/observable";
  35595. import { Nullable } from "babylonjs/types";
  35596. import "babylonjs/Animations/animatable";
  35597. /**
  35598. * This class defines the direct association between an animation and a target
  35599. */
  35600. export class TargetedAnimation {
  35601. /**
  35602. * Animation to perform
  35603. */
  35604. animation: Animation;
  35605. /**
  35606. * Target to animate
  35607. */
  35608. target: any;
  35609. /**
  35610. * Serialize the object
  35611. * @returns the JSON object representing the current entity
  35612. */
  35613. serialize(): any;
  35614. }
  35615. /**
  35616. * Use this class to create coordinated animations on multiple targets
  35617. */
  35618. export class AnimationGroup implements IDisposable {
  35619. /** The name of the animation group */
  35620. name: string;
  35621. private _scene;
  35622. private _targetedAnimations;
  35623. private _animatables;
  35624. private _from;
  35625. private _to;
  35626. private _isStarted;
  35627. private _isPaused;
  35628. private _speedRatio;
  35629. private _loopAnimation;
  35630. /**
  35631. * Gets or sets the unique id of the node
  35632. */
  35633. uniqueId: number;
  35634. /**
  35635. * This observable will notify when one animation have ended
  35636. */
  35637. onAnimationEndObservable: Observable<TargetedAnimation>;
  35638. /**
  35639. * Observer raised when one animation loops
  35640. */
  35641. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35642. /**
  35643. * Observer raised when all animations have looped
  35644. */
  35645. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35646. /**
  35647. * This observable will notify when all animations have ended.
  35648. */
  35649. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35650. /**
  35651. * This observable will notify when all animations have paused.
  35652. */
  35653. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35654. /**
  35655. * This observable will notify when all animations are playing.
  35656. */
  35657. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35658. /**
  35659. * Gets the first frame
  35660. */
  35661. get from(): number;
  35662. /**
  35663. * Gets the last frame
  35664. */
  35665. get to(): number;
  35666. /**
  35667. * Define if the animations are started
  35668. */
  35669. get isStarted(): boolean;
  35670. /**
  35671. * Gets a value indicating that the current group is playing
  35672. */
  35673. get isPlaying(): boolean;
  35674. /**
  35675. * Gets or sets the speed ratio to use for all animations
  35676. */
  35677. get speedRatio(): number;
  35678. /**
  35679. * Gets or sets the speed ratio to use for all animations
  35680. */
  35681. set speedRatio(value: number);
  35682. /**
  35683. * Gets or sets if all animations should loop or not
  35684. */
  35685. get loopAnimation(): boolean;
  35686. set loopAnimation(value: boolean);
  35687. /**
  35688. * Gets the targeted animations for this animation group
  35689. */
  35690. get targetedAnimations(): Array<TargetedAnimation>;
  35691. /**
  35692. * returning the list of animatables controlled by this animation group.
  35693. */
  35694. get animatables(): Array<Animatable>;
  35695. /**
  35696. * Instantiates a new Animation Group.
  35697. * This helps managing several animations at once.
  35698. * @see http://doc.babylonjs.com/how_to/group
  35699. * @param name Defines the name of the group
  35700. * @param scene Defines the scene the group belongs to
  35701. */
  35702. constructor(
  35703. /** The name of the animation group */
  35704. name: string, scene?: Nullable<Scene>);
  35705. /**
  35706. * Add an animation (with its target) in the group
  35707. * @param animation defines the animation we want to add
  35708. * @param target defines the target of the animation
  35709. * @returns the TargetedAnimation object
  35710. */
  35711. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35712. /**
  35713. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35714. * It can add constant keys at begin or end
  35715. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35716. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35717. * @returns the animation group
  35718. */
  35719. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35720. private _animationLoopCount;
  35721. private _animationLoopFlags;
  35722. private _processLoop;
  35723. /**
  35724. * Start all animations on given targets
  35725. * @param loop defines if animations must loop
  35726. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35727. * @param from defines the from key (optional)
  35728. * @param to defines the to key (optional)
  35729. * @returns the current animation group
  35730. */
  35731. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35732. /**
  35733. * Pause all animations
  35734. * @returns the animation group
  35735. */
  35736. pause(): AnimationGroup;
  35737. /**
  35738. * Play all animations to initial state
  35739. * This function will start() the animations if they were not started or will restart() them if they were paused
  35740. * @param loop defines if animations must loop
  35741. * @returns the animation group
  35742. */
  35743. play(loop?: boolean): AnimationGroup;
  35744. /**
  35745. * Reset all animations to initial state
  35746. * @returns the animation group
  35747. */
  35748. reset(): AnimationGroup;
  35749. /**
  35750. * Restart animations from key 0
  35751. * @returns the animation group
  35752. */
  35753. restart(): AnimationGroup;
  35754. /**
  35755. * Stop all animations
  35756. * @returns the animation group
  35757. */
  35758. stop(): AnimationGroup;
  35759. /**
  35760. * Set animation weight for all animatables
  35761. * @param weight defines the weight to use
  35762. * @return the animationGroup
  35763. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35764. */
  35765. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35766. /**
  35767. * Synchronize and normalize all animatables with a source animatable
  35768. * @param root defines the root animatable to synchronize with
  35769. * @return the animationGroup
  35770. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35771. */
  35772. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35773. /**
  35774. * Goes to a specific frame in this animation group
  35775. * @param frame the frame number to go to
  35776. * @return the animationGroup
  35777. */
  35778. goToFrame(frame: number): AnimationGroup;
  35779. /**
  35780. * Dispose all associated resources
  35781. */
  35782. dispose(): void;
  35783. private _checkAnimationGroupEnded;
  35784. /**
  35785. * Clone the current animation group and returns a copy
  35786. * @param newName defines the name of the new group
  35787. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35788. * @returns the new aniamtion group
  35789. */
  35790. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35791. /**
  35792. * Serializes the animationGroup to an object
  35793. * @returns Serialized object
  35794. */
  35795. serialize(): any;
  35796. /**
  35797. * Returns a new AnimationGroup object parsed from the source provided.
  35798. * @param parsedAnimationGroup defines the source
  35799. * @param scene defines the scene that will receive the animationGroup
  35800. * @returns a new AnimationGroup
  35801. */
  35802. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35803. /**
  35804. * Returns the string "AnimationGroup"
  35805. * @returns "AnimationGroup"
  35806. */
  35807. getClassName(): string;
  35808. /**
  35809. * Creates a detailled string about the object
  35810. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35811. * @returns a string representing the object
  35812. */
  35813. toString(fullDetails?: boolean): string;
  35814. }
  35815. }
  35816. declare module "babylonjs/scene" {
  35817. import { Nullable } from "babylonjs/types";
  35818. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35819. import { Observable } from "babylonjs/Misc/observable";
  35820. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35821. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35822. import { Geometry } from "babylonjs/Meshes/geometry";
  35823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35824. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35826. import { Mesh } from "babylonjs/Meshes/mesh";
  35827. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35828. import { Bone } from "babylonjs/Bones/bone";
  35829. import { Skeleton } from "babylonjs/Bones/skeleton";
  35830. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35831. import { Camera } from "babylonjs/Cameras/camera";
  35832. import { AbstractScene } from "babylonjs/abstractScene";
  35833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35834. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35835. import { Material } from "babylonjs/Materials/material";
  35836. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35837. import { Effect } from "babylonjs/Materials/effect";
  35838. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35839. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35840. import { Light } from "babylonjs/Lights/light";
  35841. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35842. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35843. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35844. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35845. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35846. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35847. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35848. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35849. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35850. import { Engine } from "babylonjs/Engines/engine";
  35851. import { Node } from "babylonjs/node";
  35852. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35853. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35854. import { WebRequest } from "babylonjs/Misc/webRequest";
  35855. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35856. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35857. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35858. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35859. import { Plane } from "babylonjs/Maths/math.plane";
  35860. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35861. import { Ray } from "babylonjs/Culling/ray";
  35862. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35863. import { Animation } from "babylonjs/Animations/animation";
  35864. import { Animatable } from "babylonjs/Animations/animatable";
  35865. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35866. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35867. import { Collider } from "babylonjs/Collisions/collider";
  35868. /**
  35869. * Define an interface for all classes that will hold resources
  35870. */
  35871. export interface IDisposable {
  35872. /**
  35873. * Releases all held resources
  35874. */
  35875. dispose(): void;
  35876. }
  35877. /** Interface defining initialization parameters for Scene class */
  35878. export interface SceneOptions {
  35879. /**
  35880. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35881. * It will improve performance when the number of geometries becomes important.
  35882. */
  35883. useGeometryUniqueIdsMap?: boolean;
  35884. /**
  35885. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35886. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35887. */
  35888. useMaterialMeshMap?: boolean;
  35889. /**
  35890. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35891. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35892. */
  35893. useClonedMeshMap?: boolean;
  35894. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35895. virtual?: boolean;
  35896. }
  35897. /**
  35898. * Represents a scene to be rendered by the engine.
  35899. * @see http://doc.babylonjs.com/features/scene
  35900. */
  35901. export class Scene extends AbstractScene implements IAnimatable {
  35902. /** The fog is deactivated */
  35903. static readonly FOGMODE_NONE: number;
  35904. /** The fog density is following an exponential function */
  35905. static readonly FOGMODE_EXP: number;
  35906. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35907. static readonly FOGMODE_EXP2: number;
  35908. /** The fog density is following a linear function. */
  35909. static readonly FOGMODE_LINEAR: number;
  35910. /**
  35911. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35913. */
  35914. static MinDeltaTime: number;
  35915. /**
  35916. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35917. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35918. */
  35919. static MaxDeltaTime: number;
  35920. /**
  35921. * Factory used to create the default material.
  35922. * @param name The name of the material to create
  35923. * @param scene The scene to create the material for
  35924. * @returns The default material
  35925. */
  35926. static DefaultMaterialFactory(scene: Scene): Material;
  35927. /**
  35928. * Factory used to create the a collision coordinator.
  35929. * @returns The collision coordinator
  35930. */
  35931. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35932. /** @hidden */
  35933. _inputManager: InputManager;
  35934. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35935. cameraToUseForPointers: Nullable<Camera>;
  35936. /** @hidden */
  35937. readonly _isScene: boolean;
  35938. /**
  35939. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35940. */
  35941. autoClear: boolean;
  35942. /**
  35943. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35944. */
  35945. autoClearDepthAndStencil: boolean;
  35946. /**
  35947. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35948. */
  35949. clearColor: Color4;
  35950. /**
  35951. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35952. */
  35953. ambientColor: Color3;
  35954. /**
  35955. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35956. * It should only be one of the following (if not the default embedded one):
  35957. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35958. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35959. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35960. * The material properties need to be setup according to the type of texture in use.
  35961. */
  35962. environmentBRDFTexture: BaseTexture;
  35963. /** @hidden */
  35964. protected _environmentTexture: Nullable<BaseTexture>;
  35965. /**
  35966. * Texture used in all pbr material as the reflection texture.
  35967. * As in the majority of the scene they are the same (exception for multi room and so on),
  35968. * this is easier to reference from here than from all the materials.
  35969. */
  35970. get environmentTexture(): Nullable<BaseTexture>;
  35971. /**
  35972. * Texture used in all pbr material as the reflection texture.
  35973. * As in the majority of the scene they are the same (exception for multi room and so on),
  35974. * this is easier to set here than in all the materials.
  35975. */
  35976. set environmentTexture(value: Nullable<BaseTexture>);
  35977. /** @hidden */
  35978. protected _environmentIntensity: number;
  35979. /**
  35980. * Intensity of the environment in all pbr material.
  35981. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35982. * As in the majority of the scene they are the same (exception for multi room and so on),
  35983. * this is easier to reference from here than from all the materials.
  35984. */
  35985. get environmentIntensity(): number;
  35986. /**
  35987. * Intensity of the environment in all pbr material.
  35988. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35989. * As in the majority of the scene they are the same (exception for multi room and so on),
  35990. * this is easier to set here than in all the materials.
  35991. */
  35992. set environmentIntensity(value: number);
  35993. /** @hidden */
  35994. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35995. /**
  35996. * Default image processing configuration used either in the rendering
  35997. * Forward main pass or through the imageProcessingPostProcess if present.
  35998. * As in the majority of the scene they are the same (exception for multi camera),
  35999. * this is easier to reference from here than from all the materials and post process.
  36000. *
  36001. * No setter as we it is a shared configuration, you can set the values instead.
  36002. */
  36003. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36004. private _forceWireframe;
  36005. /**
  36006. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36007. */
  36008. set forceWireframe(value: boolean);
  36009. get forceWireframe(): boolean;
  36010. private _skipFrustumClipping;
  36011. /**
  36012. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36013. */
  36014. set skipFrustumClipping(value: boolean);
  36015. get skipFrustumClipping(): boolean;
  36016. private _forcePointsCloud;
  36017. /**
  36018. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36019. */
  36020. set forcePointsCloud(value: boolean);
  36021. get forcePointsCloud(): boolean;
  36022. /**
  36023. * Gets or sets the active clipplane 1
  36024. */
  36025. clipPlane: Nullable<Plane>;
  36026. /**
  36027. * Gets or sets the active clipplane 2
  36028. */
  36029. clipPlane2: Nullable<Plane>;
  36030. /**
  36031. * Gets or sets the active clipplane 3
  36032. */
  36033. clipPlane3: Nullable<Plane>;
  36034. /**
  36035. * Gets or sets the active clipplane 4
  36036. */
  36037. clipPlane4: Nullable<Plane>;
  36038. /**
  36039. * Gets or sets the active clipplane 5
  36040. */
  36041. clipPlane5: Nullable<Plane>;
  36042. /**
  36043. * Gets or sets the active clipplane 6
  36044. */
  36045. clipPlane6: Nullable<Plane>;
  36046. /**
  36047. * Gets or sets a boolean indicating if animations are enabled
  36048. */
  36049. animationsEnabled: boolean;
  36050. private _animationPropertiesOverride;
  36051. /**
  36052. * Gets or sets the animation properties override
  36053. */
  36054. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36055. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36056. /**
  36057. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36058. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36059. */
  36060. useConstantAnimationDeltaTime: boolean;
  36061. /**
  36062. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36063. * Please note that it requires to run a ray cast through the scene on every frame
  36064. */
  36065. constantlyUpdateMeshUnderPointer: boolean;
  36066. /**
  36067. * Defines the HTML cursor to use when hovering over interactive elements
  36068. */
  36069. hoverCursor: string;
  36070. /**
  36071. * Defines the HTML default cursor to use (empty by default)
  36072. */
  36073. defaultCursor: string;
  36074. /**
  36075. * Defines wether cursors are handled by the scene.
  36076. */
  36077. doNotHandleCursors: boolean;
  36078. /**
  36079. * This is used to call preventDefault() on pointer down
  36080. * in order to block unwanted artifacts like system double clicks
  36081. */
  36082. preventDefaultOnPointerDown: boolean;
  36083. /**
  36084. * This is used to call preventDefault() on pointer up
  36085. * in order to block unwanted artifacts like system double clicks
  36086. */
  36087. preventDefaultOnPointerUp: boolean;
  36088. /**
  36089. * Gets or sets user defined metadata
  36090. */
  36091. metadata: any;
  36092. /**
  36093. * For internal use only. Please do not use.
  36094. */
  36095. reservedDataStore: any;
  36096. /**
  36097. * Gets the name of the plugin used to load this scene (null by default)
  36098. */
  36099. loadingPluginName: string;
  36100. /**
  36101. * Use this array to add regular expressions used to disable offline support for specific urls
  36102. */
  36103. disableOfflineSupportExceptionRules: RegExp[];
  36104. /**
  36105. * An event triggered when the scene is disposed.
  36106. */
  36107. onDisposeObservable: Observable<Scene>;
  36108. private _onDisposeObserver;
  36109. /** Sets a function to be executed when this scene is disposed. */
  36110. set onDispose(callback: () => void);
  36111. /**
  36112. * An event triggered before rendering the scene (right after animations and physics)
  36113. */
  36114. onBeforeRenderObservable: Observable<Scene>;
  36115. private _onBeforeRenderObserver;
  36116. /** Sets a function to be executed before rendering this scene */
  36117. set beforeRender(callback: Nullable<() => void>);
  36118. /**
  36119. * An event triggered after rendering the scene
  36120. */
  36121. onAfterRenderObservable: Observable<Scene>;
  36122. /**
  36123. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36124. */
  36125. onAfterRenderCameraObservable: Observable<Camera>;
  36126. private _onAfterRenderObserver;
  36127. /** Sets a function to be executed after rendering this scene */
  36128. set afterRender(callback: Nullable<() => void>);
  36129. /**
  36130. * An event triggered before animating the scene
  36131. */
  36132. onBeforeAnimationsObservable: Observable<Scene>;
  36133. /**
  36134. * An event triggered after animations processing
  36135. */
  36136. onAfterAnimationsObservable: Observable<Scene>;
  36137. /**
  36138. * An event triggered before draw calls are ready to be sent
  36139. */
  36140. onBeforeDrawPhaseObservable: Observable<Scene>;
  36141. /**
  36142. * An event triggered after draw calls have been sent
  36143. */
  36144. onAfterDrawPhaseObservable: Observable<Scene>;
  36145. /**
  36146. * An event triggered when the scene is ready
  36147. */
  36148. onReadyObservable: Observable<Scene>;
  36149. /**
  36150. * An event triggered before rendering a camera
  36151. */
  36152. onBeforeCameraRenderObservable: Observable<Camera>;
  36153. private _onBeforeCameraRenderObserver;
  36154. /** Sets a function to be executed before rendering a camera*/
  36155. set beforeCameraRender(callback: () => void);
  36156. /**
  36157. * An event triggered after rendering a camera
  36158. */
  36159. onAfterCameraRenderObservable: Observable<Camera>;
  36160. private _onAfterCameraRenderObserver;
  36161. /** Sets a function to be executed after rendering a camera*/
  36162. set afterCameraRender(callback: () => void);
  36163. /**
  36164. * An event triggered when active meshes evaluation is about to start
  36165. */
  36166. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36167. /**
  36168. * An event triggered when active meshes evaluation is done
  36169. */
  36170. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36171. /**
  36172. * An event triggered when particles rendering is about to start
  36173. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36174. */
  36175. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36176. /**
  36177. * An event triggered when particles rendering is done
  36178. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36179. */
  36180. onAfterParticlesRenderingObservable: Observable<Scene>;
  36181. /**
  36182. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36183. */
  36184. onDataLoadedObservable: Observable<Scene>;
  36185. /**
  36186. * An event triggered when a camera is created
  36187. */
  36188. onNewCameraAddedObservable: Observable<Camera>;
  36189. /**
  36190. * An event triggered when a camera is removed
  36191. */
  36192. onCameraRemovedObservable: Observable<Camera>;
  36193. /**
  36194. * An event triggered when a light is created
  36195. */
  36196. onNewLightAddedObservable: Observable<Light>;
  36197. /**
  36198. * An event triggered when a light is removed
  36199. */
  36200. onLightRemovedObservable: Observable<Light>;
  36201. /**
  36202. * An event triggered when a geometry is created
  36203. */
  36204. onNewGeometryAddedObservable: Observable<Geometry>;
  36205. /**
  36206. * An event triggered when a geometry is removed
  36207. */
  36208. onGeometryRemovedObservable: Observable<Geometry>;
  36209. /**
  36210. * An event triggered when a transform node is created
  36211. */
  36212. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36213. /**
  36214. * An event triggered when a transform node is removed
  36215. */
  36216. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36217. /**
  36218. * An event triggered when a mesh is created
  36219. */
  36220. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36221. /**
  36222. * An event triggered when a mesh is removed
  36223. */
  36224. onMeshRemovedObservable: Observable<AbstractMesh>;
  36225. /**
  36226. * An event triggered when a skeleton is created
  36227. */
  36228. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36229. /**
  36230. * An event triggered when a skeleton is removed
  36231. */
  36232. onSkeletonRemovedObservable: Observable<Skeleton>;
  36233. /**
  36234. * An event triggered when a material is created
  36235. */
  36236. onNewMaterialAddedObservable: Observable<Material>;
  36237. /**
  36238. * An event triggered when a material is removed
  36239. */
  36240. onMaterialRemovedObservable: Observable<Material>;
  36241. /**
  36242. * An event triggered when a texture is created
  36243. */
  36244. onNewTextureAddedObservable: Observable<BaseTexture>;
  36245. /**
  36246. * An event triggered when a texture is removed
  36247. */
  36248. onTextureRemovedObservable: Observable<BaseTexture>;
  36249. /**
  36250. * An event triggered when render targets are about to be rendered
  36251. * Can happen multiple times per frame.
  36252. */
  36253. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36254. /**
  36255. * An event triggered when render targets were rendered.
  36256. * Can happen multiple times per frame.
  36257. */
  36258. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36259. /**
  36260. * An event triggered before calculating deterministic simulation step
  36261. */
  36262. onBeforeStepObservable: Observable<Scene>;
  36263. /**
  36264. * An event triggered after calculating deterministic simulation step
  36265. */
  36266. onAfterStepObservable: Observable<Scene>;
  36267. /**
  36268. * An event triggered when the activeCamera property is updated
  36269. */
  36270. onActiveCameraChanged: Observable<Scene>;
  36271. /**
  36272. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36273. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36274. * 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)
  36275. */
  36276. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36277. /**
  36278. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36279. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36280. * 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)
  36281. */
  36282. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36283. /**
  36284. * This Observable will when a mesh has been imported into the scene.
  36285. */
  36286. onMeshImportedObservable: Observable<AbstractMesh>;
  36287. /**
  36288. * This Observable will when an animation file has been imported into the scene.
  36289. */
  36290. onAnimationFileImportedObservable: Observable<Scene>;
  36291. /**
  36292. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36293. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36294. */
  36295. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36296. /** @hidden */
  36297. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36298. /**
  36299. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36300. */
  36301. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36302. /**
  36303. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36304. */
  36305. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36306. /**
  36307. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36308. */
  36309. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36310. /** Callback called when a pointer move is detected */
  36311. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36312. /** Callback called when a pointer down is detected */
  36313. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36314. /** Callback called when a pointer up is detected */
  36315. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36316. /** Callback called when a pointer pick is detected */
  36317. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36318. /**
  36319. * 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).
  36320. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36321. */
  36322. onPrePointerObservable: Observable<PointerInfoPre>;
  36323. /**
  36324. * Observable event triggered each time an input event is received from the rendering canvas
  36325. */
  36326. onPointerObservable: Observable<PointerInfo>;
  36327. /**
  36328. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36329. */
  36330. get unTranslatedPointer(): Vector2;
  36331. /**
  36332. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36333. */
  36334. static get DragMovementThreshold(): number;
  36335. static set DragMovementThreshold(value: number);
  36336. /**
  36337. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36338. */
  36339. static get LongPressDelay(): number;
  36340. static set LongPressDelay(value: number);
  36341. /**
  36342. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36343. */
  36344. static get DoubleClickDelay(): number;
  36345. static set DoubleClickDelay(value: number);
  36346. /** If you need to check double click without raising a single click at first click, enable this flag */
  36347. static get ExclusiveDoubleClickMode(): boolean;
  36348. static set ExclusiveDoubleClickMode(value: boolean);
  36349. /** @hidden */
  36350. _mirroredCameraPosition: Nullable<Vector3>;
  36351. /**
  36352. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36353. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36354. */
  36355. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36356. /**
  36357. * Observable event triggered each time an keyboard event is received from the hosting window
  36358. */
  36359. onKeyboardObservable: Observable<KeyboardInfo>;
  36360. private _useRightHandedSystem;
  36361. /**
  36362. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36363. */
  36364. set useRightHandedSystem(value: boolean);
  36365. get useRightHandedSystem(): boolean;
  36366. private _timeAccumulator;
  36367. private _currentStepId;
  36368. private _currentInternalStep;
  36369. /**
  36370. * Sets the step Id used by deterministic lock step
  36371. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36372. * @param newStepId defines the step Id
  36373. */
  36374. setStepId(newStepId: number): void;
  36375. /**
  36376. * Gets the step Id used by deterministic lock step
  36377. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36378. * @returns the step Id
  36379. */
  36380. getStepId(): number;
  36381. /**
  36382. * Gets the internal step used by deterministic lock step
  36383. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36384. * @returns the internal step
  36385. */
  36386. getInternalStep(): number;
  36387. private _fogEnabled;
  36388. /**
  36389. * Gets or sets a boolean indicating if fog is enabled on this scene
  36390. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36391. * (Default is true)
  36392. */
  36393. set fogEnabled(value: boolean);
  36394. get fogEnabled(): boolean;
  36395. private _fogMode;
  36396. /**
  36397. * Gets or sets the fog mode to use
  36398. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36399. * | mode | value |
  36400. * | --- | --- |
  36401. * | FOGMODE_NONE | 0 |
  36402. * | FOGMODE_EXP | 1 |
  36403. * | FOGMODE_EXP2 | 2 |
  36404. * | FOGMODE_LINEAR | 3 |
  36405. */
  36406. set fogMode(value: number);
  36407. get fogMode(): number;
  36408. /**
  36409. * Gets or sets the fog color to use
  36410. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36411. * (Default is Color3(0.2, 0.2, 0.3))
  36412. */
  36413. fogColor: Color3;
  36414. /**
  36415. * Gets or sets the fog density to use
  36416. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36417. * (Default is 0.1)
  36418. */
  36419. fogDensity: number;
  36420. /**
  36421. * Gets or sets the fog start distance to use
  36422. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36423. * (Default is 0)
  36424. */
  36425. fogStart: number;
  36426. /**
  36427. * Gets or sets the fog end distance to use
  36428. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36429. * (Default is 1000)
  36430. */
  36431. fogEnd: number;
  36432. private _shadowsEnabled;
  36433. /**
  36434. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36435. */
  36436. set shadowsEnabled(value: boolean);
  36437. get shadowsEnabled(): boolean;
  36438. private _lightsEnabled;
  36439. /**
  36440. * Gets or sets a boolean indicating if lights are enabled on this scene
  36441. */
  36442. set lightsEnabled(value: boolean);
  36443. get lightsEnabled(): boolean;
  36444. /** All of the active cameras added to this scene. */
  36445. activeCameras: Camera[];
  36446. /** @hidden */
  36447. _activeCamera: Nullable<Camera>;
  36448. /** Gets or sets the current active camera */
  36449. get activeCamera(): Nullable<Camera>;
  36450. set activeCamera(value: Nullable<Camera>);
  36451. private _defaultMaterial;
  36452. /** The default material used on meshes when no material is affected */
  36453. get defaultMaterial(): Material;
  36454. /** The default material used on meshes when no material is affected */
  36455. set defaultMaterial(value: Material);
  36456. private _texturesEnabled;
  36457. /**
  36458. * Gets or sets a boolean indicating if textures are enabled on this scene
  36459. */
  36460. set texturesEnabled(value: boolean);
  36461. get texturesEnabled(): boolean;
  36462. /**
  36463. * Gets or sets a boolean indicating if particles are enabled on this scene
  36464. */
  36465. particlesEnabled: boolean;
  36466. /**
  36467. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36468. */
  36469. spritesEnabled: boolean;
  36470. private _skeletonsEnabled;
  36471. /**
  36472. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36473. */
  36474. set skeletonsEnabled(value: boolean);
  36475. get skeletonsEnabled(): boolean;
  36476. /**
  36477. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36478. */
  36479. lensFlaresEnabled: boolean;
  36480. /**
  36481. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36483. */
  36484. collisionsEnabled: boolean;
  36485. private _collisionCoordinator;
  36486. /** @hidden */
  36487. get collisionCoordinator(): ICollisionCoordinator;
  36488. /**
  36489. * Defines the gravity applied to this scene (used only for collisions)
  36490. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36491. */
  36492. gravity: Vector3;
  36493. /**
  36494. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36495. */
  36496. postProcessesEnabled: boolean;
  36497. /**
  36498. * The list of postprocesses added to the scene
  36499. */
  36500. postProcesses: PostProcess[];
  36501. /**
  36502. * Gets the current postprocess manager
  36503. */
  36504. postProcessManager: PostProcessManager;
  36505. /**
  36506. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36507. */
  36508. renderTargetsEnabled: boolean;
  36509. /**
  36510. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36511. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36512. */
  36513. dumpNextRenderTargets: boolean;
  36514. /**
  36515. * The list of user defined render targets added to the scene
  36516. */
  36517. customRenderTargets: RenderTargetTexture[];
  36518. /**
  36519. * Defines if texture loading must be delayed
  36520. * If true, textures will only be loaded when they need to be rendered
  36521. */
  36522. useDelayedTextureLoading: boolean;
  36523. /**
  36524. * Gets the list of meshes imported to the scene through SceneLoader
  36525. */
  36526. importedMeshesFiles: String[];
  36527. /**
  36528. * Gets or sets a boolean indicating if probes are enabled on this scene
  36529. */
  36530. probesEnabled: boolean;
  36531. /**
  36532. * Gets or sets the current offline provider to use to store scene data
  36533. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36534. */
  36535. offlineProvider: IOfflineProvider;
  36536. /**
  36537. * Gets or sets the action manager associated with the scene
  36538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36539. */
  36540. actionManager: AbstractActionManager;
  36541. private _meshesForIntersections;
  36542. /**
  36543. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36544. */
  36545. proceduralTexturesEnabled: boolean;
  36546. private _engine;
  36547. private _totalVertices;
  36548. /** @hidden */
  36549. _activeIndices: PerfCounter;
  36550. /** @hidden */
  36551. _activeParticles: PerfCounter;
  36552. /** @hidden */
  36553. _activeBones: PerfCounter;
  36554. private _animationRatio;
  36555. /** @hidden */
  36556. _animationTimeLast: number;
  36557. /** @hidden */
  36558. _animationTime: number;
  36559. /**
  36560. * Gets or sets a general scale for animation speed
  36561. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36562. */
  36563. animationTimeScale: number;
  36564. /** @hidden */
  36565. _cachedMaterial: Nullable<Material>;
  36566. /** @hidden */
  36567. _cachedEffect: Nullable<Effect>;
  36568. /** @hidden */
  36569. _cachedVisibility: Nullable<number>;
  36570. private _renderId;
  36571. private _frameId;
  36572. private _executeWhenReadyTimeoutId;
  36573. private _intermediateRendering;
  36574. private _viewUpdateFlag;
  36575. private _projectionUpdateFlag;
  36576. /** @hidden */
  36577. _toBeDisposed: Nullable<IDisposable>[];
  36578. private _activeRequests;
  36579. /** @hidden */
  36580. _pendingData: any[];
  36581. private _isDisposed;
  36582. /**
  36583. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36584. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36585. */
  36586. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36587. private _activeMeshes;
  36588. private _processedMaterials;
  36589. private _renderTargets;
  36590. /** @hidden */
  36591. _activeParticleSystems: SmartArray<IParticleSystem>;
  36592. private _activeSkeletons;
  36593. private _softwareSkinnedMeshes;
  36594. private _renderingManager;
  36595. /** @hidden */
  36596. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36597. private _transformMatrix;
  36598. private _sceneUbo;
  36599. /** @hidden */
  36600. _viewMatrix: Matrix;
  36601. private _projectionMatrix;
  36602. /** @hidden */
  36603. _forcedViewPosition: Nullable<Vector3>;
  36604. /** @hidden */
  36605. _frustumPlanes: Plane[];
  36606. /**
  36607. * Gets the list of frustum planes (built from the active camera)
  36608. */
  36609. get frustumPlanes(): Plane[];
  36610. /**
  36611. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36612. * This is useful if there are more lights that the maximum simulteanous authorized
  36613. */
  36614. requireLightSorting: boolean;
  36615. /** @hidden */
  36616. readonly useMaterialMeshMap: boolean;
  36617. /** @hidden */
  36618. readonly useClonedMeshMap: boolean;
  36619. private _externalData;
  36620. private _uid;
  36621. /**
  36622. * @hidden
  36623. * Backing store of defined scene components.
  36624. */
  36625. _components: ISceneComponent[];
  36626. /**
  36627. * @hidden
  36628. * Backing store of defined scene components.
  36629. */
  36630. _serializableComponents: ISceneSerializableComponent[];
  36631. /**
  36632. * List of components to register on the next registration step.
  36633. */
  36634. private _transientComponents;
  36635. /**
  36636. * Registers the transient components if needed.
  36637. */
  36638. private _registerTransientComponents;
  36639. /**
  36640. * @hidden
  36641. * Add a component to the scene.
  36642. * Note that the ccomponent could be registered on th next frame if this is called after
  36643. * the register component stage.
  36644. * @param component Defines the component to add to the scene
  36645. */
  36646. _addComponent(component: ISceneComponent): void;
  36647. /**
  36648. * @hidden
  36649. * Gets a component from the scene.
  36650. * @param name defines the name of the component to retrieve
  36651. * @returns the component or null if not present
  36652. */
  36653. _getComponent(name: string): Nullable<ISceneComponent>;
  36654. /**
  36655. * @hidden
  36656. * Defines the actions happening before camera updates.
  36657. */
  36658. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36659. /**
  36660. * @hidden
  36661. * Defines the actions happening before clear the canvas.
  36662. */
  36663. _beforeClearStage: Stage<SimpleStageAction>;
  36664. /**
  36665. * @hidden
  36666. * Defines the actions when collecting render targets for the frame.
  36667. */
  36668. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36669. /**
  36670. * @hidden
  36671. * Defines the actions happening for one camera in the frame.
  36672. */
  36673. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36674. /**
  36675. * @hidden
  36676. * Defines the actions happening during the per mesh ready checks.
  36677. */
  36678. _isReadyForMeshStage: Stage<MeshStageAction>;
  36679. /**
  36680. * @hidden
  36681. * Defines the actions happening before evaluate active mesh checks.
  36682. */
  36683. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36684. /**
  36685. * @hidden
  36686. * Defines the actions happening during the evaluate sub mesh checks.
  36687. */
  36688. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36689. /**
  36690. * @hidden
  36691. * Defines the actions happening during the active mesh stage.
  36692. */
  36693. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36694. /**
  36695. * @hidden
  36696. * Defines the actions happening during the per camera render target step.
  36697. */
  36698. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36699. /**
  36700. * @hidden
  36701. * Defines the actions happening just before the active camera is drawing.
  36702. */
  36703. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36704. /**
  36705. * @hidden
  36706. * Defines the actions happening just before a render target is drawing.
  36707. */
  36708. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36709. /**
  36710. * @hidden
  36711. * Defines the actions happening just before a rendering group is drawing.
  36712. */
  36713. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36714. /**
  36715. * @hidden
  36716. * Defines the actions happening just before a mesh is drawing.
  36717. */
  36718. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36719. /**
  36720. * @hidden
  36721. * Defines the actions happening just after a mesh has been drawn.
  36722. */
  36723. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36724. /**
  36725. * @hidden
  36726. * Defines the actions happening just after a rendering group has been drawn.
  36727. */
  36728. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36729. /**
  36730. * @hidden
  36731. * Defines the actions happening just after the active camera has been drawn.
  36732. */
  36733. _afterCameraDrawStage: Stage<CameraStageAction>;
  36734. /**
  36735. * @hidden
  36736. * Defines the actions happening just after a render target has been drawn.
  36737. */
  36738. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36739. /**
  36740. * @hidden
  36741. * Defines the actions happening just after rendering all cameras and computing intersections.
  36742. */
  36743. _afterRenderStage: Stage<SimpleStageAction>;
  36744. /**
  36745. * @hidden
  36746. * Defines the actions happening when a pointer move event happens.
  36747. */
  36748. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36749. /**
  36750. * @hidden
  36751. * Defines the actions happening when a pointer down event happens.
  36752. */
  36753. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36754. /**
  36755. * @hidden
  36756. * Defines the actions happening when a pointer up event happens.
  36757. */
  36758. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36759. /**
  36760. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36761. */
  36762. private geometriesByUniqueId;
  36763. /**
  36764. * Creates a new Scene
  36765. * @param engine defines the engine to use to render this scene
  36766. * @param options defines the scene options
  36767. */
  36768. constructor(engine: Engine, options?: SceneOptions);
  36769. /**
  36770. * Gets a string idenfifying the name of the class
  36771. * @returns "Scene" string
  36772. */
  36773. getClassName(): string;
  36774. private _defaultMeshCandidates;
  36775. /**
  36776. * @hidden
  36777. */
  36778. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36779. private _defaultSubMeshCandidates;
  36780. /**
  36781. * @hidden
  36782. */
  36783. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36784. /**
  36785. * Sets the default candidate providers for the scene.
  36786. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36787. * and getCollidingSubMeshCandidates to their default function
  36788. */
  36789. setDefaultCandidateProviders(): void;
  36790. /**
  36791. * Gets the mesh that is currently under the pointer
  36792. */
  36793. get meshUnderPointer(): Nullable<AbstractMesh>;
  36794. /**
  36795. * Gets or sets the current on-screen X position of the pointer
  36796. */
  36797. get pointerX(): number;
  36798. set pointerX(value: number);
  36799. /**
  36800. * Gets or sets the current on-screen Y position of the pointer
  36801. */
  36802. get pointerY(): number;
  36803. set pointerY(value: number);
  36804. /**
  36805. * Gets the cached material (ie. the latest rendered one)
  36806. * @returns the cached material
  36807. */
  36808. getCachedMaterial(): Nullable<Material>;
  36809. /**
  36810. * Gets the cached effect (ie. the latest rendered one)
  36811. * @returns the cached effect
  36812. */
  36813. getCachedEffect(): Nullable<Effect>;
  36814. /**
  36815. * Gets the cached visibility state (ie. the latest rendered one)
  36816. * @returns the cached visibility state
  36817. */
  36818. getCachedVisibility(): Nullable<number>;
  36819. /**
  36820. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36821. * @param material defines the current material
  36822. * @param effect defines the current effect
  36823. * @param visibility defines the current visibility state
  36824. * @returns true if one parameter is not cached
  36825. */
  36826. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36827. /**
  36828. * Gets the engine associated with the scene
  36829. * @returns an Engine
  36830. */
  36831. getEngine(): Engine;
  36832. /**
  36833. * Gets the total number of vertices rendered per frame
  36834. * @returns the total number of vertices rendered per frame
  36835. */
  36836. getTotalVertices(): number;
  36837. /**
  36838. * Gets the performance counter for total vertices
  36839. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36840. */
  36841. get totalVerticesPerfCounter(): PerfCounter;
  36842. /**
  36843. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36844. * @returns the total number of active indices rendered per frame
  36845. */
  36846. getActiveIndices(): number;
  36847. /**
  36848. * Gets the performance counter for active indices
  36849. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36850. */
  36851. get totalActiveIndicesPerfCounter(): PerfCounter;
  36852. /**
  36853. * Gets the total number of active particles rendered per frame
  36854. * @returns the total number of active particles rendered per frame
  36855. */
  36856. getActiveParticles(): number;
  36857. /**
  36858. * Gets the performance counter for active particles
  36859. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36860. */
  36861. get activeParticlesPerfCounter(): PerfCounter;
  36862. /**
  36863. * Gets the total number of active bones rendered per frame
  36864. * @returns the total number of active bones rendered per frame
  36865. */
  36866. getActiveBones(): number;
  36867. /**
  36868. * Gets the performance counter for active bones
  36869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36870. */
  36871. get activeBonesPerfCounter(): PerfCounter;
  36872. /**
  36873. * Gets the array of active meshes
  36874. * @returns an array of AbstractMesh
  36875. */
  36876. getActiveMeshes(): SmartArray<AbstractMesh>;
  36877. /**
  36878. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36879. * @returns a number
  36880. */
  36881. getAnimationRatio(): number;
  36882. /**
  36883. * Gets an unique Id for the current render phase
  36884. * @returns a number
  36885. */
  36886. getRenderId(): number;
  36887. /**
  36888. * Gets an unique Id for the current frame
  36889. * @returns a number
  36890. */
  36891. getFrameId(): number;
  36892. /** Call this function if you want to manually increment the render Id*/
  36893. incrementRenderId(): void;
  36894. private _createUbo;
  36895. /**
  36896. * Use this method to simulate a pointer move on a mesh
  36897. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36898. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36899. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36900. * @returns the current scene
  36901. */
  36902. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36903. /**
  36904. * Use this method to simulate a pointer down on a mesh
  36905. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36906. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36907. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36908. * @returns the current scene
  36909. */
  36910. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36911. /**
  36912. * Use this method to simulate a pointer up on a mesh
  36913. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36914. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36915. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36916. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36917. * @returns the current scene
  36918. */
  36919. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36920. /**
  36921. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36922. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36923. * @returns true if the pointer was captured
  36924. */
  36925. isPointerCaptured(pointerId?: number): boolean;
  36926. /**
  36927. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36928. * @param attachUp defines if you want to attach events to pointerup
  36929. * @param attachDown defines if you want to attach events to pointerdown
  36930. * @param attachMove defines if you want to attach events to pointermove
  36931. */
  36932. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36933. /** Detaches all event handlers*/
  36934. detachControl(): void;
  36935. /**
  36936. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36937. * Delay loaded resources are not taking in account
  36938. * @return true if all required resources are ready
  36939. */
  36940. isReady(): boolean;
  36941. /** Resets all cached information relative to material (including effect and visibility) */
  36942. resetCachedMaterial(): void;
  36943. /**
  36944. * Registers a function to be called before every frame render
  36945. * @param func defines the function to register
  36946. */
  36947. registerBeforeRender(func: () => void): void;
  36948. /**
  36949. * Unregisters a function called before every frame render
  36950. * @param func defines the function to unregister
  36951. */
  36952. unregisterBeforeRender(func: () => void): void;
  36953. /**
  36954. * Registers a function to be called after every frame render
  36955. * @param func defines the function to register
  36956. */
  36957. registerAfterRender(func: () => void): void;
  36958. /**
  36959. * Unregisters a function called after every frame render
  36960. * @param func defines the function to unregister
  36961. */
  36962. unregisterAfterRender(func: () => void): void;
  36963. private _executeOnceBeforeRender;
  36964. /**
  36965. * The provided function will run before render once and will be disposed afterwards.
  36966. * A timeout delay can be provided so that the function will be executed in N ms.
  36967. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36968. * @param func The function to be executed.
  36969. * @param timeout optional delay in ms
  36970. */
  36971. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36972. /** @hidden */
  36973. _addPendingData(data: any): void;
  36974. /** @hidden */
  36975. _removePendingData(data: any): void;
  36976. /**
  36977. * Returns the number of items waiting to be loaded
  36978. * @returns the number of items waiting to be loaded
  36979. */
  36980. getWaitingItemsCount(): number;
  36981. /**
  36982. * Returns a boolean indicating if the scene is still loading data
  36983. */
  36984. get isLoading(): boolean;
  36985. /**
  36986. * Registers a function to be executed when the scene is ready
  36987. * @param {Function} func - the function to be executed
  36988. */
  36989. executeWhenReady(func: () => void): void;
  36990. /**
  36991. * Returns a promise that resolves when the scene is ready
  36992. * @returns A promise that resolves when the scene is ready
  36993. */
  36994. whenReadyAsync(): Promise<void>;
  36995. /** @hidden */
  36996. _checkIsReady(): void;
  36997. /**
  36998. * Gets all animatable attached to the scene
  36999. */
  37000. get animatables(): Animatable[];
  37001. /**
  37002. * Resets the last animation time frame.
  37003. * Useful to override when animations start running when loading a scene for the first time.
  37004. */
  37005. resetLastAnimationTimeFrame(): void;
  37006. /**
  37007. * Gets the current view matrix
  37008. * @returns a Matrix
  37009. */
  37010. getViewMatrix(): Matrix;
  37011. /**
  37012. * Gets the current projection matrix
  37013. * @returns a Matrix
  37014. */
  37015. getProjectionMatrix(): Matrix;
  37016. /**
  37017. * Gets the current transform matrix
  37018. * @returns a Matrix made of View * Projection
  37019. */
  37020. getTransformMatrix(): Matrix;
  37021. /**
  37022. * Sets the current transform matrix
  37023. * @param viewL defines the View matrix to use
  37024. * @param projectionL defines the Projection matrix to use
  37025. * @param viewR defines the right View matrix to use (if provided)
  37026. * @param projectionR defines the right Projection matrix to use (if provided)
  37027. */
  37028. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37029. /**
  37030. * Gets the uniform buffer used to store scene data
  37031. * @returns a UniformBuffer
  37032. */
  37033. getSceneUniformBuffer(): UniformBuffer;
  37034. /**
  37035. * Gets an unique (relatively to the current scene) Id
  37036. * @returns an unique number for the scene
  37037. */
  37038. getUniqueId(): number;
  37039. /**
  37040. * Add a mesh to the list of scene's meshes
  37041. * @param newMesh defines the mesh to add
  37042. * @param recursive if all child meshes should also be added to the scene
  37043. */
  37044. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37045. /**
  37046. * Remove a mesh for the list of scene's meshes
  37047. * @param toRemove defines the mesh to remove
  37048. * @param recursive if all child meshes should also be removed from the scene
  37049. * @returns the index where the mesh was in the mesh list
  37050. */
  37051. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37052. /**
  37053. * Add a transform node to the list of scene's transform nodes
  37054. * @param newTransformNode defines the transform node to add
  37055. */
  37056. addTransformNode(newTransformNode: TransformNode): void;
  37057. /**
  37058. * Remove a transform node for the list of scene's transform nodes
  37059. * @param toRemove defines the transform node to remove
  37060. * @returns the index where the transform node was in the transform node list
  37061. */
  37062. removeTransformNode(toRemove: TransformNode): number;
  37063. /**
  37064. * Remove a skeleton for the list of scene's skeletons
  37065. * @param toRemove defines the skeleton to remove
  37066. * @returns the index where the skeleton was in the skeleton list
  37067. */
  37068. removeSkeleton(toRemove: Skeleton): number;
  37069. /**
  37070. * Remove a morph target for the list of scene's morph targets
  37071. * @param toRemove defines the morph target to remove
  37072. * @returns the index where the morph target was in the morph target list
  37073. */
  37074. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37075. /**
  37076. * Remove a light for the list of scene's lights
  37077. * @param toRemove defines the light to remove
  37078. * @returns the index where the light was in the light list
  37079. */
  37080. removeLight(toRemove: Light): number;
  37081. /**
  37082. * Remove a camera for the list of scene's cameras
  37083. * @param toRemove defines the camera to remove
  37084. * @returns the index where the camera was in the camera list
  37085. */
  37086. removeCamera(toRemove: Camera): number;
  37087. /**
  37088. * Remove a particle system for the list of scene's particle systems
  37089. * @param toRemove defines the particle system to remove
  37090. * @returns the index where the particle system was in the particle system list
  37091. */
  37092. removeParticleSystem(toRemove: IParticleSystem): number;
  37093. /**
  37094. * Remove a animation for the list of scene's animations
  37095. * @param toRemove defines the animation to remove
  37096. * @returns the index where the animation was in the animation list
  37097. */
  37098. removeAnimation(toRemove: Animation): number;
  37099. /**
  37100. * Will stop the animation of the given target
  37101. * @param target - the target
  37102. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37103. * @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)
  37104. */
  37105. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37106. /**
  37107. * Removes the given animation group from this scene.
  37108. * @param toRemove The animation group to remove
  37109. * @returns The index of the removed animation group
  37110. */
  37111. removeAnimationGroup(toRemove: AnimationGroup): number;
  37112. /**
  37113. * Removes the given multi-material from this scene.
  37114. * @param toRemove The multi-material to remove
  37115. * @returns The index of the removed multi-material
  37116. */
  37117. removeMultiMaterial(toRemove: MultiMaterial): number;
  37118. /**
  37119. * Removes the given material from this scene.
  37120. * @param toRemove The material to remove
  37121. * @returns The index of the removed material
  37122. */
  37123. removeMaterial(toRemove: Material): number;
  37124. /**
  37125. * Removes the given action manager from this scene.
  37126. * @param toRemove The action manager to remove
  37127. * @returns The index of the removed action manager
  37128. */
  37129. removeActionManager(toRemove: AbstractActionManager): number;
  37130. /**
  37131. * Removes the given texture from this scene.
  37132. * @param toRemove The texture to remove
  37133. * @returns The index of the removed texture
  37134. */
  37135. removeTexture(toRemove: BaseTexture): number;
  37136. /**
  37137. * Adds the given light to this scene
  37138. * @param newLight The light to add
  37139. */
  37140. addLight(newLight: Light): void;
  37141. /**
  37142. * Sorts the list list based on light priorities
  37143. */
  37144. sortLightsByPriority(): void;
  37145. /**
  37146. * Adds the given camera to this scene
  37147. * @param newCamera The camera to add
  37148. */
  37149. addCamera(newCamera: Camera): void;
  37150. /**
  37151. * Adds the given skeleton to this scene
  37152. * @param newSkeleton The skeleton to add
  37153. */
  37154. addSkeleton(newSkeleton: Skeleton): void;
  37155. /**
  37156. * Adds the given particle system to this scene
  37157. * @param newParticleSystem The particle system to add
  37158. */
  37159. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37160. /**
  37161. * Adds the given animation to this scene
  37162. * @param newAnimation The animation to add
  37163. */
  37164. addAnimation(newAnimation: Animation): void;
  37165. /**
  37166. * Adds the given animation group to this scene.
  37167. * @param newAnimationGroup The animation group to add
  37168. */
  37169. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37170. /**
  37171. * Adds the given multi-material to this scene
  37172. * @param newMultiMaterial The multi-material to add
  37173. */
  37174. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37175. /**
  37176. * Adds the given material to this scene
  37177. * @param newMaterial The material to add
  37178. */
  37179. addMaterial(newMaterial: Material): void;
  37180. /**
  37181. * Adds the given morph target to this scene
  37182. * @param newMorphTargetManager The morph target to add
  37183. */
  37184. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37185. /**
  37186. * Adds the given geometry to this scene
  37187. * @param newGeometry The geometry to add
  37188. */
  37189. addGeometry(newGeometry: Geometry): void;
  37190. /**
  37191. * Adds the given action manager to this scene
  37192. * @param newActionManager The action manager to add
  37193. */
  37194. addActionManager(newActionManager: AbstractActionManager): void;
  37195. /**
  37196. * Adds the given texture to this scene.
  37197. * @param newTexture The texture to add
  37198. */
  37199. addTexture(newTexture: BaseTexture): void;
  37200. /**
  37201. * Switch active camera
  37202. * @param newCamera defines the new active camera
  37203. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37204. */
  37205. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37206. /**
  37207. * sets the active camera of the scene using its ID
  37208. * @param id defines the camera's ID
  37209. * @return the new active camera or null if none found.
  37210. */
  37211. setActiveCameraByID(id: string): Nullable<Camera>;
  37212. /**
  37213. * sets the active camera of the scene using its name
  37214. * @param name defines the camera's name
  37215. * @returns the new active camera or null if none found.
  37216. */
  37217. setActiveCameraByName(name: string): Nullable<Camera>;
  37218. /**
  37219. * get an animation group using its name
  37220. * @param name defines the material's name
  37221. * @return the animation group or null if none found.
  37222. */
  37223. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37224. /**
  37225. * Get a material using its unique id
  37226. * @param uniqueId defines the material's unique id
  37227. * @return the material or null if none found.
  37228. */
  37229. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37230. /**
  37231. * get a material using its id
  37232. * @param id defines the material's ID
  37233. * @return the material or null if none found.
  37234. */
  37235. getMaterialByID(id: string): Nullable<Material>;
  37236. /**
  37237. * Gets a the last added material using a given id
  37238. * @param id defines the material's ID
  37239. * @return the last material with the given id or null if none found.
  37240. */
  37241. getLastMaterialByID(id: string): Nullable<Material>;
  37242. /**
  37243. * Gets a material using its name
  37244. * @param name defines the material's name
  37245. * @return the material or null if none found.
  37246. */
  37247. getMaterialByName(name: string): Nullable<Material>;
  37248. /**
  37249. * Get a texture using its unique id
  37250. * @param uniqueId defines the texture's unique id
  37251. * @return the texture or null if none found.
  37252. */
  37253. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37254. /**
  37255. * Gets a camera using its id
  37256. * @param id defines the id to look for
  37257. * @returns the camera or null if not found
  37258. */
  37259. getCameraByID(id: string): Nullable<Camera>;
  37260. /**
  37261. * Gets a camera using its unique id
  37262. * @param uniqueId defines the unique id to look for
  37263. * @returns the camera or null if not found
  37264. */
  37265. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37266. /**
  37267. * Gets a camera using its name
  37268. * @param name defines the camera's name
  37269. * @return the camera or null if none found.
  37270. */
  37271. getCameraByName(name: string): Nullable<Camera>;
  37272. /**
  37273. * Gets a bone using its id
  37274. * @param id defines the bone's id
  37275. * @return the bone or null if not found
  37276. */
  37277. getBoneByID(id: string): Nullable<Bone>;
  37278. /**
  37279. * Gets a bone using its id
  37280. * @param name defines the bone's name
  37281. * @return the bone or null if not found
  37282. */
  37283. getBoneByName(name: string): Nullable<Bone>;
  37284. /**
  37285. * Gets a light node using its name
  37286. * @param name defines the the light's name
  37287. * @return the light or null if none found.
  37288. */
  37289. getLightByName(name: string): Nullable<Light>;
  37290. /**
  37291. * Gets a light node using its id
  37292. * @param id defines the light's id
  37293. * @return the light or null if none found.
  37294. */
  37295. getLightByID(id: string): Nullable<Light>;
  37296. /**
  37297. * Gets a light node using its scene-generated unique ID
  37298. * @param uniqueId defines the light's unique id
  37299. * @return the light or null if none found.
  37300. */
  37301. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37302. /**
  37303. * Gets a particle system by id
  37304. * @param id defines the particle system id
  37305. * @return the corresponding system or null if none found
  37306. */
  37307. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37308. /**
  37309. * Gets a geometry using its ID
  37310. * @param id defines the geometry's id
  37311. * @return the geometry or null if none found.
  37312. */
  37313. getGeometryByID(id: string): Nullable<Geometry>;
  37314. private _getGeometryByUniqueID;
  37315. /**
  37316. * Add a new geometry to this scene
  37317. * @param geometry defines the geometry to be added to the scene.
  37318. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37319. * @return a boolean defining if the geometry was added or not
  37320. */
  37321. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37322. /**
  37323. * Removes an existing geometry
  37324. * @param geometry defines the geometry to be removed from the scene
  37325. * @return a boolean defining if the geometry was removed or not
  37326. */
  37327. removeGeometry(geometry: Geometry): boolean;
  37328. /**
  37329. * Gets the list of geometries attached to the scene
  37330. * @returns an array of Geometry
  37331. */
  37332. getGeometries(): Geometry[];
  37333. /**
  37334. * Gets the first added mesh found of a given ID
  37335. * @param id defines the id to search for
  37336. * @return the mesh found or null if not found at all
  37337. */
  37338. getMeshByID(id: string): Nullable<AbstractMesh>;
  37339. /**
  37340. * Gets a list of meshes using their id
  37341. * @param id defines the id to search for
  37342. * @returns a list of meshes
  37343. */
  37344. getMeshesByID(id: string): Array<AbstractMesh>;
  37345. /**
  37346. * Gets the first added transform node found of a given ID
  37347. * @param id defines the id to search for
  37348. * @return the found transform node or null if not found at all.
  37349. */
  37350. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37351. /**
  37352. * Gets a transform node with its auto-generated unique id
  37353. * @param uniqueId efines the unique id to search for
  37354. * @return the found transform node or null if not found at all.
  37355. */
  37356. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37357. /**
  37358. * Gets a list of transform nodes using their id
  37359. * @param id defines the id to search for
  37360. * @returns a list of transform nodes
  37361. */
  37362. getTransformNodesByID(id: string): Array<TransformNode>;
  37363. /**
  37364. * Gets a mesh with its auto-generated unique id
  37365. * @param uniqueId defines the unique id to search for
  37366. * @return the found mesh or null if not found at all.
  37367. */
  37368. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37369. /**
  37370. * Gets a the last added mesh using a given id
  37371. * @param id defines the id to search for
  37372. * @return the found mesh or null if not found at all.
  37373. */
  37374. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37375. /**
  37376. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37377. * @param id defines the id to search for
  37378. * @return the found node or null if not found at all
  37379. */
  37380. getLastEntryByID(id: string): Nullable<Node>;
  37381. /**
  37382. * Gets a node (Mesh, Camera, Light) using a given id
  37383. * @param id defines the id to search for
  37384. * @return the found node or null if not found at all
  37385. */
  37386. getNodeByID(id: string): Nullable<Node>;
  37387. /**
  37388. * Gets a node (Mesh, Camera, Light) using a given name
  37389. * @param name defines the name to search for
  37390. * @return the found node or null if not found at all.
  37391. */
  37392. getNodeByName(name: string): Nullable<Node>;
  37393. /**
  37394. * Gets a mesh using a given name
  37395. * @param name defines the name to search for
  37396. * @return the found mesh or null if not found at all.
  37397. */
  37398. getMeshByName(name: string): Nullable<AbstractMesh>;
  37399. /**
  37400. * Gets a transform node using a given name
  37401. * @param name defines the name to search for
  37402. * @return the found transform node or null if not found at all.
  37403. */
  37404. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37405. /**
  37406. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37407. * @param id defines the id to search for
  37408. * @return the found skeleton or null if not found at all.
  37409. */
  37410. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37411. /**
  37412. * Gets a skeleton using a given auto generated unique id
  37413. * @param uniqueId defines the unique id to search for
  37414. * @return the found skeleton or null if not found at all.
  37415. */
  37416. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37417. /**
  37418. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37419. * @param id defines the id to search for
  37420. * @return the found skeleton or null if not found at all.
  37421. */
  37422. getSkeletonById(id: string): Nullable<Skeleton>;
  37423. /**
  37424. * Gets a skeleton using a given name
  37425. * @param name defines the name to search for
  37426. * @return the found skeleton or null if not found at all.
  37427. */
  37428. getSkeletonByName(name: string): Nullable<Skeleton>;
  37429. /**
  37430. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37431. * @param id defines the id to search for
  37432. * @return the found morph target manager or null if not found at all.
  37433. */
  37434. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37435. /**
  37436. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37437. * @param id defines the id to search for
  37438. * @return the found morph target or null if not found at all.
  37439. */
  37440. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37441. /**
  37442. * Gets a boolean indicating if the given mesh is active
  37443. * @param mesh defines the mesh to look for
  37444. * @returns true if the mesh is in the active list
  37445. */
  37446. isActiveMesh(mesh: AbstractMesh): boolean;
  37447. /**
  37448. * Return a unique id as a string which can serve as an identifier for the scene
  37449. */
  37450. get uid(): string;
  37451. /**
  37452. * Add an externaly attached data from its key.
  37453. * This method call will fail and return false, if such key already exists.
  37454. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37455. * @param key the unique key that identifies the data
  37456. * @param data the data object to associate to the key for this Engine instance
  37457. * @return true if no such key were already present and the data was added successfully, false otherwise
  37458. */
  37459. addExternalData<T>(key: string, data: T): boolean;
  37460. /**
  37461. * Get an externaly attached data from its key
  37462. * @param key the unique key that identifies the data
  37463. * @return the associated data, if present (can be null), or undefined if not present
  37464. */
  37465. getExternalData<T>(key: string): Nullable<T>;
  37466. /**
  37467. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37468. * @param key the unique key that identifies the data
  37469. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37470. * @return the associated data, can be null if the factory returned null.
  37471. */
  37472. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37473. /**
  37474. * Remove an externaly attached data from the Engine instance
  37475. * @param key the unique key that identifies the data
  37476. * @return true if the data was successfully removed, false if it doesn't exist
  37477. */
  37478. removeExternalData(key: string): boolean;
  37479. private _evaluateSubMesh;
  37480. /**
  37481. * Clear the processed materials smart array preventing retention point in material dispose.
  37482. */
  37483. freeProcessedMaterials(): void;
  37484. private _preventFreeActiveMeshesAndRenderingGroups;
  37485. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37486. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37487. * when disposing several meshes in a row or a hierarchy of meshes.
  37488. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37489. */
  37490. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37491. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37492. /**
  37493. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37494. */
  37495. freeActiveMeshes(): void;
  37496. /**
  37497. * Clear the info related to rendering groups preventing retention points during dispose.
  37498. */
  37499. freeRenderingGroups(): void;
  37500. /** @hidden */
  37501. _isInIntermediateRendering(): boolean;
  37502. /**
  37503. * Lambda returning the list of potentially active meshes.
  37504. */
  37505. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37506. /**
  37507. * Lambda returning the list of potentially active sub meshes.
  37508. */
  37509. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37510. /**
  37511. * Lambda returning the list of potentially intersecting sub meshes.
  37512. */
  37513. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37514. /**
  37515. * Lambda returning the list of potentially colliding sub meshes.
  37516. */
  37517. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37518. private _activeMeshesFrozen;
  37519. private _skipEvaluateActiveMeshesCompletely;
  37520. /**
  37521. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37522. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37523. * @returns the current scene
  37524. */
  37525. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37526. /**
  37527. * Use this function to restart evaluating active meshes on every frame
  37528. * @returns the current scene
  37529. */
  37530. unfreezeActiveMeshes(): Scene;
  37531. private _evaluateActiveMeshes;
  37532. private _activeMesh;
  37533. /**
  37534. * Update the transform matrix to update from the current active camera
  37535. * @param force defines a boolean used to force the update even if cache is up to date
  37536. */
  37537. updateTransformMatrix(force?: boolean): void;
  37538. private _bindFrameBuffer;
  37539. /** @hidden */
  37540. _allowPostProcessClearColor: boolean;
  37541. /** @hidden */
  37542. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37543. private _processSubCameras;
  37544. private _checkIntersections;
  37545. /** @hidden */
  37546. _advancePhysicsEngineStep(step: number): void;
  37547. /**
  37548. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37549. */
  37550. getDeterministicFrameTime: () => number;
  37551. /** @hidden */
  37552. _animate(): void;
  37553. /** Execute all animations (for a frame) */
  37554. animate(): void;
  37555. /**
  37556. * Render the scene
  37557. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37558. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37559. */
  37560. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37561. /**
  37562. * Freeze all materials
  37563. * A frozen material will not be updatable but should be faster to render
  37564. */
  37565. freezeMaterials(): void;
  37566. /**
  37567. * Unfreeze all materials
  37568. * A frozen material will not be updatable but should be faster to render
  37569. */
  37570. unfreezeMaterials(): void;
  37571. /**
  37572. * Releases all held ressources
  37573. */
  37574. dispose(): void;
  37575. /**
  37576. * Gets if the scene is already disposed
  37577. */
  37578. get isDisposed(): boolean;
  37579. /**
  37580. * Call this function to reduce memory footprint of the scene.
  37581. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37582. */
  37583. clearCachedVertexData(): void;
  37584. /**
  37585. * This function will remove the local cached buffer data from texture.
  37586. * It will save memory but will prevent the texture from being rebuilt
  37587. */
  37588. cleanCachedTextureBuffer(): void;
  37589. /**
  37590. * Get the world extend vectors with an optional filter
  37591. *
  37592. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37593. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37594. */
  37595. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37596. min: Vector3;
  37597. max: Vector3;
  37598. };
  37599. /**
  37600. * Creates a ray that can be used to pick in the scene
  37601. * @param x defines the x coordinate of the origin (on-screen)
  37602. * @param y defines the y coordinate of the origin (on-screen)
  37603. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37604. * @param camera defines the camera to use for the picking
  37605. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37606. * @returns a Ray
  37607. */
  37608. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37609. /**
  37610. * Creates a ray that can be used to pick in the scene
  37611. * @param x defines the x coordinate of the origin (on-screen)
  37612. * @param y defines the y coordinate of the origin (on-screen)
  37613. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37614. * @param result defines the ray where to store the picking ray
  37615. * @param camera defines the camera to use for the picking
  37616. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37617. * @returns the current scene
  37618. */
  37619. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37620. /**
  37621. * Creates a ray that can be used to pick in the scene
  37622. * @param x defines the x coordinate of the origin (on-screen)
  37623. * @param y defines the y coordinate of the origin (on-screen)
  37624. * @param camera defines the camera to use for the picking
  37625. * @returns a Ray
  37626. */
  37627. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37628. /**
  37629. * Creates a ray that can be used to pick in the scene
  37630. * @param x defines the x coordinate of the origin (on-screen)
  37631. * @param y defines the y coordinate of the origin (on-screen)
  37632. * @param result defines the ray where to store the picking ray
  37633. * @param camera defines the camera to use for the picking
  37634. * @returns the current scene
  37635. */
  37636. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37637. /** Launch a ray to try to pick a mesh in the scene
  37638. * @param x position on screen
  37639. * @param y position on screen
  37640. * @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
  37641. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37642. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37643. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37644. * @returns a PickingInfo
  37645. */
  37646. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37647. /** Use the given ray to pick a mesh in the scene
  37648. * @param ray The ray to use to pick meshes
  37649. * @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
  37650. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37651. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37652. * @returns a PickingInfo
  37653. */
  37654. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37655. /**
  37656. * Launch a ray to try to pick a mesh in the scene
  37657. * @param x X position on screen
  37658. * @param y Y position on screen
  37659. * @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
  37660. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37661. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37662. * @returns an array of PickingInfo
  37663. */
  37664. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37665. /**
  37666. * Launch a ray to try to pick a mesh in the scene
  37667. * @param ray Ray to use
  37668. * @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
  37669. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37670. * @returns an array of PickingInfo
  37671. */
  37672. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37673. /**
  37674. * Force the value of meshUnderPointer
  37675. * @param mesh defines the mesh to use
  37676. */
  37677. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37678. /**
  37679. * Gets the mesh under the pointer
  37680. * @returns a Mesh or null if no mesh is under the pointer
  37681. */
  37682. getPointerOverMesh(): Nullable<AbstractMesh>;
  37683. /** @hidden */
  37684. _rebuildGeometries(): void;
  37685. /** @hidden */
  37686. _rebuildTextures(): void;
  37687. private _getByTags;
  37688. /**
  37689. * Get a list of meshes by tags
  37690. * @param tagsQuery defines the tags query to use
  37691. * @param forEach defines a predicate used to filter results
  37692. * @returns an array of Mesh
  37693. */
  37694. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37695. /**
  37696. * Get a list of cameras by tags
  37697. * @param tagsQuery defines the tags query to use
  37698. * @param forEach defines a predicate used to filter results
  37699. * @returns an array of Camera
  37700. */
  37701. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37702. /**
  37703. * Get a list of lights by tags
  37704. * @param tagsQuery defines the tags query to use
  37705. * @param forEach defines a predicate used to filter results
  37706. * @returns an array of Light
  37707. */
  37708. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37709. /**
  37710. * Get a list of materials by tags
  37711. * @param tagsQuery defines the tags query to use
  37712. * @param forEach defines a predicate used to filter results
  37713. * @returns an array of Material
  37714. */
  37715. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37716. /**
  37717. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37718. * This allowed control for front to back rendering or reversly depending of the special needs.
  37719. *
  37720. * @param renderingGroupId The rendering group id corresponding to its index
  37721. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37722. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37723. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37724. */
  37725. 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;
  37726. /**
  37727. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37728. *
  37729. * @param renderingGroupId The rendering group id corresponding to its index
  37730. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37731. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37732. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37733. */
  37734. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37735. /**
  37736. * Gets the current auto clear configuration for one rendering group of the rendering
  37737. * manager.
  37738. * @param index the rendering group index to get the information for
  37739. * @returns The auto clear setup for the requested rendering group
  37740. */
  37741. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37742. private _blockMaterialDirtyMechanism;
  37743. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37744. get blockMaterialDirtyMechanism(): boolean;
  37745. set blockMaterialDirtyMechanism(value: boolean);
  37746. /**
  37747. * Will flag all materials as dirty to trigger new shader compilation
  37748. * @param flag defines the flag used to specify which material part must be marked as dirty
  37749. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37750. */
  37751. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37752. /** @hidden */
  37753. _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;
  37754. /** @hidden */
  37755. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37756. /** @hidden */
  37757. _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;
  37758. /** @hidden */
  37759. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37760. /** @hidden */
  37761. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37762. /** @hidden */
  37763. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37764. }
  37765. }
  37766. declare module "babylonjs/assetContainer" {
  37767. import { AbstractScene } from "babylonjs/abstractScene";
  37768. import { Scene } from "babylonjs/scene";
  37769. import { Mesh } from "babylonjs/Meshes/mesh";
  37770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37771. import { Skeleton } from "babylonjs/Bones/skeleton";
  37772. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37773. import { Animatable } from "babylonjs/Animations/animatable";
  37774. import { Nullable } from "babylonjs/types";
  37775. import { Node } from "babylonjs/node";
  37776. /**
  37777. * Set of assets to keep when moving a scene into an asset container.
  37778. */
  37779. export class KeepAssets extends AbstractScene {
  37780. }
  37781. /**
  37782. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37783. */
  37784. export class InstantiatedEntries {
  37785. /**
  37786. * List of new root nodes (eg. nodes with no parent)
  37787. */
  37788. rootNodes: TransformNode[];
  37789. /**
  37790. * List of new skeletons
  37791. */
  37792. skeletons: Skeleton[];
  37793. /**
  37794. * List of new animation groups
  37795. */
  37796. animationGroups: AnimationGroup[];
  37797. }
  37798. /**
  37799. * Container with a set of assets that can be added or removed from a scene.
  37800. */
  37801. export class AssetContainer extends AbstractScene {
  37802. /**
  37803. * The scene the AssetContainer belongs to.
  37804. */
  37805. scene: Scene;
  37806. /**
  37807. * Instantiates an AssetContainer.
  37808. * @param scene The scene the AssetContainer belongs to.
  37809. */
  37810. constructor(scene: Scene);
  37811. /**
  37812. * Instantiate or clone all meshes and add the new ones to the scene.
  37813. * Skeletons and animation groups will all be cloned
  37814. * @param nameFunction defines an optional function used to get new names for clones
  37815. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37816. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37817. */
  37818. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37819. /**
  37820. * Adds all the assets from the container to the scene.
  37821. */
  37822. addAllToScene(): void;
  37823. /**
  37824. * Removes all the assets in the container from the scene
  37825. */
  37826. removeAllFromScene(): void;
  37827. /**
  37828. * Disposes all the assets in the container
  37829. */
  37830. dispose(): void;
  37831. private _moveAssets;
  37832. /**
  37833. * Removes all the assets contained in the scene and adds them to the container.
  37834. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37835. */
  37836. moveAllFromScene(keepAssets?: KeepAssets): void;
  37837. /**
  37838. * 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.
  37839. * @returns the root mesh
  37840. */
  37841. createRootMesh(): Mesh;
  37842. /**
  37843. * Merge animations from this asset container into a scene
  37844. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37845. * @param animatables set of animatables to retarget to a node from the scene
  37846. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37847. */
  37848. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37849. }
  37850. }
  37851. declare module "babylonjs/abstractScene" {
  37852. import { Scene } from "babylonjs/scene";
  37853. import { Nullable } from "babylonjs/types";
  37854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37855. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37856. import { Geometry } from "babylonjs/Meshes/geometry";
  37857. import { Skeleton } from "babylonjs/Bones/skeleton";
  37858. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37859. import { AssetContainer } from "babylonjs/assetContainer";
  37860. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37861. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37863. import { Material } from "babylonjs/Materials/material";
  37864. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37865. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37866. import { Camera } from "babylonjs/Cameras/camera";
  37867. import { Light } from "babylonjs/Lights/light";
  37868. import { Node } from "babylonjs/node";
  37869. import { Animation } from "babylonjs/Animations/animation";
  37870. /**
  37871. * Defines how the parser contract is defined.
  37872. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37873. */
  37874. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37875. /**
  37876. * Defines how the individual parser contract is defined.
  37877. * These parser can parse an individual asset
  37878. */
  37879. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37880. /**
  37881. * Base class of the scene acting as a container for the different elements composing a scene.
  37882. * This class is dynamically extended by the different components of the scene increasing
  37883. * flexibility and reducing coupling
  37884. */
  37885. export abstract class AbstractScene {
  37886. /**
  37887. * Stores the list of available parsers in the application.
  37888. */
  37889. private static _BabylonFileParsers;
  37890. /**
  37891. * Stores the list of available individual parsers in the application.
  37892. */
  37893. private static _IndividualBabylonFileParsers;
  37894. /**
  37895. * Adds a parser in the list of available ones
  37896. * @param name Defines the name of the parser
  37897. * @param parser Defines the parser to add
  37898. */
  37899. static AddParser(name: string, parser: BabylonFileParser): void;
  37900. /**
  37901. * Gets a general parser from the list of avaialble ones
  37902. * @param name Defines the name of the parser
  37903. * @returns the requested parser or null
  37904. */
  37905. static GetParser(name: string): Nullable<BabylonFileParser>;
  37906. /**
  37907. * Adds n individual parser in the list of available ones
  37908. * @param name Defines the name of the parser
  37909. * @param parser Defines the parser to add
  37910. */
  37911. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37912. /**
  37913. * Gets an individual parser from the list of avaialble ones
  37914. * @param name Defines the name of the parser
  37915. * @returns the requested parser or null
  37916. */
  37917. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37918. /**
  37919. * Parser json data and populate both a scene and its associated container object
  37920. * @param jsonData Defines the data to parse
  37921. * @param scene Defines the scene to parse the data for
  37922. * @param container Defines the container attached to the parsing sequence
  37923. * @param rootUrl Defines the root url of the data
  37924. */
  37925. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37926. /**
  37927. * Gets the list of root nodes (ie. nodes with no parent)
  37928. */
  37929. rootNodes: Node[];
  37930. /** All of the cameras added to this scene
  37931. * @see http://doc.babylonjs.com/babylon101/cameras
  37932. */
  37933. cameras: Camera[];
  37934. /**
  37935. * All of the lights added to this scene
  37936. * @see http://doc.babylonjs.com/babylon101/lights
  37937. */
  37938. lights: Light[];
  37939. /**
  37940. * All of the (abstract) meshes added to this scene
  37941. */
  37942. meshes: AbstractMesh[];
  37943. /**
  37944. * The list of skeletons added to the scene
  37945. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37946. */
  37947. skeletons: Skeleton[];
  37948. /**
  37949. * All of the particle systems added to this scene
  37950. * @see http://doc.babylonjs.com/babylon101/particles
  37951. */
  37952. particleSystems: IParticleSystem[];
  37953. /**
  37954. * Gets a list of Animations associated with the scene
  37955. */
  37956. animations: Animation[];
  37957. /**
  37958. * All of the animation groups added to this scene
  37959. * @see http://doc.babylonjs.com/how_to/group
  37960. */
  37961. animationGroups: AnimationGroup[];
  37962. /**
  37963. * All of the multi-materials added to this scene
  37964. * @see http://doc.babylonjs.com/how_to/multi_materials
  37965. */
  37966. multiMaterials: MultiMaterial[];
  37967. /**
  37968. * All of the materials added to this scene
  37969. * In the context of a Scene, it is not supposed to be modified manually.
  37970. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37971. * Note also that the order of the Material within the array is not significant and might change.
  37972. * @see http://doc.babylonjs.com/babylon101/materials
  37973. */
  37974. materials: Material[];
  37975. /**
  37976. * The list of morph target managers added to the scene
  37977. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37978. */
  37979. morphTargetManagers: MorphTargetManager[];
  37980. /**
  37981. * The list of geometries used in the scene.
  37982. */
  37983. geometries: Geometry[];
  37984. /**
  37985. * All of the tranform nodes added to this scene
  37986. * In the context of a Scene, it is not supposed to be modified manually.
  37987. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37988. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37989. * @see http://doc.babylonjs.com/how_to/transformnode
  37990. */
  37991. transformNodes: TransformNode[];
  37992. /**
  37993. * ActionManagers available on the scene.
  37994. */
  37995. actionManagers: AbstractActionManager[];
  37996. /**
  37997. * Textures to keep.
  37998. */
  37999. textures: BaseTexture[];
  38000. /**
  38001. * Environment texture for the scene
  38002. */
  38003. environmentTexture: Nullable<BaseTexture>;
  38004. /**
  38005. * @returns all meshes, lights, cameras, transformNodes and bones
  38006. */
  38007. getNodes(): Array<Node>;
  38008. }
  38009. }
  38010. declare module "babylonjs/Audio/sound" {
  38011. import { Observable } from "babylonjs/Misc/observable";
  38012. import { Vector3 } from "babylonjs/Maths/math.vector";
  38013. import { Nullable } from "babylonjs/types";
  38014. import { Scene } from "babylonjs/scene";
  38015. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38016. /**
  38017. * Interface used to define options for Sound class
  38018. */
  38019. export interface ISoundOptions {
  38020. /**
  38021. * Does the sound autoplay once loaded.
  38022. */
  38023. autoplay?: boolean;
  38024. /**
  38025. * Does the sound loop after it finishes playing once.
  38026. */
  38027. loop?: boolean;
  38028. /**
  38029. * Sound's volume
  38030. */
  38031. volume?: number;
  38032. /**
  38033. * Is it a spatial sound?
  38034. */
  38035. spatialSound?: boolean;
  38036. /**
  38037. * Maximum distance to hear that sound
  38038. */
  38039. maxDistance?: number;
  38040. /**
  38041. * Uses user defined attenuation function
  38042. */
  38043. useCustomAttenuation?: boolean;
  38044. /**
  38045. * Define the roll off factor of spatial sounds.
  38046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38047. */
  38048. rolloffFactor?: number;
  38049. /**
  38050. * Define the reference distance the sound should be heard perfectly.
  38051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38052. */
  38053. refDistance?: number;
  38054. /**
  38055. * Define the distance attenuation model the sound will follow.
  38056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38057. */
  38058. distanceModel?: string;
  38059. /**
  38060. * Defines the playback speed (1 by default)
  38061. */
  38062. playbackRate?: number;
  38063. /**
  38064. * Defines if the sound is from a streaming source
  38065. */
  38066. streaming?: boolean;
  38067. /**
  38068. * Defines an optional length (in seconds) inside the sound file
  38069. */
  38070. length?: number;
  38071. /**
  38072. * Defines an optional offset (in seconds) inside the sound file
  38073. */
  38074. offset?: number;
  38075. /**
  38076. * If true, URLs will not be required to state the audio file codec to use.
  38077. */
  38078. skipCodecCheck?: boolean;
  38079. }
  38080. /**
  38081. * Defines a sound that can be played in the application.
  38082. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38084. */
  38085. export class Sound {
  38086. /**
  38087. * The name of the sound in the scene.
  38088. */
  38089. name: string;
  38090. /**
  38091. * Does the sound autoplay once loaded.
  38092. */
  38093. autoplay: boolean;
  38094. /**
  38095. * Does the sound loop after it finishes playing once.
  38096. */
  38097. loop: boolean;
  38098. /**
  38099. * Does the sound use a custom attenuation curve to simulate the falloff
  38100. * happening when the source gets further away from the camera.
  38101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38102. */
  38103. useCustomAttenuation: boolean;
  38104. /**
  38105. * The sound track id this sound belongs to.
  38106. */
  38107. soundTrackId: number;
  38108. /**
  38109. * Is this sound currently played.
  38110. */
  38111. isPlaying: boolean;
  38112. /**
  38113. * Is this sound currently paused.
  38114. */
  38115. isPaused: boolean;
  38116. /**
  38117. * Does this sound enables spatial sound.
  38118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38119. */
  38120. spatialSound: boolean;
  38121. /**
  38122. * Define the reference distance the sound should be heard perfectly.
  38123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38124. */
  38125. refDistance: number;
  38126. /**
  38127. * Define the roll off factor of spatial sounds.
  38128. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38129. */
  38130. rolloffFactor: number;
  38131. /**
  38132. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38134. */
  38135. maxDistance: number;
  38136. /**
  38137. * Define the distance attenuation model the sound will follow.
  38138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38139. */
  38140. distanceModel: string;
  38141. /**
  38142. * @hidden
  38143. * Back Compat
  38144. **/
  38145. onended: () => any;
  38146. /**
  38147. * Observable event when the current playing sound finishes.
  38148. */
  38149. onEndedObservable: Observable<Sound>;
  38150. private _panningModel;
  38151. private _playbackRate;
  38152. private _streaming;
  38153. private _startTime;
  38154. private _startOffset;
  38155. private _position;
  38156. /** @hidden */
  38157. _positionInEmitterSpace: boolean;
  38158. private _localDirection;
  38159. private _volume;
  38160. private _isReadyToPlay;
  38161. private _isDirectional;
  38162. private _readyToPlayCallback;
  38163. private _audioBuffer;
  38164. private _soundSource;
  38165. private _streamingSource;
  38166. private _soundPanner;
  38167. private _soundGain;
  38168. private _inputAudioNode;
  38169. private _outputAudioNode;
  38170. private _coneInnerAngle;
  38171. private _coneOuterAngle;
  38172. private _coneOuterGain;
  38173. private _scene;
  38174. private _connectedTransformNode;
  38175. private _customAttenuationFunction;
  38176. private _registerFunc;
  38177. private _isOutputConnected;
  38178. private _htmlAudioElement;
  38179. private _urlType;
  38180. private _length?;
  38181. private _offset?;
  38182. /** @hidden */
  38183. static _SceneComponentInitialization: (scene: Scene) => void;
  38184. /**
  38185. * Create a sound and attach it to a scene
  38186. * @param name Name of your sound
  38187. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38188. * @param scene defines the scene the sound belongs to
  38189. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38190. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38191. */
  38192. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38193. /**
  38194. * Release the sound and its associated resources
  38195. */
  38196. dispose(): void;
  38197. /**
  38198. * Gets if the sounds is ready to be played or not.
  38199. * @returns true if ready, otherwise false
  38200. */
  38201. isReady(): boolean;
  38202. private _soundLoaded;
  38203. /**
  38204. * Sets the data of the sound from an audiobuffer
  38205. * @param audioBuffer The audioBuffer containing the data
  38206. */
  38207. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38208. /**
  38209. * Updates the current sounds options such as maxdistance, loop...
  38210. * @param options A JSON object containing values named as the object properties
  38211. */
  38212. updateOptions(options: ISoundOptions): void;
  38213. private _createSpatialParameters;
  38214. private _updateSpatialParameters;
  38215. /**
  38216. * Switch the panning model to HRTF:
  38217. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38219. */
  38220. switchPanningModelToHRTF(): void;
  38221. /**
  38222. * Switch the panning model to Equal Power:
  38223. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38225. */
  38226. switchPanningModelToEqualPower(): void;
  38227. private _switchPanningModel;
  38228. /**
  38229. * Connect this sound to a sound track audio node like gain...
  38230. * @param soundTrackAudioNode the sound track audio node to connect to
  38231. */
  38232. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38233. /**
  38234. * Transform this sound into a directional source
  38235. * @param coneInnerAngle Size of the inner cone in degree
  38236. * @param coneOuterAngle Size of the outer cone in degree
  38237. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38238. */
  38239. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38240. /**
  38241. * Gets or sets the inner angle for the directional cone.
  38242. */
  38243. get directionalConeInnerAngle(): number;
  38244. /**
  38245. * Gets or sets the inner angle for the directional cone.
  38246. */
  38247. set directionalConeInnerAngle(value: number);
  38248. /**
  38249. * Gets or sets the outer angle for the directional cone.
  38250. */
  38251. get directionalConeOuterAngle(): number;
  38252. /**
  38253. * Gets or sets the outer angle for the directional cone.
  38254. */
  38255. set directionalConeOuterAngle(value: number);
  38256. /**
  38257. * Sets the position of the emitter if spatial sound is enabled
  38258. * @param newPosition Defines the new posisiton
  38259. */
  38260. setPosition(newPosition: Vector3): void;
  38261. /**
  38262. * Sets the local direction of the emitter if spatial sound is enabled
  38263. * @param newLocalDirection Defines the new local direction
  38264. */
  38265. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38266. private _updateDirection;
  38267. /** @hidden */
  38268. updateDistanceFromListener(): void;
  38269. /**
  38270. * Sets a new custom attenuation function for the sound.
  38271. * @param callback Defines the function used for the attenuation
  38272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38273. */
  38274. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38275. /**
  38276. * Play the sound
  38277. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38278. * @param offset (optional) Start the sound at a specific time in seconds
  38279. * @param length (optional) Sound duration (in seconds)
  38280. */
  38281. play(time?: number, offset?: number, length?: number): void;
  38282. private _onended;
  38283. /**
  38284. * Stop the sound
  38285. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38286. */
  38287. stop(time?: number): void;
  38288. /**
  38289. * Put the sound in pause
  38290. */
  38291. pause(): void;
  38292. /**
  38293. * Sets a dedicated volume for this sounds
  38294. * @param newVolume Define the new volume of the sound
  38295. * @param time Define time for gradual change to new volume
  38296. */
  38297. setVolume(newVolume: number, time?: number): void;
  38298. /**
  38299. * Set the sound play back rate
  38300. * @param newPlaybackRate Define the playback rate the sound should be played at
  38301. */
  38302. setPlaybackRate(newPlaybackRate: number): void;
  38303. /**
  38304. * Gets the volume of the sound.
  38305. * @returns the volume of the sound
  38306. */
  38307. getVolume(): number;
  38308. /**
  38309. * Attach the sound to a dedicated mesh
  38310. * @param transformNode The transform node to connect the sound with
  38311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38312. */
  38313. attachToMesh(transformNode: TransformNode): void;
  38314. /**
  38315. * Detach the sound from the previously attached mesh
  38316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38317. */
  38318. detachFromMesh(): void;
  38319. private _onRegisterAfterWorldMatrixUpdate;
  38320. /**
  38321. * Clone the current sound in the scene.
  38322. * @returns the new sound clone
  38323. */
  38324. clone(): Nullable<Sound>;
  38325. /**
  38326. * Gets the current underlying audio buffer containing the data
  38327. * @returns the audio buffer
  38328. */
  38329. getAudioBuffer(): Nullable<AudioBuffer>;
  38330. /**
  38331. * Serializes the Sound in a JSON representation
  38332. * @returns the JSON representation of the sound
  38333. */
  38334. serialize(): any;
  38335. /**
  38336. * Parse a JSON representation of a sound to innstantiate in a given scene
  38337. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38338. * @param scene Define the scene the new parsed sound should be created in
  38339. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38340. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38341. * @returns the newly parsed sound
  38342. */
  38343. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38344. }
  38345. }
  38346. declare module "babylonjs/Actions/directAudioActions" {
  38347. import { Action } from "babylonjs/Actions/action";
  38348. import { Condition } from "babylonjs/Actions/condition";
  38349. import { Sound } from "babylonjs/Audio/sound";
  38350. /**
  38351. * This defines an action helpful to play a defined sound on a triggered action.
  38352. */
  38353. export class PlaySoundAction extends Action {
  38354. private _sound;
  38355. /**
  38356. * Instantiate the action
  38357. * @param triggerOptions defines the trigger options
  38358. * @param sound defines the sound to play
  38359. * @param condition defines the trigger related conditions
  38360. */
  38361. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38362. /** @hidden */
  38363. _prepare(): void;
  38364. /**
  38365. * Execute the action and play the sound.
  38366. */
  38367. execute(): void;
  38368. /**
  38369. * Serializes the actions and its related information.
  38370. * @param parent defines the object to serialize in
  38371. * @returns the serialized object
  38372. */
  38373. serialize(parent: any): any;
  38374. }
  38375. /**
  38376. * This defines an action helpful to stop a defined sound on a triggered action.
  38377. */
  38378. export class StopSoundAction extends Action {
  38379. private _sound;
  38380. /**
  38381. * Instantiate the action
  38382. * @param triggerOptions defines the trigger options
  38383. * @param sound defines the sound to stop
  38384. * @param condition defines the trigger related conditions
  38385. */
  38386. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38387. /** @hidden */
  38388. _prepare(): void;
  38389. /**
  38390. * Execute the action and stop the sound.
  38391. */
  38392. execute(): void;
  38393. /**
  38394. * Serializes the actions and its related information.
  38395. * @param parent defines the object to serialize in
  38396. * @returns the serialized object
  38397. */
  38398. serialize(parent: any): any;
  38399. }
  38400. }
  38401. declare module "babylonjs/Actions/interpolateValueAction" {
  38402. import { Action } from "babylonjs/Actions/action";
  38403. import { Condition } from "babylonjs/Actions/condition";
  38404. import { Observable } from "babylonjs/Misc/observable";
  38405. /**
  38406. * This defines an action responsible to change the value of a property
  38407. * by interpolating between its current value and the newly set one once triggered.
  38408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38409. */
  38410. export class InterpolateValueAction extends Action {
  38411. /**
  38412. * Defines the path of the property where the value should be interpolated
  38413. */
  38414. propertyPath: string;
  38415. /**
  38416. * Defines the target value at the end of the interpolation.
  38417. */
  38418. value: any;
  38419. /**
  38420. * Defines the time it will take for the property to interpolate to the value.
  38421. */
  38422. duration: number;
  38423. /**
  38424. * Defines if the other scene animations should be stopped when the action has been triggered
  38425. */
  38426. stopOtherAnimations?: boolean;
  38427. /**
  38428. * Defines a callback raised once the interpolation animation has been done.
  38429. */
  38430. onInterpolationDone?: () => void;
  38431. /**
  38432. * Observable triggered once the interpolation animation has been done.
  38433. */
  38434. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38435. private _target;
  38436. private _effectiveTarget;
  38437. private _property;
  38438. /**
  38439. * Instantiate the action
  38440. * @param triggerOptions defines the trigger options
  38441. * @param target defines the object containing the value to interpolate
  38442. * @param propertyPath defines the path to the property in the target object
  38443. * @param value defines the target value at the end of the interpolation
  38444. * @param duration deines the time it will take for the property to interpolate to the value.
  38445. * @param condition defines the trigger related conditions
  38446. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38447. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38448. */
  38449. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38450. /** @hidden */
  38451. _prepare(): void;
  38452. /**
  38453. * Execute the action starts the value interpolation.
  38454. */
  38455. execute(): void;
  38456. /**
  38457. * Serializes the actions and its related information.
  38458. * @param parent defines the object to serialize in
  38459. * @returns the serialized object
  38460. */
  38461. serialize(parent: any): any;
  38462. }
  38463. }
  38464. declare module "babylonjs/Actions/index" {
  38465. export * from "babylonjs/Actions/abstractActionManager";
  38466. export * from "babylonjs/Actions/action";
  38467. export * from "babylonjs/Actions/actionEvent";
  38468. export * from "babylonjs/Actions/actionManager";
  38469. export * from "babylonjs/Actions/condition";
  38470. export * from "babylonjs/Actions/directActions";
  38471. export * from "babylonjs/Actions/directAudioActions";
  38472. export * from "babylonjs/Actions/interpolateValueAction";
  38473. }
  38474. declare module "babylonjs/Animations/index" {
  38475. export * from "babylonjs/Animations/animatable";
  38476. export * from "babylonjs/Animations/animation";
  38477. export * from "babylonjs/Animations/animationGroup";
  38478. export * from "babylonjs/Animations/animationPropertiesOverride";
  38479. export * from "babylonjs/Animations/easing";
  38480. export * from "babylonjs/Animations/runtimeAnimation";
  38481. export * from "babylonjs/Animations/animationEvent";
  38482. export * from "babylonjs/Animations/animationGroup";
  38483. export * from "babylonjs/Animations/animationKey";
  38484. export * from "babylonjs/Animations/animationRange";
  38485. export * from "babylonjs/Animations/animatable.interface";
  38486. }
  38487. declare module "babylonjs/Audio/soundTrack" {
  38488. import { Sound } from "babylonjs/Audio/sound";
  38489. import { Analyser } from "babylonjs/Audio/analyser";
  38490. import { Scene } from "babylonjs/scene";
  38491. /**
  38492. * Options allowed during the creation of a sound track.
  38493. */
  38494. export interface ISoundTrackOptions {
  38495. /**
  38496. * The volume the sound track should take during creation
  38497. */
  38498. volume?: number;
  38499. /**
  38500. * Define if the sound track is the main sound track of the scene
  38501. */
  38502. mainTrack?: boolean;
  38503. }
  38504. /**
  38505. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38506. * It will be also used in a future release to apply effects on a specific track.
  38507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38508. */
  38509. export class SoundTrack {
  38510. /**
  38511. * The unique identifier of the sound track in the scene.
  38512. */
  38513. id: number;
  38514. /**
  38515. * The list of sounds included in the sound track.
  38516. */
  38517. soundCollection: Array<Sound>;
  38518. private _outputAudioNode;
  38519. private _scene;
  38520. private _connectedAnalyser;
  38521. private _options;
  38522. private _isInitialized;
  38523. /**
  38524. * Creates a new sound track.
  38525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38526. * @param scene Define the scene the sound track belongs to
  38527. * @param options
  38528. */
  38529. constructor(scene: Scene, options?: ISoundTrackOptions);
  38530. private _initializeSoundTrackAudioGraph;
  38531. /**
  38532. * Release the sound track and its associated resources
  38533. */
  38534. dispose(): void;
  38535. /**
  38536. * Adds a sound to this sound track
  38537. * @param sound define the cound to add
  38538. * @ignoreNaming
  38539. */
  38540. AddSound(sound: Sound): void;
  38541. /**
  38542. * Removes a sound to this sound track
  38543. * @param sound define the cound to remove
  38544. * @ignoreNaming
  38545. */
  38546. RemoveSound(sound: Sound): void;
  38547. /**
  38548. * Set a global volume for the full sound track.
  38549. * @param newVolume Define the new volume of the sound track
  38550. */
  38551. setVolume(newVolume: number): void;
  38552. /**
  38553. * Switch the panning model to HRTF:
  38554. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38556. */
  38557. switchPanningModelToHRTF(): void;
  38558. /**
  38559. * Switch the panning model to Equal Power:
  38560. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38562. */
  38563. switchPanningModelToEqualPower(): void;
  38564. /**
  38565. * Connect the sound track to an audio analyser allowing some amazing
  38566. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38568. * @param analyser The analyser to connect to the engine
  38569. */
  38570. connectToAnalyser(analyser: Analyser): void;
  38571. }
  38572. }
  38573. declare module "babylonjs/Audio/audioSceneComponent" {
  38574. import { Sound } from "babylonjs/Audio/sound";
  38575. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38576. import { Nullable } from "babylonjs/types";
  38577. import { Vector3 } from "babylonjs/Maths/math.vector";
  38578. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38579. import { Scene } from "babylonjs/scene";
  38580. import { AbstractScene } from "babylonjs/abstractScene";
  38581. import "babylonjs/Audio/audioEngine";
  38582. module "babylonjs/abstractScene" {
  38583. interface AbstractScene {
  38584. /**
  38585. * The list of sounds used in the scene.
  38586. */
  38587. sounds: Nullable<Array<Sound>>;
  38588. }
  38589. }
  38590. module "babylonjs/scene" {
  38591. interface Scene {
  38592. /**
  38593. * @hidden
  38594. * Backing field
  38595. */
  38596. _mainSoundTrack: SoundTrack;
  38597. /**
  38598. * The main sound track played by the scene.
  38599. * It cotains your primary collection of sounds.
  38600. */
  38601. mainSoundTrack: SoundTrack;
  38602. /**
  38603. * The list of sound tracks added to the scene
  38604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38605. */
  38606. soundTracks: Nullable<Array<SoundTrack>>;
  38607. /**
  38608. * Gets a sound using a given name
  38609. * @param name defines the name to search for
  38610. * @return the found sound or null if not found at all.
  38611. */
  38612. getSoundByName(name: string): Nullable<Sound>;
  38613. /**
  38614. * Gets or sets if audio support is enabled
  38615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38616. */
  38617. audioEnabled: boolean;
  38618. /**
  38619. * Gets or sets if audio will be output to headphones
  38620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38621. */
  38622. headphone: boolean;
  38623. /**
  38624. * Gets or sets custom audio listener position provider
  38625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38626. */
  38627. audioListenerPositionProvider: Nullable<() => Vector3>;
  38628. /**
  38629. * Gets or sets a refresh rate when using 3D audio positioning
  38630. */
  38631. audioPositioningRefreshRate: number;
  38632. }
  38633. }
  38634. /**
  38635. * Defines the sound scene component responsible to manage any sounds
  38636. * in a given scene.
  38637. */
  38638. export class AudioSceneComponent implements ISceneSerializableComponent {
  38639. /**
  38640. * The component name helpfull to identify the component in the list of scene components.
  38641. */
  38642. readonly name: string;
  38643. /**
  38644. * The scene the component belongs to.
  38645. */
  38646. scene: Scene;
  38647. private _audioEnabled;
  38648. /**
  38649. * Gets whether audio is enabled or not.
  38650. * Please use related enable/disable method to switch state.
  38651. */
  38652. get audioEnabled(): boolean;
  38653. private _headphone;
  38654. /**
  38655. * Gets whether audio is outputing to headphone or not.
  38656. * Please use the according Switch methods to change output.
  38657. */
  38658. get headphone(): boolean;
  38659. /**
  38660. * Gets or sets a refresh rate when using 3D audio positioning
  38661. */
  38662. audioPositioningRefreshRate: number;
  38663. private _audioListenerPositionProvider;
  38664. /**
  38665. * Gets the current audio listener position provider
  38666. */
  38667. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38668. /**
  38669. * Sets a custom listener position for all sounds in the scene
  38670. * By default, this is the position of the first active camera
  38671. */
  38672. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38673. /**
  38674. * Creates a new instance of the component for the given scene
  38675. * @param scene Defines the scene to register the component in
  38676. */
  38677. constructor(scene: Scene);
  38678. /**
  38679. * Registers the component in a given scene
  38680. */
  38681. register(): void;
  38682. /**
  38683. * Rebuilds the elements related to this component in case of
  38684. * context lost for instance.
  38685. */
  38686. rebuild(): void;
  38687. /**
  38688. * Serializes the component data to the specified json object
  38689. * @param serializationObject The object to serialize to
  38690. */
  38691. serialize(serializationObject: any): void;
  38692. /**
  38693. * Adds all the elements from the container to the scene
  38694. * @param container the container holding the elements
  38695. */
  38696. addFromContainer(container: AbstractScene): void;
  38697. /**
  38698. * Removes all the elements in the container from the scene
  38699. * @param container contains the elements to remove
  38700. * @param dispose if the removed element should be disposed (default: false)
  38701. */
  38702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38703. /**
  38704. * Disposes the component and the associated ressources.
  38705. */
  38706. dispose(): void;
  38707. /**
  38708. * Disables audio in the associated scene.
  38709. */
  38710. disableAudio(): void;
  38711. /**
  38712. * Enables audio in the associated scene.
  38713. */
  38714. enableAudio(): void;
  38715. /**
  38716. * Switch audio to headphone output.
  38717. */
  38718. switchAudioModeForHeadphones(): void;
  38719. /**
  38720. * Switch audio to normal speakers.
  38721. */
  38722. switchAudioModeForNormalSpeakers(): void;
  38723. private _cachedCameraDirection;
  38724. private _cachedCameraPosition;
  38725. private _lastCheck;
  38726. private _afterRender;
  38727. }
  38728. }
  38729. declare module "babylonjs/Audio/weightedsound" {
  38730. import { Sound } from "babylonjs/Audio/sound";
  38731. /**
  38732. * Wraps one or more Sound objects and selects one with random weight for playback.
  38733. */
  38734. export class WeightedSound {
  38735. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38736. loop: boolean;
  38737. private _coneInnerAngle;
  38738. private _coneOuterAngle;
  38739. private _volume;
  38740. /** A Sound is currently playing. */
  38741. isPlaying: boolean;
  38742. /** A Sound is currently paused. */
  38743. isPaused: boolean;
  38744. private _sounds;
  38745. private _weights;
  38746. private _currentIndex?;
  38747. /**
  38748. * Creates a new WeightedSound from the list of sounds given.
  38749. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38750. * @param sounds Array of Sounds that will be selected from.
  38751. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38752. */
  38753. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38754. /**
  38755. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38756. */
  38757. get directionalConeInnerAngle(): number;
  38758. /**
  38759. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38760. */
  38761. set directionalConeInnerAngle(value: number);
  38762. /**
  38763. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38764. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38765. */
  38766. get directionalConeOuterAngle(): number;
  38767. /**
  38768. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38769. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38770. */
  38771. set directionalConeOuterAngle(value: number);
  38772. /**
  38773. * Playback volume.
  38774. */
  38775. get volume(): number;
  38776. /**
  38777. * Playback volume.
  38778. */
  38779. set volume(value: number);
  38780. private _onended;
  38781. /**
  38782. * Suspend playback
  38783. */
  38784. pause(): void;
  38785. /**
  38786. * Stop playback
  38787. */
  38788. stop(): void;
  38789. /**
  38790. * Start playback.
  38791. * @param startOffset Position the clip head at a specific time in seconds.
  38792. */
  38793. play(startOffset?: number): void;
  38794. }
  38795. }
  38796. declare module "babylonjs/Audio/index" {
  38797. export * from "babylonjs/Audio/analyser";
  38798. export * from "babylonjs/Audio/audioEngine";
  38799. export * from "babylonjs/Audio/audioSceneComponent";
  38800. export * from "babylonjs/Audio/sound";
  38801. export * from "babylonjs/Audio/soundTrack";
  38802. export * from "babylonjs/Audio/weightedsound";
  38803. }
  38804. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38805. import { Behavior } from "babylonjs/Behaviors/behavior";
  38806. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38807. import { BackEase } from "babylonjs/Animations/easing";
  38808. /**
  38809. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38810. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38811. */
  38812. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38813. /**
  38814. * Gets the name of the behavior.
  38815. */
  38816. get name(): string;
  38817. /**
  38818. * The easing function used by animations
  38819. */
  38820. static EasingFunction: BackEase;
  38821. /**
  38822. * The easing mode used by animations
  38823. */
  38824. static EasingMode: number;
  38825. /**
  38826. * The duration of the animation, in milliseconds
  38827. */
  38828. transitionDuration: number;
  38829. /**
  38830. * Length of the distance animated by the transition when lower radius is reached
  38831. */
  38832. lowerRadiusTransitionRange: number;
  38833. /**
  38834. * Length of the distance animated by the transition when upper radius is reached
  38835. */
  38836. upperRadiusTransitionRange: number;
  38837. private _autoTransitionRange;
  38838. /**
  38839. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38840. */
  38841. get autoTransitionRange(): boolean;
  38842. /**
  38843. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38844. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38845. */
  38846. set autoTransitionRange(value: boolean);
  38847. private _attachedCamera;
  38848. private _onAfterCheckInputsObserver;
  38849. private _onMeshTargetChangedObserver;
  38850. /**
  38851. * Initializes the behavior.
  38852. */
  38853. init(): void;
  38854. /**
  38855. * Attaches the behavior to its arc rotate camera.
  38856. * @param camera Defines the camera to attach the behavior to
  38857. */
  38858. attach(camera: ArcRotateCamera): void;
  38859. /**
  38860. * Detaches the behavior from its current arc rotate camera.
  38861. */
  38862. detach(): void;
  38863. private _radiusIsAnimating;
  38864. private _radiusBounceTransition;
  38865. private _animatables;
  38866. private _cachedWheelPrecision;
  38867. /**
  38868. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38869. * @param radiusLimit The limit to check against.
  38870. * @return Bool to indicate if at limit.
  38871. */
  38872. private _isRadiusAtLimit;
  38873. /**
  38874. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38875. * @param radiusDelta The delta by which to animate to. Can be negative.
  38876. */
  38877. private _applyBoundRadiusAnimation;
  38878. /**
  38879. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38880. */
  38881. protected _clearAnimationLocks(): void;
  38882. /**
  38883. * Stops and removes all animations that have been applied to the camera
  38884. */
  38885. stopAllAnimations(): void;
  38886. }
  38887. }
  38888. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38889. import { Behavior } from "babylonjs/Behaviors/behavior";
  38890. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38891. import { ExponentialEase } from "babylonjs/Animations/easing";
  38892. import { Nullable } from "babylonjs/types";
  38893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38894. import { Vector3 } from "babylonjs/Maths/math.vector";
  38895. /**
  38896. * 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.
  38897. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38898. */
  38899. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38900. /**
  38901. * Gets the name of the behavior.
  38902. */
  38903. get name(): string;
  38904. private _mode;
  38905. private _radiusScale;
  38906. private _positionScale;
  38907. private _defaultElevation;
  38908. private _elevationReturnTime;
  38909. private _elevationReturnWaitTime;
  38910. private _zoomStopsAnimation;
  38911. private _framingTime;
  38912. /**
  38913. * The easing function used by animations
  38914. */
  38915. static EasingFunction: ExponentialEase;
  38916. /**
  38917. * The easing mode used by animations
  38918. */
  38919. static EasingMode: number;
  38920. /**
  38921. * Sets the current mode used by the behavior
  38922. */
  38923. set mode(mode: number);
  38924. /**
  38925. * Gets current mode used by the behavior.
  38926. */
  38927. get mode(): number;
  38928. /**
  38929. * Sets the scale applied to the radius (1 by default)
  38930. */
  38931. set radiusScale(radius: number);
  38932. /**
  38933. * Gets the scale applied to the radius
  38934. */
  38935. get radiusScale(): number;
  38936. /**
  38937. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38938. */
  38939. set positionScale(scale: number);
  38940. /**
  38941. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38942. */
  38943. get positionScale(): number;
  38944. /**
  38945. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38946. * behaviour is triggered, in radians.
  38947. */
  38948. set defaultElevation(elevation: number);
  38949. /**
  38950. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38951. * behaviour is triggered, in radians.
  38952. */
  38953. get defaultElevation(): number;
  38954. /**
  38955. * Sets the time (in milliseconds) taken to return to the default beta position.
  38956. * Negative value indicates camera should not return to default.
  38957. */
  38958. set elevationReturnTime(speed: number);
  38959. /**
  38960. * Gets the time (in milliseconds) taken to return to the default beta position.
  38961. * Negative value indicates camera should not return to default.
  38962. */
  38963. get elevationReturnTime(): number;
  38964. /**
  38965. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38966. */
  38967. set elevationReturnWaitTime(time: number);
  38968. /**
  38969. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38970. */
  38971. get elevationReturnWaitTime(): number;
  38972. /**
  38973. * Sets the flag that indicates if user zooming should stop animation.
  38974. */
  38975. set zoomStopsAnimation(flag: boolean);
  38976. /**
  38977. * Gets the flag that indicates if user zooming should stop animation.
  38978. */
  38979. get zoomStopsAnimation(): boolean;
  38980. /**
  38981. * Sets the transition time when framing the mesh, in milliseconds
  38982. */
  38983. set framingTime(time: number);
  38984. /**
  38985. * Gets the transition time when framing the mesh, in milliseconds
  38986. */
  38987. get framingTime(): number;
  38988. /**
  38989. * Define if the behavior should automatically change the configured
  38990. * camera limits and sensibilities.
  38991. */
  38992. autoCorrectCameraLimitsAndSensibility: boolean;
  38993. private _onPrePointerObservableObserver;
  38994. private _onAfterCheckInputsObserver;
  38995. private _onMeshTargetChangedObserver;
  38996. private _attachedCamera;
  38997. private _isPointerDown;
  38998. private _lastInteractionTime;
  38999. /**
  39000. * Initializes the behavior.
  39001. */
  39002. init(): void;
  39003. /**
  39004. * Attaches the behavior to its arc rotate camera.
  39005. * @param camera Defines the camera to attach the behavior to
  39006. */
  39007. attach(camera: ArcRotateCamera): void;
  39008. /**
  39009. * Detaches the behavior from its current arc rotate camera.
  39010. */
  39011. detach(): void;
  39012. private _animatables;
  39013. private _betaIsAnimating;
  39014. private _betaTransition;
  39015. private _radiusTransition;
  39016. private _vectorTransition;
  39017. /**
  39018. * Targets the given mesh and updates zoom level accordingly.
  39019. * @param mesh The mesh to target.
  39020. * @param radius Optional. If a cached radius position already exists, overrides default.
  39021. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39022. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39023. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39024. */
  39025. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39026. /**
  39027. * Targets the given mesh with its children and updates zoom level accordingly.
  39028. * @param mesh The mesh to target.
  39029. * @param radius Optional. If a cached radius position already exists, overrides default.
  39030. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39031. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39032. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39033. */
  39034. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39035. /**
  39036. * Targets the given meshes with their children and updates zoom level accordingly.
  39037. * @param meshes The mesh to target.
  39038. * @param radius Optional. If a cached radius position already exists, overrides default.
  39039. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39040. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39041. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39042. */
  39043. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39044. /**
  39045. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39046. * @param minimumWorld Determines the smaller position of the bounding box extend
  39047. * @param maximumWorld Determines the bigger position of the bounding box extend
  39048. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39049. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39050. */
  39051. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39052. /**
  39053. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39054. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39055. * frustum width.
  39056. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39057. * to fully enclose the mesh in the viewing frustum.
  39058. */
  39059. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39060. /**
  39061. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39062. * is automatically returned to its default position (expected to be above ground plane).
  39063. */
  39064. private _maintainCameraAboveGround;
  39065. /**
  39066. * Returns the frustum slope based on the canvas ratio and camera FOV
  39067. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39068. */
  39069. private _getFrustumSlope;
  39070. /**
  39071. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39072. */
  39073. private _clearAnimationLocks;
  39074. /**
  39075. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39076. */
  39077. private _applyUserInteraction;
  39078. /**
  39079. * Stops and removes all animations that have been applied to the camera
  39080. */
  39081. stopAllAnimations(): void;
  39082. /**
  39083. * Gets a value indicating if the user is moving the camera
  39084. */
  39085. get isUserIsMoving(): boolean;
  39086. /**
  39087. * The camera can move all the way towards the mesh.
  39088. */
  39089. static IgnoreBoundsSizeMode: number;
  39090. /**
  39091. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39092. */
  39093. static FitFrustumSidesMode: number;
  39094. }
  39095. }
  39096. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39097. import { Nullable } from "babylonjs/types";
  39098. import { Camera } from "babylonjs/Cameras/camera";
  39099. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39100. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39101. /**
  39102. * Base class for Camera Pointer Inputs.
  39103. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39104. * for example usage.
  39105. */
  39106. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39107. /**
  39108. * Defines the camera the input is attached to.
  39109. */
  39110. abstract camera: Camera;
  39111. /**
  39112. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39113. */
  39114. protected _altKey: boolean;
  39115. protected _ctrlKey: boolean;
  39116. protected _metaKey: boolean;
  39117. protected _shiftKey: boolean;
  39118. /**
  39119. * Which mouse buttons were pressed at time of last mouse event.
  39120. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39121. */
  39122. protected _buttonsPressed: number;
  39123. /**
  39124. * Defines the buttons associated with the input to handle camera move.
  39125. */
  39126. buttons: number[];
  39127. /**
  39128. * Attach the input controls to a specific dom element to get the input from.
  39129. * @param element Defines the element the controls should be listened from
  39130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39131. */
  39132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39133. /**
  39134. * Detach the current controls from the specified dom element.
  39135. * @param element Defines the element to stop listening the inputs from
  39136. */
  39137. detachControl(element: Nullable<HTMLElement>): void;
  39138. /**
  39139. * Gets the class name of the current input.
  39140. * @returns the class name
  39141. */
  39142. getClassName(): string;
  39143. /**
  39144. * Get the friendly name associated with the input class.
  39145. * @returns the input friendly name
  39146. */
  39147. getSimpleName(): string;
  39148. /**
  39149. * Called on pointer POINTERDOUBLETAP event.
  39150. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39151. */
  39152. protected onDoubleTap(type: string): void;
  39153. /**
  39154. * Called on pointer POINTERMOVE event if only a single touch is active.
  39155. * Override this method to provide functionality.
  39156. */
  39157. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39158. /**
  39159. * Called on pointer POINTERMOVE event if multiple touches are active.
  39160. * Override this method to provide functionality.
  39161. */
  39162. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39163. /**
  39164. * Called on JS contextmenu event.
  39165. * Override this method to provide functionality.
  39166. */
  39167. protected onContextMenu(evt: PointerEvent): void;
  39168. /**
  39169. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39170. * press.
  39171. * Override this method to provide functionality.
  39172. */
  39173. protected onButtonDown(evt: PointerEvent): void;
  39174. /**
  39175. * Called each time a new POINTERUP event occurs. Ie, for each button
  39176. * release.
  39177. * Override this method to provide functionality.
  39178. */
  39179. protected onButtonUp(evt: PointerEvent): void;
  39180. /**
  39181. * Called when window becomes inactive.
  39182. * Override this method to provide functionality.
  39183. */
  39184. protected onLostFocus(): void;
  39185. private _pointerInput;
  39186. private _observer;
  39187. private _onLostFocus;
  39188. private pointA;
  39189. private pointB;
  39190. }
  39191. }
  39192. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39193. import { Nullable } from "babylonjs/types";
  39194. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39195. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39196. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39197. /**
  39198. * Manage the pointers inputs to control an arc rotate camera.
  39199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39200. */
  39201. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39202. /**
  39203. * Defines the camera the input is attached to.
  39204. */
  39205. camera: ArcRotateCamera;
  39206. /**
  39207. * Gets the class name of the current input.
  39208. * @returns the class name
  39209. */
  39210. getClassName(): string;
  39211. /**
  39212. * Defines the buttons associated with the input to handle camera move.
  39213. */
  39214. buttons: number[];
  39215. /**
  39216. * Defines the pointer angular sensibility along the X axis or how fast is
  39217. * the camera rotating.
  39218. */
  39219. angularSensibilityX: number;
  39220. /**
  39221. * Defines the pointer angular sensibility along the Y axis or how fast is
  39222. * the camera rotating.
  39223. */
  39224. angularSensibilityY: number;
  39225. /**
  39226. * Defines the pointer pinch precision or how fast is the camera zooming.
  39227. */
  39228. pinchPrecision: number;
  39229. /**
  39230. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39231. * from 0.
  39232. * It defines the percentage of current camera.radius to use as delta when
  39233. * pinch zoom is used.
  39234. */
  39235. pinchDeltaPercentage: number;
  39236. /**
  39237. * Defines the pointer panning sensibility or how fast is the camera moving.
  39238. */
  39239. panningSensibility: number;
  39240. /**
  39241. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39242. */
  39243. multiTouchPanning: boolean;
  39244. /**
  39245. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39246. * zoom (pinch) through multitouch.
  39247. */
  39248. multiTouchPanAndZoom: boolean;
  39249. /**
  39250. * Revers pinch action direction.
  39251. */
  39252. pinchInwards: boolean;
  39253. private _isPanClick;
  39254. private _twoFingerActivityCount;
  39255. private _isPinching;
  39256. /**
  39257. * Called on pointer POINTERMOVE event if only a single touch is active.
  39258. */
  39259. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39260. /**
  39261. * Called on pointer POINTERDOUBLETAP event.
  39262. */
  39263. protected onDoubleTap(type: string): void;
  39264. /**
  39265. * Called on pointer POINTERMOVE event if multiple touches are active.
  39266. */
  39267. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39268. /**
  39269. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39270. * press.
  39271. */
  39272. protected onButtonDown(evt: PointerEvent): void;
  39273. /**
  39274. * Called each time a new POINTERUP event occurs. Ie, for each button
  39275. * release.
  39276. */
  39277. protected onButtonUp(evt: PointerEvent): void;
  39278. /**
  39279. * Called when window becomes inactive.
  39280. */
  39281. protected onLostFocus(): void;
  39282. }
  39283. }
  39284. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39285. import { Nullable } from "babylonjs/types";
  39286. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39287. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39288. /**
  39289. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39291. */
  39292. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39293. /**
  39294. * Defines the camera the input is attached to.
  39295. */
  39296. camera: ArcRotateCamera;
  39297. /**
  39298. * Defines the list of key codes associated with the up action (increase alpha)
  39299. */
  39300. keysUp: number[];
  39301. /**
  39302. * Defines the list of key codes associated with the down action (decrease alpha)
  39303. */
  39304. keysDown: number[];
  39305. /**
  39306. * Defines the list of key codes associated with the left action (increase beta)
  39307. */
  39308. keysLeft: number[];
  39309. /**
  39310. * Defines the list of key codes associated with the right action (decrease beta)
  39311. */
  39312. keysRight: number[];
  39313. /**
  39314. * Defines the list of key codes associated with the reset action.
  39315. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39316. */
  39317. keysReset: number[];
  39318. /**
  39319. * Defines the panning sensibility of the inputs.
  39320. * (How fast is the camera paning)
  39321. */
  39322. panningSensibility: number;
  39323. /**
  39324. * Defines the zooming sensibility of the inputs.
  39325. * (How fast is the camera zooming)
  39326. */
  39327. zoomingSensibility: number;
  39328. /**
  39329. * Defines wether maintaining the alt key down switch the movement mode from
  39330. * orientation to zoom.
  39331. */
  39332. useAltToZoom: boolean;
  39333. /**
  39334. * Rotation speed of the camera
  39335. */
  39336. angularSpeed: number;
  39337. private _keys;
  39338. private _ctrlPressed;
  39339. private _altPressed;
  39340. private _onCanvasBlurObserver;
  39341. private _onKeyboardObserver;
  39342. private _engine;
  39343. private _scene;
  39344. /**
  39345. * Attach the input controls to a specific dom element to get the input from.
  39346. * @param element Defines the element the controls should be listened from
  39347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39348. */
  39349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39350. /**
  39351. * Detach the current controls from the specified dom element.
  39352. * @param element Defines the element to stop listening the inputs from
  39353. */
  39354. detachControl(element: Nullable<HTMLElement>): void;
  39355. /**
  39356. * Update the current camera state depending on the inputs that have been used this frame.
  39357. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39358. */
  39359. checkInputs(): void;
  39360. /**
  39361. * Gets the class name of the current intput.
  39362. * @returns the class name
  39363. */
  39364. getClassName(): string;
  39365. /**
  39366. * Get the friendly name associated with the input class.
  39367. * @returns the input friendly name
  39368. */
  39369. getSimpleName(): string;
  39370. }
  39371. }
  39372. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39373. import { Nullable } from "babylonjs/types";
  39374. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39375. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39376. /**
  39377. * Manage the mouse wheel inputs to control an arc rotate camera.
  39378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39379. */
  39380. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39381. /**
  39382. * Defines the camera the input is attached to.
  39383. */
  39384. camera: ArcRotateCamera;
  39385. /**
  39386. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39387. */
  39388. wheelPrecision: number;
  39389. /**
  39390. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39391. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39392. */
  39393. wheelDeltaPercentage: number;
  39394. private _wheel;
  39395. private _observer;
  39396. private computeDeltaFromMouseWheelLegacyEvent;
  39397. /**
  39398. * Attach the input controls to a specific dom element to get the input from.
  39399. * @param element Defines the element the controls should be listened from
  39400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39401. */
  39402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39403. /**
  39404. * Detach the current controls from the specified dom element.
  39405. * @param element Defines the element to stop listening the inputs from
  39406. */
  39407. detachControl(element: Nullable<HTMLElement>): void;
  39408. /**
  39409. * Gets the class name of the current intput.
  39410. * @returns the class name
  39411. */
  39412. getClassName(): string;
  39413. /**
  39414. * Get the friendly name associated with the input class.
  39415. * @returns the input friendly name
  39416. */
  39417. getSimpleName(): string;
  39418. }
  39419. }
  39420. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39421. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39422. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39423. /**
  39424. * Default Inputs manager for the ArcRotateCamera.
  39425. * It groups all the default supported inputs for ease of use.
  39426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39427. */
  39428. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39429. /**
  39430. * Instantiates a new ArcRotateCameraInputsManager.
  39431. * @param camera Defines the camera the inputs belong to
  39432. */
  39433. constructor(camera: ArcRotateCamera);
  39434. /**
  39435. * Add mouse wheel input support to the input manager.
  39436. * @returns the current input manager
  39437. */
  39438. addMouseWheel(): ArcRotateCameraInputsManager;
  39439. /**
  39440. * Add pointers input support to the input manager.
  39441. * @returns the current input manager
  39442. */
  39443. addPointers(): ArcRotateCameraInputsManager;
  39444. /**
  39445. * Add keyboard input support to the input manager.
  39446. * @returns the current input manager
  39447. */
  39448. addKeyboard(): ArcRotateCameraInputsManager;
  39449. }
  39450. }
  39451. declare module "babylonjs/Cameras/arcRotateCamera" {
  39452. import { Observable } from "babylonjs/Misc/observable";
  39453. import { Nullable } from "babylonjs/types";
  39454. import { Scene } from "babylonjs/scene";
  39455. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39457. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39458. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39459. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39460. import { Camera } from "babylonjs/Cameras/camera";
  39461. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39462. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39463. import { Collider } from "babylonjs/Collisions/collider";
  39464. /**
  39465. * This represents an orbital type of camera.
  39466. *
  39467. * 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.
  39468. * 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.
  39469. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39470. */
  39471. export class ArcRotateCamera extends TargetCamera {
  39472. /**
  39473. * Defines the rotation angle of the camera along the longitudinal axis.
  39474. */
  39475. alpha: number;
  39476. /**
  39477. * Defines the rotation angle of the camera along the latitudinal axis.
  39478. */
  39479. beta: number;
  39480. /**
  39481. * Defines the radius of the camera from it s target point.
  39482. */
  39483. radius: number;
  39484. protected _target: Vector3;
  39485. protected _targetHost: Nullable<AbstractMesh>;
  39486. /**
  39487. * Defines the target point of the camera.
  39488. * The camera looks towards it form the radius distance.
  39489. */
  39490. get target(): Vector3;
  39491. set target(value: Vector3);
  39492. /**
  39493. * Define the current local position of the camera in the scene
  39494. */
  39495. get position(): Vector3;
  39496. set position(newPosition: Vector3);
  39497. protected _upVector: Vector3;
  39498. protected _upToYMatrix: Matrix;
  39499. protected _YToUpMatrix: Matrix;
  39500. /**
  39501. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39502. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39503. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39504. */
  39505. set upVector(vec: Vector3);
  39506. get upVector(): Vector3;
  39507. /**
  39508. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39509. */
  39510. setMatUp(): void;
  39511. /**
  39512. * Current inertia value on the longitudinal axis.
  39513. * The bigger this number the longer it will take for the camera to stop.
  39514. */
  39515. inertialAlphaOffset: number;
  39516. /**
  39517. * Current inertia value on the latitudinal axis.
  39518. * The bigger this number the longer it will take for the camera to stop.
  39519. */
  39520. inertialBetaOffset: number;
  39521. /**
  39522. * Current inertia value on the radius axis.
  39523. * The bigger this number the longer it will take for the camera to stop.
  39524. */
  39525. inertialRadiusOffset: number;
  39526. /**
  39527. * Minimum allowed angle on the longitudinal axis.
  39528. * This can help limiting how the Camera is able to move in the scene.
  39529. */
  39530. lowerAlphaLimit: Nullable<number>;
  39531. /**
  39532. * Maximum allowed angle on the longitudinal axis.
  39533. * This can help limiting how the Camera is able to move in the scene.
  39534. */
  39535. upperAlphaLimit: Nullable<number>;
  39536. /**
  39537. * Minimum allowed angle on the latitudinal axis.
  39538. * This can help limiting how the Camera is able to move in the scene.
  39539. */
  39540. lowerBetaLimit: number;
  39541. /**
  39542. * Maximum allowed angle on the latitudinal axis.
  39543. * This can help limiting how the Camera is able to move in the scene.
  39544. */
  39545. upperBetaLimit: number;
  39546. /**
  39547. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39548. * This can help limiting how the Camera is able to move in the scene.
  39549. */
  39550. lowerRadiusLimit: Nullable<number>;
  39551. /**
  39552. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39553. * This can help limiting how the Camera is able to move in the scene.
  39554. */
  39555. upperRadiusLimit: Nullable<number>;
  39556. /**
  39557. * Defines the current inertia value used during panning of the camera along the X axis.
  39558. */
  39559. inertialPanningX: number;
  39560. /**
  39561. * Defines the current inertia value used during panning of the camera along the Y axis.
  39562. */
  39563. inertialPanningY: number;
  39564. /**
  39565. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39566. * Basically if your fingers moves away from more than this distance you will be considered
  39567. * in pinch mode.
  39568. */
  39569. pinchToPanMaxDistance: number;
  39570. /**
  39571. * Defines the maximum distance the camera can pan.
  39572. * This could help keeping the cammera always in your scene.
  39573. */
  39574. panningDistanceLimit: Nullable<number>;
  39575. /**
  39576. * Defines the target of the camera before paning.
  39577. */
  39578. panningOriginTarget: Vector3;
  39579. /**
  39580. * Defines the value of the inertia used during panning.
  39581. * 0 would mean stop inertia and one would mean no decelleration at all.
  39582. */
  39583. panningInertia: number;
  39584. /**
  39585. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39586. */
  39587. get angularSensibilityX(): number;
  39588. set angularSensibilityX(value: number);
  39589. /**
  39590. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39591. */
  39592. get angularSensibilityY(): number;
  39593. set angularSensibilityY(value: number);
  39594. /**
  39595. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39596. */
  39597. get pinchPrecision(): number;
  39598. set pinchPrecision(value: number);
  39599. /**
  39600. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39601. * It will be used instead of pinchDeltaPrecision if different from 0.
  39602. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39603. */
  39604. get pinchDeltaPercentage(): number;
  39605. set pinchDeltaPercentage(value: number);
  39606. /**
  39607. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39608. */
  39609. get panningSensibility(): number;
  39610. set panningSensibility(value: number);
  39611. /**
  39612. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39613. */
  39614. get keysUp(): number[];
  39615. set keysUp(value: number[]);
  39616. /**
  39617. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39618. */
  39619. get keysDown(): number[];
  39620. set keysDown(value: number[]);
  39621. /**
  39622. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39623. */
  39624. get keysLeft(): number[];
  39625. set keysLeft(value: number[]);
  39626. /**
  39627. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39628. */
  39629. get keysRight(): number[];
  39630. set keysRight(value: number[]);
  39631. /**
  39632. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39633. */
  39634. get wheelPrecision(): number;
  39635. set wheelPrecision(value: number);
  39636. /**
  39637. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39638. * It will be used instead of pinchDeltaPrecision if different from 0.
  39639. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39640. */
  39641. get wheelDeltaPercentage(): number;
  39642. set wheelDeltaPercentage(value: number);
  39643. /**
  39644. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39645. */
  39646. zoomOnFactor: number;
  39647. /**
  39648. * Defines a screen offset for the camera position.
  39649. */
  39650. targetScreenOffset: Vector2;
  39651. /**
  39652. * Allows the camera to be completely reversed.
  39653. * If false the camera can not arrive upside down.
  39654. */
  39655. allowUpsideDown: boolean;
  39656. /**
  39657. * Define if double tap/click is used to restore the previously saved state of the camera.
  39658. */
  39659. useInputToRestoreState: boolean;
  39660. /** @hidden */
  39661. _viewMatrix: Matrix;
  39662. /** @hidden */
  39663. _useCtrlForPanning: boolean;
  39664. /** @hidden */
  39665. _panningMouseButton: number;
  39666. /**
  39667. * Defines the input associated to the camera.
  39668. */
  39669. inputs: ArcRotateCameraInputsManager;
  39670. /** @hidden */
  39671. _reset: () => void;
  39672. /**
  39673. * Defines the allowed panning axis.
  39674. */
  39675. panningAxis: Vector3;
  39676. protected _localDirection: Vector3;
  39677. protected _transformedDirection: Vector3;
  39678. private _bouncingBehavior;
  39679. /**
  39680. * Gets the bouncing behavior of the camera if it has been enabled.
  39681. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39682. */
  39683. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39684. /**
  39685. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39686. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39687. */
  39688. get useBouncingBehavior(): boolean;
  39689. set useBouncingBehavior(value: boolean);
  39690. private _framingBehavior;
  39691. /**
  39692. * Gets the framing behavior of the camera if it has been enabled.
  39693. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39694. */
  39695. get framingBehavior(): Nullable<FramingBehavior>;
  39696. /**
  39697. * Defines if the framing behavior of the camera is enabled on the camera.
  39698. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39699. */
  39700. get useFramingBehavior(): boolean;
  39701. set useFramingBehavior(value: boolean);
  39702. private _autoRotationBehavior;
  39703. /**
  39704. * Gets the auto rotation behavior of the camera if it has been enabled.
  39705. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39706. */
  39707. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39708. /**
  39709. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39710. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39711. */
  39712. get useAutoRotationBehavior(): boolean;
  39713. set useAutoRotationBehavior(value: boolean);
  39714. /**
  39715. * Observable triggered when the mesh target has been changed on the camera.
  39716. */
  39717. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39718. /**
  39719. * Event raised when the camera is colliding with a mesh.
  39720. */
  39721. onCollide: (collidedMesh: AbstractMesh) => void;
  39722. /**
  39723. * Defines whether the camera should check collision with the objects oh the scene.
  39724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39725. */
  39726. checkCollisions: boolean;
  39727. /**
  39728. * Defines the collision radius of the camera.
  39729. * This simulates a sphere around the camera.
  39730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39731. */
  39732. collisionRadius: Vector3;
  39733. protected _collider: Collider;
  39734. protected _previousPosition: Vector3;
  39735. protected _collisionVelocity: Vector3;
  39736. protected _newPosition: Vector3;
  39737. protected _previousAlpha: number;
  39738. protected _previousBeta: number;
  39739. protected _previousRadius: number;
  39740. protected _collisionTriggered: boolean;
  39741. protected _targetBoundingCenter: Nullable<Vector3>;
  39742. private _computationVector;
  39743. /**
  39744. * Instantiates a new ArcRotateCamera in a given scene
  39745. * @param name Defines the name of the camera
  39746. * @param alpha Defines the camera rotation along the logitudinal axis
  39747. * @param beta Defines the camera rotation along the latitudinal axis
  39748. * @param radius Defines the camera distance from its target
  39749. * @param target Defines the camera target
  39750. * @param scene Defines the scene the camera belongs to
  39751. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39752. */
  39753. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39754. /** @hidden */
  39755. _initCache(): void;
  39756. /** @hidden */
  39757. _updateCache(ignoreParentClass?: boolean): void;
  39758. protected _getTargetPosition(): Vector3;
  39759. private _storedAlpha;
  39760. private _storedBeta;
  39761. private _storedRadius;
  39762. private _storedTarget;
  39763. private _storedTargetScreenOffset;
  39764. /**
  39765. * Stores the current state of the camera (alpha, beta, radius and target)
  39766. * @returns the camera itself
  39767. */
  39768. storeState(): Camera;
  39769. /**
  39770. * @hidden
  39771. * Restored camera state. You must call storeState() first
  39772. */
  39773. _restoreStateValues(): boolean;
  39774. /** @hidden */
  39775. _isSynchronizedViewMatrix(): boolean;
  39776. /**
  39777. * Attached controls to the current camera.
  39778. * @param element Defines the element the controls should be listened from
  39779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39780. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39781. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39782. */
  39783. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39784. /**
  39785. * Detach the current controls from the camera.
  39786. * The camera will stop reacting to inputs.
  39787. * @param element Defines the element to stop listening the inputs from
  39788. */
  39789. detachControl(element: HTMLElement): void;
  39790. /** @hidden */
  39791. _checkInputs(): void;
  39792. protected _checkLimits(): void;
  39793. /**
  39794. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39795. */
  39796. rebuildAnglesAndRadius(): void;
  39797. /**
  39798. * Use a position to define the current camera related information like alpha, beta and radius
  39799. * @param position Defines the position to set the camera at
  39800. */
  39801. setPosition(position: Vector3): void;
  39802. /**
  39803. * Defines the target the camera should look at.
  39804. * This will automatically adapt alpha beta and radius to fit within the new target.
  39805. * @param target Defines the new target as a Vector or a mesh
  39806. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39807. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39808. */
  39809. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39810. /** @hidden */
  39811. _getViewMatrix(): Matrix;
  39812. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39813. /**
  39814. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39815. * @param meshes Defines the mesh to zoom on
  39816. * @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)
  39817. */
  39818. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39819. /**
  39820. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39821. * The target will be changed but the radius
  39822. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39823. * @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)
  39824. */
  39825. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39826. min: Vector3;
  39827. max: Vector3;
  39828. distance: number;
  39829. }, doNotUpdateMaxZ?: boolean): void;
  39830. /**
  39831. * @override
  39832. * Override Camera.createRigCamera
  39833. */
  39834. createRigCamera(name: string, cameraIndex: number): Camera;
  39835. /**
  39836. * @hidden
  39837. * @override
  39838. * Override Camera._updateRigCameras
  39839. */
  39840. _updateRigCameras(): void;
  39841. /**
  39842. * Destroy the camera and release the current resources hold by it.
  39843. */
  39844. dispose(): void;
  39845. /**
  39846. * Gets the current object class name.
  39847. * @return the class name
  39848. */
  39849. getClassName(): string;
  39850. }
  39851. }
  39852. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39853. import { Behavior } from "babylonjs/Behaviors/behavior";
  39854. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39855. /**
  39856. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39857. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39858. */
  39859. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39860. /**
  39861. * Gets the name of the behavior.
  39862. */
  39863. get name(): string;
  39864. private _zoomStopsAnimation;
  39865. private _idleRotationSpeed;
  39866. private _idleRotationWaitTime;
  39867. private _idleRotationSpinupTime;
  39868. /**
  39869. * Sets the flag that indicates if user zooming should stop animation.
  39870. */
  39871. set zoomStopsAnimation(flag: boolean);
  39872. /**
  39873. * Gets the flag that indicates if user zooming should stop animation.
  39874. */
  39875. get zoomStopsAnimation(): boolean;
  39876. /**
  39877. * Sets the default speed at which the camera rotates around the model.
  39878. */
  39879. set idleRotationSpeed(speed: number);
  39880. /**
  39881. * Gets the default speed at which the camera rotates around the model.
  39882. */
  39883. get idleRotationSpeed(): number;
  39884. /**
  39885. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39886. */
  39887. set idleRotationWaitTime(time: number);
  39888. /**
  39889. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39890. */
  39891. get idleRotationWaitTime(): number;
  39892. /**
  39893. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39894. */
  39895. set idleRotationSpinupTime(time: number);
  39896. /**
  39897. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39898. */
  39899. get idleRotationSpinupTime(): number;
  39900. /**
  39901. * Gets a value indicating if the camera is currently rotating because of this behavior
  39902. */
  39903. get rotationInProgress(): boolean;
  39904. private _onPrePointerObservableObserver;
  39905. private _onAfterCheckInputsObserver;
  39906. private _attachedCamera;
  39907. private _isPointerDown;
  39908. private _lastFrameTime;
  39909. private _lastInteractionTime;
  39910. private _cameraRotationSpeed;
  39911. /**
  39912. * Initializes the behavior.
  39913. */
  39914. init(): void;
  39915. /**
  39916. * Attaches the behavior to its arc rotate camera.
  39917. * @param camera Defines the camera to attach the behavior to
  39918. */
  39919. attach(camera: ArcRotateCamera): void;
  39920. /**
  39921. * Detaches the behavior from its current arc rotate camera.
  39922. */
  39923. detach(): void;
  39924. /**
  39925. * Returns true if user is scrolling.
  39926. * @return true if user is scrolling.
  39927. */
  39928. private _userIsZooming;
  39929. private _lastFrameRadius;
  39930. private _shouldAnimationStopForInteraction;
  39931. /**
  39932. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39933. */
  39934. private _applyUserInteraction;
  39935. private _userIsMoving;
  39936. }
  39937. }
  39938. declare module "babylonjs/Behaviors/Cameras/index" {
  39939. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39940. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39941. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39942. }
  39943. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39944. import { Mesh } from "babylonjs/Meshes/mesh";
  39945. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39946. import { Behavior } from "babylonjs/Behaviors/behavior";
  39947. /**
  39948. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39949. */
  39950. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39951. private ui;
  39952. /**
  39953. * The name of the behavior
  39954. */
  39955. name: string;
  39956. /**
  39957. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39958. */
  39959. distanceAwayFromFace: number;
  39960. /**
  39961. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39962. */
  39963. distanceAwayFromBottomOfFace: number;
  39964. private _faceVectors;
  39965. private _target;
  39966. private _scene;
  39967. private _onRenderObserver;
  39968. private _tmpMatrix;
  39969. private _tmpVector;
  39970. /**
  39971. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39972. * @param ui The transform node that should be attched to the mesh
  39973. */
  39974. constructor(ui: TransformNode);
  39975. /**
  39976. * Initializes the behavior
  39977. */
  39978. init(): void;
  39979. private _closestFace;
  39980. private _zeroVector;
  39981. private _lookAtTmpMatrix;
  39982. private _lookAtToRef;
  39983. /**
  39984. * Attaches the AttachToBoxBehavior to the passed in mesh
  39985. * @param target The mesh that the specified node will be attached to
  39986. */
  39987. attach(target: Mesh): void;
  39988. /**
  39989. * Detaches the behavior from the mesh
  39990. */
  39991. detach(): void;
  39992. }
  39993. }
  39994. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39995. import { Behavior } from "babylonjs/Behaviors/behavior";
  39996. import { Mesh } from "babylonjs/Meshes/mesh";
  39997. /**
  39998. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39999. */
  40000. export class FadeInOutBehavior implements Behavior<Mesh> {
  40001. /**
  40002. * Time in milliseconds to delay before fading in (Default: 0)
  40003. */
  40004. delay: number;
  40005. /**
  40006. * Time in milliseconds for the mesh to fade in (Default: 300)
  40007. */
  40008. fadeInTime: number;
  40009. private _millisecondsPerFrame;
  40010. private _hovered;
  40011. private _hoverValue;
  40012. private _ownerNode;
  40013. /**
  40014. * Instatiates the FadeInOutBehavior
  40015. */
  40016. constructor();
  40017. /**
  40018. * The name of the behavior
  40019. */
  40020. get name(): string;
  40021. /**
  40022. * Initializes the behavior
  40023. */
  40024. init(): void;
  40025. /**
  40026. * Attaches the fade behavior on the passed in mesh
  40027. * @param ownerNode The mesh that will be faded in/out once attached
  40028. */
  40029. attach(ownerNode: Mesh): void;
  40030. /**
  40031. * Detaches the behavior from the mesh
  40032. */
  40033. detach(): void;
  40034. /**
  40035. * Triggers the mesh to begin fading in or out
  40036. * @param value if the object should fade in or out (true to fade in)
  40037. */
  40038. fadeIn(value: boolean): void;
  40039. private _update;
  40040. private _setAllVisibility;
  40041. }
  40042. }
  40043. declare module "babylonjs/Misc/pivotTools" {
  40044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40045. /**
  40046. * Class containing a set of static utilities functions for managing Pivots
  40047. * @hidden
  40048. */
  40049. export class PivotTools {
  40050. private static _PivotCached;
  40051. private static _OldPivotPoint;
  40052. private static _PivotTranslation;
  40053. private static _PivotTmpVector;
  40054. /** @hidden */
  40055. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40056. /** @hidden */
  40057. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40058. }
  40059. }
  40060. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40061. import { Scene } from "babylonjs/scene";
  40062. import { Vector4 } from "babylonjs/Maths/math.vector";
  40063. import { Mesh } from "babylonjs/Meshes/mesh";
  40064. import { Nullable } from "babylonjs/types";
  40065. import { Plane } from "babylonjs/Maths/math.plane";
  40066. /**
  40067. * Class containing static functions to help procedurally build meshes
  40068. */
  40069. export class PlaneBuilder {
  40070. /**
  40071. * Creates a plane mesh
  40072. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40073. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40074. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40078. * @param name defines the name of the mesh
  40079. * @param options defines the options used to create the mesh
  40080. * @param scene defines the hosting scene
  40081. * @returns the plane mesh
  40082. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40083. */
  40084. static CreatePlane(name: string, options: {
  40085. size?: number;
  40086. width?: number;
  40087. height?: number;
  40088. sideOrientation?: number;
  40089. frontUVs?: Vector4;
  40090. backUVs?: Vector4;
  40091. updatable?: boolean;
  40092. sourcePlane?: Plane;
  40093. }, scene?: Nullable<Scene>): Mesh;
  40094. }
  40095. }
  40096. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40097. import { Behavior } from "babylonjs/Behaviors/behavior";
  40098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40099. import { Observable } from "babylonjs/Misc/observable";
  40100. import { Vector3 } from "babylonjs/Maths/math.vector";
  40101. import { Ray } from "babylonjs/Culling/ray";
  40102. import "babylonjs/Meshes/Builders/planeBuilder";
  40103. /**
  40104. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40105. */
  40106. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40107. private static _AnyMouseID;
  40108. /**
  40109. * Abstract mesh the behavior is set on
  40110. */
  40111. attachedNode: AbstractMesh;
  40112. private _dragPlane;
  40113. private _scene;
  40114. private _pointerObserver;
  40115. private _beforeRenderObserver;
  40116. private static _planeScene;
  40117. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40118. /**
  40119. * 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)
  40120. */
  40121. maxDragAngle: number;
  40122. /**
  40123. * @hidden
  40124. */
  40125. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40126. /**
  40127. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40128. */
  40129. currentDraggingPointerID: number;
  40130. /**
  40131. * The last position where the pointer hit the drag plane in world space
  40132. */
  40133. lastDragPosition: Vector3;
  40134. /**
  40135. * If the behavior is currently in a dragging state
  40136. */
  40137. dragging: boolean;
  40138. /**
  40139. * 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)
  40140. */
  40141. dragDeltaRatio: number;
  40142. /**
  40143. * If the drag plane orientation should be updated during the dragging (Default: true)
  40144. */
  40145. updateDragPlane: boolean;
  40146. private _debugMode;
  40147. private _moving;
  40148. /**
  40149. * Fires each time the attached mesh is dragged with the pointer
  40150. * * delta between last drag position and current drag position in world space
  40151. * * dragDistance along the drag axis
  40152. * * dragPlaneNormal normal of the current drag plane used during the drag
  40153. * * dragPlanePoint in world space where the drag intersects the drag plane
  40154. */
  40155. onDragObservable: Observable<{
  40156. delta: Vector3;
  40157. dragPlanePoint: Vector3;
  40158. dragPlaneNormal: Vector3;
  40159. dragDistance: number;
  40160. pointerId: number;
  40161. }>;
  40162. /**
  40163. * Fires each time a drag begins (eg. mouse down on mesh)
  40164. */
  40165. onDragStartObservable: Observable<{
  40166. dragPlanePoint: Vector3;
  40167. pointerId: number;
  40168. }>;
  40169. /**
  40170. * Fires each time a drag ends (eg. mouse release after drag)
  40171. */
  40172. onDragEndObservable: Observable<{
  40173. dragPlanePoint: Vector3;
  40174. pointerId: number;
  40175. }>;
  40176. /**
  40177. * If the attached mesh should be moved when dragged
  40178. */
  40179. moveAttached: boolean;
  40180. /**
  40181. * If the drag behavior will react to drag events (Default: true)
  40182. */
  40183. enabled: boolean;
  40184. /**
  40185. * If pointer events should start and release the drag (Default: true)
  40186. */
  40187. startAndReleaseDragOnPointerEvents: boolean;
  40188. /**
  40189. * If camera controls should be detached during the drag
  40190. */
  40191. detachCameraControls: boolean;
  40192. /**
  40193. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40194. */
  40195. useObjectOrientationForDragging: boolean;
  40196. private _options;
  40197. /**
  40198. * Gets the options used by the behavior
  40199. */
  40200. get options(): {
  40201. dragAxis?: Vector3;
  40202. dragPlaneNormal?: Vector3;
  40203. };
  40204. /**
  40205. * Sets the options used by the behavior
  40206. */
  40207. set options(options: {
  40208. dragAxis?: Vector3;
  40209. dragPlaneNormal?: Vector3;
  40210. });
  40211. /**
  40212. * Creates a pointer drag behavior that can be attached to a mesh
  40213. * @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)
  40214. */
  40215. constructor(options?: {
  40216. dragAxis?: Vector3;
  40217. dragPlaneNormal?: Vector3;
  40218. });
  40219. /**
  40220. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40221. */
  40222. validateDrag: (targetPosition: Vector3) => boolean;
  40223. /**
  40224. * The name of the behavior
  40225. */
  40226. get name(): string;
  40227. /**
  40228. * Initializes the behavior
  40229. */
  40230. init(): void;
  40231. private _tmpVector;
  40232. private _alternatePickedPoint;
  40233. private _worldDragAxis;
  40234. private _targetPosition;
  40235. private _attachedElement;
  40236. /**
  40237. * Attaches the drag behavior the passed in mesh
  40238. * @param ownerNode The mesh that will be dragged around once attached
  40239. * @param predicate Predicate to use for pick filtering
  40240. */
  40241. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40242. /**
  40243. * Force relase the drag action by code.
  40244. */
  40245. releaseDrag(): void;
  40246. private _startDragRay;
  40247. private _lastPointerRay;
  40248. /**
  40249. * Simulates the start of a pointer drag event on the behavior
  40250. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40251. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40252. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40253. */
  40254. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40255. private _startDrag;
  40256. private _dragDelta;
  40257. private _moveDrag;
  40258. private _pickWithRayOnDragPlane;
  40259. private _pointA;
  40260. private _pointB;
  40261. private _pointC;
  40262. private _lineA;
  40263. private _lineB;
  40264. private _localAxis;
  40265. private _lookAt;
  40266. private _updateDragPlanePosition;
  40267. /**
  40268. * Detaches the behavior from the mesh
  40269. */
  40270. detach(): void;
  40271. }
  40272. }
  40273. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40274. import { Mesh } from "babylonjs/Meshes/mesh";
  40275. import { Behavior } from "babylonjs/Behaviors/behavior";
  40276. /**
  40277. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40278. */
  40279. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40280. private _dragBehaviorA;
  40281. private _dragBehaviorB;
  40282. private _startDistance;
  40283. private _initialScale;
  40284. private _targetScale;
  40285. private _ownerNode;
  40286. private _sceneRenderObserver;
  40287. /**
  40288. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40289. */
  40290. constructor();
  40291. /**
  40292. * The name of the behavior
  40293. */
  40294. get name(): string;
  40295. /**
  40296. * Initializes the behavior
  40297. */
  40298. init(): void;
  40299. private _getCurrentDistance;
  40300. /**
  40301. * Attaches the scale behavior the passed in mesh
  40302. * @param ownerNode The mesh that will be scaled around once attached
  40303. */
  40304. attach(ownerNode: Mesh): void;
  40305. /**
  40306. * Detaches the behavior from the mesh
  40307. */
  40308. detach(): void;
  40309. }
  40310. }
  40311. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40312. import { Behavior } from "babylonjs/Behaviors/behavior";
  40313. import { Mesh } from "babylonjs/Meshes/mesh";
  40314. import { Observable } from "babylonjs/Misc/observable";
  40315. /**
  40316. * 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
  40317. */
  40318. export class SixDofDragBehavior implements Behavior<Mesh> {
  40319. private static _virtualScene;
  40320. private _ownerNode;
  40321. private _sceneRenderObserver;
  40322. private _scene;
  40323. private _targetPosition;
  40324. private _virtualOriginMesh;
  40325. private _virtualDragMesh;
  40326. private _pointerObserver;
  40327. private _moving;
  40328. private _startingOrientation;
  40329. /**
  40330. * 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)
  40331. */
  40332. private zDragFactor;
  40333. /**
  40334. * If the object should rotate to face the drag origin
  40335. */
  40336. rotateDraggedObject: boolean;
  40337. /**
  40338. * If the behavior is currently in a dragging state
  40339. */
  40340. dragging: boolean;
  40341. /**
  40342. * 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)
  40343. */
  40344. dragDeltaRatio: number;
  40345. /**
  40346. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40347. */
  40348. currentDraggingPointerID: number;
  40349. /**
  40350. * If camera controls should be detached during the drag
  40351. */
  40352. detachCameraControls: boolean;
  40353. /**
  40354. * Fires each time a drag starts
  40355. */
  40356. onDragStartObservable: Observable<{}>;
  40357. /**
  40358. * Fires each time a drag ends (eg. mouse release after drag)
  40359. */
  40360. onDragEndObservable: Observable<{}>;
  40361. /**
  40362. * 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
  40363. */
  40364. constructor();
  40365. /**
  40366. * The name of the behavior
  40367. */
  40368. get name(): string;
  40369. /**
  40370. * Initializes the behavior
  40371. */
  40372. init(): void;
  40373. /**
  40374. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40375. */
  40376. private get _pointerCamera();
  40377. /**
  40378. * Attaches the scale behavior the passed in mesh
  40379. * @param ownerNode The mesh that will be scaled around once attached
  40380. */
  40381. attach(ownerNode: Mesh): void;
  40382. /**
  40383. * Detaches the behavior from the mesh
  40384. */
  40385. detach(): void;
  40386. }
  40387. }
  40388. declare module "babylonjs/Behaviors/Meshes/index" {
  40389. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40390. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40391. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40392. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40393. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40394. }
  40395. declare module "babylonjs/Behaviors/index" {
  40396. export * from "babylonjs/Behaviors/behavior";
  40397. export * from "babylonjs/Behaviors/Cameras/index";
  40398. export * from "babylonjs/Behaviors/Meshes/index";
  40399. }
  40400. declare module "babylonjs/Bones/boneIKController" {
  40401. import { Bone } from "babylonjs/Bones/bone";
  40402. import { Vector3 } from "babylonjs/Maths/math.vector";
  40403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40404. import { Nullable } from "babylonjs/types";
  40405. /**
  40406. * Class used to apply inverse kinematics to bones
  40407. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40408. */
  40409. export class BoneIKController {
  40410. private static _tmpVecs;
  40411. private static _tmpQuat;
  40412. private static _tmpMats;
  40413. /**
  40414. * Gets or sets the target mesh
  40415. */
  40416. targetMesh: AbstractMesh;
  40417. /** Gets or sets the mesh used as pole */
  40418. poleTargetMesh: AbstractMesh;
  40419. /**
  40420. * Gets or sets the bone used as pole
  40421. */
  40422. poleTargetBone: Nullable<Bone>;
  40423. /**
  40424. * Gets or sets the target position
  40425. */
  40426. targetPosition: Vector3;
  40427. /**
  40428. * Gets or sets the pole target position
  40429. */
  40430. poleTargetPosition: Vector3;
  40431. /**
  40432. * Gets or sets the pole target local offset
  40433. */
  40434. poleTargetLocalOffset: Vector3;
  40435. /**
  40436. * Gets or sets the pole angle
  40437. */
  40438. poleAngle: number;
  40439. /**
  40440. * Gets or sets the mesh associated with the controller
  40441. */
  40442. mesh: AbstractMesh;
  40443. /**
  40444. * 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)
  40445. */
  40446. slerpAmount: number;
  40447. private _bone1Quat;
  40448. private _bone1Mat;
  40449. private _bone2Ang;
  40450. private _bone1;
  40451. private _bone2;
  40452. private _bone1Length;
  40453. private _bone2Length;
  40454. private _maxAngle;
  40455. private _maxReach;
  40456. private _rightHandedSystem;
  40457. private _bendAxis;
  40458. private _slerping;
  40459. private _adjustRoll;
  40460. /**
  40461. * Gets or sets maximum allowed angle
  40462. */
  40463. get maxAngle(): number;
  40464. set maxAngle(value: number);
  40465. /**
  40466. * Creates a new BoneIKController
  40467. * @param mesh defines the mesh to control
  40468. * @param bone defines the bone to control
  40469. * @param options defines options to set up the controller
  40470. */
  40471. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40472. targetMesh?: AbstractMesh;
  40473. poleTargetMesh?: AbstractMesh;
  40474. poleTargetBone?: Bone;
  40475. poleTargetLocalOffset?: Vector3;
  40476. poleAngle?: number;
  40477. bendAxis?: Vector3;
  40478. maxAngle?: number;
  40479. slerpAmount?: number;
  40480. });
  40481. private _setMaxAngle;
  40482. /**
  40483. * Force the controller to update the bones
  40484. */
  40485. update(): void;
  40486. }
  40487. }
  40488. declare module "babylonjs/Bones/boneLookController" {
  40489. import { Vector3 } from "babylonjs/Maths/math.vector";
  40490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40491. import { Bone } from "babylonjs/Bones/bone";
  40492. import { Space } from "babylonjs/Maths/math.axis";
  40493. /**
  40494. * Class used to make a bone look toward a point in space
  40495. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40496. */
  40497. export class BoneLookController {
  40498. private static _tmpVecs;
  40499. private static _tmpQuat;
  40500. private static _tmpMats;
  40501. /**
  40502. * The target Vector3 that the bone will look at
  40503. */
  40504. target: Vector3;
  40505. /**
  40506. * The mesh that the bone is attached to
  40507. */
  40508. mesh: AbstractMesh;
  40509. /**
  40510. * The bone that will be looking to the target
  40511. */
  40512. bone: Bone;
  40513. /**
  40514. * The up axis of the coordinate system that is used when the bone is rotated
  40515. */
  40516. upAxis: Vector3;
  40517. /**
  40518. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40519. */
  40520. upAxisSpace: Space;
  40521. /**
  40522. * Used to make an adjustment to the yaw of the bone
  40523. */
  40524. adjustYaw: number;
  40525. /**
  40526. * Used to make an adjustment to the pitch of the bone
  40527. */
  40528. adjustPitch: number;
  40529. /**
  40530. * Used to make an adjustment to the roll of the bone
  40531. */
  40532. adjustRoll: number;
  40533. /**
  40534. * 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)
  40535. */
  40536. slerpAmount: number;
  40537. private _minYaw;
  40538. private _maxYaw;
  40539. private _minPitch;
  40540. private _maxPitch;
  40541. private _minYawSin;
  40542. private _minYawCos;
  40543. private _maxYawSin;
  40544. private _maxYawCos;
  40545. private _midYawConstraint;
  40546. private _minPitchTan;
  40547. private _maxPitchTan;
  40548. private _boneQuat;
  40549. private _slerping;
  40550. private _transformYawPitch;
  40551. private _transformYawPitchInv;
  40552. private _firstFrameSkipped;
  40553. private _yawRange;
  40554. private _fowardAxis;
  40555. /**
  40556. * Gets or sets the minimum yaw angle that the bone can look to
  40557. */
  40558. get minYaw(): number;
  40559. set minYaw(value: number);
  40560. /**
  40561. * Gets or sets the maximum yaw angle that the bone can look to
  40562. */
  40563. get maxYaw(): number;
  40564. set maxYaw(value: number);
  40565. /**
  40566. * Gets or sets the minimum pitch angle that the bone can look to
  40567. */
  40568. get minPitch(): number;
  40569. set minPitch(value: number);
  40570. /**
  40571. * Gets or sets the maximum pitch angle that the bone can look to
  40572. */
  40573. get maxPitch(): number;
  40574. set maxPitch(value: number);
  40575. /**
  40576. * Create a BoneLookController
  40577. * @param mesh the mesh that the bone belongs to
  40578. * @param bone the bone that will be looking to the target
  40579. * @param target the target Vector3 to look at
  40580. * @param options optional settings:
  40581. * * maxYaw: the maximum angle the bone will yaw to
  40582. * * minYaw: the minimum angle the bone will yaw to
  40583. * * maxPitch: the maximum angle the bone will pitch to
  40584. * * minPitch: the minimum angle the bone will yaw to
  40585. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40586. * * upAxis: the up axis of the coordinate system
  40587. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40588. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40589. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40590. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40591. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40592. * * adjustRoll: used to make an adjustment to the roll of the bone
  40593. **/
  40594. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40595. maxYaw?: number;
  40596. minYaw?: number;
  40597. maxPitch?: number;
  40598. minPitch?: number;
  40599. slerpAmount?: number;
  40600. upAxis?: Vector3;
  40601. upAxisSpace?: Space;
  40602. yawAxis?: Vector3;
  40603. pitchAxis?: Vector3;
  40604. adjustYaw?: number;
  40605. adjustPitch?: number;
  40606. adjustRoll?: number;
  40607. });
  40608. /**
  40609. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40610. */
  40611. update(): void;
  40612. private _getAngleDiff;
  40613. private _getAngleBetween;
  40614. private _isAngleBetween;
  40615. }
  40616. }
  40617. declare module "babylonjs/Bones/index" {
  40618. export * from "babylonjs/Bones/bone";
  40619. export * from "babylonjs/Bones/boneIKController";
  40620. export * from "babylonjs/Bones/boneLookController";
  40621. export * from "babylonjs/Bones/skeleton";
  40622. }
  40623. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40624. import { Nullable } from "babylonjs/types";
  40625. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40626. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40627. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40628. /**
  40629. * Manage the gamepad inputs to control an arc rotate camera.
  40630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40631. */
  40632. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40633. /**
  40634. * Defines the camera the input is attached to.
  40635. */
  40636. camera: ArcRotateCamera;
  40637. /**
  40638. * Defines the gamepad the input is gathering event from.
  40639. */
  40640. gamepad: Nullable<Gamepad>;
  40641. /**
  40642. * Defines the gamepad rotation sensiblity.
  40643. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40644. */
  40645. gamepadRotationSensibility: number;
  40646. /**
  40647. * Defines the gamepad move sensiblity.
  40648. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40649. */
  40650. gamepadMoveSensibility: number;
  40651. private _yAxisScale;
  40652. /**
  40653. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40654. */
  40655. get invertYAxis(): boolean;
  40656. set invertYAxis(value: boolean);
  40657. private _onGamepadConnectedObserver;
  40658. private _onGamepadDisconnectedObserver;
  40659. /**
  40660. * Attach the input controls to a specific dom element to get the input from.
  40661. * @param element Defines the element the controls should be listened from
  40662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40663. */
  40664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40665. /**
  40666. * Detach the current controls from the specified dom element.
  40667. * @param element Defines the element to stop listening the inputs from
  40668. */
  40669. detachControl(element: Nullable<HTMLElement>): void;
  40670. /**
  40671. * Update the current camera state depending on the inputs that have been used this frame.
  40672. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40673. */
  40674. checkInputs(): void;
  40675. /**
  40676. * Gets the class name of the current intput.
  40677. * @returns the class name
  40678. */
  40679. getClassName(): string;
  40680. /**
  40681. * Get the friendly name associated with the input class.
  40682. * @returns the input friendly name
  40683. */
  40684. getSimpleName(): string;
  40685. }
  40686. }
  40687. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40688. import { Nullable } from "babylonjs/types";
  40689. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40690. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40691. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40692. interface ArcRotateCameraInputsManager {
  40693. /**
  40694. * Add orientation input support to the input manager.
  40695. * @returns the current input manager
  40696. */
  40697. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40698. }
  40699. }
  40700. /**
  40701. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40703. */
  40704. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40705. /**
  40706. * Defines the camera the input is attached to.
  40707. */
  40708. camera: ArcRotateCamera;
  40709. /**
  40710. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40711. */
  40712. alphaCorrection: number;
  40713. /**
  40714. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40715. */
  40716. gammaCorrection: number;
  40717. private _alpha;
  40718. private _gamma;
  40719. private _dirty;
  40720. private _deviceOrientationHandler;
  40721. /**
  40722. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40723. */
  40724. constructor();
  40725. /**
  40726. * Attach the input controls to a specific dom element to get the input from.
  40727. * @param element Defines the element the controls should be listened from
  40728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40729. */
  40730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40731. /** @hidden */
  40732. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40733. /**
  40734. * Update the current camera state depending on the inputs that have been used this frame.
  40735. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40736. */
  40737. checkInputs(): void;
  40738. /**
  40739. * Detach the current controls from the specified dom element.
  40740. * @param element Defines the element to stop listening the inputs from
  40741. */
  40742. detachControl(element: Nullable<HTMLElement>): void;
  40743. /**
  40744. * Gets the class name of the current intput.
  40745. * @returns the class name
  40746. */
  40747. getClassName(): string;
  40748. /**
  40749. * Get the friendly name associated with the input class.
  40750. * @returns the input friendly name
  40751. */
  40752. getSimpleName(): string;
  40753. }
  40754. }
  40755. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40756. import { Nullable } from "babylonjs/types";
  40757. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40758. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40759. /**
  40760. * Listen to mouse events to control the camera.
  40761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40762. */
  40763. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40764. /**
  40765. * Defines the camera the input is attached to.
  40766. */
  40767. camera: FlyCamera;
  40768. /**
  40769. * Defines if touch is enabled. (Default is true.)
  40770. */
  40771. touchEnabled: boolean;
  40772. /**
  40773. * Defines the buttons associated with the input to handle camera rotation.
  40774. */
  40775. buttons: number[];
  40776. /**
  40777. * Assign buttons for Yaw control.
  40778. */
  40779. buttonsYaw: number[];
  40780. /**
  40781. * Assign buttons for Pitch control.
  40782. */
  40783. buttonsPitch: number[];
  40784. /**
  40785. * Assign buttons for Roll control.
  40786. */
  40787. buttonsRoll: number[];
  40788. /**
  40789. * Detect if any button is being pressed while mouse is moved.
  40790. * -1 = Mouse locked.
  40791. * 0 = Left button.
  40792. * 1 = Middle Button.
  40793. * 2 = Right Button.
  40794. */
  40795. activeButton: number;
  40796. /**
  40797. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40798. * Higher values reduce its sensitivity.
  40799. */
  40800. angularSensibility: number;
  40801. private _mousemoveCallback;
  40802. private _observer;
  40803. private _rollObserver;
  40804. private previousPosition;
  40805. private noPreventDefault;
  40806. private element;
  40807. /**
  40808. * Listen to mouse events to control the camera.
  40809. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40811. */
  40812. constructor(touchEnabled?: boolean);
  40813. /**
  40814. * Attach the mouse control to the HTML DOM element.
  40815. * @param element Defines the element that listens to the input events.
  40816. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40817. */
  40818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40819. /**
  40820. * Detach the current controls from the specified dom element.
  40821. * @param element Defines the element to stop listening the inputs from
  40822. */
  40823. detachControl(element: Nullable<HTMLElement>): void;
  40824. /**
  40825. * Gets the class name of the current input.
  40826. * @returns the class name.
  40827. */
  40828. getClassName(): string;
  40829. /**
  40830. * Get the friendly name associated with the input class.
  40831. * @returns the input's friendly name.
  40832. */
  40833. getSimpleName(): string;
  40834. private _pointerInput;
  40835. private _onMouseMove;
  40836. /**
  40837. * Rotate camera by mouse offset.
  40838. */
  40839. private rotateCamera;
  40840. }
  40841. }
  40842. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40843. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40844. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40845. /**
  40846. * Default Inputs manager for the FlyCamera.
  40847. * It groups all the default supported inputs for ease of use.
  40848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40849. */
  40850. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40851. /**
  40852. * Instantiates a new FlyCameraInputsManager.
  40853. * @param camera Defines the camera the inputs belong to.
  40854. */
  40855. constructor(camera: FlyCamera);
  40856. /**
  40857. * Add keyboard input support to the input manager.
  40858. * @returns the new FlyCameraKeyboardMoveInput().
  40859. */
  40860. addKeyboard(): FlyCameraInputsManager;
  40861. /**
  40862. * Add mouse input support to the input manager.
  40863. * @param touchEnabled Enable touch screen support.
  40864. * @returns the new FlyCameraMouseInput().
  40865. */
  40866. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40867. }
  40868. }
  40869. declare module "babylonjs/Cameras/flyCamera" {
  40870. import { Scene } from "babylonjs/scene";
  40871. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40873. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40874. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40875. /**
  40876. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40877. * such as in a 3D Space Shooter or a Flight Simulator.
  40878. */
  40879. export class FlyCamera extends TargetCamera {
  40880. /**
  40881. * Define the collision ellipsoid of the camera.
  40882. * This is helpful for simulating a camera body, like a player's body.
  40883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40884. */
  40885. ellipsoid: Vector3;
  40886. /**
  40887. * Define an offset for the position of the ellipsoid around the camera.
  40888. * This can be helpful if the camera is attached away from the player's body center,
  40889. * such as at its head.
  40890. */
  40891. ellipsoidOffset: Vector3;
  40892. /**
  40893. * Enable or disable collisions of the camera with the rest of the scene objects.
  40894. */
  40895. checkCollisions: boolean;
  40896. /**
  40897. * Enable or disable gravity on the camera.
  40898. */
  40899. applyGravity: boolean;
  40900. /**
  40901. * Define the current direction the camera is moving to.
  40902. */
  40903. cameraDirection: Vector3;
  40904. /**
  40905. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40906. * This overrides and empties cameraRotation.
  40907. */
  40908. rotationQuaternion: Quaternion;
  40909. /**
  40910. * Track Roll to maintain the wanted Rolling when looking around.
  40911. */
  40912. _trackRoll: number;
  40913. /**
  40914. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40915. */
  40916. rollCorrect: number;
  40917. /**
  40918. * Mimic a banked turn, Rolling the camera when Yawing.
  40919. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40920. */
  40921. bankedTurn: boolean;
  40922. /**
  40923. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40924. */
  40925. bankedTurnLimit: number;
  40926. /**
  40927. * Value of 0 disables the banked Roll.
  40928. * Value of 1 is equal to the Yaw angle in radians.
  40929. */
  40930. bankedTurnMultiplier: number;
  40931. /**
  40932. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40933. */
  40934. inputs: FlyCameraInputsManager;
  40935. /**
  40936. * Gets the input sensibility for mouse input.
  40937. * Higher values reduce sensitivity.
  40938. */
  40939. get angularSensibility(): number;
  40940. /**
  40941. * Sets the input sensibility for a mouse input.
  40942. * Higher values reduce sensitivity.
  40943. */
  40944. set angularSensibility(value: number);
  40945. /**
  40946. * Get the keys for camera movement forward.
  40947. */
  40948. get keysForward(): number[];
  40949. /**
  40950. * Set the keys for camera movement forward.
  40951. */
  40952. set keysForward(value: number[]);
  40953. /**
  40954. * Get the keys for camera movement backward.
  40955. */
  40956. get keysBackward(): number[];
  40957. set keysBackward(value: number[]);
  40958. /**
  40959. * Get the keys for camera movement up.
  40960. */
  40961. get keysUp(): number[];
  40962. /**
  40963. * Set the keys for camera movement up.
  40964. */
  40965. set keysUp(value: number[]);
  40966. /**
  40967. * Get the keys for camera movement down.
  40968. */
  40969. get keysDown(): number[];
  40970. /**
  40971. * Set the keys for camera movement down.
  40972. */
  40973. set keysDown(value: number[]);
  40974. /**
  40975. * Get the keys for camera movement left.
  40976. */
  40977. get keysLeft(): number[];
  40978. /**
  40979. * Set the keys for camera movement left.
  40980. */
  40981. set keysLeft(value: number[]);
  40982. /**
  40983. * Set the keys for camera movement right.
  40984. */
  40985. get keysRight(): number[];
  40986. /**
  40987. * Set the keys for camera movement right.
  40988. */
  40989. set keysRight(value: number[]);
  40990. /**
  40991. * Event raised when the camera collides with a mesh in the scene.
  40992. */
  40993. onCollide: (collidedMesh: AbstractMesh) => void;
  40994. private _collider;
  40995. private _needMoveForGravity;
  40996. private _oldPosition;
  40997. private _diffPosition;
  40998. private _newPosition;
  40999. /** @hidden */
  41000. _localDirection: Vector3;
  41001. /** @hidden */
  41002. _transformedDirection: Vector3;
  41003. /**
  41004. * Instantiates a FlyCamera.
  41005. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41006. * such as in a 3D Space Shooter or a Flight Simulator.
  41007. * @param name Define the name of the camera in the scene.
  41008. * @param position Define the starting position of the camera in the scene.
  41009. * @param scene Define the scene the camera belongs to.
  41010. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41011. */
  41012. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41013. /**
  41014. * Attach a control to the HTML DOM element.
  41015. * @param element Defines the element that listens to the input events.
  41016. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41017. */
  41018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41019. /**
  41020. * Detach a control from the HTML DOM element.
  41021. * The camera will stop reacting to that input.
  41022. * @param element Defines the element that listens to the input events.
  41023. */
  41024. detachControl(element: HTMLElement): void;
  41025. private _collisionMask;
  41026. /**
  41027. * Get the mask that the camera ignores in collision events.
  41028. */
  41029. get collisionMask(): number;
  41030. /**
  41031. * Set the mask that the camera ignores in collision events.
  41032. */
  41033. set collisionMask(mask: number);
  41034. /** @hidden */
  41035. _collideWithWorld(displacement: Vector3): void;
  41036. /** @hidden */
  41037. private _onCollisionPositionChange;
  41038. /** @hidden */
  41039. _checkInputs(): void;
  41040. /** @hidden */
  41041. _decideIfNeedsToMove(): boolean;
  41042. /** @hidden */
  41043. _updatePosition(): void;
  41044. /**
  41045. * Restore the Roll to its target value at the rate specified.
  41046. * @param rate - Higher means slower restoring.
  41047. * @hidden
  41048. */
  41049. restoreRoll(rate: number): void;
  41050. /**
  41051. * Destroy the camera and release the current resources held by it.
  41052. */
  41053. dispose(): void;
  41054. /**
  41055. * Get the current object class name.
  41056. * @returns the class name.
  41057. */
  41058. getClassName(): string;
  41059. }
  41060. }
  41061. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41062. import { Nullable } from "babylonjs/types";
  41063. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41064. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41065. /**
  41066. * Listen to keyboard events to control the camera.
  41067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41068. */
  41069. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41070. /**
  41071. * Defines the camera the input is attached to.
  41072. */
  41073. camera: FlyCamera;
  41074. /**
  41075. * The list of keyboard keys used to control the forward move of the camera.
  41076. */
  41077. keysForward: number[];
  41078. /**
  41079. * The list of keyboard keys used to control the backward move of the camera.
  41080. */
  41081. keysBackward: number[];
  41082. /**
  41083. * The list of keyboard keys used to control the forward move of the camera.
  41084. */
  41085. keysUp: number[];
  41086. /**
  41087. * The list of keyboard keys used to control the backward move of the camera.
  41088. */
  41089. keysDown: number[];
  41090. /**
  41091. * The list of keyboard keys used to control the right strafe move of the camera.
  41092. */
  41093. keysRight: number[];
  41094. /**
  41095. * The list of keyboard keys used to control the left strafe move of the camera.
  41096. */
  41097. keysLeft: number[];
  41098. private _keys;
  41099. private _onCanvasBlurObserver;
  41100. private _onKeyboardObserver;
  41101. private _engine;
  41102. private _scene;
  41103. /**
  41104. * Attach the input controls to a specific dom element to get the input from.
  41105. * @param element Defines the element the controls should be listened from
  41106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41107. */
  41108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41109. /**
  41110. * Detach the current controls from the specified dom element.
  41111. * @param element Defines the element to stop listening the inputs from
  41112. */
  41113. detachControl(element: Nullable<HTMLElement>): void;
  41114. /**
  41115. * Gets the class name of the current intput.
  41116. * @returns the class name
  41117. */
  41118. getClassName(): string;
  41119. /** @hidden */
  41120. _onLostFocus(e: FocusEvent): void;
  41121. /**
  41122. * Get the friendly name associated with the input class.
  41123. * @returns the input friendly name
  41124. */
  41125. getSimpleName(): string;
  41126. /**
  41127. * Update the current camera state depending on the inputs that have been used this frame.
  41128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41129. */
  41130. checkInputs(): void;
  41131. }
  41132. }
  41133. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41134. import { Nullable } from "babylonjs/types";
  41135. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41136. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41137. /**
  41138. * Manage the mouse wheel inputs to control a follow camera.
  41139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41140. */
  41141. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41142. /**
  41143. * Defines the camera the input is attached to.
  41144. */
  41145. camera: FollowCamera;
  41146. /**
  41147. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41148. */
  41149. axisControlRadius: boolean;
  41150. /**
  41151. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41152. */
  41153. axisControlHeight: boolean;
  41154. /**
  41155. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41156. */
  41157. axisControlRotation: boolean;
  41158. /**
  41159. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41160. * relation to mouseWheel events.
  41161. */
  41162. wheelPrecision: number;
  41163. /**
  41164. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41165. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41166. */
  41167. wheelDeltaPercentage: number;
  41168. private _wheel;
  41169. private _observer;
  41170. /**
  41171. * Attach the input controls to a specific dom element to get the input from.
  41172. * @param element Defines the element the controls should be listened from
  41173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41174. */
  41175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41176. /**
  41177. * Detach the current controls from the specified dom element.
  41178. * @param element Defines the element to stop listening the inputs from
  41179. */
  41180. detachControl(element: Nullable<HTMLElement>): void;
  41181. /**
  41182. * Gets the class name of the current intput.
  41183. * @returns the class name
  41184. */
  41185. getClassName(): string;
  41186. /**
  41187. * Get the friendly name associated with the input class.
  41188. * @returns the input friendly name
  41189. */
  41190. getSimpleName(): string;
  41191. }
  41192. }
  41193. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41194. import { Nullable } from "babylonjs/types";
  41195. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41196. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41197. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41198. /**
  41199. * Manage the pointers inputs to control an follow camera.
  41200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41201. */
  41202. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41203. /**
  41204. * Defines the camera the input is attached to.
  41205. */
  41206. camera: FollowCamera;
  41207. /**
  41208. * Gets the class name of the current input.
  41209. * @returns the class name
  41210. */
  41211. getClassName(): string;
  41212. /**
  41213. * Defines the pointer angular sensibility along the X axis or how fast is
  41214. * the camera rotating.
  41215. * A negative number will reverse the axis direction.
  41216. */
  41217. angularSensibilityX: number;
  41218. /**
  41219. * Defines the pointer angular sensibility along the Y axis or how fast is
  41220. * the camera rotating.
  41221. * A negative number will reverse the axis direction.
  41222. */
  41223. angularSensibilityY: number;
  41224. /**
  41225. * Defines the pointer pinch precision or how fast is the camera zooming.
  41226. * A negative number will reverse the axis direction.
  41227. */
  41228. pinchPrecision: number;
  41229. /**
  41230. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41231. * from 0.
  41232. * It defines the percentage of current camera.radius to use as delta when
  41233. * pinch zoom is used.
  41234. */
  41235. pinchDeltaPercentage: number;
  41236. /**
  41237. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41238. */
  41239. axisXControlRadius: boolean;
  41240. /**
  41241. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41242. */
  41243. axisXControlHeight: boolean;
  41244. /**
  41245. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41246. */
  41247. axisXControlRotation: boolean;
  41248. /**
  41249. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41250. */
  41251. axisYControlRadius: boolean;
  41252. /**
  41253. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41254. */
  41255. axisYControlHeight: boolean;
  41256. /**
  41257. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41258. */
  41259. axisYControlRotation: boolean;
  41260. /**
  41261. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41262. */
  41263. axisPinchControlRadius: boolean;
  41264. /**
  41265. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41266. */
  41267. axisPinchControlHeight: boolean;
  41268. /**
  41269. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41270. */
  41271. axisPinchControlRotation: boolean;
  41272. /**
  41273. * Log error messages if basic misconfiguration has occurred.
  41274. */
  41275. warningEnable: boolean;
  41276. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41277. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41278. private _warningCounter;
  41279. private _warning;
  41280. }
  41281. }
  41282. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41283. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41284. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41285. /**
  41286. * Default Inputs manager for the FollowCamera.
  41287. * It groups all the default supported inputs for ease of use.
  41288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41289. */
  41290. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41291. /**
  41292. * Instantiates a new FollowCameraInputsManager.
  41293. * @param camera Defines the camera the inputs belong to
  41294. */
  41295. constructor(camera: FollowCamera);
  41296. /**
  41297. * Add keyboard input support to the input manager.
  41298. * @returns the current input manager
  41299. */
  41300. addKeyboard(): FollowCameraInputsManager;
  41301. /**
  41302. * Add mouse wheel input support to the input manager.
  41303. * @returns the current input manager
  41304. */
  41305. addMouseWheel(): FollowCameraInputsManager;
  41306. /**
  41307. * Add pointers input support to the input manager.
  41308. * @returns the current input manager
  41309. */
  41310. addPointers(): FollowCameraInputsManager;
  41311. /**
  41312. * Add orientation input support to the input manager.
  41313. * @returns the current input manager
  41314. */
  41315. addVRDeviceOrientation(): FollowCameraInputsManager;
  41316. }
  41317. }
  41318. declare module "babylonjs/Cameras/followCamera" {
  41319. import { Nullable } from "babylonjs/types";
  41320. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41321. import { Scene } from "babylonjs/scene";
  41322. import { Vector3 } from "babylonjs/Maths/math.vector";
  41323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41324. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41325. /**
  41326. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41327. * an arc rotate version arcFollowCamera are available.
  41328. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41329. */
  41330. export class FollowCamera extends TargetCamera {
  41331. /**
  41332. * Distance the follow camera should follow an object at
  41333. */
  41334. radius: number;
  41335. /**
  41336. * Minimum allowed distance of the camera to the axis of rotation
  41337. * (The camera can not get closer).
  41338. * This can help limiting how the Camera is able to move in the scene.
  41339. */
  41340. lowerRadiusLimit: Nullable<number>;
  41341. /**
  41342. * Maximum allowed distance of the camera to the axis of rotation
  41343. * (The camera can not get further).
  41344. * This can help limiting how the Camera is able to move in the scene.
  41345. */
  41346. upperRadiusLimit: Nullable<number>;
  41347. /**
  41348. * Define a rotation offset between the camera and the object it follows
  41349. */
  41350. rotationOffset: number;
  41351. /**
  41352. * Minimum allowed angle to camera position relative to target object.
  41353. * This can help limiting how the Camera is able to move in the scene.
  41354. */
  41355. lowerRotationOffsetLimit: Nullable<number>;
  41356. /**
  41357. * Maximum allowed angle to camera position relative to target object.
  41358. * This can help limiting how the Camera is able to move in the scene.
  41359. */
  41360. upperRotationOffsetLimit: Nullable<number>;
  41361. /**
  41362. * Define a height offset between the camera and the object it follows.
  41363. * It can help following an object from the top (like a car chaing a plane)
  41364. */
  41365. heightOffset: number;
  41366. /**
  41367. * Minimum allowed height of camera position relative to target object.
  41368. * This can help limiting how the Camera is able to move in the scene.
  41369. */
  41370. lowerHeightOffsetLimit: Nullable<number>;
  41371. /**
  41372. * Maximum allowed height of camera position relative to target object.
  41373. * This can help limiting how the Camera is able to move in the scene.
  41374. */
  41375. upperHeightOffsetLimit: Nullable<number>;
  41376. /**
  41377. * Define how fast the camera can accelerate to follow it s target.
  41378. */
  41379. cameraAcceleration: number;
  41380. /**
  41381. * Define the speed limit of the camera following an object.
  41382. */
  41383. maxCameraSpeed: number;
  41384. /**
  41385. * Define the target of the camera.
  41386. */
  41387. lockedTarget: Nullable<AbstractMesh>;
  41388. /**
  41389. * Defines the input associated with the camera.
  41390. */
  41391. inputs: FollowCameraInputsManager;
  41392. /**
  41393. * Instantiates the follow camera.
  41394. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41395. * @param name Define the name of the camera in the scene
  41396. * @param position Define the position of the camera
  41397. * @param scene Define the scene the camera belong to
  41398. * @param lockedTarget Define the target of the camera
  41399. */
  41400. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41401. private _follow;
  41402. /**
  41403. * Attached controls to the current camera.
  41404. * @param element Defines the element the controls should be listened from
  41405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41406. */
  41407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41408. /**
  41409. * Detach the current controls from the camera.
  41410. * The camera will stop reacting to inputs.
  41411. * @param element Defines the element to stop listening the inputs from
  41412. */
  41413. detachControl(element: HTMLElement): void;
  41414. /** @hidden */
  41415. _checkInputs(): void;
  41416. private _checkLimits;
  41417. /**
  41418. * Gets the camera class name.
  41419. * @returns the class name
  41420. */
  41421. getClassName(): string;
  41422. }
  41423. /**
  41424. * Arc Rotate version of the follow camera.
  41425. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41426. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41427. */
  41428. export class ArcFollowCamera extends TargetCamera {
  41429. /** The longitudinal angle of the camera */
  41430. alpha: number;
  41431. /** The latitudinal angle of the camera */
  41432. beta: number;
  41433. /** The radius of the camera from its target */
  41434. radius: number;
  41435. /** Define the camera target (the messh it should follow) */
  41436. target: Nullable<AbstractMesh>;
  41437. private _cartesianCoordinates;
  41438. /**
  41439. * Instantiates a new ArcFollowCamera
  41440. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41441. * @param name Define the name of the camera
  41442. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41443. * @param beta Define the rotation angle of the camera around the elevation axis
  41444. * @param radius Define the radius of the camera from its target point
  41445. * @param target Define the target of the camera
  41446. * @param scene Define the scene the camera belongs to
  41447. */
  41448. constructor(name: string,
  41449. /** The longitudinal angle of the camera */
  41450. alpha: number,
  41451. /** The latitudinal angle of the camera */
  41452. beta: number,
  41453. /** The radius of the camera from its target */
  41454. radius: number,
  41455. /** Define the camera target (the messh it should follow) */
  41456. target: Nullable<AbstractMesh>, scene: Scene);
  41457. private _follow;
  41458. /** @hidden */
  41459. _checkInputs(): void;
  41460. /**
  41461. * Returns the class name of the object.
  41462. * It is mostly used internally for serialization purposes.
  41463. */
  41464. getClassName(): string;
  41465. }
  41466. }
  41467. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41468. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41469. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41470. import { Nullable } from "babylonjs/types";
  41471. /**
  41472. * Manage the keyboard inputs to control the movement of a follow camera.
  41473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41474. */
  41475. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41476. /**
  41477. * Defines the camera the input is attached to.
  41478. */
  41479. camera: FollowCamera;
  41480. /**
  41481. * Defines the list of key codes associated with the up action (increase heightOffset)
  41482. */
  41483. keysHeightOffsetIncr: number[];
  41484. /**
  41485. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41486. */
  41487. keysHeightOffsetDecr: number[];
  41488. /**
  41489. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41490. */
  41491. keysHeightOffsetModifierAlt: boolean;
  41492. /**
  41493. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41494. */
  41495. keysHeightOffsetModifierCtrl: boolean;
  41496. /**
  41497. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41498. */
  41499. keysHeightOffsetModifierShift: boolean;
  41500. /**
  41501. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41502. */
  41503. keysRotationOffsetIncr: number[];
  41504. /**
  41505. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41506. */
  41507. keysRotationOffsetDecr: number[];
  41508. /**
  41509. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41510. */
  41511. keysRotationOffsetModifierAlt: boolean;
  41512. /**
  41513. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41514. */
  41515. keysRotationOffsetModifierCtrl: boolean;
  41516. /**
  41517. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41518. */
  41519. keysRotationOffsetModifierShift: boolean;
  41520. /**
  41521. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41522. */
  41523. keysRadiusIncr: number[];
  41524. /**
  41525. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41526. */
  41527. keysRadiusDecr: number[];
  41528. /**
  41529. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41530. */
  41531. keysRadiusModifierAlt: boolean;
  41532. /**
  41533. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41534. */
  41535. keysRadiusModifierCtrl: boolean;
  41536. /**
  41537. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41538. */
  41539. keysRadiusModifierShift: boolean;
  41540. /**
  41541. * Defines the rate of change of heightOffset.
  41542. */
  41543. heightSensibility: number;
  41544. /**
  41545. * Defines the rate of change of rotationOffset.
  41546. */
  41547. rotationSensibility: number;
  41548. /**
  41549. * Defines the rate of change of radius.
  41550. */
  41551. radiusSensibility: number;
  41552. private _keys;
  41553. private _ctrlPressed;
  41554. private _altPressed;
  41555. private _shiftPressed;
  41556. private _onCanvasBlurObserver;
  41557. private _onKeyboardObserver;
  41558. private _engine;
  41559. private _scene;
  41560. /**
  41561. * Attach the input controls to a specific dom element to get the input from.
  41562. * @param element Defines the element the controls should be listened from
  41563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41564. */
  41565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41566. /**
  41567. * Detach the current controls from the specified dom element.
  41568. * @param element Defines the element to stop listening the inputs from
  41569. */
  41570. detachControl(element: Nullable<HTMLElement>): void;
  41571. /**
  41572. * Update the current camera state depending on the inputs that have been used this frame.
  41573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41574. */
  41575. checkInputs(): void;
  41576. /**
  41577. * Gets the class name of the current input.
  41578. * @returns the class name
  41579. */
  41580. getClassName(): string;
  41581. /**
  41582. * Get the friendly name associated with the input class.
  41583. * @returns the input friendly name
  41584. */
  41585. getSimpleName(): string;
  41586. /**
  41587. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41588. * allow modification of the heightOffset value.
  41589. */
  41590. private _modifierHeightOffset;
  41591. /**
  41592. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41593. * allow modification of the rotationOffset value.
  41594. */
  41595. private _modifierRotationOffset;
  41596. /**
  41597. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41598. * allow modification of the radius value.
  41599. */
  41600. private _modifierRadius;
  41601. }
  41602. }
  41603. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41604. import { Nullable } from "babylonjs/types";
  41605. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41606. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41607. import { Observable } from "babylonjs/Misc/observable";
  41608. module "babylonjs/Cameras/freeCameraInputsManager" {
  41609. interface FreeCameraInputsManager {
  41610. /**
  41611. * @hidden
  41612. */
  41613. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41614. /**
  41615. * Add orientation input support to the input manager.
  41616. * @returns the current input manager
  41617. */
  41618. addDeviceOrientation(): FreeCameraInputsManager;
  41619. }
  41620. }
  41621. /**
  41622. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41623. * Screen rotation is taken into account.
  41624. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41625. */
  41626. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41627. private _camera;
  41628. private _screenOrientationAngle;
  41629. private _constantTranform;
  41630. private _screenQuaternion;
  41631. private _alpha;
  41632. private _beta;
  41633. private _gamma;
  41634. /**
  41635. * Can be used to detect if a device orientation sensor is available on a device
  41636. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41637. * @returns a promise that will resolve on orientation change
  41638. */
  41639. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41640. /**
  41641. * @hidden
  41642. */
  41643. _onDeviceOrientationChangedObservable: Observable<void>;
  41644. /**
  41645. * Instantiates a new input
  41646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41647. */
  41648. constructor();
  41649. /**
  41650. * Define the camera controlled by the input.
  41651. */
  41652. get camera(): FreeCamera;
  41653. set camera(camera: FreeCamera);
  41654. /**
  41655. * Attach the input controls to a specific dom element to get the input from.
  41656. * @param element Defines the element the controls should be listened from
  41657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41658. */
  41659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41660. private _orientationChanged;
  41661. private _deviceOrientation;
  41662. /**
  41663. * Detach the current controls from the specified dom element.
  41664. * @param element Defines the element to stop listening the inputs from
  41665. */
  41666. detachControl(element: Nullable<HTMLElement>): void;
  41667. /**
  41668. * Update the current camera state depending on the inputs that have been used this frame.
  41669. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41670. */
  41671. checkInputs(): void;
  41672. /**
  41673. * Gets the class name of the current intput.
  41674. * @returns the class name
  41675. */
  41676. getClassName(): string;
  41677. /**
  41678. * Get the friendly name associated with the input class.
  41679. * @returns the input friendly name
  41680. */
  41681. getSimpleName(): string;
  41682. }
  41683. }
  41684. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41685. import { Nullable } from "babylonjs/types";
  41686. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41687. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41688. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41689. /**
  41690. * Manage the gamepad inputs to control a free camera.
  41691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41692. */
  41693. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41694. /**
  41695. * Define the camera the input is attached to.
  41696. */
  41697. camera: FreeCamera;
  41698. /**
  41699. * Define the Gamepad controlling the input
  41700. */
  41701. gamepad: Nullable<Gamepad>;
  41702. /**
  41703. * Defines the gamepad rotation sensiblity.
  41704. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41705. */
  41706. gamepadAngularSensibility: number;
  41707. /**
  41708. * Defines the gamepad move sensiblity.
  41709. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41710. */
  41711. gamepadMoveSensibility: number;
  41712. private _yAxisScale;
  41713. /**
  41714. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41715. */
  41716. get invertYAxis(): boolean;
  41717. set invertYAxis(value: boolean);
  41718. private _onGamepadConnectedObserver;
  41719. private _onGamepadDisconnectedObserver;
  41720. private _cameraTransform;
  41721. private _deltaTransform;
  41722. private _vector3;
  41723. private _vector2;
  41724. /**
  41725. * Attach the input controls to a specific dom element to get the input from.
  41726. * @param element Defines the element the controls should be listened from
  41727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41728. */
  41729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41730. /**
  41731. * Detach the current controls from the specified dom element.
  41732. * @param element Defines the element to stop listening the inputs from
  41733. */
  41734. detachControl(element: Nullable<HTMLElement>): void;
  41735. /**
  41736. * Update the current camera state depending on the inputs that have been used this frame.
  41737. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41738. */
  41739. checkInputs(): void;
  41740. /**
  41741. * Gets the class name of the current intput.
  41742. * @returns the class name
  41743. */
  41744. getClassName(): string;
  41745. /**
  41746. * Get the friendly name associated with the input class.
  41747. * @returns the input friendly name
  41748. */
  41749. getSimpleName(): string;
  41750. }
  41751. }
  41752. declare module "babylonjs/Misc/virtualJoystick" {
  41753. import { Nullable } from "babylonjs/types";
  41754. import { Vector3 } from "babylonjs/Maths/math.vector";
  41755. /**
  41756. * Defines the potential axis of a Joystick
  41757. */
  41758. export enum JoystickAxis {
  41759. /** X axis */
  41760. X = 0,
  41761. /** Y axis */
  41762. Y = 1,
  41763. /** Z axis */
  41764. Z = 2
  41765. }
  41766. /**
  41767. * Class used to define virtual joystick (used in touch mode)
  41768. */
  41769. export class VirtualJoystick {
  41770. /**
  41771. * Gets or sets a boolean indicating that left and right values must be inverted
  41772. */
  41773. reverseLeftRight: boolean;
  41774. /**
  41775. * Gets or sets a boolean indicating that up and down values must be inverted
  41776. */
  41777. reverseUpDown: boolean;
  41778. /**
  41779. * Gets the offset value for the position (ie. the change of the position value)
  41780. */
  41781. deltaPosition: Vector3;
  41782. /**
  41783. * Gets a boolean indicating if the virtual joystick was pressed
  41784. */
  41785. pressed: boolean;
  41786. /**
  41787. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41788. */
  41789. static Canvas: Nullable<HTMLCanvasElement>;
  41790. private static _globalJoystickIndex;
  41791. private static vjCanvasContext;
  41792. private static vjCanvasWidth;
  41793. private static vjCanvasHeight;
  41794. private static halfWidth;
  41795. private _action;
  41796. private _axisTargetedByLeftAndRight;
  41797. private _axisTargetedByUpAndDown;
  41798. private _joystickSensibility;
  41799. private _inversedSensibility;
  41800. private _joystickPointerID;
  41801. private _joystickColor;
  41802. private _joystickPointerPos;
  41803. private _joystickPreviousPointerPos;
  41804. private _joystickPointerStartPos;
  41805. private _deltaJoystickVector;
  41806. private _leftJoystick;
  41807. private _touches;
  41808. private _onPointerDownHandlerRef;
  41809. private _onPointerMoveHandlerRef;
  41810. private _onPointerUpHandlerRef;
  41811. private _onResize;
  41812. /**
  41813. * Creates a new virtual joystick
  41814. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41815. */
  41816. constructor(leftJoystick?: boolean);
  41817. /**
  41818. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41819. * @param newJoystickSensibility defines the new sensibility
  41820. */
  41821. setJoystickSensibility(newJoystickSensibility: number): void;
  41822. private _onPointerDown;
  41823. private _onPointerMove;
  41824. private _onPointerUp;
  41825. /**
  41826. * Change the color of the virtual joystick
  41827. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41828. */
  41829. setJoystickColor(newColor: string): void;
  41830. /**
  41831. * Defines a callback to call when the joystick is touched
  41832. * @param action defines the callback
  41833. */
  41834. setActionOnTouch(action: () => any): void;
  41835. /**
  41836. * Defines which axis you'd like to control for left & right
  41837. * @param axis defines the axis to use
  41838. */
  41839. setAxisForLeftRight(axis: JoystickAxis): void;
  41840. /**
  41841. * Defines which axis you'd like to control for up & down
  41842. * @param axis defines the axis to use
  41843. */
  41844. setAxisForUpDown(axis: JoystickAxis): void;
  41845. private _drawVirtualJoystick;
  41846. /**
  41847. * Release internal HTML canvas
  41848. */
  41849. releaseCanvas(): void;
  41850. }
  41851. }
  41852. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41853. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41854. import { Nullable } from "babylonjs/types";
  41855. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41856. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41857. module "babylonjs/Cameras/freeCameraInputsManager" {
  41858. interface FreeCameraInputsManager {
  41859. /**
  41860. * Add virtual joystick input support to the input manager.
  41861. * @returns the current input manager
  41862. */
  41863. addVirtualJoystick(): FreeCameraInputsManager;
  41864. }
  41865. }
  41866. /**
  41867. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41869. */
  41870. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41871. /**
  41872. * Defines the camera the input is attached to.
  41873. */
  41874. camera: FreeCamera;
  41875. private _leftjoystick;
  41876. private _rightjoystick;
  41877. /**
  41878. * Gets the left stick of the virtual joystick.
  41879. * @returns The virtual Joystick
  41880. */
  41881. getLeftJoystick(): VirtualJoystick;
  41882. /**
  41883. * Gets the right stick of the virtual joystick.
  41884. * @returns The virtual Joystick
  41885. */
  41886. getRightJoystick(): VirtualJoystick;
  41887. /**
  41888. * Update the current camera state depending on the inputs that have been used this frame.
  41889. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41890. */
  41891. checkInputs(): void;
  41892. /**
  41893. * Attach the input controls to a specific dom element to get the input from.
  41894. * @param element Defines the element the controls should be listened from
  41895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41896. */
  41897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41898. /**
  41899. * Detach the current controls from the specified dom element.
  41900. * @param element Defines the element to stop listening the inputs from
  41901. */
  41902. detachControl(element: Nullable<HTMLElement>): void;
  41903. /**
  41904. * Gets the class name of the current intput.
  41905. * @returns the class name
  41906. */
  41907. getClassName(): string;
  41908. /**
  41909. * Get the friendly name associated with the input class.
  41910. * @returns the input friendly name
  41911. */
  41912. getSimpleName(): string;
  41913. }
  41914. }
  41915. declare module "babylonjs/Cameras/Inputs/index" {
  41916. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41917. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41918. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41919. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41920. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41921. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41922. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41923. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41924. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41925. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41926. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41927. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41928. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41929. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41930. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41931. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41932. }
  41933. declare module "babylonjs/Cameras/touchCamera" {
  41934. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41935. import { Scene } from "babylonjs/scene";
  41936. import { Vector3 } from "babylonjs/Maths/math.vector";
  41937. /**
  41938. * This represents a FPS type of camera controlled by touch.
  41939. * This is like a universal camera minus the Gamepad controls.
  41940. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41941. */
  41942. export class TouchCamera extends FreeCamera {
  41943. /**
  41944. * Defines the touch sensibility for rotation.
  41945. * The higher the faster.
  41946. */
  41947. get touchAngularSensibility(): number;
  41948. set touchAngularSensibility(value: number);
  41949. /**
  41950. * Defines the touch sensibility for move.
  41951. * The higher the faster.
  41952. */
  41953. get touchMoveSensibility(): number;
  41954. set touchMoveSensibility(value: number);
  41955. /**
  41956. * Instantiates a new touch camera.
  41957. * This represents a FPS type of camera controlled by touch.
  41958. * This is like a universal camera minus the Gamepad controls.
  41959. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41960. * @param name Define the name of the camera in the scene
  41961. * @param position Define the start position of the camera in the scene
  41962. * @param scene Define the scene the camera belongs to
  41963. */
  41964. constructor(name: string, position: Vector3, scene: Scene);
  41965. /**
  41966. * Gets the current object class name.
  41967. * @return the class name
  41968. */
  41969. getClassName(): string;
  41970. /** @hidden */
  41971. _setupInputs(): void;
  41972. }
  41973. }
  41974. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41975. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41976. import { Scene } from "babylonjs/scene";
  41977. import { Vector3 } from "babylonjs/Maths/math.vector";
  41978. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41979. import { Axis } from "babylonjs/Maths/math.axis";
  41980. /**
  41981. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41982. * being tilted forward or back and left or right.
  41983. */
  41984. export class DeviceOrientationCamera extends FreeCamera {
  41985. private _initialQuaternion;
  41986. private _quaternionCache;
  41987. private _tmpDragQuaternion;
  41988. private _disablePointerInputWhenUsingDeviceOrientation;
  41989. /**
  41990. * Creates a new device orientation camera
  41991. * @param name The name of the camera
  41992. * @param position The start position camera
  41993. * @param scene The scene the camera belongs to
  41994. */
  41995. constructor(name: string, position: Vector3, scene: Scene);
  41996. /**
  41997. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41998. */
  41999. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42000. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42001. private _dragFactor;
  42002. /**
  42003. * Enabled turning on the y axis when the orientation sensor is active
  42004. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42005. */
  42006. enableHorizontalDragging(dragFactor?: number): void;
  42007. /**
  42008. * Gets the current instance class name ("DeviceOrientationCamera").
  42009. * This helps avoiding instanceof at run time.
  42010. * @returns the class name
  42011. */
  42012. getClassName(): string;
  42013. /**
  42014. * @hidden
  42015. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42016. */
  42017. _checkInputs(): void;
  42018. /**
  42019. * Reset the camera to its default orientation on the specified axis only.
  42020. * @param axis The axis to reset
  42021. */
  42022. resetToCurrentRotation(axis?: Axis): void;
  42023. }
  42024. }
  42025. declare module "babylonjs/Gamepads/xboxGamepad" {
  42026. import { Observable } from "babylonjs/Misc/observable";
  42027. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42028. /**
  42029. * Defines supported buttons for XBox360 compatible gamepads
  42030. */
  42031. export enum Xbox360Button {
  42032. /** A */
  42033. A = 0,
  42034. /** B */
  42035. B = 1,
  42036. /** X */
  42037. X = 2,
  42038. /** Y */
  42039. Y = 3,
  42040. /** Start */
  42041. Start = 4,
  42042. /** Back */
  42043. Back = 5,
  42044. /** Left button */
  42045. LB = 6,
  42046. /** Right button */
  42047. RB = 7,
  42048. /** Left stick */
  42049. LeftStick = 8,
  42050. /** Right stick */
  42051. RightStick = 9
  42052. }
  42053. /** Defines values for XBox360 DPad */
  42054. export enum Xbox360Dpad {
  42055. /** Up */
  42056. Up = 0,
  42057. /** Down */
  42058. Down = 1,
  42059. /** Left */
  42060. Left = 2,
  42061. /** Right */
  42062. Right = 3
  42063. }
  42064. /**
  42065. * Defines a XBox360 gamepad
  42066. */
  42067. export class Xbox360Pad extends Gamepad {
  42068. private _leftTrigger;
  42069. private _rightTrigger;
  42070. private _onlefttriggerchanged;
  42071. private _onrighttriggerchanged;
  42072. private _onbuttondown;
  42073. private _onbuttonup;
  42074. private _ondpaddown;
  42075. private _ondpadup;
  42076. /** Observable raised when a button is pressed */
  42077. onButtonDownObservable: Observable<Xbox360Button>;
  42078. /** Observable raised when a button is released */
  42079. onButtonUpObservable: Observable<Xbox360Button>;
  42080. /** Observable raised when a pad is pressed */
  42081. onPadDownObservable: Observable<Xbox360Dpad>;
  42082. /** Observable raised when a pad is released */
  42083. onPadUpObservable: Observable<Xbox360Dpad>;
  42084. private _buttonA;
  42085. private _buttonB;
  42086. private _buttonX;
  42087. private _buttonY;
  42088. private _buttonBack;
  42089. private _buttonStart;
  42090. private _buttonLB;
  42091. private _buttonRB;
  42092. private _buttonLeftStick;
  42093. private _buttonRightStick;
  42094. private _dPadUp;
  42095. private _dPadDown;
  42096. private _dPadLeft;
  42097. private _dPadRight;
  42098. private _isXboxOnePad;
  42099. /**
  42100. * Creates a new XBox360 gamepad object
  42101. * @param id defines the id of this gamepad
  42102. * @param index defines its index
  42103. * @param gamepad defines the internal HTML gamepad object
  42104. * @param xboxOne defines if it is a XBox One gamepad
  42105. */
  42106. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42107. /**
  42108. * Defines the callback to call when left trigger is pressed
  42109. * @param callback defines the callback to use
  42110. */
  42111. onlefttriggerchanged(callback: (value: number) => void): void;
  42112. /**
  42113. * Defines the callback to call when right trigger is pressed
  42114. * @param callback defines the callback to use
  42115. */
  42116. onrighttriggerchanged(callback: (value: number) => void): void;
  42117. /**
  42118. * Gets the left trigger value
  42119. */
  42120. get leftTrigger(): number;
  42121. /**
  42122. * Sets the left trigger value
  42123. */
  42124. set leftTrigger(newValue: number);
  42125. /**
  42126. * Gets the right trigger value
  42127. */
  42128. get rightTrigger(): number;
  42129. /**
  42130. * Sets the right trigger value
  42131. */
  42132. set rightTrigger(newValue: number);
  42133. /**
  42134. * Defines the callback to call when a button is pressed
  42135. * @param callback defines the callback to use
  42136. */
  42137. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42138. /**
  42139. * Defines the callback to call when a button is released
  42140. * @param callback defines the callback to use
  42141. */
  42142. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42143. /**
  42144. * Defines the callback to call when a pad is pressed
  42145. * @param callback defines the callback to use
  42146. */
  42147. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42148. /**
  42149. * Defines the callback to call when a pad is released
  42150. * @param callback defines the callback to use
  42151. */
  42152. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42153. private _setButtonValue;
  42154. private _setDPadValue;
  42155. /**
  42156. * Gets the value of the `A` button
  42157. */
  42158. get buttonA(): number;
  42159. /**
  42160. * Sets the value of the `A` button
  42161. */
  42162. set buttonA(value: number);
  42163. /**
  42164. * Gets the value of the `B` button
  42165. */
  42166. get buttonB(): number;
  42167. /**
  42168. * Sets the value of the `B` button
  42169. */
  42170. set buttonB(value: number);
  42171. /**
  42172. * Gets the value of the `X` button
  42173. */
  42174. get buttonX(): number;
  42175. /**
  42176. * Sets the value of the `X` button
  42177. */
  42178. set buttonX(value: number);
  42179. /**
  42180. * Gets the value of the `Y` button
  42181. */
  42182. get buttonY(): number;
  42183. /**
  42184. * Sets the value of the `Y` button
  42185. */
  42186. set buttonY(value: number);
  42187. /**
  42188. * Gets the value of the `Start` button
  42189. */
  42190. get buttonStart(): number;
  42191. /**
  42192. * Sets the value of the `Start` button
  42193. */
  42194. set buttonStart(value: number);
  42195. /**
  42196. * Gets the value of the `Back` button
  42197. */
  42198. get buttonBack(): number;
  42199. /**
  42200. * Sets the value of the `Back` button
  42201. */
  42202. set buttonBack(value: number);
  42203. /**
  42204. * Gets the value of the `Left` button
  42205. */
  42206. get buttonLB(): number;
  42207. /**
  42208. * Sets the value of the `Left` button
  42209. */
  42210. set buttonLB(value: number);
  42211. /**
  42212. * Gets the value of the `Right` button
  42213. */
  42214. get buttonRB(): number;
  42215. /**
  42216. * Sets the value of the `Right` button
  42217. */
  42218. set buttonRB(value: number);
  42219. /**
  42220. * Gets the value of the Left joystick
  42221. */
  42222. get buttonLeftStick(): number;
  42223. /**
  42224. * Sets the value of the Left joystick
  42225. */
  42226. set buttonLeftStick(value: number);
  42227. /**
  42228. * Gets the value of the Right joystick
  42229. */
  42230. get buttonRightStick(): number;
  42231. /**
  42232. * Sets the value of the Right joystick
  42233. */
  42234. set buttonRightStick(value: number);
  42235. /**
  42236. * Gets the value of D-pad up
  42237. */
  42238. get dPadUp(): number;
  42239. /**
  42240. * Sets the value of D-pad up
  42241. */
  42242. set dPadUp(value: number);
  42243. /**
  42244. * Gets the value of D-pad down
  42245. */
  42246. get dPadDown(): number;
  42247. /**
  42248. * Sets the value of D-pad down
  42249. */
  42250. set dPadDown(value: number);
  42251. /**
  42252. * Gets the value of D-pad left
  42253. */
  42254. get dPadLeft(): number;
  42255. /**
  42256. * Sets the value of D-pad left
  42257. */
  42258. set dPadLeft(value: number);
  42259. /**
  42260. * Gets the value of D-pad right
  42261. */
  42262. get dPadRight(): number;
  42263. /**
  42264. * Sets the value of D-pad right
  42265. */
  42266. set dPadRight(value: number);
  42267. /**
  42268. * Force the gamepad to synchronize with device values
  42269. */
  42270. update(): void;
  42271. /**
  42272. * Disposes the gamepad
  42273. */
  42274. dispose(): void;
  42275. }
  42276. }
  42277. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42278. import { Observable } from "babylonjs/Misc/observable";
  42279. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42280. /**
  42281. * Defines supported buttons for DualShock compatible gamepads
  42282. */
  42283. export enum DualShockButton {
  42284. /** Cross */
  42285. Cross = 0,
  42286. /** Circle */
  42287. Circle = 1,
  42288. /** Square */
  42289. Square = 2,
  42290. /** Triangle */
  42291. Triangle = 3,
  42292. /** Options */
  42293. Options = 4,
  42294. /** Share */
  42295. Share = 5,
  42296. /** L1 */
  42297. L1 = 6,
  42298. /** R1 */
  42299. R1 = 7,
  42300. /** Left stick */
  42301. LeftStick = 8,
  42302. /** Right stick */
  42303. RightStick = 9
  42304. }
  42305. /** Defines values for DualShock DPad */
  42306. export enum DualShockDpad {
  42307. /** Up */
  42308. Up = 0,
  42309. /** Down */
  42310. Down = 1,
  42311. /** Left */
  42312. Left = 2,
  42313. /** Right */
  42314. Right = 3
  42315. }
  42316. /**
  42317. * Defines a DualShock gamepad
  42318. */
  42319. export class DualShockPad extends Gamepad {
  42320. private _leftTrigger;
  42321. private _rightTrigger;
  42322. private _onlefttriggerchanged;
  42323. private _onrighttriggerchanged;
  42324. private _onbuttondown;
  42325. private _onbuttonup;
  42326. private _ondpaddown;
  42327. private _ondpadup;
  42328. /** Observable raised when a button is pressed */
  42329. onButtonDownObservable: Observable<DualShockButton>;
  42330. /** Observable raised when a button is released */
  42331. onButtonUpObservable: Observable<DualShockButton>;
  42332. /** Observable raised when a pad is pressed */
  42333. onPadDownObservable: Observable<DualShockDpad>;
  42334. /** Observable raised when a pad is released */
  42335. onPadUpObservable: Observable<DualShockDpad>;
  42336. private _buttonCross;
  42337. private _buttonCircle;
  42338. private _buttonSquare;
  42339. private _buttonTriangle;
  42340. private _buttonShare;
  42341. private _buttonOptions;
  42342. private _buttonL1;
  42343. private _buttonR1;
  42344. private _buttonLeftStick;
  42345. private _buttonRightStick;
  42346. private _dPadUp;
  42347. private _dPadDown;
  42348. private _dPadLeft;
  42349. private _dPadRight;
  42350. /**
  42351. * Creates a new DualShock gamepad object
  42352. * @param id defines the id of this gamepad
  42353. * @param index defines its index
  42354. * @param gamepad defines the internal HTML gamepad object
  42355. */
  42356. constructor(id: string, index: number, gamepad: any);
  42357. /**
  42358. * Defines the callback to call when left trigger is pressed
  42359. * @param callback defines the callback to use
  42360. */
  42361. onlefttriggerchanged(callback: (value: number) => void): void;
  42362. /**
  42363. * Defines the callback to call when right trigger is pressed
  42364. * @param callback defines the callback to use
  42365. */
  42366. onrighttriggerchanged(callback: (value: number) => void): void;
  42367. /**
  42368. * Gets the left trigger value
  42369. */
  42370. get leftTrigger(): number;
  42371. /**
  42372. * Sets the left trigger value
  42373. */
  42374. set leftTrigger(newValue: number);
  42375. /**
  42376. * Gets the right trigger value
  42377. */
  42378. get rightTrigger(): number;
  42379. /**
  42380. * Sets the right trigger value
  42381. */
  42382. set rightTrigger(newValue: number);
  42383. /**
  42384. * Defines the callback to call when a button is pressed
  42385. * @param callback defines the callback to use
  42386. */
  42387. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42388. /**
  42389. * Defines the callback to call when a button is released
  42390. * @param callback defines the callback to use
  42391. */
  42392. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42393. /**
  42394. * Defines the callback to call when a pad is pressed
  42395. * @param callback defines the callback to use
  42396. */
  42397. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42398. /**
  42399. * Defines the callback to call when a pad is released
  42400. * @param callback defines the callback to use
  42401. */
  42402. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42403. private _setButtonValue;
  42404. private _setDPadValue;
  42405. /**
  42406. * Gets the value of the `Cross` button
  42407. */
  42408. get buttonCross(): number;
  42409. /**
  42410. * Sets the value of the `Cross` button
  42411. */
  42412. set buttonCross(value: number);
  42413. /**
  42414. * Gets the value of the `Circle` button
  42415. */
  42416. get buttonCircle(): number;
  42417. /**
  42418. * Sets the value of the `Circle` button
  42419. */
  42420. set buttonCircle(value: number);
  42421. /**
  42422. * Gets the value of the `Square` button
  42423. */
  42424. get buttonSquare(): number;
  42425. /**
  42426. * Sets the value of the `Square` button
  42427. */
  42428. set buttonSquare(value: number);
  42429. /**
  42430. * Gets the value of the `Triangle` button
  42431. */
  42432. get buttonTriangle(): number;
  42433. /**
  42434. * Sets the value of the `Triangle` button
  42435. */
  42436. set buttonTriangle(value: number);
  42437. /**
  42438. * Gets the value of the `Options` button
  42439. */
  42440. get buttonOptions(): number;
  42441. /**
  42442. * Sets the value of the `Options` button
  42443. */
  42444. set buttonOptions(value: number);
  42445. /**
  42446. * Gets the value of the `Share` button
  42447. */
  42448. get buttonShare(): number;
  42449. /**
  42450. * Sets the value of the `Share` button
  42451. */
  42452. set buttonShare(value: number);
  42453. /**
  42454. * Gets the value of the `L1` button
  42455. */
  42456. get buttonL1(): number;
  42457. /**
  42458. * Sets the value of the `L1` button
  42459. */
  42460. set buttonL1(value: number);
  42461. /**
  42462. * Gets the value of the `R1` button
  42463. */
  42464. get buttonR1(): number;
  42465. /**
  42466. * Sets the value of the `R1` button
  42467. */
  42468. set buttonR1(value: number);
  42469. /**
  42470. * Gets the value of the Left joystick
  42471. */
  42472. get buttonLeftStick(): number;
  42473. /**
  42474. * Sets the value of the Left joystick
  42475. */
  42476. set buttonLeftStick(value: number);
  42477. /**
  42478. * Gets the value of the Right joystick
  42479. */
  42480. get buttonRightStick(): number;
  42481. /**
  42482. * Sets the value of the Right joystick
  42483. */
  42484. set buttonRightStick(value: number);
  42485. /**
  42486. * Gets the value of D-pad up
  42487. */
  42488. get dPadUp(): number;
  42489. /**
  42490. * Sets the value of D-pad up
  42491. */
  42492. set dPadUp(value: number);
  42493. /**
  42494. * Gets the value of D-pad down
  42495. */
  42496. get dPadDown(): number;
  42497. /**
  42498. * Sets the value of D-pad down
  42499. */
  42500. set dPadDown(value: number);
  42501. /**
  42502. * Gets the value of D-pad left
  42503. */
  42504. get dPadLeft(): number;
  42505. /**
  42506. * Sets the value of D-pad left
  42507. */
  42508. set dPadLeft(value: number);
  42509. /**
  42510. * Gets the value of D-pad right
  42511. */
  42512. get dPadRight(): number;
  42513. /**
  42514. * Sets the value of D-pad right
  42515. */
  42516. set dPadRight(value: number);
  42517. /**
  42518. * Force the gamepad to synchronize with device values
  42519. */
  42520. update(): void;
  42521. /**
  42522. * Disposes the gamepad
  42523. */
  42524. dispose(): void;
  42525. }
  42526. }
  42527. declare module "babylonjs/Gamepads/gamepadManager" {
  42528. import { Observable } from "babylonjs/Misc/observable";
  42529. import { Nullable } from "babylonjs/types";
  42530. import { Scene } from "babylonjs/scene";
  42531. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42532. /**
  42533. * Manager for handling gamepads
  42534. */
  42535. export class GamepadManager {
  42536. private _scene?;
  42537. private _babylonGamepads;
  42538. private _oneGamepadConnected;
  42539. /** @hidden */
  42540. _isMonitoring: boolean;
  42541. private _gamepadEventSupported;
  42542. private _gamepadSupport?;
  42543. /**
  42544. * observable to be triggered when the gamepad controller has been connected
  42545. */
  42546. onGamepadConnectedObservable: Observable<Gamepad>;
  42547. /**
  42548. * observable to be triggered when the gamepad controller has been disconnected
  42549. */
  42550. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42551. private _onGamepadConnectedEvent;
  42552. private _onGamepadDisconnectedEvent;
  42553. /**
  42554. * Initializes the gamepad manager
  42555. * @param _scene BabylonJS scene
  42556. */
  42557. constructor(_scene?: Scene | undefined);
  42558. /**
  42559. * The gamepads in the game pad manager
  42560. */
  42561. get gamepads(): Gamepad[];
  42562. /**
  42563. * Get the gamepad controllers based on type
  42564. * @param type The type of gamepad controller
  42565. * @returns Nullable gamepad
  42566. */
  42567. getGamepadByType(type?: number): Nullable<Gamepad>;
  42568. /**
  42569. * Disposes the gamepad manager
  42570. */
  42571. dispose(): void;
  42572. private _addNewGamepad;
  42573. private _startMonitoringGamepads;
  42574. private _stopMonitoringGamepads;
  42575. /** @hidden */
  42576. _checkGamepadsStatus(): void;
  42577. private _updateGamepadObjects;
  42578. }
  42579. }
  42580. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42581. import { Nullable } from "babylonjs/types";
  42582. import { Scene } from "babylonjs/scene";
  42583. import { ISceneComponent } from "babylonjs/sceneComponent";
  42584. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42585. module "babylonjs/scene" {
  42586. interface Scene {
  42587. /** @hidden */
  42588. _gamepadManager: Nullable<GamepadManager>;
  42589. /**
  42590. * Gets the gamepad manager associated with the scene
  42591. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42592. */
  42593. gamepadManager: GamepadManager;
  42594. }
  42595. }
  42596. module "babylonjs/Cameras/freeCameraInputsManager" {
  42597. /**
  42598. * Interface representing a free camera inputs manager
  42599. */
  42600. interface FreeCameraInputsManager {
  42601. /**
  42602. * Adds gamepad input support to the FreeCameraInputsManager.
  42603. * @returns the FreeCameraInputsManager
  42604. */
  42605. addGamepad(): FreeCameraInputsManager;
  42606. }
  42607. }
  42608. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42609. /**
  42610. * Interface representing an arc rotate camera inputs manager
  42611. */
  42612. interface ArcRotateCameraInputsManager {
  42613. /**
  42614. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42615. * @returns the camera inputs manager
  42616. */
  42617. addGamepad(): ArcRotateCameraInputsManager;
  42618. }
  42619. }
  42620. /**
  42621. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42622. */
  42623. export class GamepadSystemSceneComponent implements ISceneComponent {
  42624. /**
  42625. * The component name helpfull to identify the component in the list of scene components.
  42626. */
  42627. readonly name: string;
  42628. /**
  42629. * The scene the component belongs to.
  42630. */
  42631. scene: Scene;
  42632. /**
  42633. * Creates a new instance of the component for the given scene
  42634. * @param scene Defines the scene to register the component in
  42635. */
  42636. constructor(scene: Scene);
  42637. /**
  42638. * Registers the component in a given scene
  42639. */
  42640. register(): void;
  42641. /**
  42642. * Rebuilds the elements related to this component in case of
  42643. * context lost for instance.
  42644. */
  42645. rebuild(): void;
  42646. /**
  42647. * Disposes the component and the associated ressources
  42648. */
  42649. dispose(): void;
  42650. private _beforeCameraUpdate;
  42651. }
  42652. }
  42653. declare module "babylonjs/Cameras/universalCamera" {
  42654. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42655. import { Scene } from "babylonjs/scene";
  42656. import { Vector3 } from "babylonjs/Maths/math.vector";
  42657. import "babylonjs/Gamepads/gamepadSceneComponent";
  42658. /**
  42659. * 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,
  42660. * which still works and will still be found in many Playgrounds.
  42661. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42662. */
  42663. export class UniversalCamera extends TouchCamera {
  42664. /**
  42665. * Defines the gamepad rotation sensiblity.
  42666. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42667. */
  42668. get gamepadAngularSensibility(): number;
  42669. set gamepadAngularSensibility(value: number);
  42670. /**
  42671. * Defines the gamepad move sensiblity.
  42672. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42673. */
  42674. get gamepadMoveSensibility(): number;
  42675. set gamepadMoveSensibility(value: number);
  42676. /**
  42677. * 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,
  42678. * which still works and will still be found in many Playgrounds.
  42679. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42680. * @param name Define the name of the camera in the scene
  42681. * @param position Define the start position of the camera in the scene
  42682. * @param scene Define the scene the camera belongs to
  42683. */
  42684. constructor(name: string, position: Vector3, scene: Scene);
  42685. /**
  42686. * Gets the current object class name.
  42687. * @return the class name
  42688. */
  42689. getClassName(): string;
  42690. }
  42691. }
  42692. declare module "babylonjs/Cameras/gamepadCamera" {
  42693. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42694. import { Scene } from "babylonjs/scene";
  42695. import { Vector3 } from "babylonjs/Maths/math.vector";
  42696. /**
  42697. * This represents a FPS type of camera. This is only here for back compat purpose.
  42698. * Please use the UniversalCamera instead as both are identical.
  42699. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42700. */
  42701. export class GamepadCamera extends UniversalCamera {
  42702. /**
  42703. * Instantiates a new Gamepad Camera
  42704. * This represents a FPS type of camera. This is only here for back compat purpose.
  42705. * Please use the UniversalCamera instead as both are identical.
  42706. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42707. * @param name Define the name of the camera in the scene
  42708. * @param position Define the start position of the camera in the scene
  42709. * @param scene Define the scene the camera belongs to
  42710. */
  42711. constructor(name: string, position: Vector3, scene: Scene);
  42712. /**
  42713. * Gets the current object class name.
  42714. * @return the class name
  42715. */
  42716. getClassName(): string;
  42717. }
  42718. }
  42719. declare module "babylonjs/Shaders/pass.fragment" {
  42720. /** @hidden */
  42721. export var passPixelShader: {
  42722. name: string;
  42723. shader: string;
  42724. };
  42725. }
  42726. declare module "babylonjs/Shaders/passCube.fragment" {
  42727. /** @hidden */
  42728. export var passCubePixelShader: {
  42729. name: string;
  42730. shader: string;
  42731. };
  42732. }
  42733. declare module "babylonjs/PostProcesses/passPostProcess" {
  42734. import { Nullable } from "babylonjs/types";
  42735. import { Camera } from "babylonjs/Cameras/camera";
  42736. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42737. import { Engine } from "babylonjs/Engines/engine";
  42738. import "babylonjs/Shaders/pass.fragment";
  42739. import "babylonjs/Shaders/passCube.fragment";
  42740. /**
  42741. * PassPostProcess which produces an output the same as it's input
  42742. */
  42743. export class PassPostProcess extends PostProcess {
  42744. /**
  42745. * Creates the PassPostProcess
  42746. * @param name The name of the effect.
  42747. * @param options The required width/height ratio to downsize to before computing the render pass.
  42748. * @param camera The camera to apply the render pass to.
  42749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42750. * @param engine The engine which the post process will be applied. (default: current engine)
  42751. * @param reusable If the post process can be reused on the same frame. (default: false)
  42752. * @param textureType The type of texture to be used when performing the post processing.
  42753. * @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)
  42754. */
  42755. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42756. }
  42757. /**
  42758. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42759. */
  42760. export class PassCubePostProcess extends PostProcess {
  42761. private _face;
  42762. /**
  42763. * Gets or sets the cube face to display.
  42764. * * 0 is +X
  42765. * * 1 is -X
  42766. * * 2 is +Y
  42767. * * 3 is -Y
  42768. * * 4 is +Z
  42769. * * 5 is -Z
  42770. */
  42771. get face(): number;
  42772. set face(value: number);
  42773. /**
  42774. * Creates the PassCubePostProcess
  42775. * @param name The name of the effect.
  42776. * @param options The required width/height ratio to downsize to before computing the render pass.
  42777. * @param camera The camera to apply the render pass to.
  42778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42779. * @param engine The engine which the post process will be applied. (default: current engine)
  42780. * @param reusable If the post process can be reused on the same frame. (default: false)
  42781. * @param textureType The type of texture to be used when performing the post processing.
  42782. * @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)
  42783. */
  42784. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42785. }
  42786. }
  42787. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42788. /** @hidden */
  42789. export var anaglyphPixelShader: {
  42790. name: string;
  42791. shader: string;
  42792. };
  42793. }
  42794. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42795. import { Engine } from "babylonjs/Engines/engine";
  42796. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42797. import { Camera } from "babylonjs/Cameras/camera";
  42798. import "babylonjs/Shaders/anaglyph.fragment";
  42799. /**
  42800. * Postprocess used to generate anaglyphic rendering
  42801. */
  42802. export class AnaglyphPostProcess extends PostProcess {
  42803. private _passedProcess;
  42804. /**
  42805. * Creates a new AnaglyphPostProcess
  42806. * @param name defines postprocess name
  42807. * @param options defines creation options or target ratio scale
  42808. * @param rigCameras defines cameras using this postprocess
  42809. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42810. * @param engine defines hosting engine
  42811. * @param reusable defines if the postprocess will be reused multiple times per frame
  42812. */
  42813. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42814. }
  42815. }
  42816. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42817. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42818. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42819. import { Scene } from "babylonjs/scene";
  42820. import { Vector3 } from "babylonjs/Maths/math.vector";
  42821. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42822. /**
  42823. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42824. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42825. */
  42826. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42827. /**
  42828. * Creates a new AnaglyphArcRotateCamera
  42829. * @param name defines camera name
  42830. * @param alpha defines alpha angle (in radians)
  42831. * @param beta defines beta angle (in radians)
  42832. * @param radius defines radius
  42833. * @param target defines camera target
  42834. * @param interaxialDistance defines distance between each color axis
  42835. * @param scene defines the hosting scene
  42836. */
  42837. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42838. /**
  42839. * Gets camera class name
  42840. * @returns AnaglyphArcRotateCamera
  42841. */
  42842. getClassName(): string;
  42843. }
  42844. }
  42845. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42846. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42847. import { Scene } from "babylonjs/scene";
  42848. import { Vector3 } from "babylonjs/Maths/math.vector";
  42849. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42850. /**
  42851. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42852. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42853. */
  42854. export class AnaglyphFreeCamera extends FreeCamera {
  42855. /**
  42856. * Creates a new AnaglyphFreeCamera
  42857. * @param name defines camera name
  42858. * @param position defines initial position
  42859. * @param interaxialDistance defines distance between each color axis
  42860. * @param scene defines the hosting scene
  42861. */
  42862. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42863. /**
  42864. * Gets camera class name
  42865. * @returns AnaglyphFreeCamera
  42866. */
  42867. getClassName(): string;
  42868. }
  42869. }
  42870. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42871. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42872. import { Scene } from "babylonjs/scene";
  42873. import { Vector3 } from "babylonjs/Maths/math.vector";
  42874. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42875. /**
  42876. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42877. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42878. */
  42879. export class AnaglyphGamepadCamera extends GamepadCamera {
  42880. /**
  42881. * Creates a new AnaglyphGamepadCamera
  42882. * @param name defines camera name
  42883. * @param position defines initial position
  42884. * @param interaxialDistance defines distance between each color axis
  42885. * @param scene defines the hosting scene
  42886. */
  42887. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42888. /**
  42889. * Gets camera class name
  42890. * @returns AnaglyphGamepadCamera
  42891. */
  42892. getClassName(): string;
  42893. }
  42894. }
  42895. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42896. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42897. import { Scene } from "babylonjs/scene";
  42898. import { Vector3 } from "babylonjs/Maths/math.vector";
  42899. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42900. /**
  42901. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42902. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42903. */
  42904. export class AnaglyphUniversalCamera extends UniversalCamera {
  42905. /**
  42906. * Creates a new AnaglyphUniversalCamera
  42907. * @param name defines camera name
  42908. * @param position defines initial position
  42909. * @param interaxialDistance defines distance between each color axis
  42910. * @param scene defines the hosting scene
  42911. */
  42912. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42913. /**
  42914. * Gets camera class name
  42915. * @returns AnaglyphUniversalCamera
  42916. */
  42917. getClassName(): string;
  42918. }
  42919. }
  42920. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42921. /** @hidden */
  42922. export var stereoscopicInterlacePixelShader: {
  42923. name: string;
  42924. shader: string;
  42925. };
  42926. }
  42927. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42928. import { Camera } from "babylonjs/Cameras/camera";
  42929. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42930. import { Engine } from "babylonjs/Engines/engine";
  42931. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42932. /**
  42933. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42934. */
  42935. export class StereoscopicInterlacePostProcess extends PostProcess {
  42936. private _stepSize;
  42937. private _passedProcess;
  42938. /**
  42939. * Initializes a StereoscopicInterlacePostProcess
  42940. * @param name The name of the effect.
  42941. * @param rigCameras The rig cameras to be appled to the post process
  42942. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42944. * @param engine The engine which the post process will be applied. (default: current engine)
  42945. * @param reusable If the post process can be reused on the same frame. (default: false)
  42946. */
  42947. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42948. }
  42949. }
  42950. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42951. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42952. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42953. import { Scene } from "babylonjs/scene";
  42954. import { Vector3 } from "babylonjs/Maths/math.vector";
  42955. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42956. /**
  42957. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42958. * @see http://doc.babylonjs.com/features/cameras
  42959. */
  42960. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42961. /**
  42962. * Creates a new StereoscopicArcRotateCamera
  42963. * @param name defines camera name
  42964. * @param alpha defines alpha angle (in radians)
  42965. * @param beta defines beta angle (in radians)
  42966. * @param radius defines radius
  42967. * @param target defines camera target
  42968. * @param interaxialDistance defines distance between each color axis
  42969. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42970. * @param scene defines the hosting scene
  42971. */
  42972. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42973. /**
  42974. * Gets camera class name
  42975. * @returns StereoscopicArcRotateCamera
  42976. */
  42977. getClassName(): string;
  42978. }
  42979. }
  42980. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42981. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42982. import { Scene } from "babylonjs/scene";
  42983. import { Vector3 } from "babylonjs/Maths/math.vector";
  42984. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42985. /**
  42986. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42987. * @see http://doc.babylonjs.com/features/cameras
  42988. */
  42989. export class StereoscopicFreeCamera extends FreeCamera {
  42990. /**
  42991. * Creates a new StereoscopicFreeCamera
  42992. * @param name defines camera name
  42993. * @param position defines initial position
  42994. * @param interaxialDistance defines distance between each color axis
  42995. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42996. * @param scene defines the hosting scene
  42997. */
  42998. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42999. /**
  43000. * Gets camera class name
  43001. * @returns StereoscopicFreeCamera
  43002. */
  43003. getClassName(): string;
  43004. }
  43005. }
  43006. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43007. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43008. import { Scene } from "babylonjs/scene";
  43009. import { Vector3 } from "babylonjs/Maths/math.vector";
  43010. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43011. /**
  43012. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43013. * @see http://doc.babylonjs.com/features/cameras
  43014. */
  43015. export class StereoscopicGamepadCamera extends GamepadCamera {
  43016. /**
  43017. * Creates a new StereoscopicGamepadCamera
  43018. * @param name defines camera name
  43019. * @param position defines initial position
  43020. * @param interaxialDistance defines distance between each color axis
  43021. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43022. * @param scene defines the hosting scene
  43023. */
  43024. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43025. /**
  43026. * Gets camera class name
  43027. * @returns StereoscopicGamepadCamera
  43028. */
  43029. getClassName(): string;
  43030. }
  43031. }
  43032. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43033. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43034. import { Scene } from "babylonjs/scene";
  43035. import { Vector3 } from "babylonjs/Maths/math.vector";
  43036. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43037. /**
  43038. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43039. * @see http://doc.babylonjs.com/features/cameras
  43040. */
  43041. export class StereoscopicUniversalCamera extends UniversalCamera {
  43042. /**
  43043. * Creates a new StereoscopicUniversalCamera
  43044. * @param name defines camera name
  43045. * @param position defines initial position
  43046. * @param interaxialDistance defines distance between each color axis
  43047. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43048. * @param scene defines the hosting scene
  43049. */
  43050. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43051. /**
  43052. * Gets camera class name
  43053. * @returns StereoscopicUniversalCamera
  43054. */
  43055. getClassName(): string;
  43056. }
  43057. }
  43058. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43059. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43060. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43061. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43062. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43063. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43064. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43065. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43066. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43067. }
  43068. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43069. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43070. import { Scene } from "babylonjs/scene";
  43071. import { Vector3 } from "babylonjs/Maths/math.vector";
  43072. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43073. /**
  43074. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43075. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43076. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43077. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43078. */
  43079. export class VirtualJoysticksCamera extends FreeCamera {
  43080. /**
  43081. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43082. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43083. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43084. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43085. * @param name Define the name of the camera in the scene
  43086. * @param position Define the start position of the camera in the scene
  43087. * @param scene Define the scene the camera belongs to
  43088. */
  43089. constructor(name: string, position: Vector3, scene: Scene);
  43090. /**
  43091. * Gets the current object class name.
  43092. * @return the class name
  43093. */
  43094. getClassName(): string;
  43095. }
  43096. }
  43097. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43098. import { Matrix } from "babylonjs/Maths/math.vector";
  43099. /**
  43100. * This represents all the required metrics to create a VR camera.
  43101. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43102. */
  43103. export class VRCameraMetrics {
  43104. /**
  43105. * Define the horizontal resolution off the screen.
  43106. */
  43107. hResolution: number;
  43108. /**
  43109. * Define the vertical resolution off the screen.
  43110. */
  43111. vResolution: number;
  43112. /**
  43113. * Define the horizontal screen size.
  43114. */
  43115. hScreenSize: number;
  43116. /**
  43117. * Define the vertical screen size.
  43118. */
  43119. vScreenSize: number;
  43120. /**
  43121. * Define the vertical screen center position.
  43122. */
  43123. vScreenCenter: number;
  43124. /**
  43125. * Define the distance of the eyes to the screen.
  43126. */
  43127. eyeToScreenDistance: number;
  43128. /**
  43129. * Define the distance between both lenses
  43130. */
  43131. lensSeparationDistance: number;
  43132. /**
  43133. * Define the distance between both viewer's eyes.
  43134. */
  43135. interpupillaryDistance: number;
  43136. /**
  43137. * Define the distortion factor of the VR postprocess.
  43138. * Please, touch with care.
  43139. */
  43140. distortionK: number[];
  43141. /**
  43142. * Define the chromatic aberration correction factors for the VR post process.
  43143. */
  43144. chromaAbCorrection: number[];
  43145. /**
  43146. * Define the scale factor of the post process.
  43147. * The smaller the better but the slower.
  43148. */
  43149. postProcessScaleFactor: number;
  43150. /**
  43151. * Define an offset for the lens center.
  43152. */
  43153. lensCenterOffset: number;
  43154. /**
  43155. * Define if the current vr camera should compensate the distortion of the lense or not.
  43156. */
  43157. compensateDistortion: boolean;
  43158. /**
  43159. * Defines if multiview should be enabled when rendering (Default: false)
  43160. */
  43161. multiviewEnabled: boolean;
  43162. /**
  43163. * Gets the rendering aspect ratio based on the provided resolutions.
  43164. */
  43165. get aspectRatio(): number;
  43166. /**
  43167. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43168. */
  43169. get aspectRatioFov(): number;
  43170. /**
  43171. * @hidden
  43172. */
  43173. get leftHMatrix(): Matrix;
  43174. /**
  43175. * @hidden
  43176. */
  43177. get rightHMatrix(): Matrix;
  43178. /**
  43179. * @hidden
  43180. */
  43181. get leftPreViewMatrix(): Matrix;
  43182. /**
  43183. * @hidden
  43184. */
  43185. get rightPreViewMatrix(): Matrix;
  43186. /**
  43187. * Get the default VRMetrics based on the most generic setup.
  43188. * @returns the default vr metrics
  43189. */
  43190. static GetDefault(): VRCameraMetrics;
  43191. }
  43192. }
  43193. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43194. /** @hidden */
  43195. export var vrDistortionCorrectionPixelShader: {
  43196. name: string;
  43197. shader: string;
  43198. };
  43199. }
  43200. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43201. import { Camera } from "babylonjs/Cameras/camera";
  43202. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43203. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43204. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43205. /**
  43206. * VRDistortionCorrectionPostProcess used for mobile VR
  43207. */
  43208. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43209. private _isRightEye;
  43210. private _distortionFactors;
  43211. private _postProcessScaleFactor;
  43212. private _lensCenterOffset;
  43213. private _scaleIn;
  43214. private _scaleFactor;
  43215. private _lensCenter;
  43216. /**
  43217. * Initializes the VRDistortionCorrectionPostProcess
  43218. * @param name The name of the effect.
  43219. * @param camera The camera to apply the render pass to.
  43220. * @param isRightEye If this is for the right eye distortion
  43221. * @param vrMetrics All the required metrics for the VR camera
  43222. */
  43223. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43224. }
  43225. }
  43226. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43227. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43228. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43229. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43230. import { Scene } from "babylonjs/scene";
  43231. import { Vector3 } from "babylonjs/Maths/math.vector";
  43232. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43233. import "babylonjs/Cameras/RigModes/vrRigMode";
  43234. /**
  43235. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43236. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43237. */
  43238. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43239. /**
  43240. * Creates a new VRDeviceOrientationArcRotateCamera
  43241. * @param name defines camera name
  43242. * @param alpha defines the camera rotation along the logitudinal axis
  43243. * @param beta defines the camera rotation along the latitudinal axis
  43244. * @param radius defines the camera distance from its target
  43245. * @param target defines the camera target
  43246. * @param scene defines the scene the camera belongs to
  43247. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43248. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43249. */
  43250. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43251. /**
  43252. * Gets camera class name
  43253. * @returns VRDeviceOrientationArcRotateCamera
  43254. */
  43255. getClassName(): string;
  43256. }
  43257. }
  43258. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43259. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43260. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43261. import { Scene } from "babylonjs/scene";
  43262. import { Vector3 } from "babylonjs/Maths/math.vector";
  43263. import "babylonjs/Cameras/RigModes/vrRigMode";
  43264. /**
  43265. * Camera used to simulate VR rendering (based on FreeCamera)
  43266. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43267. */
  43268. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43269. /**
  43270. * Creates a new VRDeviceOrientationFreeCamera
  43271. * @param name defines camera name
  43272. * @param position defines the start position of the camera
  43273. * @param scene defines the scene the camera belongs to
  43274. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43275. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43276. */
  43277. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43278. /**
  43279. * Gets camera class name
  43280. * @returns VRDeviceOrientationFreeCamera
  43281. */
  43282. getClassName(): string;
  43283. }
  43284. }
  43285. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43286. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43287. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43288. import { Scene } from "babylonjs/scene";
  43289. import { Vector3 } from "babylonjs/Maths/math.vector";
  43290. import "babylonjs/Gamepads/gamepadSceneComponent";
  43291. /**
  43292. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43293. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43294. */
  43295. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43296. /**
  43297. * Creates a new VRDeviceOrientationGamepadCamera
  43298. * @param name defines camera name
  43299. * @param position defines the start position of the camera
  43300. * @param scene defines the scene the camera belongs to
  43301. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43302. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43303. */
  43304. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43305. /**
  43306. * Gets camera class name
  43307. * @returns VRDeviceOrientationGamepadCamera
  43308. */
  43309. getClassName(): string;
  43310. }
  43311. }
  43312. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43313. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43314. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43315. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43316. /** @hidden */
  43317. export var imageProcessingPixelShader: {
  43318. name: string;
  43319. shader: string;
  43320. };
  43321. }
  43322. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43323. import { Nullable } from "babylonjs/types";
  43324. import { Color4 } from "babylonjs/Maths/math.color";
  43325. import { Camera } from "babylonjs/Cameras/camera";
  43326. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43327. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43328. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43329. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43330. import { Engine } from "babylonjs/Engines/engine";
  43331. import "babylonjs/Shaders/imageProcessing.fragment";
  43332. import "babylonjs/Shaders/postprocess.vertex";
  43333. /**
  43334. * ImageProcessingPostProcess
  43335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43336. */
  43337. export class ImageProcessingPostProcess extends PostProcess {
  43338. /**
  43339. * Default configuration related to image processing available in the PBR Material.
  43340. */
  43341. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43342. /**
  43343. * Gets the image processing configuration used either in this material.
  43344. */
  43345. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43346. /**
  43347. * Sets the Default image processing configuration used either in the this material.
  43348. *
  43349. * If sets to null, the scene one is in use.
  43350. */
  43351. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43352. /**
  43353. * Keep track of the image processing observer to allow dispose and replace.
  43354. */
  43355. private _imageProcessingObserver;
  43356. /**
  43357. * Attaches a new image processing configuration to the PBR Material.
  43358. * @param configuration
  43359. */
  43360. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43361. /**
  43362. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43363. */
  43364. get colorCurves(): Nullable<ColorCurves>;
  43365. /**
  43366. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43367. */
  43368. set colorCurves(value: Nullable<ColorCurves>);
  43369. /**
  43370. * Gets wether the color curves effect is enabled.
  43371. */
  43372. get colorCurvesEnabled(): boolean;
  43373. /**
  43374. * Sets wether the color curves effect is enabled.
  43375. */
  43376. set colorCurvesEnabled(value: boolean);
  43377. /**
  43378. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43379. */
  43380. get colorGradingTexture(): Nullable<BaseTexture>;
  43381. /**
  43382. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43383. */
  43384. set colorGradingTexture(value: Nullable<BaseTexture>);
  43385. /**
  43386. * Gets wether the color grading effect is enabled.
  43387. */
  43388. get colorGradingEnabled(): boolean;
  43389. /**
  43390. * Gets wether the color grading effect is enabled.
  43391. */
  43392. set colorGradingEnabled(value: boolean);
  43393. /**
  43394. * Gets exposure used in the effect.
  43395. */
  43396. get exposure(): number;
  43397. /**
  43398. * Sets exposure used in the effect.
  43399. */
  43400. set exposure(value: number);
  43401. /**
  43402. * Gets wether tonemapping is enabled or not.
  43403. */
  43404. get toneMappingEnabled(): boolean;
  43405. /**
  43406. * Sets wether tonemapping is enabled or not
  43407. */
  43408. set toneMappingEnabled(value: boolean);
  43409. /**
  43410. * Gets the type of tone mapping effect.
  43411. */
  43412. get toneMappingType(): number;
  43413. /**
  43414. * Sets the type of tone mapping effect.
  43415. */
  43416. set toneMappingType(value: number);
  43417. /**
  43418. * Gets contrast used in the effect.
  43419. */
  43420. get contrast(): number;
  43421. /**
  43422. * Sets contrast used in the effect.
  43423. */
  43424. set contrast(value: number);
  43425. /**
  43426. * Gets Vignette stretch size.
  43427. */
  43428. get vignetteStretch(): number;
  43429. /**
  43430. * Sets Vignette stretch size.
  43431. */
  43432. set vignetteStretch(value: number);
  43433. /**
  43434. * Gets Vignette centre X Offset.
  43435. */
  43436. get vignetteCentreX(): number;
  43437. /**
  43438. * Sets Vignette centre X Offset.
  43439. */
  43440. set vignetteCentreX(value: number);
  43441. /**
  43442. * Gets Vignette centre Y Offset.
  43443. */
  43444. get vignetteCentreY(): number;
  43445. /**
  43446. * Sets Vignette centre Y Offset.
  43447. */
  43448. set vignetteCentreY(value: number);
  43449. /**
  43450. * Gets Vignette weight or intensity of the vignette effect.
  43451. */
  43452. get vignetteWeight(): number;
  43453. /**
  43454. * Sets Vignette weight or intensity of the vignette effect.
  43455. */
  43456. set vignetteWeight(value: number);
  43457. /**
  43458. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43459. * if vignetteEnabled is set to true.
  43460. */
  43461. get vignetteColor(): Color4;
  43462. /**
  43463. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43464. * if vignetteEnabled is set to true.
  43465. */
  43466. set vignetteColor(value: Color4);
  43467. /**
  43468. * Gets Camera field of view used by the Vignette effect.
  43469. */
  43470. get vignetteCameraFov(): number;
  43471. /**
  43472. * Sets Camera field of view used by the Vignette effect.
  43473. */
  43474. set vignetteCameraFov(value: number);
  43475. /**
  43476. * Gets the vignette blend mode allowing different kind of effect.
  43477. */
  43478. get vignetteBlendMode(): number;
  43479. /**
  43480. * Sets the vignette blend mode allowing different kind of effect.
  43481. */
  43482. set vignetteBlendMode(value: number);
  43483. /**
  43484. * Gets wether the vignette effect is enabled.
  43485. */
  43486. get vignetteEnabled(): boolean;
  43487. /**
  43488. * Sets wether the vignette effect is enabled.
  43489. */
  43490. set vignetteEnabled(value: boolean);
  43491. private _fromLinearSpace;
  43492. /**
  43493. * Gets wether the input of the processing is in Gamma or Linear Space.
  43494. */
  43495. get fromLinearSpace(): boolean;
  43496. /**
  43497. * Sets wether the input of the processing is in Gamma or Linear Space.
  43498. */
  43499. set fromLinearSpace(value: boolean);
  43500. /**
  43501. * Defines cache preventing GC.
  43502. */
  43503. private _defines;
  43504. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43505. /**
  43506. * "ImageProcessingPostProcess"
  43507. * @returns "ImageProcessingPostProcess"
  43508. */
  43509. getClassName(): string;
  43510. protected _updateParameters(): void;
  43511. dispose(camera?: Camera): void;
  43512. }
  43513. }
  43514. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43515. import { Scene } from "babylonjs/scene";
  43516. import { Color3 } from "babylonjs/Maths/math.color";
  43517. import { Mesh } from "babylonjs/Meshes/mesh";
  43518. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43519. import { Nullable } from "babylonjs/types";
  43520. /**
  43521. * Class containing static functions to help procedurally build meshes
  43522. */
  43523. export class GroundBuilder {
  43524. /**
  43525. * Creates a ground mesh
  43526. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43527. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43529. * @param name defines the name of the mesh
  43530. * @param options defines the options used to create the mesh
  43531. * @param scene defines the hosting scene
  43532. * @returns the ground mesh
  43533. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43534. */
  43535. static CreateGround(name: string, options: {
  43536. width?: number;
  43537. height?: number;
  43538. subdivisions?: number;
  43539. subdivisionsX?: number;
  43540. subdivisionsY?: number;
  43541. updatable?: boolean;
  43542. }, scene: any): Mesh;
  43543. /**
  43544. * Creates a tiled ground mesh
  43545. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43546. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43547. * * 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
  43548. * * 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
  43549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43550. * @param name defines the name of the mesh
  43551. * @param options defines the options used to create the mesh
  43552. * @param scene defines the hosting scene
  43553. * @returns the tiled ground mesh
  43554. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43555. */
  43556. static CreateTiledGround(name: string, options: {
  43557. xmin: number;
  43558. zmin: number;
  43559. xmax: number;
  43560. zmax: number;
  43561. subdivisions?: {
  43562. w: number;
  43563. h: number;
  43564. };
  43565. precision?: {
  43566. w: number;
  43567. h: number;
  43568. };
  43569. updatable?: boolean;
  43570. }, scene?: Nullable<Scene>): Mesh;
  43571. /**
  43572. * Creates a ground mesh from a height map
  43573. * * The parameter `url` sets the URL of the height map image resource.
  43574. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43575. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43576. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43577. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43578. * * 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.
  43579. * * 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).
  43580. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43582. * @param name defines the name of the mesh
  43583. * @param url defines the url to the height map
  43584. * @param options defines the options used to create the mesh
  43585. * @param scene defines the hosting scene
  43586. * @returns the ground mesh
  43587. * @see https://doc.babylonjs.com/babylon101/height_map
  43588. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43589. */
  43590. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43591. width?: number;
  43592. height?: number;
  43593. subdivisions?: number;
  43594. minHeight?: number;
  43595. maxHeight?: number;
  43596. colorFilter?: Color3;
  43597. alphaFilter?: number;
  43598. updatable?: boolean;
  43599. onReady?: (mesh: GroundMesh) => void;
  43600. }, scene?: Nullable<Scene>): GroundMesh;
  43601. }
  43602. }
  43603. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43604. import { Vector4 } from "babylonjs/Maths/math.vector";
  43605. import { Mesh } from "babylonjs/Meshes/mesh";
  43606. /**
  43607. * Class containing static functions to help procedurally build meshes
  43608. */
  43609. export class TorusBuilder {
  43610. /**
  43611. * Creates a torus mesh
  43612. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43613. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43614. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43618. * @param name defines the name of the mesh
  43619. * @param options defines the options used to create the mesh
  43620. * @param scene defines the hosting scene
  43621. * @returns the torus mesh
  43622. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43623. */
  43624. static CreateTorus(name: string, options: {
  43625. diameter?: number;
  43626. thickness?: number;
  43627. tessellation?: number;
  43628. updatable?: boolean;
  43629. sideOrientation?: number;
  43630. frontUVs?: Vector4;
  43631. backUVs?: Vector4;
  43632. }, scene: any): Mesh;
  43633. }
  43634. }
  43635. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43636. import { Vector4 } from "babylonjs/Maths/math.vector";
  43637. import { Color4 } from "babylonjs/Maths/math.color";
  43638. import { Mesh } from "babylonjs/Meshes/mesh";
  43639. /**
  43640. * Class containing static functions to help procedurally build meshes
  43641. */
  43642. export class CylinderBuilder {
  43643. /**
  43644. * Creates a cylinder or a cone mesh
  43645. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43646. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43647. * * 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.
  43648. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43649. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43650. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43651. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43652. * * 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).
  43653. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43654. * * 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).
  43655. * * 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
  43656. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43657. * * 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
  43658. * * 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.
  43659. * * If `enclose` is false, a ring surface is one element.
  43660. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43661. * * 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
  43662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43665. * @param name defines the name of the mesh
  43666. * @param options defines the options used to create the mesh
  43667. * @param scene defines the hosting scene
  43668. * @returns the cylinder mesh
  43669. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43670. */
  43671. static CreateCylinder(name: string, options: {
  43672. height?: number;
  43673. diameterTop?: number;
  43674. diameterBottom?: number;
  43675. diameter?: number;
  43676. tessellation?: number;
  43677. subdivisions?: number;
  43678. arc?: number;
  43679. faceColors?: Color4[];
  43680. faceUV?: Vector4[];
  43681. updatable?: boolean;
  43682. hasRings?: boolean;
  43683. enclose?: boolean;
  43684. cap?: number;
  43685. sideOrientation?: number;
  43686. frontUVs?: Vector4;
  43687. backUVs?: Vector4;
  43688. }, scene: any): Mesh;
  43689. }
  43690. }
  43691. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43692. import { Nullable } from "babylonjs/types";
  43693. import { IDisposable } from "babylonjs/scene";
  43694. /**
  43695. * States of the webXR experience
  43696. */
  43697. export enum WebXRState {
  43698. /**
  43699. * Transitioning to being in XR mode
  43700. */
  43701. ENTERING_XR = 0,
  43702. /**
  43703. * Transitioning to non XR mode
  43704. */
  43705. EXITING_XR = 1,
  43706. /**
  43707. * In XR mode and presenting
  43708. */
  43709. IN_XR = 2,
  43710. /**
  43711. * Not entered XR mode
  43712. */
  43713. NOT_IN_XR = 3
  43714. }
  43715. /**
  43716. * Abstraction of the XR render target
  43717. */
  43718. export interface WebXRRenderTarget extends IDisposable {
  43719. /**
  43720. * xrpresent context of the canvas which can be used to display/mirror xr content
  43721. */
  43722. canvasContext: WebGLRenderingContext;
  43723. /**
  43724. * xr layer for the canvas
  43725. */
  43726. xrLayer: Nullable<XRWebGLLayer>;
  43727. /**
  43728. * Initializes the xr layer for the session
  43729. * @param xrSession xr session
  43730. * @returns a promise that will resolve once the XR Layer has been created
  43731. */
  43732. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43733. }
  43734. }
  43735. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43736. import { Nullable } from "babylonjs/types";
  43737. import { Observable } from "babylonjs/Misc/observable";
  43738. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43739. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43740. /**
  43741. * COnfiguration object for WebXR output canvas
  43742. */
  43743. export class WebXRManagedOutputCanvasOptions {
  43744. /**
  43745. * Options for this XR Layer output
  43746. */
  43747. canvasOptions: XRWebGLLayerOptions;
  43748. /**
  43749. * CSS styling for a newly created canvas (if not provided)
  43750. */
  43751. newCanvasCssStyle?: string;
  43752. /**
  43753. * Get the default values of the configuration object
  43754. * @returns default values of this configuration object
  43755. */
  43756. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43757. }
  43758. /**
  43759. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43760. */
  43761. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43762. private configuration;
  43763. private _engine;
  43764. private _canvas;
  43765. /**
  43766. * xrpresent context of the canvas which can be used to display/mirror xr content
  43767. */
  43768. canvasContext: WebGLRenderingContext;
  43769. /**
  43770. * xr layer for the canvas
  43771. */
  43772. xrLayer: Nullable<XRWebGLLayer>;
  43773. /**
  43774. * Initializes the xr layer for the session
  43775. * @param xrSession xr session
  43776. * @returns a promise that will resolve once the XR Layer has been created
  43777. */
  43778. initializeXRLayerAsync(xrSession: any): any;
  43779. /**
  43780. * Initializes the canvas to be added/removed upon entering/exiting xr
  43781. * @param engine the Babylon engine
  43782. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43783. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43784. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43785. */
  43786. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43787. /**
  43788. * Disposes of the object
  43789. */
  43790. dispose(): void;
  43791. private _setManagedOutputCanvas;
  43792. private _addCanvas;
  43793. private _removeCanvas;
  43794. }
  43795. }
  43796. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43797. import { Observable } from "babylonjs/Misc/observable";
  43798. import { Nullable } from "babylonjs/types";
  43799. import { IDisposable, Scene } from "babylonjs/scene";
  43800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43801. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43802. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43803. /**
  43804. * Manages an XRSession to work with Babylon's engine
  43805. * @see https://doc.babylonjs.com/how_to/webxr
  43806. */
  43807. export class WebXRSessionManager implements IDisposable {
  43808. /** The scene which the session should be created for */
  43809. scene: Scene;
  43810. /**
  43811. * Fires every time a new xrFrame arrives which can be used to update the camera
  43812. */
  43813. onXRFrameObservable: Observable<XRFrame>;
  43814. /**
  43815. * Fires when the xr session is ended either by the device or manually done
  43816. */
  43817. onXRSessionEnded: Observable<any>;
  43818. /**
  43819. * Fires when the xr session is ended either by the device or manually done
  43820. */
  43821. onXRSessionInit: Observable<XRSession>;
  43822. /**
  43823. * Underlying xr session
  43824. */
  43825. session: XRSession;
  43826. /**
  43827. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43828. * or get the offset the player is currently at.
  43829. */
  43830. viewerReferenceSpace: XRReferenceSpace;
  43831. /**
  43832. * The current reference space used in this session. This reference space can constantly change!
  43833. * It is mainly used to offset the camera's position.
  43834. */
  43835. referenceSpace: XRReferenceSpace;
  43836. /**
  43837. * The base reference space from which the session started. good if you want to reset your
  43838. * reference space
  43839. */
  43840. baseReferenceSpace: XRReferenceSpace;
  43841. /**
  43842. * Used just in case of a failure to initialize an immersive session.
  43843. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43844. */
  43845. defaultHeightCompensation: number;
  43846. /**
  43847. * Current XR frame
  43848. */
  43849. currentFrame: Nullable<XRFrame>;
  43850. /** WebXR timestamp updated every frame */
  43851. currentTimestamp: number;
  43852. private _xrNavigator;
  43853. private baseLayer;
  43854. private _rttProvider;
  43855. private _sessionEnded;
  43856. /**
  43857. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43858. * @param scene The scene which the session should be created for
  43859. */
  43860. constructor(
  43861. /** The scene which the session should be created for */
  43862. scene: Scene);
  43863. /**
  43864. * Initializes the manager
  43865. * After initialization enterXR can be called to start an XR session
  43866. * @returns Promise which resolves after it is initialized
  43867. */
  43868. initializeAsync(): Promise<void>;
  43869. /**
  43870. * Initializes an xr session
  43871. * @param xrSessionMode mode to initialize
  43872. * @param optionalFeatures defines optional values to pass to the session builder
  43873. * @returns a promise which will resolve once the session has been initialized
  43874. */
  43875. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43876. /**
  43877. * Sets the reference space on the xr session
  43878. * @param referenceSpace space to set
  43879. * @returns a promise that will resolve once the reference space has been set
  43880. */
  43881. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43882. /**
  43883. * Updates the render state of the session
  43884. * @param state state to set
  43885. * @returns a promise that resolves once the render state has been updated
  43886. */
  43887. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43888. /**
  43889. * Starts rendering to the xr layer
  43890. * @returns a promise that will resolve once rendering has started
  43891. */
  43892. startRenderingToXRAsync(): Promise<void>;
  43893. /**
  43894. * Gets the correct render target texture to be rendered this frame for this eye
  43895. * @param eye the eye for which to get the render target
  43896. * @returns the render target for the specified eye
  43897. */
  43898. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43899. /**
  43900. * Stops the xrSession and restores the renderloop
  43901. * @returns Promise which resolves after it exits XR
  43902. */
  43903. exitXRAsync(): Promise<void>;
  43904. /**
  43905. * Checks if a session would be supported for the creation options specified
  43906. * @param sessionMode session mode to check if supported eg. immersive-vr
  43907. * @returns true if supported
  43908. */
  43909. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43910. /**
  43911. * Creates a WebXRRenderTarget object for the XR session
  43912. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43913. * @param options optional options to provide when creating a new render target
  43914. * @returns a WebXR render target to which the session can render
  43915. */
  43916. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43917. /**
  43918. * @hidden
  43919. * Converts the render layer of xrSession to a render target
  43920. * @param session session to create render target for
  43921. * @param scene scene the new render target should be created for
  43922. * @param baseLayer the webgl layer to create the render target for
  43923. */
  43924. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43925. /**
  43926. * Disposes of the session manager
  43927. */
  43928. dispose(): void;
  43929. /**
  43930. * Gets a promise returning true when fullfiled if the given session mode is supported
  43931. * @param sessionMode defines the session to test
  43932. * @returns a promise
  43933. */
  43934. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43935. }
  43936. }
  43937. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43938. import { Scene } from "babylonjs/scene";
  43939. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43940. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43941. /**
  43942. * WebXR Camera which holds the views for the xrSession
  43943. * @see https://doc.babylonjs.com/how_to/webxr
  43944. */
  43945. export class WebXRCamera extends FreeCamera {
  43946. private _xrSessionManager;
  43947. /**
  43948. * Is the camera in debug mode. Used when using an emulator
  43949. */
  43950. debugMode: boolean;
  43951. private _firstFrame;
  43952. private _referencedPosition;
  43953. private _referenceQuaternion;
  43954. private _xrInvPositionCache;
  43955. private _xrInvQuaternionCache;
  43956. /**
  43957. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43958. * @param name the name of the camera
  43959. * @param scene the scene to add the camera to
  43960. */
  43961. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43962. private _updateNumberOfRigCameras;
  43963. /** @hidden */
  43964. _updateForDualEyeDebugging(): void;
  43965. private _updateReferenceSpace;
  43966. private _updateReferenceSpaceOffset;
  43967. private _updateFromXRSession;
  43968. }
  43969. }
  43970. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43971. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43972. import { IDisposable } from "babylonjs/scene";
  43973. /**
  43974. * Defining the interface required for a (webxr) feature
  43975. */
  43976. export interface IWebXRFeature extends IDisposable {
  43977. /**
  43978. * Attach the feature to the session
  43979. * Will usually be called by the features manager
  43980. *
  43981. * @returns true if successful.
  43982. */
  43983. attach(): boolean;
  43984. /**
  43985. * Detach the feature from the session
  43986. * Will usually be called by the features manager
  43987. *
  43988. * @returns true if successful.
  43989. */
  43990. detach(): boolean;
  43991. }
  43992. /**
  43993. * Defining the constructor of a feature. Used to register the modules.
  43994. */
  43995. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43996. /**
  43997. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43998. * It is mainly used in AR sessions.
  43999. *
  44000. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44001. */
  44002. export class WebXRFeaturesManager implements IDisposable {
  44003. private _xrSessionManager;
  44004. private static readonly _AvailableFeatures;
  44005. /**
  44006. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44007. * Mainly used internally.
  44008. *
  44009. * @param featureName the name of the feature to register
  44010. * @param constructorFunction the function used to construct the module
  44011. * @param version the (babylon) version of the module
  44012. * @param stable is that a stable version of this module
  44013. */
  44014. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44015. /**
  44016. * Returns a constructor of a specific feature.
  44017. *
  44018. * @param featureName the name of the feature to construct
  44019. * @param version the version of the feature to load
  44020. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44021. * @param options optional options provided to the module.
  44022. * @returns a function that, when called, will return a new instance of this feature
  44023. */
  44024. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44025. /**
  44026. * Return the latest unstable version of this feature
  44027. * @param featureName the name of the feature to search
  44028. * @returns the version number. if not found will return -1
  44029. */
  44030. static GetLatestVersionOfFeature(featureName: string): number;
  44031. /**
  44032. * Return the latest stable version of this feature
  44033. * @param featureName the name of the feature to search
  44034. * @returns the version number. if not found will return -1
  44035. */
  44036. static GetStableVersionOfFeature(featureName: string): number;
  44037. /**
  44038. * Can be used to return the list of features currently registered
  44039. *
  44040. * @returns an Array of available features
  44041. */
  44042. static GetAvailableFeatures(): string[];
  44043. /**
  44044. * Gets the versions available for a specific feature
  44045. * @param featureName the name of the feature
  44046. * @returns an array with the available versions
  44047. */
  44048. static GetAvailableVersions(featureName: string): string[];
  44049. private _features;
  44050. /**
  44051. * constructs a new features manages.
  44052. *
  44053. * @param _xrSessionManager an instance of WebXRSessionManager
  44054. */
  44055. constructor(_xrSessionManager: WebXRSessionManager);
  44056. /**
  44057. * 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.
  44058. *
  44059. * @param featureName the name of the feature to load or the class of the feature
  44060. * @param version optional version to load. if not provided the latest version will be enabled
  44061. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44062. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44063. * @returns a new constructed feature or throws an error if feature not found.
  44064. */
  44065. enableFeature(featureName: string | {
  44066. Name: string;
  44067. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44068. /**
  44069. * Used to disable an already-enabled feature
  44070. * @param featureName the feature to disable
  44071. * @returns true if disable was successful
  44072. */
  44073. disableFeature(featureName: string | {
  44074. Name: string;
  44075. }): boolean;
  44076. /**
  44077. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44078. * Can be used during a session to start a feature
  44079. * @param featureName the name of feature to attach
  44080. */
  44081. attachFeature(featureName: string): void;
  44082. /**
  44083. * Can be used inside a session or when the session ends to detach a specific feature
  44084. * @param featureName the name of the feature to detach
  44085. */
  44086. detachFeature(featureName: string): void;
  44087. /**
  44088. * Get the list of enabled features
  44089. * @returns an array of enabled features
  44090. */
  44091. getEnabledFeatures(): string[];
  44092. /**
  44093. * get the implementation of an enabled feature.
  44094. * @param featureName the name of the feature to load
  44095. * @returns the feature class, if found
  44096. */
  44097. getEnabledFeature(featureName: string): IWebXRFeature;
  44098. /**
  44099. * dispose this features manager
  44100. */
  44101. dispose(): void;
  44102. }
  44103. }
  44104. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44105. import { Observable } from "babylonjs/Misc/observable";
  44106. import { IDisposable, Scene } from "babylonjs/scene";
  44107. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44108. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44109. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44110. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44111. /**
  44112. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44113. * @see https://doc.babylonjs.com/how_to/webxr
  44114. */
  44115. export class WebXRExperienceHelper implements IDisposable {
  44116. private scene;
  44117. /**
  44118. * Camera used to render xr content
  44119. */
  44120. camera: WebXRCamera;
  44121. /**
  44122. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44123. */
  44124. state: WebXRState;
  44125. private _setState;
  44126. /**
  44127. * Fires when the state of the experience helper has changed
  44128. */
  44129. onStateChangedObservable: Observable<WebXRState>;
  44130. /**
  44131. * Observers registered here will be triggered after the camera's initial transformation is set
  44132. * This can be used to set a different ground level or an extra rotation.
  44133. *
  44134. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44135. * to the position set after this observable is done executing.
  44136. */
  44137. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44138. /** Session manager used to keep track of xr session */
  44139. sessionManager: WebXRSessionManager;
  44140. /** A features manager for this xr session */
  44141. featuresManager: WebXRFeaturesManager;
  44142. private _nonVRCamera;
  44143. private _originalSceneAutoClear;
  44144. private _supported;
  44145. /**
  44146. * Creates the experience helper
  44147. * @param scene the scene to attach the experience helper to
  44148. * @returns a promise for the experience helper
  44149. */
  44150. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44151. /**
  44152. * Creates a WebXRExperienceHelper
  44153. * @param scene The scene the helper should be created in
  44154. */
  44155. private constructor();
  44156. /**
  44157. * Exits XR mode and returns the scene to its original state
  44158. * @returns promise that resolves after xr mode has exited
  44159. */
  44160. exitXRAsync(): Promise<void>;
  44161. /**
  44162. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44163. * @param sessionMode options for the XR session
  44164. * @param referenceSpaceType frame of reference of the XR session
  44165. * @param renderTarget the output canvas that will be used to enter XR mode
  44166. * @returns promise that resolves after xr mode has entered
  44167. */
  44168. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44169. /**
  44170. * Disposes of the experience helper
  44171. */
  44172. dispose(): void;
  44173. private _nonXRToXRCamera;
  44174. }
  44175. }
  44176. declare module "babylonjs/Cameras/XR/motionController/webXRControllerComponent" {
  44177. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  44178. import { Observable } from "babylonjs/Misc/observable";
  44179. import { IDisposable } from "babylonjs/scene";
  44180. /**
  44181. * X-Y values for axes in WebXR
  44182. */
  44183. export interface IWebXRMotionControllerAxesValue {
  44184. /**
  44185. * The value of the x axis
  44186. */
  44187. x: number;
  44188. /**
  44189. * The value of the y-axis
  44190. */
  44191. y: number;
  44192. }
  44193. /**
  44194. * changed / previous values for the values of this component
  44195. */
  44196. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44197. /**
  44198. * current (this frame) value
  44199. */
  44200. current: T;
  44201. /**
  44202. * previous (last change) value
  44203. */
  44204. previous: T;
  44205. }
  44206. /**
  44207. * Represents changes in the component between current frame and last values recorded
  44208. */
  44209. export interface IWebXRMotionControllerComponentChanges {
  44210. /**
  44211. * will be populated with previous and current values if touched changed
  44212. */
  44213. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44214. /**
  44215. * will be populated with previous and current values if pressed changed
  44216. */
  44217. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44218. /**
  44219. * will be populated with previous and current values if value changed
  44220. */
  44221. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44222. /**
  44223. * will be populated with previous and current values if axes changed
  44224. */
  44225. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44226. }
  44227. /**
  44228. * This class represents a single component (for example button or thumbstick) of a motion controller
  44229. */
  44230. export class WebXRControllerComponent implements IDisposable {
  44231. /**
  44232. * the id of this component
  44233. */
  44234. id: string;
  44235. /**
  44236. * the type of the component
  44237. */
  44238. type: MotionControllerComponentType;
  44239. private _buttonIndex;
  44240. private _axesIndices;
  44241. /**
  44242. * Observers registered here will be triggered when the state of a button changes
  44243. * State change is either pressed / touched / value
  44244. */
  44245. onButtonStateChanged: Observable<WebXRControllerComponent>;
  44246. /**
  44247. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44248. * the axes data changes
  44249. */
  44250. onAxisValueChanged: Observable<{
  44251. x: number;
  44252. y: number;
  44253. }>;
  44254. private _currentValue;
  44255. private _touched;
  44256. private _pressed;
  44257. private _axes;
  44258. private _changes;
  44259. /**
  44260. * Creates a new component for a motion controller.
  44261. * It is created by the motion controller itself
  44262. *
  44263. * @param id the id of this component
  44264. * @param type the type of the component
  44265. * @param _buttonIndex index in the buttons array of the gamepad
  44266. * @param _axesIndices indices of the values in the axes array of the gamepad
  44267. */
  44268. constructor(
  44269. /**
  44270. * the id of this component
  44271. */
  44272. id: string,
  44273. /**
  44274. * the type of the component
  44275. */
  44276. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44277. /**
  44278. * Get the current value of this component
  44279. */
  44280. get value(): number;
  44281. /**
  44282. * is the button currently pressed
  44283. */
  44284. get pressed(): boolean;
  44285. /**
  44286. * is the button currently touched
  44287. */
  44288. get touched(): boolean;
  44289. /**
  44290. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44291. */
  44292. get axes(): IWebXRMotionControllerAxesValue;
  44293. /**
  44294. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44295. */
  44296. get changes(): IWebXRMotionControllerComponentChanges;
  44297. /**
  44298. * Is this component a button (hence - pressable)
  44299. * @returns true if can be pressed
  44300. */
  44301. isButton(): boolean;
  44302. /**
  44303. * Are there axes correlating to this component
  44304. * @return true is axes data is available
  44305. */
  44306. isAxes(): boolean;
  44307. /**
  44308. * update this component using the gamepad object it is in. Called on every frame
  44309. * @param nativeController the native gamepad controller object
  44310. */
  44311. update(nativeController: IMinimalMotionControllerObject): void;
  44312. /**
  44313. * Dispose this component
  44314. */
  44315. dispose(): void;
  44316. }
  44317. }
  44318. declare module "babylonjs/Loading/sceneLoader" {
  44319. import { Observable } from "babylonjs/Misc/observable";
  44320. import { Nullable } from "babylonjs/types";
  44321. import { Scene } from "babylonjs/scene";
  44322. import { Engine } from "babylonjs/Engines/engine";
  44323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44324. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44325. import { AssetContainer } from "babylonjs/assetContainer";
  44326. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44327. import { Skeleton } from "babylonjs/Bones/skeleton";
  44328. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44329. import { WebRequest } from "babylonjs/Misc/webRequest";
  44330. /**
  44331. * Class used to represent data loading progression
  44332. */
  44333. export class SceneLoaderProgressEvent {
  44334. /** defines if data length to load can be evaluated */
  44335. readonly lengthComputable: boolean;
  44336. /** defines the loaded data length */
  44337. readonly loaded: number;
  44338. /** defines the data length to load */
  44339. readonly total: number;
  44340. /**
  44341. * Create a new progress event
  44342. * @param lengthComputable defines if data length to load can be evaluated
  44343. * @param loaded defines the loaded data length
  44344. * @param total defines the data length to load
  44345. */
  44346. constructor(
  44347. /** defines if data length to load can be evaluated */
  44348. lengthComputable: boolean,
  44349. /** defines the loaded data length */
  44350. loaded: number,
  44351. /** defines the data length to load */
  44352. total: number);
  44353. /**
  44354. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44355. * @param event defines the source event
  44356. * @returns a new SceneLoaderProgressEvent
  44357. */
  44358. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44359. }
  44360. /**
  44361. * Interface used by SceneLoader plugins to define supported file extensions
  44362. */
  44363. export interface ISceneLoaderPluginExtensions {
  44364. /**
  44365. * Defines the list of supported extensions
  44366. */
  44367. [extension: string]: {
  44368. isBinary: boolean;
  44369. };
  44370. }
  44371. /**
  44372. * Interface used by SceneLoader plugin factory
  44373. */
  44374. export interface ISceneLoaderPluginFactory {
  44375. /**
  44376. * Defines the name of the factory
  44377. */
  44378. name: string;
  44379. /**
  44380. * Function called to create a new plugin
  44381. * @return the new plugin
  44382. */
  44383. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44384. /**
  44385. * The callback that returns true if the data can be directly loaded.
  44386. * @param data string containing the file data
  44387. * @returns if the data can be loaded directly
  44388. */
  44389. canDirectLoad?(data: string): boolean;
  44390. }
  44391. /**
  44392. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44393. */
  44394. export interface ISceneLoaderPluginBase {
  44395. /**
  44396. * The friendly name of this plugin.
  44397. */
  44398. name: string;
  44399. /**
  44400. * The file extensions supported by this plugin.
  44401. */
  44402. extensions: string | ISceneLoaderPluginExtensions;
  44403. /**
  44404. * The callback called when loading from a url.
  44405. * @param scene scene loading this url
  44406. * @param url url to load
  44407. * @param onSuccess callback called when the file successfully loads
  44408. * @param onProgress callback called while file is loading (if the server supports this mode)
  44409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44410. * @param onError callback called when the file fails to load
  44411. * @returns a file request object
  44412. */
  44413. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44414. /**
  44415. * The callback called when loading from a file object.
  44416. * @param scene scene loading this file
  44417. * @param file defines the file to load
  44418. * @param onSuccess defines the callback to call when data is loaded
  44419. * @param onProgress defines the callback to call during loading process
  44420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44421. * @param onError defines the callback to call when an error occurs
  44422. * @returns a file request object
  44423. */
  44424. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44425. /**
  44426. * The callback that returns true if the data can be directly loaded.
  44427. * @param data string containing the file data
  44428. * @returns if the data can be loaded directly
  44429. */
  44430. canDirectLoad?(data: string): boolean;
  44431. /**
  44432. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44433. * @param scene scene loading this data
  44434. * @param data string containing the data
  44435. * @returns data to pass to the plugin
  44436. */
  44437. directLoad?(scene: Scene, data: string): any;
  44438. /**
  44439. * The callback that allows custom handling of the root url based on the response url.
  44440. * @param rootUrl the original root url
  44441. * @param responseURL the response url if available
  44442. * @returns the new root url
  44443. */
  44444. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44445. }
  44446. /**
  44447. * Interface used to define a SceneLoader plugin
  44448. */
  44449. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44450. /**
  44451. * Import meshes into a scene.
  44452. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44453. * @param scene The scene to import into
  44454. * @param data The data to import
  44455. * @param rootUrl The root url for scene and resources
  44456. * @param meshes The meshes array to import into
  44457. * @param particleSystems The particle systems array to import into
  44458. * @param skeletons The skeletons array to import into
  44459. * @param onError The callback when import fails
  44460. * @returns True if successful or false otherwise
  44461. */
  44462. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44463. /**
  44464. * Load into a scene.
  44465. * @param scene The scene to load into
  44466. * @param data The data to import
  44467. * @param rootUrl The root url for scene and resources
  44468. * @param onError The callback when import fails
  44469. * @returns True if successful or false otherwise
  44470. */
  44471. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44472. /**
  44473. * Load into an asset container.
  44474. * @param scene The scene to load into
  44475. * @param data The data to import
  44476. * @param rootUrl The root url for scene and resources
  44477. * @param onError The callback when import fails
  44478. * @returns The loaded asset container
  44479. */
  44480. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44481. }
  44482. /**
  44483. * Interface used to define an async SceneLoader plugin
  44484. */
  44485. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44486. /**
  44487. * Import meshes into a scene.
  44488. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44489. * @param scene The scene to import into
  44490. * @param data The data to import
  44491. * @param rootUrl The root url for scene and resources
  44492. * @param onProgress The callback when the load progresses
  44493. * @param fileName Defines the name of the file to load
  44494. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44495. */
  44496. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44497. meshes: AbstractMesh[];
  44498. particleSystems: IParticleSystem[];
  44499. skeletons: Skeleton[];
  44500. animationGroups: AnimationGroup[];
  44501. }>;
  44502. /**
  44503. * Load into a scene.
  44504. * @param scene The scene to load into
  44505. * @param data The data to import
  44506. * @param rootUrl The root url for scene and resources
  44507. * @param onProgress The callback when the load progresses
  44508. * @param fileName Defines the name of the file to load
  44509. * @returns Nothing
  44510. */
  44511. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44512. /**
  44513. * Load into an asset container.
  44514. * @param scene The scene to load into
  44515. * @param data The data to import
  44516. * @param rootUrl The root url for scene and resources
  44517. * @param onProgress The callback when the load progresses
  44518. * @param fileName Defines the name of the file to load
  44519. * @returns The loaded asset container
  44520. */
  44521. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44522. }
  44523. /**
  44524. * Mode that determines how to handle old animation groups before loading new ones.
  44525. */
  44526. export enum SceneLoaderAnimationGroupLoadingMode {
  44527. /**
  44528. * Reset all old animations to initial state then dispose them.
  44529. */
  44530. Clean = 0,
  44531. /**
  44532. * Stop all old animations.
  44533. */
  44534. Stop = 1,
  44535. /**
  44536. * Restart old animations from first frame.
  44537. */
  44538. Sync = 2,
  44539. /**
  44540. * Old animations remains untouched.
  44541. */
  44542. NoSync = 3
  44543. }
  44544. /**
  44545. * Class used to load scene from various file formats using registered plugins
  44546. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44547. */
  44548. export class SceneLoader {
  44549. /**
  44550. * No logging while loading
  44551. */
  44552. static readonly NO_LOGGING: number;
  44553. /**
  44554. * Minimal logging while loading
  44555. */
  44556. static readonly MINIMAL_LOGGING: number;
  44557. /**
  44558. * Summary logging while loading
  44559. */
  44560. static readonly SUMMARY_LOGGING: number;
  44561. /**
  44562. * Detailled logging while loading
  44563. */
  44564. static readonly DETAILED_LOGGING: number;
  44565. /**
  44566. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44567. */
  44568. static get ForceFullSceneLoadingForIncremental(): boolean;
  44569. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44570. /**
  44571. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44572. */
  44573. static get ShowLoadingScreen(): boolean;
  44574. static set ShowLoadingScreen(value: boolean);
  44575. /**
  44576. * Defines the current logging level (while loading the scene)
  44577. * @ignorenaming
  44578. */
  44579. static get loggingLevel(): number;
  44580. static set loggingLevel(value: number);
  44581. /**
  44582. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44583. */
  44584. static get CleanBoneMatrixWeights(): boolean;
  44585. static set CleanBoneMatrixWeights(value: boolean);
  44586. /**
  44587. * Event raised when a plugin is used to load a scene
  44588. */
  44589. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44590. private static _registeredPlugins;
  44591. private static _getDefaultPlugin;
  44592. private static _getPluginForExtension;
  44593. private static _getPluginForDirectLoad;
  44594. private static _getPluginForFilename;
  44595. private static _getDirectLoad;
  44596. private static _loadData;
  44597. private static _getFileInfo;
  44598. /**
  44599. * Gets a plugin that can load the given extension
  44600. * @param extension defines the extension to load
  44601. * @returns a plugin or null if none works
  44602. */
  44603. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44604. /**
  44605. * Gets a boolean indicating that the given extension can be loaded
  44606. * @param extension defines the extension to load
  44607. * @returns true if the extension is supported
  44608. */
  44609. static IsPluginForExtensionAvailable(extension: string): boolean;
  44610. /**
  44611. * Adds a new plugin to the list of registered plugins
  44612. * @param plugin defines the plugin to add
  44613. */
  44614. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44615. /**
  44616. * Import meshes into a scene
  44617. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44618. * @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)
  44619. * @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)
  44620. * @param scene the instance of BABYLON.Scene to append to
  44621. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44622. * @param onProgress a callback with a progress event for each file being loaded
  44623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44624. * @param pluginExtension the extension used to determine the plugin
  44625. * @returns The loaded plugin
  44626. */
  44627. 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>;
  44628. /**
  44629. * Import meshes into a scene
  44630. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44631. * @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)
  44632. * @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)
  44633. * @param scene the instance of BABYLON.Scene to append to
  44634. * @param onProgress a callback with a progress event for each file being loaded
  44635. * @param pluginExtension the extension used to determine the plugin
  44636. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44637. */
  44638. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44639. meshes: AbstractMesh[];
  44640. particleSystems: IParticleSystem[];
  44641. skeletons: Skeleton[];
  44642. animationGroups: AnimationGroup[];
  44643. }>;
  44644. /**
  44645. * Load a scene
  44646. * @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)
  44647. * @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)
  44648. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44649. * @param onSuccess a callback with the scene when import succeeds
  44650. * @param onProgress a callback with a progress event for each file being loaded
  44651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44652. * @param pluginExtension the extension used to determine the plugin
  44653. * @returns The loaded plugin
  44654. */
  44655. 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>;
  44656. /**
  44657. * Load a scene
  44658. * @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)
  44659. * @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)
  44660. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44661. * @param onProgress a callback with a progress event for each file being loaded
  44662. * @param pluginExtension the extension used to determine the plugin
  44663. * @returns The loaded scene
  44664. */
  44665. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44666. /**
  44667. * Append a scene
  44668. * @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)
  44669. * @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)
  44670. * @param scene is the instance of BABYLON.Scene to append to
  44671. * @param onSuccess a callback with the scene when import succeeds
  44672. * @param onProgress a callback with a progress event for each file being loaded
  44673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44674. * @param pluginExtension the extension used to determine the plugin
  44675. * @returns The loaded plugin
  44676. */
  44677. 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>;
  44678. /**
  44679. * Append a scene
  44680. * @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)
  44681. * @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)
  44682. * @param scene is the instance of BABYLON.Scene to append to
  44683. * @param onProgress a callback with a progress event for each file being loaded
  44684. * @param pluginExtension the extension used to determine the plugin
  44685. * @returns The given scene
  44686. */
  44687. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44688. /**
  44689. * Load a scene into an asset container
  44690. * @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)
  44691. * @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)
  44692. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44693. * @param onSuccess a callback with the scene when import succeeds
  44694. * @param onProgress a callback with a progress event for each file being loaded
  44695. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44696. * @param pluginExtension the extension used to determine the plugin
  44697. * @returns The loaded plugin
  44698. */
  44699. 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>;
  44700. /**
  44701. * Load a scene into an asset container
  44702. * @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)
  44703. * @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)
  44704. * @param scene is the instance of Scene to append to
  44705. * @param onProgress a callback with a progress event for each file being loaded
  44706. * @param pluginExtension the extension used to determine the plugin
  44707. * @returns The loaded asset container
  44708. */
  44709. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44710. /**
  44711. * Import animations from a file into a scene
  44712. * @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)
  44713. * @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)
  44714. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44715. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44716. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44717. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44718. * @param onSuccess a callback with the scene when import succeeds
  44719. * @param onProgress a callback with a progress event for each file being loaded
  44720. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44721. */
  44722. 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;
  44723. /**
  44724. * Import animations from a file into a scene
  44725. * @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)
  44726. * @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)
  44727. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44728. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44729. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44730. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44731. * @param onSuccess a callback with the scene when import succeeds
  44732. * @param onProgress a callback with a progress event for each file being loaded
  44733. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44734. * @returns the updated scene with imported animations
  44735. */
  44736. 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>;
  44737. }
  44738. }
  44739. declare module "babylonjs/Cameras/XR/motionController/webXRAbstractController" {
  44740. import { IDisposable, Scene } from "babylonjs/scene";
  44741. import { WebXRControllerComponent } from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  44742. import { Observable } from "babylonjs/Misc/observable";
  44743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44744. import { Nullable } from "babylonjs/types";
  44745. /**
  44746. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44747. */
  44748. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  44749. /**
  44750. * The type of components available in motion controllers.
  44751. * This is not the name of the component.
  44752. */
  44753. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44754. /**
  44755. * The schema of motion controller layout.
  44756. * No object will be initialized using this interface
  44757. * This is used just to define the profile.
  44758. */
  44759. export interface IMotionControllerLayout {
  44760. /**
  44761. * Defines the main button component id
  44762. */
  44763. selectComponentId: string;
  44764. /**
  44765. * Available components (unsorted)
  44766. */
  44767. components: {
  44768. /**
  44769. * A map of component Ids
  44770. */
  44771. [componentId: string]: {
  44772. /**
  44773. * The type of input the component outputs
  44774. */
  44775. type: MotionControllerComponentType;
  44776. };
  44777. };
  44778. /**
  44779. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  44780. */
  44781. gamepad?: {
  44782. /**
  44783. * Is the mapping based on the xr-standard defined here:
  44784. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  44785. */
  44786. mapping: "" | "xr-standard";
  44787. /**
  44788. * The buttons available in this input in the right order
  44789. * index of this button will be the index in the gamepadObject.buttons array
  44790. * correlates to the componentId in components
  44791. */
  44792. buttons: Array<string | null>;
  44793. /**
  44794. * Definition of the axes of the gamepad input, sorted
  44795. * Correlates to componentIds in the components map
  44796. */
  44797. axes: Array<{
  44798. /**
  44799. * The component id that the axis correlates to
  44800. */
  44801. componentId: string;
  44802. /**
  44803. * X or Y Axis
  44804. */
  44805. axis: "x-axis" | "y-axis";
  44806. } | null>;
  44807. };
  44808. }
  44809. /**
  44810. * A definition for the layout map in the input profile
  44811. */
  44812. export interface IMotionControllerLayoutMap {
  44813. /**
  44814. * Layouts with handness type as a key
  44815. */
  44816. [handness: string]: IMotionControllerLayout;
  44817. }
  44818. /**
  44819. * The XR Input profile schema
  44820. * Profiles can be found here:
  44821. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44822. */
  44823. export interface IMotionControllerProfile {
  44824. /**
  44825. * The id of this profile
  44826. * correlates to the profile(s) in the xrInput.profiles array
  44827. */
  44828. profileId: string;
  44829. /**
  44830. * fallback profiles for this profileId
  44831. */
  44832. fallbackProfileIds: string[];
  44833. /**
  44834. * The layout map, with handness as key
  44835. */
  44836. layouts: IMotionControllerLayoutMap;
  44837. }
  44838. /**
  44839. * A helper-interface for the 3 meshes needed for controller button animation
  44840. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44841. */
  44842. export interface IMotionControllerButtonMeshMap {
  44843. /**
  44844. * The mesh that will be changed when value changes
  44845. */
  44846. valueMesh: AbstractMesh;
  44847. /**
  44848. * the mesh that defines the pressed value mesh position.
  44849. * This is used to find the max-position of this button
  44850. */
  44851. pressedMesh: AbstractMesh;
  44852. /**
  44853. * the mesh that defines the unpressed value mesh position.
  44854. * This is used to find the min (or initial) position of this button
  44855. */
  44856. unpressedMesh: AbstractMesh;
  44857. }
  44858. /**
  44859. * A helper-interface for the 3 meshes needed for controller axis animation.
  44860. * This will be expanded when touchpad animations are fully supported
  44861. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44862. */
  44863. export interface IMotionControllerAxisMeshMap {
  44864. /**
  44865. * The mesh that will be changed when axis value changes
  44866. */
  44867. valueMesh: AbstractMesh;
  44868. /**
  44869. * the mesh that defines the minimum value mesh position.
  44870. */
  44871. minMesh: AbstractMesh;
  44872. /**
  44873. * the mesh that defines the maximum value mesh position.
  44874. */
  44875. maxMesh: AbstractMesh;
  44876. }
  44877. /**
  44878. * The elements needed for change-detection of the gamepad objects in motion controllers
  44879. */
  44880. export interface IMinimalMotionControllerObject {
  44881. /**
  44882. * An array of available buttons
  44883. */
  44884. buttons: Array<{
  44885. /**
  44886. * Value of the button/trigger
  44887. */
  44888. value: number;
  44889. /**
  44890. * If the button/trigger is currently touched
  44891. */
  44892. touched: boolean;
  44893. /**
  44894. * If the button/trigger is currently pressed
  44895. */
  44896. pressed: boolean;
  44897. }>;
  44898. /**
  44899. * Available axes of this controller
  44900. */
  44901. axes: number[];
  44902. }
  44903. /**
  44904. * An Abstract Motion controller
  44905. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44906. * Each component has an observable to check for changes in value and state
  44907. */
  44908. export abstract class WebXRAbstractMotionController implements IDisposable {
  44909. protected scene: Scene;
  44910. protected layout: IMotionControllerLayout;
  44911. /**
  44912. * The gamepad object correlating to this controller
  44913. */
  44914. gamepadObject: IMinimalMotionControllerObject;
  44915. /**
  44916. * handness (left/right/none) of this controller
  44917. */
  44918. handness: MotionControllerHandness;
  44919. /**
  44920. * Component type map
  44921. */
  44922. static ComponentType: {
  44923. TRIGGER: string;
  44924. SQUEEZE: string;
  44925. TOUCHPAD: string;
  44926. THUMBSTICK: string;
  44927. BUTTON: string;
  44928. };
  44929. /**
  44930. * The profile id of this motion controller
  44931. */
  44932. abstract profileId: string;
  44933. /**
  44934. * A map of components (WebXRControllerComponent) in this motion controller
  44935. * Components have a ComponentType and can also have both button and axis definitions
  44936. */
  44937. readonly components: {
  44938. [id: string]: WebXRControllerComponent;
  44939. };
  44940. /**
  44941. * Observers registered here will be triggered when the model of this controller is done loading
  44942. */
  44943. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44944. /**
  44945. * The root mesh of the model. It is null if the model was not yet initialized
  44946. */
  44947. rootMesh: Nullable<AbstractMesh>;
  44948. private _modelReady;
  44949. /**
  44950. * constructs a new abstract motion controller
  44951. * @param scene the scene to which the model of the controller will be added
  44952. * @param layout The profile layout to load
  44953. * @param gamepadObject The gamepad object correlating to this controller
  44954. * @param handness handness (left/right/none) of this controller
  44955. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44956. */
  44957. constructor(scene: Scene, layout: IMotionControllerLayout,
  44958. /**
  44959. * The gamepad object correlating to this controller
  44960. */
  44961. gamepadObject: IMinimalMotionControllerObject,
  44962. /**
  44963. * handness (left/right/none) of this controller
  44964. */
  44965. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44966. private _initComponent;
  44967. /**
  44968. * Update this model using the current XRFrame
  44969. * @param xrFrame the current xr frame to use and update the model
  44970. */
  44971. updateFromXRFrame(xrFrame: XRFrame): void;
  44972. /**
  44973. * Get the list of components available in this motion controller
  44974. * @returns an array of strings correlating to available components
  44975. */
  44976. getComponentTypes(): string[];
  44977. /**
  44978. * Get the main (Select) component of this controller as defined in the layout
  44979. * @returns the main component of this controller
  44980. */
  44981. getMainComponent(): WebXRControllerComponent;
  44982. /**
  44983. * get a component based an its component id as defined in layout.components
  44984. * @param id the id of the component
  44985. * @returns the component correlates to the id or undefined if not found
  44986. */
  44987. getComponent(id: string): WebXRControllerComponent;
  44988. /**
  44989. * Loads the model correlating to this controller
  44990. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44991. * @returns A promise fulfilled with the result of the model loading
  44992. */
  44993. loadModel(): Promise<boolean>;
  44994. /**
  44995. * Update the model itself with the current frame data
  44996. * @param xrFrame the frame to use for updating the model mesh
  44997. */
  44998. protected updateModel(xrFrame: XRFrame): void;
  44999. /**
  45000. * Moves the axis on the controller mesh based on its current state
  45001. * @param axis the index of the axis
  45002. * @param axisValue the value of the axis which determines the meshes new position
  45003. * @hidden
  45004. */
  45005. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  45006. /**
  45007. * Moves the buttons on the controller mesh based on their current state
  45008. * @param buttonName the name of the button to move
  45009. * @param buttonValue the value of the button which determines the buttons new position
  45010. */
  45011. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  45012. private _getGenericFilenameAndPath;
  45013. private _getGenericParentMesh;
  45014. /**
  45015. * Get the filename and path for this controller's model
  45016. * @returns a map of filename and path
  45017. */
  45018. protected abstract _getFilenameAndPath(): {
  45019. filename: string;
  45020. path: string;
  45021. };
  45022. /**
  45023. * This function will be called after the model was successfully loaded and can be used
  45024. * for mesh transformations before it is available for the user
  45025. * @param meshes the loaded meshes
  45026. */
  45027. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45028. /**
  45029. * Set the root mesh for this controller. Important for the WebXR controller class
  45030. * @param meshes the loaded meshes
  45031. */
  45032. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45033. /**
  45034. * A function executed each frame that updates the mesh (if needed)
  45035. * @param xrFrame the current xrFrame
  45036. */
  45037. protected abstract _updateModel(xrFrame: XRFrame): void;
  45038. /**
  45039. * This function is called before the mesh is loaded. It checks for loading constraints.
  45040. * For example, this function can check if the GLB loader is available
  45041. * If this function returns false, the generic controller will be loaded instead
  45042. * @returns Is the client ready to load the mesh
  45043. */
  45044. protected abstract _getModelLoadingConstraints(): boolean;
  45045. /**
  45046. * Dispose this controller, the model mesh and all its components
  45047. */
  45048. dispose(): void;
  45049. }
  45050. }
  45051. declare module "babylonjs/Cameras/XR/motionController/webXRGenericMotionController" {
  45052. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45054. import { Scene } from "babylonjs/scene";
  45055. /**
  45056. * A generic trigger-only motion controller for WebXR
  45057. */
  45058. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45059. /**
  45060. * Static version of the profile id of this controller
  45061. */
  45062. static ProfileId: string;
  45063. profileId: string;
  45064. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45065. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45066. protected _updateModel(): void;
  45067. protected _getFilenameAndPath(): {
  45068. filename: string;
  45069. path: string;
  45070. };
  45071. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45072. protected _getModelLoadingConstraints(): boolean;
  45073. }
  45074. }
  45075. declare module "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager" {
  45076. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45077. import { Scene } from "babylonjs/scene";
  45078. /**
  45079. * A construction function type to create a new controller based on an xrInput object
  45080. */
  45081. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45082. /**
  45083. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45084. *
  45085. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45086. * it should be replaced with auto-loaded controllers.
  45087. *
  45088. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45089. */
  45090. export class WebXRMotionControllerManager {
  45091. private static _AvailableControllers;
  45092. private static _Fallbacks;
  45093. /**
  45094. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45095. *
  45096. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45097. *
  45098. * @param type the profile type to register
  45099. * @param constructFunction the function to be called when loading this profile
  45100. */
  45101. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45102. /**
  45103. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45104. * The order of search:
  45105. *
  45106. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45107. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45108. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45109. * 4) return the generic trigger controller if none were found
  45110. *
  45111. * @param xrInput the xrInput to which a new controller is initialized
  45112. * @param scene the scene to which the model will be added
  45113. * @return the motion controller class for this profile id or the generic standard class if none was found
  45114. */
  45115. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene): WebXRAbstractMotionController;
  45116. /**
  45117. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45118. * @param profileId the profile to which a fallback needs to be found
  45119. * @return an array with corresponding fallback profiles
  45120. */
  45121. static FindFallbackWithProfileId(profileId: string): string[];
  45122. /**
  45123. * Register a fallback to a specific profile.
  45124. * @param profileId the profileId that will receive the fallbacks
  45125. * @param fallbacks A list of fallback profiles
  45126. */
  45127. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45128. /**
  45129. * Register the default fallbacks.
  45130. * This function is called automatically when this file is imported.
  45131. */
  45132. static DefaultFallbacks(): void;
  45133. }
  45134. }
  45135. declare module "babylonjs/Cameras/XR/webXRController" {
  45136. import { Observable } from "babylonjs/Misc/observable";
  45137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45138. import { Ray } from "babylonjs/Culling/ray";
  45139. import { Scene } from "babylonjs/scene";
  45140. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45141. /**
  45142. * Represents an XR input
  45143. */
  45144. export class WebXRController {
  45145. private scene;
  45146. /** The underlying input source for the controller */
  45147. inputSource: XRInputSource;
  45148. /**
  45149. * 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
  45150. */
  45151. grip?: AbstractMesh;
  45152. /**
  45153. * Pointer which can be used to select objects or attach a visible laser to
  45154. */
  45155. pointer: AbstractMesh;
  45156. private _gamepadMode;
  45157. /**
  45158. * If available, this is the gamepad object related to this controller.
  45159. * Using this object it is possible to get click events and trackpad changes of the
  45160. * webxr controller that is currently being used.
  45161. */
  45162. gamepadController?: WebXRAbstractMotionController;
  45163. /**
  45164. * Event that fires when the controller is removed/disposed
  45165. */
  45166. onDisposeObservable: Observable<{}>;
  45167. private _tmpQuaternion;
  45168. private _tmpVector;
  45169. /**
  45170. * Creates the controller
  45171. * @see https://doc.babylonjs.com/how_to/webxr
  45172. * @param scene the scene which the controller should be associated to
  45173. * @param inputSource the underlying input source for the controller
  45174. * @param parentContainer parent that the controller meshes should be children of
  45175. */
  45176. constructor(scene: Scene,
  45177. /** The underlying input source for the controller */
  45178. inputSource: XRInputSource);
  45179. /**
  45180. * Updates the controller pose based on the given XRFrame
  45181. * @param xrFrame xr frame to update the pose with
  45182. * @param referenceSpace reference space to use
  45183. */
  45184. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45185. /**
  45186. * Gets a world space ray coming from the controller
  45187. * @param result the resulting ray
  45188. */
  45189. getWorldPointerRayToRef(result: Ray): void;
  45190. /**
  45191. * Get the scene associated with this controller
  45192. * @returns the scene object
  45193. */
  45194. getScene(): Scene;
  45195. /**
  45196. * Disposes of the object
  45197. */
  45198. dispose(): void;
  45199. }
  45200. }
  45201. declare module "babylonjs/Cameras/XR/webXRInput" {
  45202. import { Observable } from "babylonjs/Misc/observable";
  45203. import { IDisposable } from "babylonjs/scene";
  45204. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45205. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45206. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  45207. /**
  45208. * The schema for initialization options of the XR Input class
  45209. */
  45210. export interface IWebXRInputOptions {
  45211. /**
  45212. * If set to true no model will be automatically loaded
  45213. */
  45214. doNotLoadControllerMeshes?: boolean;
  45215. }
  45216. /**
  45217. * XR input used to track XR inputs such as controllers/rays
  45218. */
  45219. export class WebXRInput implements IDisposable {
  45220. /**
  45221. * the xr session manager for this session
  45222. */
  45223. xrSessionManager: WebXRSessionManager;
  45224. /**
  45225. * the WebXR camera for this session. Mainly used for teleportation
  45226. */
  45227. xrCamera: WebXRCamera;
  45228. private readonly options;
  45229. /**
  45230. * XR controllers being tracked
  45231. */
  45232. controllers: Array<WebXRController>;
  45233. private _frameObserver;
  45234. private _sessionEndedObserver;
  45235. private _sessionInitObserver;
  45236. /**
  45237. * Event when a controller has been connected/added
  45238. */
  45239. onControllerAddedObservable: Observable<WebXRController>;
  45240. /**
  45241. * Event when a controller has been removed/disconnected
  45242. */
  45243. onControllerRemovedObservable: Observable<WebXRController>;
  45244. /**
  45245. * Initializes the WebXRInput
  45246. * @param xrSessionManager the xr session manager for this session
  45247. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45248. * @param options = initialization options for this xr input
  45249. */
  45250. constructor(
  45251. /**
  45252. * the xr session manager for this session
  45253. */
  45254. xrSessionManager: WebXRSessionManager,
  45255. /**
  45256. * the WebXR camera for this session. Mainly used for teleportation
  45257. */
  45258. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45259. private _onInputSourcesChange;
  45260. private _addAndRemoveControllers;
  45261. /**
  45262. * Disposes of the object
  45263. */
  45264. dispose(): void;
  45265. }
  45266. }
  45267. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45268. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45269. /**
  45270. * Handles pointer input automatically for the pointer of XR controllers
  45271. */
  45272. export class WebXRControllerPointerSelection {
  45273. private static _idCounter;
  45274. private _tmpRay;
  45275. /**
  45276. * Creates a WebXRControllerPointerSelection
  45277. * @param input input manager to setup pointer selection
  45278. */
  45279. constructor(input: WebXRInput);
  45280. private _convertNormalToDirectionOfRay;
  45281. private _updatePointerDistance;
  45282. }
  45283. }
  45284. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45286. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45287. /**
  45288. * Enables teleportation
  45289. */
  45290. export class WebXRControllerTeleportation {
  45291. private _teleportationFillColor;
  45292. private _teleportationBorderColor;
  45293. private _tmpRay;
  45294. private _tmpVector;
  45295. /**
  45296. * when set to true (default) teleportation will wait for thumbstick changes.
  45297. * When set to false teleportation will be disabled.
  45298. *
  45299. * If set to false while teleporting results can be unexpected.
  45300. */
  45301. enabled: boolean;
  45302. /**
  45303. * Creates a WebXRControllerTeleportation
  45304. * @param input input manager to add teleportation to
  45305. * @param floorMeshes floormeshes which can be teleported to
  45306. */
  45307. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45308. }
  45309. }
  45310. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45311. import { Nullable } from "babylonjs/types";
  45312. import { Observable } from "babylonjs/Misc/observable";
  45313. import { IDisposable, Scene } from "babylonjs/scene";
  45314. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45315. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45316. /**
  45317. * Button which can be used to enter a different mode of XR
  45318. */
  45319. export class WebXREnterExitUIButton {
  45320. /** button element */
  45321. element: HTMLElement;
  45322. /** XR initialization options for the button */
  45323. sessionMode: XRSessionMode;
  45324. /** Reference space type */
  45325. referenceSpaceType: XRReferenceSpaceType;
  45326. /**
  45327. * Creates a WebXREnterExitUIButton
  45328. * @param element button element
  45329. * @param sessionMode XR initialization session mode
  45330. * @param referenceSpaceType the type of reference space to be used
  45331. */
  45332. constructor(
  45333. /** button element */
  45334. element: HTMLElement,
  45335. /** XR initialization options for the button */
  45336. sessionMode: XRSessionMode,
  45337. /** Reference space type */
  45338. referenceSpaceType: XRReferenceSpaceType);
  45339. /**
  45340. * Overwritable function which can be used to update the button's visuals when the state changes
  45341. * @param activeButton the current active button in the UI
  45342. */
  45343. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45344. }
  45345. /**
  45346. * Options to create the webXR UI
  45347. */
  45348. export class WebXREnterExitUIOptions {
  45349. /**
  45350. * Context to enter xr with
  45351. */
  45352. renderTarget?: Nullable<WebXRRenderTarget>;
  45353. /**
  45354. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45355. */
  45356. customButtons?: Array<WebXREnterExitUIButton>;
  45357. /**
  45358. * A session mode to use when creating the default button.
  45359. * Default is immersive-vr
  45360. */
  45361. sessionMode?: XRSessionMode;
  45362. /**
  45363. * A reference space type to use when creating the default button.
  45364. * Default is local-floor
  45365. */
  45366. referenceSpaceType?: XRReferenceSpaceType;
  45367. }
  45368. /**
  45369. * UI to allow the user to enter/exit XR mode
  45370. */
  45371. export class WebXREnterExitUI implements IDisposable {
  45372. private scene;
  45373. /** version of the options passed to this UI */
  45374. options: WebXREnterExitUIOptions;
  45375. private _overlay;
  45376. private _buttons;
  45377. private _activeButton;
  45378. /**
  45379. * Fired every time the active button is changed.
  45380. *
  45381. * When xr is entered via a button that launches xr that button will be the callback parameter
  45382. *
  45383. * When exiting xr the callback parameter will be null)
  45384. */
  45385. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45386. /**
  45387. * Creates UI to allow the user to enter/exit XR mode
  45388. * @param scene the scene to add the ui to
  45389. * @param helper the xr experience helper to enter/exit xr with
  45390. * @param options options to configure the UI
  45391. * @returns the created ui
  45392. */
  45393. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45394. /**
  45395. *
  45396. * @param scene babylon scene object to use
  45397. * @param options (read-only) version of the options passed to this UI
  45398. */
  45399. private constructor();
  45400. private _updateButtons;
  45401. /**
  45402. * Disposes of the object
  45403. */
  45404. dispose(): void;
  45405. }
  45406. }
  45407. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45408. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45409. import { Scene } from "babylonjs/scene";
  45410. import { WebXRInput, IWebXRInputOptions } from "babylonjs/Cameras/XR/webXRInput";
  45411. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45412. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45413. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45414. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45416. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45417. /**
  45418. * Options for the default xr helper
  45419. */
  45420. export class WebXRDefaultExperienceOptions {
  45421. /**
  45422. * Floor meshes that should be used for teleporting
  45423. */
  45424. floorMeshes?: Array<AbstractMesh>;
  45425. /**
  45426. * Enable or disable default UI to enter XR
  45427. */
  45428. disableDefaultUI?: boolean;
  45429. /**
  45430. * optional configuration for the output canvas
  45431. */
  45432. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45433. /**
  45434. * optional UI options. This can be used among other to change session mode and reference space type
  45435. */
  45436. uiOptions?: WebXREnterExitUIOptions;
  45437. /**
  45438. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45439. */
  45440. inputOptions?: IWebXRInputOptions;
  45441. }
  45442. /**
  45443. * Default experience which provides a similar setup to the previous webVRExperience
  45444. */
  45445. export class WebXRDefaultExperience {
  45446. /**
  45447. * Base experience
  45448. */
  45449. baseExperience: WebXRExperienceHelper;
  45450. /**
  45451. * Input experience extension
  45452. */
  45453. input: WebXRInput;
  45454. /**
  45455. * Enables laser pointer and selection
  45456. */
  45457. pointerSelection: WebXRControllerPointerSelection;
  45458. /**
  45459. * Enables teleportation
  45460. */
  45461. teleportation: WebXRControllerTeleportation;
  45462. /**
  45463. * Enables ui for entering/exiting xr
  45464. */
  45465. enterExitUI: WebXREnterExitUI;
  45466. /**
  45467. * Default target xr should render to
  45468. */
  45469. renderTarget: WebXRRenderTarget;
  45470. /**
  45471. * Creates the default xr experience
  45472. * @param scene scene
  45473. * @param options options for basic configuration
  45474. * @returns resulting WebXRDefaultExperience
  45475. */
  45476. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45477. private constructor();
  45478. /**
  45479. * DIsposes of the experience helper
  45480. */
  45481. dispose(): void;
  45482. }
  45483. }
  45484. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45485. import { Observable } from "babylonjs/Misc/observable";
  45486. import { Nullable } from "babylonjs/types";
  45487. import { Camera } from "babylonjs/Cameras/camera";
  45488. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45489. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45490. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45491. import { Scene } from "babylonjs/scene";
  45492. import { Vector3 } from "babylonjs/Maths/math.vector";
  45493. import { Color3 } from "babylonjs/Maths/math.color";
  45494. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45496. import { Mesh } from "babylonjs/Meshes/mesh";
  45497. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45498. import { EasingFunction } from "babylonjs/Animations/easing";
  45499. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45500. import "babylonjs/Meshes/Builders/groundBuilder";
  45501. import "babylonjs/Meshes/Builders/torusBuilder";
  45502. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45503. import "babylonjs/Gamepads/gamepadSceneComponent";
  45504. import "babylonjs/Animations/animatable";
  45505. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45506. /**
  45507. * Options to modify the vr teleportation behavior.
  45508. */
  45509. export interface VRTeleportationOptions {
  45510. /**
  45511. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45512. */
  45513. floorMeshName?: string;
  45514. /**
  45515. * A list of meshes to be used as the teleportation floor. (default: empty)
  45516. */
  45517. floorMeshes?: Mesh[];
  45518. /**
  45519. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45520. */
  45521. teleportationMode?: number;
  45522. /**
  45523. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45524. */
  45525. teleportationTime?: number;
  45526. /**
  45527. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45528. */
  45529. teleportationSpeed?: number;
  45530. /**
  45531. * The easing function used in the animation or null for Linear. (default CircleEase)
  45532. */
  45533. easingFunction?: EasingFunction;
  45534. }
  45535. /**
  45536. * Options to modify the vr experience helper's behavior.
  45537. */
  45538. export interface VRExperienceHelperOptions extends WebVROptions {
  45539. /**
  45540. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45541. */
  45542. createDeviceOrientationCamera?: boolean;
  45543. /**
  45544. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45545. */
  45546. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45547. /**
  45548. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45549. */
  45550. laserToggle?: boolean;
  45551. /**
  45552. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45553. */
  45554. floorMeshes?: Mesh[];
  45555. /**
  45556. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45557. */
  45558. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45559. /**
  45560. * Defines if WebXR should be used instead of WebVR (if available)
  45561. */
  45562. useXR?: boolean;
  45563. }
  45564. /**
  45565. * Event containing information after VR has been entered
  45566. */
  45567. export class OnAfterEnteringVRObservableEvent {
  45568. /**
  45569. * If entering vr was successful
  45570. */
  45571. success: boolean;
  45572. }
  45573. /**
  45574. * Helps to quickly add VR support to an existing scene.
  45575. * See http://doc.babylonjs.com/how_to/webvr_helper
  45576. */
  45577. export class VRExperienceHelper {
  45578. /** Options to modify the vr experience helper's behavior. */
  45579. webVROptions: VRExperienceHelperOptions;
  45580. private _scene;
  45581. private _position;
  45582. private _btnVR;
  45583. private _btnVRDisplayed;
  45584. private _webVRsupported;
  45585. private _webVRready;
  45586. private _webVRrequesting;
  45587. private _webVRpresenting;
  45588. private _hasEnteredVR;
  45589. private _fullscreenVRpresenting;
  45590. private _inputElement;
  45591. private _webVRCamera;
  45592. private _vrDeviceOrientationCamera;
  45593. private _deviceOrientationCamera;
  45594. private _existingCamera;
  45595. private _onKeyDown;
  45596. private _onVrDisplayPresentChange;
  45597. private _onVRDisplayChanged;
  45598. private _onVRRequestPresentStart;
  45599. private _onVRRequestPresentComplete;
  45600. /**
  45601. * 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)
  45602. */
  45603. enableGazeEvenWhenNoPointerLock: boolean;
  45604. /**
  45605. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45606. */
  45607. exitVROnDoubleTap: boolean;
  45608. /**
  45609. * Observable raised right before entering VR.
  45610. */
  45611. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45612. /**
  45613. * Observable raised when entering VR has completed.
  45614. */
  45615. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45616. /**
  45617. * Observable raised when exiting VR.
  45618. */
  45619. onExitingVRObservable: Observable<VRExperienceHelper>;
  45620. /**
  45621. * Observable raised when controller mesh is loaded.
  45622. */
  45623. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45624. /** Return this.onEnteringVRObservable
  45625. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45626. */
  45627. get onEnteringVR(): Observable<VRExperienceHelper>;
  45628. /** Return this.onExitingVRObservable
  45629. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45630. */
  45631. get onExitingVR(): Observable<VRExperienceHelper>;
  45632. /** Return this.onControllerMeshLoadedObservable
  45633. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45634. */
  45635. get onControllerMeshLoaded(): Observable<WebVRController>;
  45636. private _rayLength;
  45637. private _useCustomVRButton;
  45638. private _teleportationRequested;
  45639. private _teleportActive;
  45640. private _floorMeshName;
  45641. private _floorMeshesCollection;
  45642. private _teleportationMode;
  45643. private _teleportationTime;
  45644. private _teleportationSpeed;
  45645. private _teleportationEasing;
  45646. private _rotationAllowed;
  45647. private _teleportBackwardsVector;
  45648. private _teleportationTarget;
  45649. private _isDefaultTeleportationTarget;
  45650. private _postProcessMove;
  45651. private _teleportationFillColor;
  45652. private _teleportationBorderColor;
  45653. private _rotationAngle;
  45654. private _haloCenter;
  45655. private _cameraGazer;
  45656. private _padSensibilityUp;
  45657. private _padSensibilityDown;
  45658. private _leftController;
  45659. private _rightController;
  45660. private _gazeColor;
  45661. private _laserColor;
  45662. private _pickedLaserColor;
  45663. private _pickedGazeColor;
  45664. /**
  45665. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45666. */
  45667. onNewMeshSelected: Observable<AbstractMesh>;
  45668. /**
  45669. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45670. * This observable will provide the mesh and the controller used to select the mesh
  45671. */
  45672. onMeshSelectedWithController: Observable<{
  45673. mesh: AbstractMesh;
  45674. controller: WebVRController;
  45675. }>;
  45676. /**
  45677. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45678. */
  45679. onNewMeshPicked: Observable<PickingInfo>;
  45680. private _circleEase;
  45681. /**
  45682. * Observable raised before camera teleportation
  45683. */
  45684. onBeforeCameraTeleport: Observable<Vector3>;
  45685. /**
  45686. * Observable raised after camera teleportation
  45687. */
  45688. onAfterCameraTeleport: Observable<Vector3>;
  45689. /**
  45690. * Observable raised when current selected mesh gets unselected
  45691. */
  45692. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45693. private _raySelectionPredicate;
  45694. /**
  45695. * To be optionaly changed by user to define custom ray selection
  45696. */
  45697. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45698. /**
  45699. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45700. */
  45701. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45702. /**
  45703. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45704. */
  45705. teleportationEnabled: boolean;
  45706. private _defaultHeight;
  45707. private _teleportationInitialized;
  45708. private _interactionsEnabled;
  45709. private _interactionsRequested;
  45710. private _displayGaze;
  45711. private _displayLaserPointer;
  45712. /**
  45713. * The mesh used to display where the user is going to teleport.
  45714. */
  45715. get teleportationTarget(): Mesh;
  45716. /**
  45717. * Sets the mesh to be used to display where the user is going to teleport.
  45718. */
  45719. set teleportationTarget(value: Mesh);
  45720. /**
  45721. * 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
  45722. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45723. * See http://doc.babylonjs.com/resources/baking_transformations
  45724. */
  45725. get gazeTrackerMesh(): Mesh;
  45726. set gazeTrackerMesh(value: Mesh);
  45727. /**
  45728. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45729. */
  45730. updateGazeTrackerScale: boolean;
  45731. /**
  45732. * If the gaze trackers color should be updated when selecting meshes
  45733. */
  45734. updateGazeTrackerColor: boolean;
  45735. /**
  45736. * If the controller laser color should be updated when selecting meshes
  45737. */
  45738. updateControllerLaserColor: boolean;
  45739. /**
  45740. * The gaze tracking mesh corresponding to the left controller
  45741. */
  45742. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45743. /**
  45744. * The gaze tracking mesh corresponding to the right controller
  45745. */
  45746. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45747. /**
  45748. * If the ray of the gaze should be displayed.
  45749. */
  45750. get displayGaze(): boolean;
  45751. /**
  45752. * Sets if the ray of the gaze should be displayed.
  45753. */
  45754. set displayGaze(value: boolean);
  45755. /**
  45756. * If the ray of the LaserPointer should be displayed.
  45757. */
  45758. get displayLaserPointer(): boolean;
  45759. /**
  45760. * Sets if the ray of the LaserPointer should be displayed.
  45761. */
  45762. set displayLaserPointer(value: boolean);
  45763. /**
  45764. * The deviceOrientationCamera used as the camera when not in VR.
  45765. */
  45766. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45767. /**
  45768. * Based on the current WebVR support, returns the current VR camera used.
  45769. */
  45770. get currentVRCamera(): Nullable<Camera>;
  45771. /**
  45772. * The webVRCamera which is used when in VR.
  45773. */
  45774. get webVRCamera(): WebVRFreeCamera;
  45775. /**
  45776. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45777. */
  45778. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45779. /**
  45780. * The html button that is used to trigger entering into VR.
  45781. */
  45782. get vrButton(): Nullable<HTMLButtonElement>;
  45783. private get _teleportationRequestInitiated();
  45784. /**
  45785. * Defines wether or not Pointer lock should be requested when switching to
  45786. * full screen.
  45787. */
  45788. requestPointerLockOnFullScreen: boolean;
  45789. /**
  45790. * If asking to force XR, this will be populated with the default xr experience
  45791. */
  45792. xr: WebXRDefaultExperience;
  45793. /**
  45794. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45795. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45796. */
  45797. xrTestDone: boolean;
  45798. /**
  45799. * Instantiates a VRExperienceHelper.
  45800. * Helps to quickly add VR support to an existing scene.
  45801. * @param scene The scene the VRExperienceHelper belongs to.
  45802. * @param webVROptions Options to modify the vr experience helper's behavior.
  45803. */
  45804. constructor(scene: Scene,
  45805. /** Options to modify the vr experience helper's behavior. */
  45806. webVROptions?: VRExperienceHelperOptions);
  45807. private completeVRInit;
  45808. private _onDefaultMeshLoaded;
  45809. private _onResize;
  45810. private _onFullscreenChange;
  45811. /**
  45812. * Gets a value indicating if we are currently in VR mode.
  45813. */
  45814. get isInVRMode(): boolean;
  45815. private onVrDisplayPresentChange;
  45816. private onVRDisplayChanged;
  45817. private moveButtonToBottomRight;
  45818. private displayVRButton;
  45819. private updateButtonVisibility;
  45820. private _cachedAngularSensibility;
  45821. /**
  45822. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45823. * Otherwise, will use the fullscreen API.
  45824. */
  45825. enterVR(): void;
  45826. /**
  45827. * Attempt to exit VR, or fullscreen.
  45828. */
  45829. exitVR(): void;
  45830. /**
  45831. * The position of the vr experience helper.
  45832. */
  45833. get position(): Vector3;
  45834. /**
  45835. * Sets the position of the vr experience helper.
  45836. */
  45837. set position(value: Vector3);
  45838. /**
  45839. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45840. */
  45841. enableInteractions(): void;
  45842. private get _noControllerIsActive();
  45843. private beforeRender;
  45844. private _isTeleportationFloor;
  45845. /**
  45846. * Adds a floor mesh to be used for teleportation.
  45847. * @param floorMesh the mesh to be used for teleportation.
  45848. */
  45849. addFloorMesh(floorMesh: Mesh): void;
  45850. /**
  45851. * Removes a floor mesh from being used for teleportation.
  45852. * @param floorMesh the mesh to be removed.
  45853. */
  45854. removeFloorMesh(floorMesh: Mesh): void;
  45855. /**
  45856. * Enables interactions and teleportation using the VR controllers and gaze.
  45857. * @param vrTeleportationOptions options to modify teleportation behavior.
  45858. */
  45859. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45860. private _onNewGamepadConnected;
  45861. private _tryEnableInteractionOnController;
  45862. private _onNewGamepadDisconnected;
  45863. private _enableInteractionOnController;
  45864. private _checkTeleportWithRay;
  45865. private _checkRotate;
  45866. private _checkTeleportBackwards;
  45867. private _enableTeleportationOnController;
  45868. private _createTeleportationCircles;
  45869. private _displayTeleportationTarget;
  45870. private _hideTeleportationTarget;
  45871. private _rotateCamera;
  45872. private _moveTeleportationSelectorTo;
  45873. private _workingVector;
  45874. private _workingQuaternion;
  45875. private _workingMatrix;
  45876. /**
  45877. * Time Constant Teleportation Mode
  45878. */
  45879. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45880. /**
  45881. * Speed Constant Teleportation Mode
  45882. */
  45883. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45884. /**
  45885. * Teleports the users feet to the desired location
  45886. * @param location The location where the user's feet should be placed
  45887. */
  45888. teleportCamera(location: Vector3): void;
  45889. private _convertNormalToDirectionOfRay;
  45890. private _castRayAndSelectObject;
  45891. private _notifySelectedMeshUnselected;
  45892. /**
  45893. * Permanently set new colors for the laser pointer
  45894. * @param color the new laser color
  45895. * @param pickedColor the new laser color when picked mesh detected
  45896. */
  45897. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45898. /**
  45899. * Permanently set new colors for the gaze pointer
  45900. * @param color the new gaze color
  45901. * @param pickedColor the new gaze color when picked mesh detected
  45902. */
  45903. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45904. /**
  45905. * Sets the color of the laser ray from the vr controllers.
  45906. * @param color new color for the ray.
  45907. */
  45908. changeLaserColor(color: Color3): void;
  45909. /**
  45910. * Sets the color of the ray from the vr headsets gaze.
  45911. * @param color new color for the ray.
  45912. */
  45913. changeGazeColor(color: Color3): void;
  45914. /**
  45915. * Exits VR and disposes of the vr experience helper
  45916. */
  45917. dispose(): void;
  45918. /**
  45919. * Gets the name of the VRExperienceHelper class
  45920. * @returns "VRExperienceHelper"
  45921. */
  45922. getClassName(): string;
  45923. }
  45924. }
  45925. declare module "babylonjs/Cameras/VR/index" {
  45926. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45927. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45928. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45929. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45930. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45931. export * from "babylonjs/Cameras/VR/webVRCamera";
  45932. }
  45933. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45934. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45935. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45936. import { Observable } from "babylonjs/Misc/observable";
  45937. import { Matrix } from "babylonjs/Maths/math.vector";
  45938. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45939. /**
  45940. * Options used for hit testing
  45941. */
  45942. export interface IWebXRHitTestOptions {
  45943. /**
  45944. * Only test when user interacted with the scene. Default - hit test every frame
  45945. */
  45946. testOnPointerDownOnly?: boolean;
  45947. /**
  45948. * The node to use to transform the local results to world coordinates
  45949. */
  45950. worldParentNode?: TransformNode;
  45951. }
  45952. /**
  45953. * Interface defining the babylon result of raycasting/hit-test
  45954. */
  45955. export interface IWebXRHitResult {
  45956. /**
  45957. * The native hit test result
  45958. */
  45959. xrHitResult: XRHitResult;
  45960. /**
  45961. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45962. */
  45963. transformationMatrix: Matrix;
  45964. }
  45965. /**
  45966. * The currently-working hit-test module.
  45967. * Hit test (or raycasting) is used to interact with the real world.
  45968. * For further information read here - https://github.com/immersive-web/hit-test
  45969. */
  45970. export class WebXRHitTestLegacy implements IWebXRFeature {
  45971. private _xrSessionManager;
  45972. /**
  45973. * options to use when constructing this feature
  45974. */
  45975. readonly options: IWebXRHitTestOptions;
  45976. /**
  45977. * The module's name
  45978. */
  45979. static readonly Name: string;
  45980. /**
  45981. * The (Babylon) version of this module.
  45982. * This is an integer representing the implementation version.
  45983. * This number does not correspond to the webxr specs version
  45984. */
  45985. static readonly Version: number;
  45986. /**
  45987. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45988. * @param event the (select) event to use to select with
  45989. * @param referenceSpace the reference space to use for this hit test
  45990. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45991. */
  45992. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45993. /**
  45994. * execute a hit test with an XR Ray
  45995. *
  45996. * @param xrSession a native xrSession that will execute this hit test
  45997. * @param xrRay the ray (position and direction) to use for raycasting
  45998. * @param referenceSpace native XR reference space to use for the hit-test
  45999. * @param filter filter function that will filter the results
  46000. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46001. */
  46002. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  46003. /**
  46004. * Triggered when new babylon (transformed) hit test results are available
  46005. */
  46006. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  46007. /**
  46008. * Creates a new instance of the (legacy version) hit test feature
  46009. * @param _xrSessionManager an instance of WebXRSessionManager
  46010. * @param options options to use when constructing this feature
  46011. */
  46012. constructor(_xrSessionManager: WebXRSessionManager,
  46013. /**
  46014. * options to use when constructing this feature
  46015. */
  46016. options?: IWebXRHitTestOptions);
  46017. private _onSelectEnabled;
  46018. private _xrFrameObserver;
  46019. private _attached;
  46020. /**
  46021. * Populated with the last native XR Hit Results
  46022. */
  46023. lastNativeXRHitResults: XRHitResult[];
  46024. /**
  46025. * attach this feature
  46026. * Will usually be called by the features manager
  46027. *
  46028. * @returns true if successful.
  46029. */
  46030. attach(): boolean;
  46031. /**
  46032. * detach this feature.
  46033. * Will usually be called by the features manager
  46034. *
  46035. * @returns true if successful.
  46036. */
  46037. detach(): boolean;
  46038. private _onHitTestResults;
  46039. private _onSelect;
  46040. /**
  46041. * Dispose this feature and all of the resources attached
  46042. */
  46043. dispose(): void;
  46044. }
  46045. }
  46046. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  46047. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46048. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46049. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46050. import { Observable } from "babylonjs/Misc/observable";
  46051. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  46052. /**
  46053. * Options used in the plane detector module
  46054. */
  46055. export interface IWebXRPlaneDetectorOptions {
  46056. /**
  46057. * The node to use to transform the local results to world coordinates
  46058. */
  46059. worldParentNode?: TransformNode;
  46060. }
  46061. /**
  46062. * A babylon interface for a webxr plane.
  46063. * A Plane is actually a polygon, built from N points in space
  46064. */
  46065. export interface IWebXRPlane {
  46066. /**
  46067. * a babylon-assigned ID for this polygon
  46068. */
  46069. id: number;
  46070. /**
  46071. * the native xr-plane object
  46072. */
  46073. xrPlane: XRPlane;
  46074. /**
  46075. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  46076. */
  46077. polygonDefinition: Array<Vector3>;
  46078. /**
  46079. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  46080. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  46081. */
  46082. transformationMatrix: Matrix;
  46083. }
  46084. /**
  46085. * The plane detector is used to detect planes in the real world when in AR
  46086. * For more information see https://github.com/immersive-web/real-world-geometry/
  46087. */
  46088. export class WebXRPlaneDetector implements IWebXRFeature {
  46089. private _xrSessionManager;
  46090. private _options;
  46091. /**
  46092. * The module's name
  46093. */
  46094. static readonly Name: string;
  46095. /**
  46096. * The (Babylon) version of this module.
  46097. * This is an integer representing the implementation version.
  46098. * This number does not correspond to the webxr specs version
  46099. */
  46100. static readonly Version: number;
  46101. /**
  46102. * Observers registered here will be executed when a new plane was added to the session
  46103. */
  46104. onPlaneAddedObservable: Observable<IWebXRPlane>;
  46105. /**
  46106. * Observers registered here will be executed when a plane is no longer detected in the session
  46107. */
  46108. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  46109. /**
  46110. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  46111. * This can execute N times every frame
  46112. */
  46113. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  46114. private _enabled;
  46115. private _attached;
  46116. private _detectedPlanes;
  46117. private _lastFrameDetected;
  46118. private _observerTracked;
  46119. /**
  46120. * construct a new Plane Detector
  46121. * @param _xrSessionManager an instance of xr Session manager
  46122. * @param _options configuration to use when constructing this feature
  46123. */
  46124. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  46125. /**
  46126. * attach this feature
  46127. * Will usually be called by the features manager
  46128. *
  46129. * @returns true if successful.
  46130. */
  46131. attach(): boolean;
  46132. /**
  46133. * detach this feature.
  46134. * Will usually be called by the features manager
  46135. *
  46136. * @returns true if successful.
  46137. */
  46138. detach(): boolean;
  46139. /**
  46140. * Dispose this feature and all of the resources attached
  46141. */
  46142. dispose(): void;
  46143. private _updatePlaneWithXRPlane;
  46144. /**
  46145. * avoiding using Array.find for global support.
  46146. * @param xrPlane the plane to find in the array
  46147. */
  46148. private findIndexInPlaneArray;
  46149. }
  46150. }
  46151. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  46152. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46153. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46154. import { Observable } from "babylonjs/Misc/observable";
  46155. import { Matrix } from "babylonjs/Maths/math.vector";
  46156. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46157. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46158. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46159. /**
  46160. * Configuration options of the anchor system
  46161. */
  46162. export interface IWebXRAnchorSystemOptions {
  46163. /**
  46164. * a node that will be used to convert local to world coordinates
  46165. */
  46166. worldParentNode?: TransformNode;
  46167. /**
  46168. * should the anchor system use plane detection.
  46169. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46170. */
  46171. usePlaneDetection?: boolean;
  46172. /**
  46173. * Should a new anchor be added every time a select event is triggered
  46174. */
  46175. addAnchorOnSelect?: boolean;
  46176. }
  46177. /**
  46178. * A babylon container for an XR Anchor
  46179. */
  46180. export interface IWebXRAnchor {
  46181. /**
  46182. * A babylon-assigned ID for this anchor
  46183. */
  46184. id: number;
  46185. /**
  46186. * The native anchor object
  46187. */
  46188. xrAnchor: XRAnchor;
  46189. /**
  46190. * Transformation matrix to apply to an object attached to this anchor
  46191. */
  46192. transformationMatrix: Matrix;
  46193. }
  46194. /**
  46195. * An implementation of the anchor system of WebXR.
  46196. * Note that the current documented implementation is not available in any browser. Future implementations
  46197. * will use the frame to create an anchor and not the session or a detected plane
  46198. * For further information see https://github.com/immersive-web/anchors/
  46199. */
  46200. export class WebXRAnchorSystem implements IWebXRFeature {
  46201. private _xrSessionManager;
  46202. private _options;
  46203. /**
  46204. * The module's name
  46205. */
  46206. static readonly Name: string;
  46207. /**
  46208. * The (Babylon) version of this module.
  46209. * This is an integer representing the implementation version.
  46210. * This number does not correspond to the webxr specs version
  46211. */
  46212. static readonly Version: number;
  46213. /**
  46214. * Observers registered here will be executed when a new anchor was added to the session
  46215. */
  46216. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46217. /**
  46218. * Observers registered here will be executed when an existing anchor updates
  46219. * This can execute N times every frame
  46220. */
  46221. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46222. /**
  46223. * Observers registered here will be executed when an anchor was removed from the session
  46224. */
  46225. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46226. private _planeDetector;
  46227. private _hitTestModule;
  46228. private _enabled;
  46229. private _attached;
  46230. private _trackedAnchors;
  46231. private _lastFrameDetected;
  46232. private _observerTracked;
  46233. /**
  46234. * constructs a new anchor system
  46235. * @param _xrSessionManager an instance of WebXRSessionManager
  46236. * @param _options configuration object for this feature
  46237. */
  46238. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46239. /**
  46240. * set the plane detector to use in order to create anchors from frames
  46241. * @param planeDetector the plane-detector module to use
  46242. * @param enable enable plane-anchors. default is true
  46243. */
  46244. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46245. /**
  46246. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46247. * @param hitTestModule the hit-test module to use.
  46248. */
  46249. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46250. /**
  46251. * attach this feature
  46252. * Will usually be called by the features manager
  46253. *
  46254. * @returns true if successful.
  46255. */
  46256. attach(): boolean;
  46257. /**
  46258. * detach this feature.
  46259. * Will usually be called by the features manager
  46260. *
  46261. * @returns true if successful.
  46262. */
  46263. detach(): boolean;
  46264. /**
  46265. * Dispose this feature and all of the resources attached
  46266. */
  46267. dispose(): void;
  46268. private _onSelect;
  46269. /**
  46270. * Add anchor at a specific XR point.
  46271. *
  46272. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46273. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46274. * @returns a promise the fulfills when the anchor was created
  46275. */
  46276. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46277. private _updateAnchorWithXRFrame;
  46278. /**
  46279. * avoiding using Array.find for global support.
  46280. * @param xrAnchor the plane to find in the array
  46281. */
  46282. private _findIndexInAnchorArray;
  46283. }
  46284. }
  46285. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46286. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46287. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46289. import { Observable } from "babylonjs/Misc/observable";
  46290. /**
  46291. * Options interface for the background remover plugin
  46292. */
  46293. export interface IWebXRBackgroundRemoverOptions {
  46294. /**
  46295. * don't disable the environment helper
  46296. */
  46297. ignoreEnvironmentHelper?: boolean;
  46298. /**
  46299. * flags to configure the removal of the environment helper.
  46300. * If not set, the entire background will be removed. If set, flags should be set as well.
  46301. */
  46302. environmentHelperRemovalFlags?: {
  46303. /**
  46304. * Should the skybox be removed (default false)
  46305. */
  46306. skyBox?: boolean;
  46307. /**
  46308. * Should the ground be removed (default false)
  46309. */
  46310. ground?: boolean;
  46311. };
  46312. /**
  46313. * Further background meshes to disable when entering AR
  46314. */
  46315. backgroundMeshes?: AbstractMesh[];
  46316. }
  46317. /**
  46318. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46319. */
  46320. export class WebXRBackgroundRemover implements IWebXRFeature {
  46321. private _xrSessionManager;
  46322. /**
  46323. * read-only options to be used in this module
  46324. */
  46325. readonly options: IWebXRBackgroundRemoverOptions;
  46326. /**
  46327. * The module's name
  46328. */
  46329. static readonly Name: string;
  46330. /**
  46331. * The (Babylon) version of this module.
  46332. * This is an integer representing the implementation version.
  46333. * This number does not correspond to the webxr specs version
  46334. */
  46335. static readonly Version: number;
  46336. /**
  46337. * registered observers will be triggered when the background state changes
  46338. */
  46339. onBackgroundStateChangedObservable: Observable<boolean>;
  46340. /**
  46341. * constructs a new background remover module
  46342. * @param _xrSessionManager the session manager for this module
  46343. * @param options read-only options to be used in this module
  46344. */
  46345. constructor(_xrSessionManager: WebXRSessionManager,
  46346. /**
  46347. * read-only options to be used in this module
  46348. */
  46349. options?: IWebXRBackgroundRemoverOptions);
  46350. /**
  46351. * attach this feature
  46352. * Will usually be called by the features manager
  46353. *
  46354. * @returns true if successful.
  46355. */
  46356. attach(): boolean;
  46357. /**
  46358. * detach this feature.
  46359. * Will usually be called by the features manager
  46360. *
  46361. * @returns true if successful.
  46362. */
  46363. detach(): boolean;
  46364. private _setBackgroundState;
  46365. /**
  46366. * Dispose this feature and all of the resources attached
  46367. */
  46368. dispose(): void;
  46369. }
  46370. }
  46371. declare module "babylonjs/Cameras/XR/features/index" {
  46372. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46373. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46374. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46375. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46376. }
  46377. declare module "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController" {
  46378. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46380. import { Scene } from "babylonjs/scene";
  46381. /**
  46382. * The motion controller class for all microsoft mixed reality controllers
  46383. */
  46384. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  46385. /**
  46386. * The base url used to load the left and right controller models
  46387. */
  46388. static MODEL_BASE_URL: string;
  46389. /**
  46390. * The name of the left controller model file
  46391. */
  46392. static MODEL_LEFT_FILENAME: string;
  46393. /**
  46394. * The name of the right controller model file
  46395. */
  46396. static MODEL_RIGHT_FILENAME: string;
  46397. profileId: string;
  46398. protected readonly _mapping: {
  46399. defaultButton: {
  46400. "valueNodeName": string;
  46401. "unpressedNodeName": string;
  46402. "pressedNodeName": string;
  46403. };
  46404. defaultAxis: {
  46405. "valueNodeName": string;
  46406. "minNodeName": string;
  46407. "maxNodeName": string;
  46408. };
  46409. buttons: {
  46410. "xr-standard-trigger": {
  46411. "rootNodeName": string;
  46412. "componentProperty": string;
  46413. "states": string[];
  46414. };
  46415. "xr-standard-squeeze": {
  46416. "rootNodeName": string;
  46417. "componentProperty": string;
  46418. "states": string[];
  46419. };
  46420. "xr-standard-touchpad": {
  46421. "rootNodeName": string;
  46422. "labelAnchorNodeName": string;
  46423. "touchPointNodeName": string;
  46424. };
  46425. "xr-standard-thumbstick": {
  46426. "rootNodeName": string;
  46427. "componentProperty": string;
  46428. "states": string[];
  46429. };
  46430. "menu": {
  46431. "rootNodeName": string;
  46432. "componentProperty": string;
  46433. "states": string[];
  46434. };
  46435. };
  46436. axes: {
  46437. "xr-standard-touchpad": {
  46438. "x-axis": {
  46439. "rootNodeName": string;
  46440. };
  46441. "y-axis": {
  46442. "rootNodeName": string;
  46443. };
  46444. };
  46445. "xr-standard-thumbstick": {
  46446. "x-axis": {
  46447. "rootNodeName": string;
  46448. };
  46449. "y-axis": {
  46450. "rootNodeName": string;
  46451. };
  46452. };
  46453. };
  46454. };
  46455. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  46456. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46457. private _getChildByName;
  46458. private _getImmediateChildByName;
  46459. protected _getFilenameAndPath(): {
  46460. filename: string;
  46461. path: string;
  46462. };
  46463. protected _updateModel(): void;
  46464. protected _getModelLoadingConstraints(): boolean;
  46465. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46466. }
  46467. }
  46468. declare module "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController" {
  46469. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46471. import { Scene } from "babylonjs/scene";
  46472. /**
  46473. * The motion controller class for oculus touch (quest, rift).
  46474. * This class supports legacy mapping as well the standard xr mapping
  46475. */
  46476. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  46477. private _forceLegacyControllers;
  46478. /**
  46479. * The base url used to load the left and right controller models
  46480. */
  46481. static MODEL_BASE_URL: string;
  46482. /**
  46483. * The name of the left controller model file
  46484. */
  46485. static MODEL_LEFT_FILENAME: string;
  46486. /**
  46487. * The name of the right controller model file
  46488. */
  46489. static MODEL_RIGHT_FILENAME: string;
  46490. /**
  46491. * Base Url for the Quest controller model.
  46492. */
  46493. static QUEST_MODEL_BASE_URL: string;
  46494. profileId: string;
  46495. private _modelRootNode;
  46496. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  46497. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46498. protected _getFilenameAndPath(): {
  46499. filename: string;
  46500. path: string;
  46501. };
  46502. /**
  46503. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  46504. * between the touch and touch 2.
  46505. */
  46506. private _isQuest;
  46507. protected _updateModel(): void;
  46508. protected _getModelLoadingConstraints(): boolean;
  46509. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46510. }
  46511. }
  46512. declare module "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController" {
  46513. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46514. import { Scene } from "babylonjs/scene";
  46515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46516. /**
  46517. * The motion controller class for the standard HTC-Vive controllers
  46518. */
  46519. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  46520. /**
  46521. * The base url used to load the left and right controller models
  46522. */
  46523. static MODEL_BASE_URL: string;
  46524. /**
  46525. * File name for the controller model.
  46526. */
  46527. static MODEL_FILENAME: string;
  46528. profileId: string;
  46529. private _modelRootNode;
  46530. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  46531. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46532. protected _getFilenameAndPath(): {
  46533. filename: string;
  46534. path: string;
  46535. };
  46536. protected _updateModel(): void;
  46537. protected _getModelLoadingConstraints(): boolean;
  46538. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46539. }
  46540. }
  46541. declare module "babylonjs/Cameras/XR/motionController/index" {
  46542. export * from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46543. export * from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  46544. export * from "babylonjs/Cameras/XR/motionController/webXRGenericMotionController";
  46545. export * from "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController";
  46546. export * from "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager";
  46547. export * from "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController";
  46548. export * from "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController";
  46549. }
  46550. declare module "babylonjs/Cameras/XR/index" {
  46551. export * from "babylonjs/Cameras/XR/webXRCamera";
  46552. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46553. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46554. export * from "babylonjs/Cameras/XR/webXRInput";
  46555. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46556. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46557. export * from "babylonjs/Cameras/XR/webXRController";
  46558. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46559. export * from "babylonjs/Cameras/XR/webXRTypes";
  46560. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46561. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46562. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46563. export * from "babylonjs/Cameras/XR/features/index";
  46564. export * from "babylonjs/Cameras/XR/motionController/index";
  46565. }
  46566. declare module "babylonjs/Cameras/RigModes/index" {
  46567. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46568. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46569. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46570. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46571. }
  46572. declare module "babylonjs/Cameras/index" {
  46573. export * from "babylonjs/Cameras/Inputs/index";
  46574. export * from "babylonjs/Cameras/cameraInputsManager";
  46575. export * from "babylonjs/Cameras/camera";
  46576. export * from "babylonjs/Cameras/targetCamera";
  46577. export * from "babylonjs/Cameras/freeCamera";
  46578. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46579. export * from "babylonjs/Cameras/touchCamera";
  46580. export * from "babylonjs/Cameras/arcRotateCamera";
  46581. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46582. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46583. export * from "babylonjs/Cameras/flyCamera";
  46584. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46585. export * from "babylonjs/Cameras/followCamera";
  46586. export * from "babylonjs/Cameras/followCameraInputsManager";
  46587. export * from "babylonjs/Cameras/gamepadCamera";
  46588. export * from "babylonjs/Cameras/Stereoscopic/index";
  46589. export * from "babylonjs/Cameras/universalCamera";
  46590. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46591. export * from "babylonjs/Cameras/VR/index";
  46592. export * from "babylonjs/Cameras/XR/index";
  46593. export * from "babylonjs/Cameras/RigModes/index";
  46594. }
  46595. declare module "babylonjs/Collisions/index" {
  46596. export * from "babylonjs/Collisions/collider";
  46597. export * from "babylonjs/Collisions/collisionCoordinator";
  46598. export * from "babylonjs/Collisions/pickingInfo";
  46599. export * from "babylonjs/Collisions/intersectionInfo";
  46600. export * from "babylonjs/Collisions/meshCollisionData";
  46601. }
  46602. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46603. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46604. import { Vector3 } from "babylonjs/Maths/math.vector";
  46605. import { Ray } from "babylonjs/Culling/ray";
  46606. import { Plane } from "babylonjs/Maths/math.plane";
  46607. /**
  46608. * Contains an array of blocks representing the octree
  46609. */
  46610. export interface IOctreeContainer<T> {
  46611. /**
  46612. * Blocks within the octree
  46613. */
  46614. blocks: Array<OctreeBlock<T>>;
  46615. }
  46616. /**
  46617. * Class used to store a cell in an octree
  46618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46619. */
  46620. export class OctreeBlock<T> {
  46621. /**
  46622. * Gets the content of the current block
  46623. */
  46624. entries: T[];
  46625. /**
  46626. * Gets the list of block children
  46627. */
  46628. blocks: Array<OctreeBlock<T>>;
  46629. private _depth;
  46630. private _maxDepth;
  46631. private _capacity;
  46632. private _minPoint;
  46633. private _maxPoint;
  46634. private _boundingVectors;
  46635. private _creationFunc;
  46636. /**
  46637. * Creates a new block
  46638. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46639. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46640. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46641. * @param depth defines the current depth of this block in the octree
  46642. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46643. * @param creationFunc defines a callback to call when an element is added to the block
  46644. */
  46645. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46646. /**
  46647. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46648. */
  46649. get capacity(): number;
  46650. /**
  46651. * Gets the minimum vector (in world space) of the block's bounding box
  46652. */
  46653. get minPoint(): Vector3;
  46654. /**
  46655. * Gets the maximum vector (in world space) of the block's bounding box
  46656. */
  46657. get maxPoint(): Vector3;
  46658. /**
  46659. * Add a new element to this block
  46660. * @param entry defines the element to add
  46661. */
  46662. addEntry(entry: T): void;
  46663. /**
  46664. * Remove an element from this block
  46665. * @param entry defines the element to remove
  46666. */
  46667. removeEntry(entry: T): void;
  46668. /**
  46669. * Add an array of elements to this block
  46670. * @param entries defines the array of elements to add
  46671. */
  46672. addEntries(entries: T[]): void;
  46673. /**
  46674. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46675. * @param frustumPlanes defines the frustum planes to test
  46676. * @param selection defines the array to store current content if selection is positive
  46677. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46678. */
  46679. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46680. /**
  46681. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46682. * @param sphereCenter defines the bounding sphere center
  46683. * @param sphereRadius defines the bounding sphere radius
  46684. * @param selection defines the array to store current content if selection is positive
  46685. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46686. */
  46687. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46688. /**
  46689. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46690. * @param ray defines the ray to test with
  46691. * @param selection defines the array to store current content if selection is positive
  46692. */
  46693. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46694. /**
  46695. * Subdivide the content into child blocks (this block will then be empty)
  46696. */
  46697. createInnerBlocks(): void;
  46698. /**
  46699. * @hidden
  46700. */
  46701. 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;
  46702. }
  46703. }
  46704. declare module "babylonjs/Culling/Octrees/octree" {
  46705. import { SmartArray } from "babylonjs/Misc/smartArray";
  46706. import { Vector3 } from "babylonjs/Maths/math.vector";
  46707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46709. import { Ray } from "babylonjs/Culling/ray";
  46710. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46711. import { Plane } from "babylonjs/Maths/math.plane";
  46712. /**
  46713. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46714. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46715. */
  46716. export class Octree<T> {
  46717. /** 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.) */
  46718. maxDepth: number;
  46719. /**
  46720. * Blocks within the octree containing objects
  46721. */
  46722. blocks: Array<OctreeBlock<T>>;
  46723. /**
  46724. * Content stored in the octree
  46725. */
  46726. dynamicContent: T[];
  46727. private _maxBlockCapacity;
  46728. private _selectionContent;
  46729. private _creationFunc;
  46730. /**
  46731. * Creates a octree
  46732. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46733. * @param creationFunc function to be used to instatiate the octree
  46734. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46735. * @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.)
  46736. */
  46737. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46738. /** 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.) */
  46739. maxDepth?: number);
  46740. /**
  46741. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46742. * @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);
  46743. * @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);
  46744. * @param entries meshes to be added to the octree blocks
  46745. */
  46746. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46747. /**
  46748. * Adds a mesh to the octree
  46749. * @param entry Mesh to add to the octree
  46750. */
  46751. addMesh(entry: T): void;
  46752. /**
  46753. * Remove an element from the octree
  46754. * @param entry defines the element to remove
  46755. */
  46756. removeMesh(entry: T): void;
  46757. /**
  46758. * Selects an array of meshes within the frustum
  46759. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46760. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46761. * @returns array of meshes within the frustum
  46762. */
  46763. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46764. /**
  46765. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46766. * @param sphereCenter defines the bounding sphere center
  46767. * @param sphereRadius defines the bounding sphere radius
  46768. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46769. * @returns an array of objects that intersect the sphere
  46770. */
  46771. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46772. /**
  46773. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46774. * @param ray defines the ray to test with
  46775. * @returns array of intersected objects
  46776. */
  46777. intersectsRay(ray: Ray): SmartArray<T>;
  46778. /**
  46779. * Adds a mesh into the octree block if it intersects the block
  46780. */
  46781. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46782. /**
  46783. * Adds a submesh into the octree block if it intersects the block
  46784. */
  46785. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46786. }
  46787. }
  46788. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46789. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46790. import { Scene } from "babylonjs/scene";
  46791. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46793. import { Ray } from "babylonjs/Culling/ray";
  46794. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46795. import { Collider } from "babylonjs/Collisions/collider";
  46796. module "babylonjs/scene" {
  46797. interface Scene {
  46798. /**
  46799. * @hidden
  46800. * Backing Filed
  46801. */
  46802. _selectionOctree: Octree<AbstractMesh>;
  46803. /**
  46804. * Gets the octree used to boost mesh selection (picking)
  46805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46806. */
  46807. selectionOctree: Octree<AbstractMesh>;
  46808. /**
  46809. * Creates or updates the octree used to boost selection (picking)
  46810. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46811. * @param maxCapacity defines the maximum capacity per leaf
  46812. * @param maxDepth defines the maximum depth of the octree
  46813. * @returns an octree of AbstractMesh
  46814. */
  46815. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46816. }
  46817. }
  46818. module "babylonjs/Meshes/abstractMesh" {
  46819. interface AbstractMesh {
  46820. /**
  46821. * @hidden
  46822. * Backing Field
  46823. */
  46824. _submeshesOctree: Octree<SubMesh>;
  46825. /**
  46826. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46827. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46828. * @param maxCapacity defines the maximum size of each block (64 by default)
  46829. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46830. * @returns the new octree
  46831. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46832. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46833. */
  46834. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46835. }
  46836. }
  46837. /**
  46838. * Defines the octree scene component responsible to manage any octrees
  46839. * in a given scene.
  46840. */
  46841. export class OctreeSceneComponent {
  46842. /**
  46843. * The component name help to identify the component in the list of scene components.
  46844. */
  46845. readonly name: string;
  46846. /**
  46847. * The scene the component belongs to.
  46848. */
  46849. scene: Scene;
  46850. /**
  46851. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46852. */
  46853. readonly checksIsEnabled: boolean;
  46854. /**
  46855. * Creates a new instance of the component for the given scene
  46856. * @param scene Defines the scene to register the component in
  46857. */
  46858. constructor(scene: Scene);
  46859. /**
  46860. * Registers the component in a given scene
  46861. */
  46862. register(): void;
  46863. /**
  46864. * Return the list of active meshes
  46865. * @returns the list of active meshes
  46866. */
  46867. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46868. /**
  46869. * Return the list of active sub meshes
  46870. * @param mesh The mesh to get the candidates sub meshes from
  46871. * @returns the list of active sub meshes
  46872. */
  46873. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46874. private _tempRay;
  46875. /**
  46876. * Return the list of sub meshes intersecting with a given local ray
  46877. * @param mesh defines the mesh to find the submesh for
  46878. * @param localRay defines the ray in local space
  46879. * @returns the list of intersecting sub meshes
  46880. */
  46881. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46882. /**
  46883. * Return the list of sub meshes colliding with a collider
  46884. * @param mesh defines the mesh to find the submesh for
  46885. * @param collider defines the collider to evaluate the collision against
  46886. * @returns the list of colliding sub meshes
  46887. */
  46888. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46889. /**
  46890. * Rebuilds the elements related to this component in case of
  46891. * context lost for instance.
  46892. */
  46893. rebuild(): void;
  46894. /**
  46895. * Disposes the component and the associated ressources.
  46896. */
  46897. dispose(): void;
  46898. }
  46899. }
  46900. declare module "babylonjs/Culling/Octrees/index" {
  46901. export * from "babylonjs/Culling/Octrees/octree";
  46902. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46903. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46904. }
  46905. declare module "babylonjs/Culling/index" {
  46906. export * from "babylonjs/Culling/boundingBox";
  46907. export * from "babylonjs/Culling/boundingInfo";
  46908. export * from "babylonjs/Culling/boundingSphere";
  46909. export * from "babylonjs/Culling/Octrees/index";
  46910. export * from "babylonjs/Culling/ray";
  46911. }
  46912. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46913. import { IDisposable, Scene } from "babylonjs/scene";
  46914. import { Nullable } from "babylonjs/types";
  46915. import { Observable } from "babylonjs/Misc/observable";
  46916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46917. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46918. import { Camera } from "babylonjs/Cameras/camera";
  46919. /**
  46920. * Renders a layer on top of an existing scene
  46921. */
  46922. export class UtilityLayerRenderer implements IDisposable {
  46923. /** the original scene that will be rendered on top of */
  46924. originalScene: Scene;
  46925. private _pointerCaptures;
  46926. private _lastPointerEvents;
  46927. private static _DefaultUtilityLayer;
  46928. private static _DefaultKeepDepthUtilityLayer;
  46929. private _sharedGizmoLight;
  46930. private _renderCamera;
  46931. /**
  46932. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46933. * @returns the camera that is used when rendering the utility layer
  46934. */
  46935. getRenderCamera(): Nullable<Camera>;
  46936. /**
  46937. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46938. * @param cam the camera that should be used when rendering the utility layer
  46939. */
  46940. setRenderCamera(cam: Nullable<Camera>): void;
  46941. /**
  46942. * @hidden
  46943. * Light which used by gizmos to get light shading
  46944. */
  46945. _getSharedGizmoLight(): HemisphericLight;
  46946. /**
  46947. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46948. */
  46949. pickUtilitySceneFirst: boolean;
  46950. /**
  46951. * 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)
  46952. */
  46953. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46954. /**
  46955. * 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)
  46956. */
  46957. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46958. /**
  46959. * The scene that is rendered on top of the original scene
  46960. */
  46961. utilityLayerScene: Scene;
  46962. /**
  46963. * If the utility layer should automatically be rendered on top of existing scene
  46964. */
  46965. shouldRender: boolean;
  46966. /**
  46967. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46968. */
  46969. onlyCheckPointerDownEvents: boolean;
  46970. /**
  46971. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46972. */
  46973. processAllEvents: boolean;
  46974. /**
  46975. * Observable raised when the pointer move from the utility layer scene to the main scene
  46976. */
  46977. onPointerOutObservable: Observable<number>;
  46978. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46979. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46980. private _afterRenderObserver;
  46981. private _sceneDisposeObserver;
  46982. private _originalPointerObserver;
  46983. /**
  46984. * Instantiates a UtilityLayerRenderer
  46985. * @param originalScene the original scene that will be rendered on top of
  46986. * @param handleEvents boolean indicating if the utility layer should handle events
  46987. */
  46988. constructor(
  46989. /** the original scene that will be rendered on top of */
  46990. originalScene: Scene, handleEvents?: boolean);
  46991. private _notifyObservers;
  46992. /**
  46993. * Renders the utility layers scene on top of the original scene
  46994. */
  46995. render(): void;
  46996. /**
  46997. * Disposes of the renderer
  46998. */
  46999. dispose(): void;
  47000. private _updateCamera;
  47001. }
  47002. }
  47003. declare module "babylonjs/Gizmos/gizmo" {
  47004. import { Nullable } from "babylonjs/types";
  47005. import { IDisposable } from "babylonjs/scene";
  47006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47007. import { Mesh } from "babylonjs/Meshes/mesh";
  47008. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47009. /**
  47010. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47011. */
  47012. export class Gizmo implements IDisposable {
  47013. /** The utility layer the gizmo will be added to */
  47014. gizmoLayer: UtilityLayerRenderer;
  47015. /**
  47016. * The root mesh of the gizmo
  47017. */
  47018. _rootMesh: Mesh;
  47019. private _attachedMesh;
  47020. /**
  47021. * Ratio for the scale of the gizmo (Default: 1)
  47022. */
  47023. scaleRatio: number;
  47024. /**
  47025. * If a custom mesh has been set (Default: false)
  47026. */
  47027. protected _customMeshSet: boolean;
  47028. /**
  47029. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47030. * * When set, interactions will be enabled
  47031. */
  47032. get attachedMesh(): Nullable<AbstractMesh>;
  47033. set attachedMesh(value: Nullable<AbstractMesh>);
  47034. /**
  47035. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47036. * @param mesh The mesh to replace the default mesh of the gizmo
  47037. */
  47038. setCustomMesh(mesh: Mesh): void;
  47039. /**
  47040. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47041. */
  47042. updateGizmoRotationToMatchAttachedMesh: boolean;
  47043. /**
  47044. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47045. */
  47046. updateGizmoPositionToMatchAttachedMesh: boolean;
  47047. /**
  47048. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47049. */
  47050. updateScale: boolean;
  47051. protected _interactionsEnabled: boolean;
  47052. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47053. private _beforeRenderObserver;
  47054. private _tempVector;
  47055. /**
  47056. * Creates a gizmo
  47057. * @param gizmoLayer The utility layer the gizmo will be added to
  47058. */
  47059. constructor(
  47060. /** The utility layer the gizmo will be added to */
  47061. gizmoLayer?: UtilityLayerRenderer);
  47062. /**
  47063. * Updates the gizmo to match the attached mesh's position/rotation
  47064. */
  47065. protected _update(): void;
  47066. /**
  47067. * Disposes of the gizmo
  47068. */
  47069. dispose(): void;
  47070. }
  47071. }
  47072. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47073. import { Observable } from "babylonjs/Misc/observable";
  47074. import { Nullable } from "babylonjs/types";
  47075. import { Vector3 } from "babylonjs/Maths/math.vector";
  47076. import { Color3 } from "babylonjs/Maths/math.color";
  47077. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47079. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47080. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47081. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47082. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47083. import { Scene } from "babylonjs/scene";
  47084. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47085. /**
  47086. * Single plane drag gizmo
  47087. */
  47088. export class PlaneDragGizmo extends Gizmo {
  47089. /**
  47090. * Drag behavior responsible for the gizmos dragging interactions
  47091. */
  47092. dragBehavior: PointerDragBehavior;
  47093. private _pointerObserver;
  47094. /**
  47095. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47096. */
  47097. snapDistance: number;
  47098. /**
  47099. * Event that fires each time the gizmo snaps to a new location.
  47100. * * snapDistance is the the change in distance
  47101. */
  47102. onSnapObservable: Observable<{
  47103. snapDistance: number;
  47104. }>;
  47105. private _plane;
  47106. private _coloredMaterial;
  47107. private _hoverMaterial;
  47108. private _isEnabled;
  47109. private _parent;
  47110. /** @hidden */
  47111. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47112. /** @hidden */
  47113. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47114. /**
  47115. * Creates a PlaneDragGizmo
  47116. * @param gizmoLayer The utility layer the gizmo will be added to
  47117. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47118. * @param color The color of the gizmo
  47119. */
  47120. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47121. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47122. /**
  47123. * If the gizmo is enabled
  47124. */
  47125. set isEnabled(value: boolean);
  47126. get isEnabled(): boolean;
  47127. /**
  47128. * Disposes of the gizmo
  47129. */
  47130. dispose(): void;
  47131. }
  47132. }
  47133. declare module "babylonjs/Gizmos/positionGizmo" {
  47134. import { Observable } from "babylonjs/Misc/observable";
  47135. import { Nullable } from "babylonjs/types";
  47136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47137. import { Mesh } from "babylonjs/Meshes/mesh";
  47138. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47139. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47140. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47141. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47142. /**
  47143. * Gizmo that enables dragging a mesh along 3 axis
  47144. */
  47145. export class PositionGizmo extends Gizmo {
  47146. /**
  47147. * Internal gizmo used for interactions on the x axis
  47148. */
  47149. xGizmo: AxisDragGizmo;
  47150. /**
  47151. * Internal gizmo used for interactions on the y axis
  47152. */
  47153. yGizmo: AxisDragGizmo;
  47154. /**
  47155. * Internal gizmo used for interactions on the z axis
  47156. */
  47157. zGizmo: AxisDragGizmo;
  47158. /**
  47159. * Internal gizmo used for interactions on the yz plane
  47160. */
  47161. xPlaneGizmo: PlaneDragGizmo;
  47162. /**
  47163. * Internal gizmo used for interactions on the xz plane
  47164. */
  47165. yPlaneGizmo: PlaneDragGizmo;
  47166. /**
  47167. * Internal gizmo used for interactions on the xy plane
  47168. */
  47169. zPlaneGizmo: PlaneDragGizmo;
  47170. /**
  47171. * private variables
  47172. */
  47173. private _meshAttached;
  47174. private _updateGizmoRotationToMatchAttachedMesh;
  47175. private _snapDistance;
  47176. private _scaleRatio;
  47177. /** Fires an event when any of it's sub gizmos are dragged */
  47178. onDragStartObservable: Observable<unknown>;
  47179. /** Fires an event when any of it's sub gizmos are released from dragging */
  47180. onDragEndObservable: Observable<unknown>;
  47181. /**
  47182. * If set to true, planar drag is enabled
  47183. */
  47184. private _planarGizmoEnabled;
  47185. get attachedMesh(): Nullable<AbstractMesh>;
  47186. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47187. /**
  47188. * Creates a PositionGizmo
  47189. * @param gizmoLayer The utility layer the gizmo will be added to
  47190. */
  47191. constructor(gizmoLayer?: UtilityLayerRenderer);
  47192. /**
  47193. * If the planar drag gizmo is enabled
  47194. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47195. */
  47196. set planarGizmoEnabled(value: boolean);
  47197. get planarGizmoEnabled(): boolean;
  47198. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47199. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47200. /**
  47201. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47202. */
  47203. set snapDistance(value: number);
  47204. get snapDistance(): number;
  47205. /**
  47206. * Ratio for the scale of the gizmo (Default: 1)
  47207. */
  47208. set scaleRatio(value: number);
  47209. get scaleRatio(): number;
  47210. /**
  47211. * Disposes of the gizmo
  47212. */
  47213. dispose(): void;
  47214. /**
  47215. * CustomMeshes are not supported by this gizmo
  47216. * @param mesh The mesh to replace the default mesh of the gizmo
  47217. */
  47218. setCustomMesh(mesh: Mesh): void;
  47219. }
  47220. }
  47221. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47222. import { Observable } from "babylonjs/Misc/observable";
  47223. import { Nullable } from "babylonjs/types";
  47224. import { Vector3 } from "babylonjs/Maths/math.vector";
  47225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47227. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47228. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47229. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47230. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47231. import { Scene } from "babylonjs/scene";
  47232. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47233. import { Color3 } from "babylonjs/Maths/math.color";
  47234. /**
  47235. * Single axis drag gizmo
  47236. */
  47237. export class AxisDragGizmo extends Gizmo {
  47238. /**
  47239. * Drag behavior responsible for the gizmos dragging interactions
  47240. */
  47241. dragBehavior: PointerDragBehavior;
  47242. private _pointerObserver;
  47243. /**
  47244. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47245. */
  47246. snapDistance: number;
  47247. /**
  47248. * Event that fires each time the gizmo snaps to a new location.
  47249. * * snapDistance is the the change in distance
  47250. */
  47251. onSnapObservable: Observable<{
  47252. snapDistance: number;
  47253. }>;
  47254. private _isEnabled;
  47255. private _parent;
  47256. private _arrow;
  47257. private _coloredMaterial;
  47258. private _hoverMaterial;
  47259. /** @hidden */
  47260. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47261. /** @hidden */
  47262. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47263. /**
  47264. * Creates an AxisDragGizmo
  47265. * @param gizmoLayer The utility layer the gizmo will be added to
  47266. * @param dragAxis The axis which the gizmo will be able to drag on
  47267. * @param color The color of the gizmo
  47268. */
  47269. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47270. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47271. /**
  47272. * If the gizmo is enabled
  47273. */
  47274. set isEnabled(value: boolean);
  47275. get isEnabled(): boolean;
  47276. /**
  47277. * Disposes of the gizmo
  47278. */
  47279. dispose(): void;
  47280. }
  47281. }
  47282. declare module "babylonjs/Debug/axesViewer" {
  47283. import { Vector3 } from "babylonjs/Maths/math.vector";
  47284. import { Nullable } from "babylonjs/types";
  47285. import { Scene } from "babylonjs/scene";
  47286. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47287. /**
  47288. * The Axes viewer will show 3 axes in a specific point in space
  47289. */
  47290. export class AxesViewer {
  47291. private _xAxis;
  47292. private _yAxis;
  47293. private _zAxis;
  47294. private _scaleLinesFactor;
  47295. private _instanced;
  47296. /**
  47297. * Gets the hosting scene
  47298. */
  47299. scene: Scene;
  47300. /**
  47301. * Gets or sets a number used to scale line length
  47302. */
  47303. scaleLines: number;
  47304. /** Gets the node hierarchy used to render x-axis */
  47305. get xAxis(): TransformNode;
  47306. /** Gets the node hierarchy used to render y-axis */
  47307. get yAxis(): TransformNode;
  47308. /** Gets the node hierarchy used to render z-axis */
  47309. get zAxis(): TransformNode;
  47310. /**
  47311. * Creates a new AxesViewer
  47312. * @param scene defines the hosting scene
  47313. * @param scaleLines defines a number used to scale line length (1 by default)
  47314. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47315. * @param xAxis defines the node hierarchy used to render the x-axis
  47316. * @param yAxis defines the node hierarchy used to render the y-axis
  47317. * @param zAxis defines the node hierarchy used to render the z-axis
  47318. */
  47319. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47320. /**
  47321. * Force the viewer to update
  47322. * @param position defines the position of the viewer
  47323. * @param xaxis defines the x axis of the viewer
  47324. * @param yaxis defines the y axis of the viewer
  47325. * @param zaxis defines the z axis of the viewer
  47326. */
  47327. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47328. /**
  47329. * Creates an instance of this axes viewer.
  47330. * @returns a new axes viewer with instanced meshes
  47331. */
  47332. createInstance(): AxesViewer;
  47333. /** Releases resources */
  47334. dispose(): void;
  47335. private static _SetRenderingGroupId;
  47336. }
  47337. }
  47338. declare module "babylonjs/Debug/boneAxesViewer" {
  47339. import { Nullable } from "babylonjs/types";
  47340. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47341. import { Vector3 } from "babylonjs/Maths/math.vector";
  47342. import { Mesh } from "babylonjs/Meshes/mesh";
  47343. import { Bone } from "babylonjs/Bones/bone";
  47344. import { Scene } from "babylonjs/scene";
  47345. /**
  47346. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47347. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47348. */
  47349. export class BoneAxesViewer extends AxesViewer {
  47350. /**
  47351. * Gets or sets the target mesh where to display the axes viewer
  47352. */
  47353. mesh: Nullable<Mesh>;
  47354. /**
  47355. * Gets or sets the target bone where to display the axes viewer
  47356. */
  47357. bone: Nullable<Bone>;
  47358. /** Gets current position */
  47359. pos: Vector3;
  47360. /** Gets direction of X axis */
  47361. xaxis: Vector3;
  47362. /** Gets direction of Y axis */
  47363. yaxis: Vector3;
  47364. /** Gets direction of Z axis */
  47365. zaxis: Vector3;
  47366. /**
  47367. * Creates a new BoneAxesViewer
  47368. * @param scene defines the hosting scene
  47369. * @param bone defines the target bone
  47370. * @param mesh defines the target mesh
  47371. * @param scaleLines defines a scaling factor for line length (1 by default)
  47372. */
  47373. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47374. /**
  47375. * Force the viewer to update
  47376. */
  47377. update(): void;
  47378. /** Releases resources */
  47379. dispose(): void;
  47380. }
  47381. }
  47382. declare module "babylonjs/Debug/debugLayer" {
  47383. import { Scene } from "babylonjs/scene";
  47384. /**
  47385. * Interface used to define scene explorer extensibility option
  47386. */
  47387. export interface IExplorerExtensibilityOption {
  47388. /**
  47389. * Define the option label
  47390. */
  47391. label: string;
  47392. /**
  47393. * Defines the action to execute on click
  47394. */
  47395. action: (entity: any) => void;
  47396. }
  47397. /**
  47398. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47399. */
  47400. export interface IExplorerExtensibilityGroup {
  47401. /**
  47402. * Defines a predicate to test if a given type mut be extended
  47403. */
  47404. predicate: (entity: any) => boolean;
  47405. /**
  47406. * Gets the list of options added to a type
  47407. */
  47408. entries: IExplorerExtensibilityOption[];
  47409. }
  47410. /**
  47411. * Interface used to define the options to use to create the Inspector
  47412. */
  47413. export interface IInspectorOptions {
  47414. /**
  47415. * Display in overlay mode (default: false)
  47416. */
  47417. overlay?: boolean;
  47418. /**
  47419. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47420. */
  47421. globalRoot?: HTMLElement;
  47422. /**
  47423. * Display the Scene explorer
  47424. */
  47425. showExplorer?: boolean;
  47426. /**
  47427. * Display the property inspector
  47428. */
  47429. showInspector?: boolean;
  47430. /**
  47431. * Display in embed mode (both panes on the right)
  47432. */
  47433. embedMode?: boolean;
  47434. /**
  47435. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47436. */
  47437. handleResize?: boolean;
  47438. /**
  47439. * Allow the panes to popup (default: true)
  47440. */
  47441. enablePopup?: boolean;
  47442. /**
  47443. * Allow the panes to be closed by users (default: true)
  47444. */
  47445. enableClose?: boolean;
  47446. /**
  47447. * Optional list of extensibility entries
  47448. */
  47449. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47450. /**
  47451. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47452. */
  47453. inspectorURL?: string;
  47454. /**
  47455. * Optional initial tab (default to DebugLayerTab.Properties)
  47456. */
  47457. initialTab?: DebugLayerTab;
  47458. }
  47459. module "babylonjs/scene" {
  47460. interface Scene {
  47461. /**
  47462. * @hidden
  47463. * Backing field
  47464. */
  47465. _debugLayer: DebugLayer;
  47466. /**
  47467. * Gets the debug layer (aka Inspector) associated with the scene
  47468. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47469. */
  47470. debugLayer: DebugLayer;
  47471. }
  47472. }
  47473. /**
  47474. * Enum of inspector action tab
  47475. */
  47476. export enum DebugLayerTab {
  47477. /**
  47478. * Properties tag (default)
  47479. */
  47480. Properties = 0,
  47481. /**
  47482. * Debug tab
  47483. */
  47484. Debug = 1,
  47485. /**
  47486. * Statistics tab
  47487. */
  47488. Statistics = 2,
  47489. /**
  47490. * Tools tab
  47491. */
  47492. Tools = 3,
  47493. /**
  47494. * Settings tab
  47495. */
  47496. Settings = 4
  47497. }
  47498. /**
  47499. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47500. * what is happening in your scene
  47501. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47502. */
  47503. export class DebugLayer {
  47504. /**
  47505. * Define the url to get the inspector script from.
  47506. * By default it uses the babylonjs CDN.
  47507. * @ignoreNaming
  47508. */
  47509. static InspectorURL: string;
  47510. private _scene;
  47511. private BJSINSPECTOR;
  47512. private _onPropertyChangedObservable?;
  47513. /**
  47514. * Observable triggered when a property is changed through the inspector.
  47515. */
  47516. get onPropertyChangedObservable(): any;
  47517. /**
  47518. * Instantiates a new debug layer.
  47519. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47520. * what is happening in your scene
  47521. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47522. * @param scene Defines the scene to inspect
  47523. */
  47524. constructor(scene: Scene);
  47525. /** Creates the inspector window. */
  47526. private _createInspector;
  47527. /**
  47528. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47529. * @param entity defines the entity to select
  47530. * @param lineContainerTitle defines the specific block to highlight
  47531. */
  47532. select(entity: any, lineContainerTitle?: string): void;
  47533. /** Get the inspector from bundle or global */
  47534. private _getGlobalInspector;
  47535. /**
  47536. * Get if the inspector is visible or not.
  47537. * @returns true if visible otherwise, false
  47538. */
  47539. isVisible(): boolean;
  47540. /**
  47541. * Hide the inspector and close its window.
  47542. */
  47543. hide(): void;
  47544. /**
  47545. * Launch the debugLayer.
  47546. * @param config Define the configuration of the inspector
  47547. * @return a promise fulfilled when the debug layer is visible
  47548. */
  47549. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47550. }
  47551. }
  47552. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47553. import { Nullable } from "babylonjs/types";
  47554. import { Scene } from "babylonjs/scene";
  47555. import { Vector4 } from "babylonjs/Maths/math.vector";
  47556. import { Color4 } from "babylonjs/Maths/math.color";
  47557. import { Mesh } from "babylonjs/Meshes/mesh";
  47558. /**
  47559. * Class containing static functions to help procedurally build meshes
  47560. */
  47561. export class BoxBuilder {
  47562. /**
  47563. * Creates a box mesh
  47564. * * The parameter `size` sets the size (float) of each box side (default 1)
  47565. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47566. * * 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)
  47567. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47571. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47572. * @param name defines the name of the mesh
  47573. * @param options defines the options used to create the mesh
  47574. * @param scene defines the hosting scene
  47575. * @returns the box mesh
  47576. */
  47577. static CreateBox(name: string, options: {
  47578. size?: number;
  47579. width?: number;
  47580. height?: number;
  47581. depth?: number;
  47582. faceUV?: Vector4[];
  47583. faceColors?: Color4[];
  47584. sideOrientation?: number;
  47585. frontUVs?: Vector4;
  47586. backUVs?: Vector4;
  47587. wrap?: boolean;
  47588. topBaseAt?: number;
  47589. bottomBaseAt?: number;
  47590. updatable?: boolean;
  47591. }, scene?: Nullable<Scene>): Mesh;
  47592. }
  47593. }
  47594. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47595. import { Vector4 } from "babylonjs/Maths/math.vector";
  47596. import { Mesh } from "babylonjs/Meshes/mesh";
  47597. import { Scene } from "babylonjs/scene";
  47598. import { Nullable } from "babylonjs/types";
  47599. /**
  47600. * Class containing static functions to help procedurally build meshes
  47601. */
  47602. export class SphereBuilder {
  47603. /**
  47604. * Creates a sphere mesh
  47605. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47606. * * 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`)
  47607. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47608. * * 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
  47609. * * 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)
  47610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47613. * @param name defines the name of the mesh
  47614. * @param options defines the options used to create the mesh
  47615. * @param scene defines the hosting scene
  47616. * @returns the sphere mesh
  47617. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47618. */
  47619. static CreateSphere(name: string, options: {
  47620. segments?: number;
  47621. diameter?: number;
  47622. diameterX?: number;
  47623. diameterY?: number;
  47624. diameterZ?: number;
  47625. arc?: number;
  47626. slice?: number;
  47627. sideOrientation?: number;
  47628. frontUVs?: Vector4;
  47629. backUVs?: Vector4;
  47630. updatable?: boolean;
  47631. }, scene?: Nullable<Scene>): Mesh;
  47632. }
  47633. }
  47634. declare module "babylonjs/Debug/physicsViewer" {
  47635. import { Nullable } from "babylonjs/types";
  47636. import { Scene } from "babylonjs/scene";
  47637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47638. import { Mesh } from "babylonjs/Meshes/mesh";
  47639. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47640. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47641. /**
  47642. * Used to show the physics impostor around the specific mesh
  47643. */
  47644. export class PhysicsViewer {
  47645. /** @hidden */
  47646. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47647. /** @hidden */
  47648. protected _meshes: Array<Nullable<AbstractMesh>>;
  47649. /** @hidden */
  47650. protected _scene: Nullable<Scene>;
  47651. /** @hidden */
  47652. protected _numMeshes: number;
  47653. /** @hidden */
  47654. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47655. private _renderFunction;
  47656. private _utilityLayer;
  47657. private _debugBoxMesh;
  47658. private _debugSphereMesh;
  47659. private _debugCylinderMesh;
  47660. private _debugMaterial;
  47661. private _debugMeshMeshes;
  47662. /**
  47663. * Creates a new PhysicsViewer
  47664. * @param scene defines the hosting scene
  47665. */
  47666. constructor(scene: Scene);
  47667. /** @hidden */
  47668. protected _updateDebugMeshes(): void;
  47669. /**
  47670. * Renders a specified physic impostor
  47671. * @param impostor defines the impostor to render
  47672. * @param targetMesh defines the mesh represented by the impostor
  47673. * @returns the new debug mesh used to render the impostor
  47674. */
  47675. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47676. /**
  47677. * Hides a specified physic impostor
  47678. * @param impostor defines the impostor to hide
  47679. */
  47680. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47681. private _getDebugMaterial;
  47682. private _getDebugBoxMesh;
  47683. private _getDebugSphereMesh;
  47684. private _getDebugCylinderMesh;
  47685. private _getDebugMeshMesh;
  47686. private _getDebugMesh;
  47687. /** Releases all resources */
  47688. dispose(): void;
  47689. }
  47690. }
  47691. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47692. import { Vector3 } from "babylonjs/Maths/math.vector";
  47693. import { Color4 } from "babylonjs/Maths/math.color";
  47694. import { Nullable } from "babylonjs/types";
  47695. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47696. import { Scene } from "babylonjs/scene";
  47697. /**
  47698. * Class containing static functions to help procedurally build meshes
  47699. */
  47700. export class LinesBuilder {
  47701. /**
  47702. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47703. * * 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
  47704. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47705. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47706. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47707. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47708. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47709. * * 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
  47710. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47713. * @param name defines the name of the new line system
  47714. * @param options defines the options used to create the line system
  47715. * @param scene defines the hosting scene
  47716. * @returns a new line system mesh
  47717. */
  47718. static CreateLineSystem(name: string, options: {
  47719. lines: Vector3[][];
  47720. updatable?: boolean;
  47721. instance?: Nullable<LinesMesh>;
  47722. colors?: Nullable<Color4[][]>;
  47723. useVertexAlpha?: boolean;
  47724. }, scene: Nullable<Scene>): LinesMesh;
  47725. /**
  47726. * Creates a line mesh
  47727. * 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
  47728. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47729. * * The parameter `points` is an array successive Vector3
  47730. * * 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
  47731. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47732. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47733. * * When updating an instance, remember that only point positions can change, not the number of points
  47734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47736. * @param name defines the name of the new line system
  47737. * @param options defines the options used to create the line system
  47738. * @param scene defines the hosting scene
  47739. * @returns a new line mesh
  47740. */
  47741. static CreateLines(name: string, options: {
  47742. points: Vector3[];
  47743. updatable?: boolean;
  47744. instance?: Nullable<LinesMesh>;
  47745. colors?: Color4[];
  47746. useVertexAlpha?: boolean;
  47747. }, scene?: Nullable<Scene>): LinesMesh;
  47748. /**
  47749. * Creates a dashed line mesh
  47750. * * 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
  47751. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47752. * * The parameter `points` is an array successive Vector3
  47753. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47754. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47755. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47756. * * 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
  47757. * * When updating an instance, remember that only point positions can change, not the number of points
  47758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47759. * @param name defines the name of the mesh
  47760. * @param options defines the options used to create the mesh
  47761. * @param scene defines the hosting scene
  47762. * @returns the dashed line mesh
  47763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47764. */
  47765. static CreateDashedLines(name: string, options: {
  47766. points: Vector3[];
  47767. dashSize?: number;
  47768. gapSize?: number;
  47769. dashNb?: number;
  47770. updatable?: boolean;
  47771. instance?: LinesMesh;
  47772. }, scene?: Nullable<Scene>): LinesMesh;
  47773. }
  47774. }
  47775. declare module "babylonjs/Debug/rayHelper" {
  47776. import { Nullable } from "babylonjs/types";
  47777. import { Ray } from "babylonjs/Culling/ray";
  47778. import { Vector3 } from "babylonjs/Maths/math.vector";
  47779. import { Color3 } from "babylonjs/Maths/math.color";
  47780. import { Scene } from "babylonjs/scene";
  47781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47782. import "babylonjs/Meshes/Builders/linesBuilder";
  47783. /**
  47784. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47785. * in order to better appreciate the issue one might have.
  47786. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47787. */
  47788. export class RayHelper {
  47789. /**
  47790. * Defines the ray we are currently tryin to visualize.
  47791. */
  47792. ray: Nullable<Ray>;
  47793. private _renderPoints;
  47794. private _renderLine;
  47795. private _renderFunction;
  47796. private _scene;
  47797. private _updateToMeshFunction;
  47798. private _attachedToMesh;
  47799. private _meshSpaceDirection;
  47800. private _meshSpaceOrigin;
  47801. /**
  47802. * Helper function to create a colored helper in a scene in one line.
  47803. * @param ray Defines the ray we are currently tryin to visualize
  47804. * @param scene Defines the scene the ray is used in
  47805. * @param color Defines the color we want to see the ray in
  47806. * @returns The newly created ray helper.
  47807. */
  47808. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47809. /**
  47810. * Instantiate a new ray helper.
  47811. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47812. * in order to better appreciate the issue one might have.
  47813. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47814. * @param ray Defines the ray we are currently tryin to visualize
  47815. */
  47816. constructor(ray: Ray);
  47817. /**
  47818. * Shows the ray we are willing to debug.
  47819. * @param scene Defines the scene the ray needs to be rendered in
  47820. * @param color Defines the color the ray needs to be rendered in
  47821. */
  47822. show(scene: Scene, color?: Color3): void;
  47823. /**
  47824. * Hides the ray we are debugging.
  47825. */
  47826. hide(): void;
  47827. private _render;
  47828. /**
  47829. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47830. * @param mesh Defines the mesh we want the helper attached to
  47831. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47832. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47833. * @param length Defines the length of the ray
  47834. */
  47835. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47836. /**
  47837. * Detach the ray helper from the mesh it has previously been attached to.
  47838. */
  47839. detachFromMesh(): void;
  47840. private _updateToMesh;
  47841. /**
  47842. * Dispose the helper and release its associated resources.
  47843. */
  47844. dispose(): void;
  47845. }
  47846. }
  47847. declare module "babylonjs/Debug/skeletonViewer" {
  47848. import { Color3 } from "babylonjs/Maths/math.color";
  47849. import { Scene } from "babylonjs/scene";
  47850. import { Nullable } from "babylonjs/types";
  47851. import { Skeleton } from "babylonjs/Bones/skeleton";
  47852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47853. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47854. /**
  47855. * Class used to render a debug view of a given skeleton
  47856. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47857. */
  47858. export class SkeletonViewer {
  47859. /** defines the skeleton to render */
  47860. skeleton: Skeleton;
  47861. /** defines the mesh attached to the skeleton */
  47862. mesh: AbstractMesh;
  47863. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47864. autoUpdateBonesMatrices: boolean;
  47865. /** defines the rendering group id to use with the viewer */
  47866. renderingGroupId: number;
  47867. /** Gets or sets the color used to render the skeleton */
  47868. color: Color3;
  47869. private _scene;
  47870. private _debugLines;
  47871. private _debugMesh;
  47872. private _isEnabled;
  47873. private _renderFunction;
  47874. private _utilityLayer;
  47875. /**
  47876. * Returns the mesh used to render the bones
  47877. */
  47878. get debugMesh(): Nullable<LinesMesh>;
  47879. /**
  47880. * Creates a new SkeletonViewer
  47881. * @param skeleton defines the skeleton to render
  47882. * @param mesh defines the mesh attached to the skeleton
  47883. * @param scene defines the hosting scene
  47884. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47885. * @param renderingGroupId defines the rendering group id to use with the viewer
  47886. */
  47887. constructor(
  47888. /** defines the skeleton to render */
  47889. skeleton: Skeleton,
  47890. /** defines the mesh attached to the skeleton */
  47891. mesh: AbstractMesh, scene: Scene,
  47892. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47893. autoUpdateBonesMatrices?: boolean,
  47894. /** defines the rendering group id to use with the viewer */
  47895. renderingGroupId?: number);
  47896. /** Gets or sets a boolean indicating if the viewer is enabled */
  47897. set isEnabled(value: boolean);
  47898. get isEnabled(): boolean;
  47899. private _getBonePosition;
  47900. private _getLinesForBonesWithLength;
  47901. private _getLinesForBonesNoLength;
  47902. /** Update the viewer to sync with current skeleton state */
  47903. update(): void;
  47904. /** Release associated resources */
  47905. dispose(): void;
  47906. }
  47907. }
  47908. declare module "babylonjs/Debug/index" {
  47909. export * from "babylonjs/Debug/axesViewer";
  47910. export * from "babylonjs/Debug/boneAxesViewer";
  47911. export * from "babylonjs/Debug/debugLayer";
  47912. export * from "babylonjs/Debug/physicsViewer";
  47913. export * from "babylonjs/Debug/rayHelper";
  47914. export * from "babylonjs/Debug/skeletonViewer";
  47915. }
  47916. declare module "babylonjs/Engines/nullEngine" {
  47917. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47918. import { Scene } from "babylonjs/scene";
  47919. import { Engine } from "babylonjs/Engines/engine";
  47920. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47921. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47923. import { Effect } from "babylonjs/Materials/effect";
  47924. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47925. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47926. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47927. /**
  47928. * Options to create the null engine
  47929. */
  47930. export class NullEngineOptions {
  47931. /**
  47932. * Render width (Default: 512)
  47933. */
  47934. renderWidth: number;
  47935. /**
  47936. * Render height (Default: 256)
  47937. */
  47938. renderHeight: number;
  47939. /**
  47940. * Texture size (Default: 512)
  47941. */
  47942. textureSize: number;
  47943. /**
  47944. * If delta time between frames should be constant
  47945. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47946. */
  47947. deterministicLockstep: boolean;
  47948. /**
  47949. * Maximum about of steps between frames (Default: 4)
  47950. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47951. */
  47952. lockstepMaxSteps: number;
  47953. }
  47954. /**
  47955. * The null engine class provides support for headless version of babylon.js.
  47956. * This can be used in server side scenario or for testing purposes
  47957. */
  47958. export class NullEngine extends Engine {
  47959. private _options;
  47960. /**
  47961. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47962. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47963. * @returns true if engine is in deterministic lock step mode
  47964. */
  47965. isDeterministicLockStep(): boolean;
  47966. /**
  47967. * Gets the max steps when engine is running in deterministic lock step
  47968. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47969. * @returns the max steps
  47970. */
  47971. getLockstepMaxSteps(): number;
  47972. /**
  47973. * Gets the current hardware scaling level.
  47974. * By default the hardware scaling level is computed from the window device ratio.
  47975. * 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.
  47976. * @returns a number indicating the current hardware scaling level
  47977. */
  47978. getHardwareScalingLevel(): number;
  47979. constructor(options?: NullEngineOptions);
  47980. /**
  47981. * Creates a vertex buffer
  47982. * @param vertices the data for the vertex buffer
  47983. * @returns the new WebGL static buffer
  47984. */
  47985. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47986. /**
  47987. * Creates a new index buffer
  47988. * @param indices defines the content of the index buffer
  47989. * @param updatable defines if the index buffer must be updatable
  47990. * @returns a new webGL buffer
  47991. */
  47992. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47993. /**
  47994. * Clear the current render buffer or the current render target (if any is set up)
  47995. * @param color defines the color to use
  47996. * @param backBuffer defines if the back buffer must be cleared
  47997. * @param depth defines if the depth buffer must be cleared
  47998. * @param stencil defines if the stencil buffer must be cleared
  47999. */
  48000. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48001. /**
  48002. * Gets the current render width
  48003. * @param useScreen defines if screen size must be used (or the current render target if any)
  48004. * @returns a number defining the current render width
  48005. */
  48006. getRenderWidth(useScreen?: boolean): number;
  48007. /**
  48008. * Gets the current render height
  48009. * @param useScreen defines if screen size must be used (or the current render target if any)
  48010. * @returns a number defining the current render height
  48011. */
  48012. getRenderHeight(useScreen?: boolean): number;
  48013. /**
  48014. * Set the WebGL's viewport
  48015. * @param viewport defines the viewport element to be used
  48016. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48017. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48018. */
  48019. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48020. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48021. /**
  48022. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48023. * @param pipelineContext defines the pipeline context to use
  48024. * @param uniformsNames defines the list of uniform names
  48025. * @returns an array of webGL uniform locations
  48026. */
  48027. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48028. /**
  48029. * Gets the lsit of active attributes for a given webGL program
  48030. * @param pipelineContext defines the pipeline context to use
  48031. * @param attributesNames defines the list of attribute names to get
  48032. * @returns an array of indices indicating the offset of each attribute
  48033. */
  48034. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48035. /**
  48036. * Binds an effect to the webGL context
  48037. * @param effect defines the effect to bind
  48038. */
  48039. bindSamplers(effect: Effect): void;
  48040. /**
  48041. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48042. * @param effect defines the effect to activate
  48043. */
  48044. enableEffect(effect: Effect): void;
  48045. /**
  48046. * Set various states to the webGL context
  48047. * @param culling defines backface culling state
  48048. * @param zOffset defines the value to apply to zOffset (0 by default)
  48049. * @param force defines if states must be applied even if cache is up to date
  48050. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48051. */
  48052. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48053. /**
  48054. * Set the value of an uniform to an array of int32
  48055. * @param uniform defines the webGL uniform location where to store the value
  48056. * @param array defines the array of int32 to store
  48057. */
  48058. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48059. /**
  48060. * Set the value of an uniform to an array of int32 (stored as vec2)
  48061. * @param uniform defines the webGL uniform location where to store the value
  48062. * @param array defines the array of int32 to store
  48063. */
  48064. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48065. /**
  48066. * Set the value of an uniform to an array of int32 (stored as vec3)
  48067. * @param uniform defines the webGL uniform location where to store the value
  48068. * @param array defines the array of int32 to store
  48069. */
  48070. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48071. /**
  48072. * Set the value of an uniform to an array of int32 (stored as vec4)
  48073. * @param uniform defines the webGL uniform location where to store the value
  48074. * @param array defines the array of int32 to store
  48075. */
  48076. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48077. /**
  48078. * Set the value of an uniform to an array of float32
  48079. * @param uniform defines the webGL uniform location where to store the value
  48080. * @param array defines the array of float32 to store
  48081. */
  48082. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48083. /**
  48084. * Set the value of an uniform to an array of float32 (stored as vec2)
  48085. * @param uniform defines the webGL uniform location where to store the value
  48086. * @param array defines the array of float32 to store
  48087. */
  48088. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48089. /**
  48090. * Set the value of an uniform to an array of float32 (stored as vec3)
  48091. * @param uniform defines the webGL uniform location where to store the value
  48092. * @param array defines the array of float32 to store
  48093. */
  48094. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48095. /**
  48096. * Set the value of an uniform to an array of float32 (stored as vec4)
  48097. * @param uniform defines the webGL uniform location where to store the value
  48098. * @param array defines the array of float32 to store
  48099. */
  48100. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48101. /**
  48102. * Set the value of an uniform to an array of number
  48103. * @param uniform defines the webGL uniform location where to store the value
  48104. * @param array defines the array of number to store
  48105. */
  48106. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48107. /**
  48108. * Set the value of an uniform to an array of number (stored as vec2)
  48109. * @param uniform defines the webGL uniform location where to store the value
  48110. * @param array defines the array of number to store
  48111. */
  48112. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48113. /**
  48114. * Set the value of an uniform to an array of number (stored as vec3)
  48115. * @param uniform defines the webGL uniform location where to store the value
  48116. * @param array defines the array of number to store
  48117. */
  48118. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48119. /**
  48120. * Set the value of an uniform to an array of number (stored as vec4)
  48121. * @param uniform defines the webGL uniform location where to store the value
  48122. * @param array defines the array of number to store
  48123. */
  48124. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48125. /**
  48126. * Set the value of an uniform to an array of float32 (stored as matrices)
  48127. * @param uniform defines the webGL uniform location where to store the value
  48128. * @param matrices defines the array of float32 to store
  48129. */
  48130. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48131. /**
  48132. * Set the value of an uniform to a matrix (3x3)
  48133. * @param uniform defines the webGL uniform location where to store the value
  48134. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48135. */
  48136. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48137. /**
  48138. * Set the value of an uniform to a matrix (2x2)
  48139. * @param uniform defines the webGL uniform location where to store the value
  48140. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48141. */
  48142. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48143. /**
  48144. * Set the value of an uniform to a number (float)
  48145. * @param uniform defines the webGL uniform location where to store the value
  48146. * @param value defines the float number to store
  48147. */
  48148. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48149. /**
  48150. * Set the value of an uniform to a vec2
  48151. * @param uniform defines the webGL uniform location where to store the value
  48152. * @param x defines the 1st component of the value
  48153. * @param y defines the 2nd component of the value
  48154. */
  48155. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48156. /**
  48157. * Set the value of an uniform to a vec3
  48158. * @param uniform defines the webGL uniform location where to store the value
  48159. * @param x defines the 1st component of the value
  48160. * @param y defines the 2nd component of the value
  48161. * @param z defines the 3rd component of the value
  48162. */
  48163. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48164. /**
  48165. * Set the value of an uniform to a boolean
  48166. * @param uniform defines the webGL uniform location where to store the value
  48167. * @param bool defines the boolean to store
  48168. */
  48169. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48170. /**
  48171. * Set the value of an uniform to a vec4
  48172. * @param uniform defines the webGL uniform location where to store the value
  48173. * @param x defines the 1st component of the value
  48174. * @param y defines the 2nd component of the value
  48175. * @param z defines the 3rd component of the value
  48176. * @param w defines the 4th component of the value
  48177. */
  48178. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48179. /**
  48180. * Sets the current alpha mode
  48181. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48182. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48183. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48184. */
  48185. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48186. /**
  48187. * Bind webGl buffers directly to the webGL context
  48188. * @param vertexBuffers defines the vertex buffer to bind
  48189. * @param indexBuffer defines the index buffer to bind
  48190. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48191. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48192. * @param effect defines the effect associated with the vertex buffer
  48193. */
  48194. bindBuffers(vertexBuffers: {
  48195. [key: string]: VertexBuffer;
  48196. }, indexBuffer: DataBuffer, effect: Effect): void;
  48197. /**
  48198. * Force the entire cache to be cleared
  48199. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48200. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48201. */
  48202. wipeCaches(bruteForce?: boolean): void;
  48203. /**
  48204. * Send a draw order
  48205. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48206. * @param indexStart defines the starting index
  48207. * @param indexCount defines the number of index to draw
  48208. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48209. */
  48210. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48211. /**
  48212. * Draw a list of indexed primitives
  48213. * @param fillMode defines the primitive to use
  48214. * @param indexStart defines the starting index
  48215. * @param indexCount defines the number of index to draw
  48216. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48217. */
  48218. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48219. /**
  48220. * Draw a list of unindexed primitives
  48221. * @param fillMode defines the primitive to use
  48222. * @param verticesStart defines the index of first vertex to draw
  48223. * @param verticesCount defines the count of vertices to draw
  48224. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48225. */
  48226. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48227. /** @hidden */
  48228. _createTexture(): WebGLTexture;
  48229. /** @hidden */
  48230. _releaseTexture(texture: InternalTexture): void;
  48231. /**
  48232. * Usually called from Texture.ts.
  48233. * Passed information to create a WebGLTexture
  48234. * @param urlArg defines a value which contains one of the following:
  48235. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48236. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48237. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48238. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48239. * @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)
  48240. * @param scene needed for loading to the correct scene
  48241. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48242. * @param onLoad optional callback to be called upon successful completion
  48243. * @param onError optional callback to be called upon failure
  48244. * @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
  48245. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48246. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48247. * @param forcedExtension defines the extension to use to pick the right loader
  48248. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48249. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48250. */
  48251. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  48252. /**
  48253. * Creates a new render target texture
  48254. * @param size defines the size of the texture
  48255. * @param options defines the options used to create the texture
  48256. * @returns a new render target texture stored in an InternalTexture
  48257. */
  48258. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48259. /**
  48260. * Update the sampling mode of a given texture
  48261. * @param samplingMode defines the required sampling mode
  48262. * @param texture defines the texture to update
  48263. */
  48264. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48265. /**
  48266. * Binds the frame buffer to the specified texture.
  48267. * @param texture The texture to render to or null for the default canvas
  48268. * @param faceIndex The face of the texture to render to in case of cube texture
  48269. * @param requiredWidth The width of the target to render to
  48270. * @param requiredHeight The height of the target to render to
  48271. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48272. * @param depthStencilTexture The depth stencil texture to use to render
  48273. * @param lodLevel defines le lod level to bind to the frame buffer
  48274. */
  48275. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48276. /**
  48277. * Unbind the current render target texture from the webGL context
  48278. * @param texture defines the render target texture to unbind
  48279. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48280. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48281. */
  48282. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48283. /**
  48284. * Creates a dynamic vertex buffer
  48285. * @param vertices the data for the dynamic vertex buffer
  48286. * @returns the new WebGL dynamic buffer
  48287. */
  48288. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48289. /**
  48290. * Update the content of a dynamic texture
  48291. * @param texture defines the texture to update
  48292. * @param canvas defines the canvas containing the source
  48293. * @param invertY defines if data must be stored with Y axis inverted
  48294. * @param premulAlpha defines if alpha is stored as premultiplied
  48295. * @param format defines the format of the data
  48296. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48297. */
  48298. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48299. /**
  48300. * Gets a boolean indicating if all created effects are ready
  48301. * @returns true if all effects are ready
  48302. */
  48303. areAllEffectsReady(): boolean;
  48304. /**
  48305. * @hidden
  48306. * Get the current error code of the webGL context
  48307. * @returns the error code
  48308. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48309. */
  48310. getError(): number;
  48311. /** @hidden */
  48312. _getUnpackAlignement(): number;
  48313. /** @hidden */
  48314. _unpackFlipY(value: boolean): void;
  48315. /**
  48316. * Update a dynamic index buffer
  48317. * @param indexBuffer defines the target index buffer
  48318. * @param indices defines the data to update
  48319. * @param offset defines the offset in the target index buffer where update should start
  48320. */
  48321. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48322. /**
  48323. * Updates a dynamic vertex buffer.
  48324. * @param vertexBuffer the vertex buffer to update
  48325. * @param vertices the data used to update the vertex buffer
  48326. * @param byteOffset the byte offset of the data (optional)
  48327. * @param byteLength the byte length of the data (optional)
  48328. */
  48329. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48330. /** @hidden */
  48331. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48332. /** @hidden */
  48333. _bindTexture(channel: number, texture: InternalTexture): void;
  48334. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48335. /**
  48336. * 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
  48337. */
  48338. releaseEffects(): void;
  48339. displayLoadingUI(): void;
  48340. hideLoadingUI(): void;
  48341. /** @hidden */
  48342. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48343. /** @hidden */
  48344. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48345. /** @hidden */
  48346. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48347. /** @hidden */
  48348. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48349. }
  48350. }
  48351. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48352. import { Nullable, int } from "babylonjs/types";
  48353. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48354. /** @hidden */
  48355. export class _OcclusionDataStorage {
  48356. /** @hidden */
  48357. occlusionInternalRetryCounter: number;
  48358. /** @hidden */
  48359. isOcclusionQueryInProgress: boolean;
  48360. /** @hidden */
  48361. isOccluded: boolean;
  48362. /** @hidden */
  48363. occlusionRetryCount: number;
  48364. /** @hidden */
  48365. occlusionType: number;
  48366. /** @hidden */
  48367. occlusionQueryAlgorithmType: number;
  48368. }
  48369. module "babylonjs/Engines/engine" {
  48370. interface Engine {
  48371. /**
  48372. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48373. * @return the new query
  48374. */
  48375. createQuery(): WebGLQuery;
  48376. /**
  48377. * Delete and release a webGL query
  48378. * @param query defines the query to delete
  48379. * @return the current engine
  48380. */
  48381. deleteQuery(query: WebGLQuery): Engine;
  48382. /**
  48383. * Check if a given query has resolved and got its value
  48384. * @param query defines the query to check
  48385. * @returns true if the query got its value
  48386. */
  48387. isQueryResultAvailable(query: WebGLQuery): boolean;
  48388. /**
  48389. * Gets the value of a given query
  48390. * @param query defines the query to check
  48391. * @returns the value of the query
  48392. */
  48393. getQueryResult(query: WebGLQuery): number;
  48394. /**
  48395. * Initiates an occlusion query
  48396. * @param algorithmType defines the algorithm to use
  48397. * @param query defines the query to use
  48398. * @returns the current engine
  48399. * @see http://doc.babylonjs.com/features/occlusionquery
  48400. */
  48401. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48402. /**
  48403. * Ends an occlusion query
  48404. * @see http://doc.babylonjs.com/features/occlusionquery
  48405. * @param algorithmType defines the algorithm to use
  48406. * @returns the current engine
  48407. */
  48408. endOcclusionQuery(algorithmType: number): Engine;
  48409. /**
  48410. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48411. * Please note that only one query can be issued at a time
  48412. * @returns a time token used to track the time span
  48413. */
  48414. startTimeQuery(): Nullable<_TimeToken>;
  48415. /**
  48416. * Ends a time query
  48417. * @param token defines the token used to measure the time span
  48418. * @returns the time spent (in ns)
  48419. */
  48420. endTimeQuery(token: _TimeToken): int;
  48421. /** @hidden */
  48422. _currentNonTimestampToken: Nullable<_TimeToken>;
  48423. /** @hidden */
  48424. _createTimeQuery(): WebGLQuery;
  48425. /** @hidden */
  48426. _deleteTimeQuery(query: WebGLQuery): void;
  48427. /** @hidden */
  48428. _getGlAlgorithmType(algorithmType: number): number;
  48429. /** @hidden */
  48430. _getTimeQueryResult(query: WebGLQuery): any;
  48431. /** @hidden */
  48432. _getTimeQueryAvailability(query: WebGLQuery): any;
  48433. }
  48434. }
  48435. module "babylonjs/Meshes/abstractMesh" {
  48436. interface AbstractMesh {
  48437. /**
  48438. * Backing filed
  48439. * @hidden
  48440. */
  48441. __occlusionDataStorage: _OcclusionDataStorage;
  48442. /**
  48443. * Access property
  48444. * @hidden
  48445. */
  48446. _occlusionDataStorage: _OcclusionDataStorage;
  48447. /**
  48448. * 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.
  48449. * The default value is -1 which means don't break the query and wait till the result
  48450. * @see http://doc.babylonjs.com/features/occlusionquery
  48451. */
  48452. occlusionRetryCount: number;
  48453. /**
  48454. * 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:
  48455. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48456. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48457. * * 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.
  48458. * @see http://doc.babylonjs.com/features/occlusionquery
  48459. */
  48460. occlusionType: number;
  48461. /**
  48462. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48463. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48464. * * 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.
  48465. * @see http://doc.babylonjs.com/features/occlusionquery
  48466. */
  48467. occlusionQueryAlgorithmType: number;
  48468. /**
  48469. * 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
  48470. * @see http://doc.babylonjs.com/features/occlusionquery
  48471. */
  48472. isOccluded: boolean;
  48473. /**
  48474. * Flag to check the progress status of the query
  48475. * @see http://doc.babylonjs.com/features/occlusionquery
  48476. */
  48477. isOcclusionQueryInProgress: boolean;
  48478. }
  48479. }
  48480. }
  48481. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48482. import { Nullable } from "babylonjs/types";
  48483. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48484. /** @hidden */
  48485. export var _forceTransformFeedbackToBundle: boolean;
  48486. module "babylonjs/Engines/engine" {
  48487. interface Engine {
  48488. /**
  48489. * Creates a webGL transform feedback object
  48490. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48491. * @returns the webGL transform feedback object
  48492. */
  48493. createTransformFeedback(): WebGLTransformFeedback;
  48494. /**
  48495. * Delete a webGL transform feedback object
  48496. * @param value defines the webGL transform feedback object to delete
  48497. */
  48498. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48499. /**
  48500. * Bind a webGL transform feedback object to the webgl context
  48501. * @param value defines the webGL transform feedback object to bind
  48502. */
  48503. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48504. /**
  48505. * Begins a transform feedback operation
  48506. * @param usePoints defines if points or triangles must be used
  48507. */
  48508. beginTransformFeedback(usePoints: boolean): void;
  48509. /**
  48510. * Ends a transform feedback operation
  48511. */
  48512. endTransformFeedback(): void;
  48513. /**
  48514. * Specify the varyings to use with transform feedback
  48515. * @param program defines the associated webGL program
  48516. * @param value defines the list of strings representing the varying names
  48517. */
  48518. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48519. /**
  48520. * Bind a webGL buffer for a transform feedback operation
  48521. * @param value defines the webGL buffer to bind
  48522. */
  48523. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48524. }
  48525. }
  48526. }
  48527. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48528. import { Scene } from "babylonjs/scene";
  48529. import { Engine } from "babylonjs/Engines/engine";
  48530. import { Texture } from "babylonjs/Materials/Textures/texture";
  48531. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48532. import "babylonjs/Engines/Extensions/engine.multiRender";
  48533. /**
  48534. * Creation options of the multi render target texture.
  48535. */
  48536. export interface IMultiRenderTargetOptions {
  48537. /**
  48538. * Define if the texture needs to create mip maps after render.
  48539. */
  48540. generateMipMaps?: boolean;
  48541. /**
  48542. * Define the types of all the draw buffers we want to create
  48543. */
  48544. types?: number[];
  48545. /**
  48546. * Define the sampling modes of all the draw buffers we want to create
  48547. */
  48548. samplingModes?: number[];
  48549. /**
  48550. * Define if a depth buffer is required
  48551. */
  48552. generateDepthBuffer?: boolean;
  48553. /**
  48554. * Define if a stencil buffer is required
  48555. */
  48556. generateStencilBuffer?: boolean;
  48557. /**
  48558. * Define if a depth texture is required instead of a depth buffer
  48559. */
  48560. generateDepthTexture?: boolean;
  48561. /**
  48562. * Define the number of desired draw buffers
  48563. */
  48564. textureCount?: number;
  48565. /**
  48566. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48567. */
  48568. doNotChangeAspectRatio?: boolean;
  48569. /**
  48570. * Define the default type of the buffers we are creating
  48571. */
  48572. defaultType?: number;
  48573. }
  48574. /**
  48575. * A multi render target, like a render target provides the ability to render to a texture.
  48576. * Unlike the render target, it can render to several draw buffers in one draw.
  48577. * This is specially interesting in deferred rendering or for any effects requiring more than
  48578. * just one color from a single pass.
  48579. */
  48580. export class MultiRenderTarget extends RenderTargetTexture {
  48581. private _internalTextures;
  48582. private _textures;
  48583. private _multiRenderTargetOptions;
  48584. /**
  48585. * Get if draw buffers are currently supported by the used hardware and browser.
  48586. */
  48587. get isSupported(): boolean;
  48588. /**
  48589. * Get the list of textures generated by the multi render target.
  48590. */
  48591. get textures(): Texture[];
  48592. /**
  48593. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48594. */
  48595. get depthTexture(): Texture;
  48596. /**
  48597. * Set the wrapping mode on U of all the textures we are rendering to.
  48598. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48599. */
  48600. set wrapU(wrap: number);
  48601. /**
  48602. * Set the wrapping mode on V of all the textures we are rendering to.
  48603. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48604. */
  48605. set wrapV(wrap: number);
  48606. /**
  48607. * Instantiate a new multi render target texture.
  48608. * A multi render target, like a render target provides the ability to render to a texture.
  48609. * Unlike the render target, it can render to several draw buffers in one draw.
  48610. * This is specially interesting in deferred rendering or for any effects requiring more than
  48611. * just one color from a single pass.
  48612. * @param name Define the name of the texture
  48613. * @param size Define the size of the buffers to render to
  48614. * @param count Define the number of target we are rendering into
  48615. * @param scene Define the scene the texture belongs to
  48616. * @param options Define the options used to create the multi render target
  48617. */
  48618. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48619. /** @hidden */
  48620. _rebuild(): void;
  48621. private _createInternalTextures;
  48622. private _createTextures;
  48623. /**
  48624. * Define the number of samples used if MSAA is enabled.
  48625. */
  48626. get samples(): number;
  48627. set samples(value: number);
  48628. /**
  48629. * Resize all the textures in the multi render target.
  48630. * Be carrefull as it will recreate all the data in the new texture.
  48631. * @param size Define the new size
  48632. */
  48633. resize(size: any): void;
  48634. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48635. /**
  48636. * Dispose the render targets and their associated resources
  48637. */
  48638. dispose(): void;
  48639. /**
  48640. * Release all the underlying texture used as draw buffers.
  48641. */
  48642. releaseInternalTextures(): void;
  48643. }
  48644. }
  48645. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48646. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48647. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48648. import { Nullable } from "babylonjs/types";
  48649. module "babylonjs/Engines/thinEngine" {
  48650. interface ThinEngine {
  48651. /**
  48652. * Unbind a list of render target textures from the webGL context
  48653. * This is used only when drawBuffer extension or webGL2 are active
  48654. * @param textures defines the render target textures to unbind
  48655. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48656. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48657. */
  48658. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48659. /**
  48660. * Create a multi render target texture
  48661. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48662. * @param size defines the size of the texture
  48663. * @param options defines the creation options
  48664. * @returns the cube texture as an InternalTexture
  48665. */
  48666. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48667. /**
  48668. * Update the sample count for a given multiple render target texture
  48669. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48670. * @param textures defines the textures to update
  48671. * @param samples defines the sample count to set
  48672. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48673. */
  48674. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48675. }
  48676. }
  48677. }
  48678. declare module "babylonjs/Engines/Extensions/engine.views" {
  48679. import { Camera } from "babylonjs/Cameras/camera";
  48680. import { Nullable } from "babylonjs/types";
  48681. /**
  48682. * Class used to define an additional view for the engine
  48683. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48684. */
  48685. export class EngineView {
  48686. /** Defines the canvas where to render the view */
  48687. target: HTMLCanvasElement;
  48688. /** Defines an optional camera used to render the view (will use active camera else) */
  48689. camera?: Camera;
  48690. }
  48691. module "babylonjs/Engines/engine" {
  48692. interface Engine {
  48693. /**
  48694. * Gets or sets the HTML element to use for attaching events
  48695. */
  48696. inputElement: Nullable<HTMLElement>;
  48697. /**
  48698. * Gets the current engine view
  48699. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48700. */
  48701. activeView: Nullable<EngineView>;
  48702. /** Gets or sets the list of views */
  48703. views: EngineView[];
  48704. /**
  48705. * Register a new child canvas
  48706. * @param canvas defines the canvas to register
  48707. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48708. * @returns the associated view
  48709. */
  48710. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48711. /**
  48712. * Remove a registered child canvas
  48713. * @param canvas defines the canvas to remove
  48714. * @returns the current engine
  48715. */
  48716. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48717. }
  48718. }
  48719. }
  48720. declare module "babylonjs/Engines/Extensions/index" {
  48721. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48722. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48723. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48724. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48725. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48726. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48727. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48728. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48729. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48730. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48731. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48732. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48733. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48734. export * from "babylonjs/Engines/Extensions/engine.views";
  48735. }
  48736. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48737. import { Nullable } from "babylonjs/types";
  48738. /**
  48739. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48740. */
  48741. export interface CubeMapInfo {
  48742. /**
  48743. * The pixel array for the front face.
  48744. * This is stored in format, left to right, up to down format.
  48745. */
  48746. front: Nullable<ArrayBufferView>;
  48747. /**
  48748. * The pixel array for the back face.
  48749. * This is stored in format, left to right, up to down format.
  48750. */
  48751. back: Nullable<ArrayBufferView>;
  48752. /**
  48753. * The pixel array for the left face.
  48754. * This is stored in format, left to right, up to down format.
  48755. */
  48756. left: Nullable<ArrayBufferView>;
  48757. /**
  48758. * The pixel array for the right face.
  48759. * This is stored in format, left to right, up to down format.
  48760. */
  48761. right: Nullable<ArrayBufferView>;
  48762. /**
  48763. * The pixel array for the up face.
  48764. * This is stored in format, left to right, up to down format.
  48765. */
  48766. up: Nullable<ArrayBufferView>;
  48767. /**
  48768. * The pixel array for the down face.
  48769. * This is stored in format, left to right, up to down format.
  48770. */
  48771. down: Nullable<ArrayBufferView>;
  48772. /**
  48773. * The size of the cubemap stored.
  48774. *
  48775. * Each faces will be size * size pixels.
  48776. */
  48777. size: number;
  48778. /**
  48779. * The format of the texture.
  48780. *
  48781. * RGBA, RGB.
  48782. */
  48783. format: number;
  48784. /**
  48785. * The type of the texture data.
  48786. *
  48787. * UNSIGNED_INT, FLOAT.
  48788. */
  48789. type: number;
  48790. /**
  48791. * Specifies whether the texture is in gamma space.
  48792. */
  48793. gammaSpace: boolean;
  48794. }
  48795. /**
  48796. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48797. */
  48798. export class PanoramaToCubeMapTools {
  48799. private static FACE_FRONT;
  48800. private static FACE_BACK;
  48801. private static FACE_RIGHT;
  48802. private static FACE_LEFT;
  48803. private static FACE_DOWN;
  48804. private static FACE_UP;
  48805. /**
  48806. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48807. *
  48808. * @param float32Array The source data.
  48809. * @param inputWidth The width of the input panorama.
  48810. * @param inputHeight The height of the input panorama.
  48811. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48812. * @return The cubemap data
  48813. */
  48814. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48815. private static CreateCubemapTexture;
  48816. private static CalcProjectionSpherical;
  48817. }
  48818. }
  48819. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48820. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48822. import { Nullable } from "babylonjs/types";
  48823. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48824. /**
  48825. * Helper class dealing with the extraction of spherical polynomial dataArray
  48826. * from a cube map.
  48827. */
  48828. export class CubeMapToSphericalPolynomialTools {
  48829. private static FileFaces;
  48830. /**
  48831. * Converts a texture to the according Spherical Polynomial data.
  48832. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48833. *
  48834. * @param texture The texture to extract the information from.
  48835. * @return The Spherical Polynomial data.
  48836. */
  48837. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48838. /**
  48839. * Converts a cubemap to the according Spherical Polynomial data.
  48840. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48841. *
  48842. * @param cubeInfo The Cube map to extract the information from.
  48843. * @return The Spherical Polynomial data.
  48844. */
  48845. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48846. }
  48847. }
  48848. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48849. import { Nullable } from "babylonjs/types";
  48850. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48851. module "babylonjs/Materials/Textures/baseTexture" {
  48852. interface BaseTexture {
  48853. /**
  48854. * Get the polynomial representation of the texture data.
  48855. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48856. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48857. */
  48858. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48859. }
  48860. }
  48861. }
  48862. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48863. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48864. /** @hidden */
  48865. export var rgbdEncodePixelShader: {
  48866. name: string;
  48867. shader: string;
  48868. };
  48869. }
  48870. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48871. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48872. /** @hidden */
  48873. export var rgbdDecodePixelShader: {
  48874. name: string;
  48875. shader: string;
  48876. };
  48877. }
  48878. declare module "babylonjs/Misc/environmentTextureTools" {
  48879. import { Nullable } from "babylonjs/types";
  48880. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48881. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48882. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48883. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48884. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48885. import "babylonjs/Shaders/rgbdEncode.fragment";
  48886. import "babylonjs/Shaders/rgbdDecode.fragment";
  48887. /**
  48888. * Raw texture data and descriptor sufficient for WebGL texture upload
  48889. */
  48890. export interface EnvironmentTextureInfo {
  48891. /**
  48892. * Version of the environment map
  48893. */
  48894. version: number;
  48895. /**
  48896. * Width of image
  48897. */
  48898. width: number;
  48899. /**
  48900. * Irradiance information stored in the file.
  48901. */
  48902. irradiance: any;
  48903. /**
  48904. * Specular information stored in the file.
  48905. */
  48906. specular: any;
  48907. }
  48908. /**
  48909. * Defines One Image in the file. It requires only the position in the file
  48910. * as well as the length.
  48911. */
  48912. interface BufferImageData {
  48913. /**
  48914. * Length of the image data.
  48915. */
  48916. length: number;
  48917. /**
  48918. * Position of the data from the null terminator delimiting the end of the JSON.
  48919. */
  48920. position: number;
  48921. }
  48922. /**
  48923. * Defines the specular data enclosed in the file.
  48924. * This corresponds to the version 1 of the data.
  48925. */
  48926. export interface EnvironmentTextureSpecularInfoV1 {
  48927. /**
  48928. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48929. */
  48930. specularDataPosition?: number;
  48931. /**
  48932. * This contains all the images data needed to reconstruct the cubemap.
  48933. */
  48934. mipmaps: Array<BufferImageData>;
  48935. /**
  48936. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48937. */
  48938. lodGenerationScale: number;
  48939. }
  48940. /**
  48941. * Sets of helpers addressing the serialization and deserialization of environment texture
  48942. * stored in a BabylonJS env file.
  48943. * Those files are usually stored as .env files.
  48944. */
  48945. export class EnvironmentTextureTools {
  48946. /**
  48947. * Magic number identifying the env file.
  48948. */
  48949. private static _MagicBytes;
  48950. /**
  48951. * Gets the environment info from an env file.
  48952. * @param data The array buffer containing the .env bytes.
  48953. * @returns the environment file info (the json header) if successfully parsed.
  48954. */
  48955. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48956. /**
  48957. * Creates an environment texture from a loaded cube texture.
  48958. * @param texture defines the cube texture to convert in env file
  48959. * @return a promise containing the environment data if succesfull.
  48960. */
  48961. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48962. /**
  48963. * Creates a JSON representation of the spherical data.
  48964. * @param texture defines the texture containing the polynomials
  48965. * @return the JSON representation of the spherical info
  48966. */
  48967. private static _CreateEnvTextureIrradiance;
  48968. /**
  48969. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48970. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48971. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48972. * @return the views described by info providing access to the underlying buffer
  48973. */
  48974. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48975. /**
  48976. * Uploads the texture info contained in the env file to the GPU.
  48977. * @param texture defines the internal texture to upload to
  48978. * @param arrayBuffer defines the buffer cotaining the data to load
  48979. * @param info defines the texture info retrieved through the GetEnvInfo method
  48980. * @returns a promise
  48981. */
  48982. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48983. private static _OnImageReadyAsync;
  48984. /**
  48985. * Uploads the levels of image data to the GPU.
  48986. * @param texture defines the internal texture to upload to
  48987. * @param imageData defines the array buffer views of image data [mipmap][face]
  48988. * @returns a promise
  48989. */
  48990. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48991. /**
  48992. * Uploads spherical polynomials information to the texture.
  48993. * @param texture defines the texture we are trying to upload the information to
  48994. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48995. */
  48996. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48997. /** @hidden */
  48998. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48999. }
  49000. }
  49001. declare module "babylonjs/Maths/math.vertexFormat" {
  49002. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49003. /**
  49004. * Contains position and normal vectors for a vertex
  49005. */
  49006. export class PositionNormalVertex {
  49007. /** the position of the vertex (defaut: 0,0,0) */
  49008. position: Vector3;
  49009. /** the normal of the vertex (defaut: 0,1,0) */
  49010. normal: Vector3;
  49011. /**
  49012. * Creates a PositionNormalVertex
  49013. * @param position the position of the vertex (defaut: 0,0,0)
  49014. * @param normal the normal of the vertex (defaut: 0,1,0)
  49015. */
  49016. constructor(
  49017. /** the position of the vertex (defaut: 0,0,0) */
  49018. position?: Vector3,
  49019. /** the normal of the vertex (defaut: 0,1,0) */
  49020. normal?: Vector3);
  49021. /**
  49022. * Clones the PositionNormalVertex
  49023. * @returns the cloned PositionNormalVertex
  49024. */
  49025. clone(): PositionNormalVertex;
  49026. }
  49027. /**
  49028. * Contains position, normal and uv vectors for a vertex
  49029. */
  49030. export class PositionNormalTextureVertex {
  49031. /** the position of the vertex (defaut: 0,0,0) */
  49032. position: Vector3;
  49033. /** the normal of the vertex (defaut: 0,1,0) */
  49034. normal: Vector3;
  49035. /** the uv of the vertex (default: 0,0) */
  49036. uv: Vector2;
  49037. /**
  49038. * Creates a PositionNormalTextureVertex
  49039. * @param position the position of the vertex (defaut: 0,0,0)
  49040. * @param normal the normal of the vertex (defaut: 0,1,0)
  49041. * @param uv the uv of the vertex (default: 0,0)
  49042. */
  49043. constructor(
  49044. /** the position of the vertex (defaut: 0,0,0) */
  49045. position?: Vector3,
  49046. /** the normal of the vertex (defaut: 0,1,0) */
  49047. normal?: Vector3,
  49048. /** the uv of the vertex (default: 0,0) */
  49049. uv?: Vector2);
  49050. /**
  49051. * Clones the PositionNormalTextureVertex
  49052. * @returns the cloned PositionNormalTextureVertex
  49053. */
  49054. clone(): PositionNormalTextureVertex;
  49055. }
  49056. }
  49057. declare module "babylonjs/Maths/math" {
  49058. export * from "babylonjs/Maths/math.axis";
  49059. export * from "babylonjs/Maths/math.color";
  49060. export * from "babylonjs/Maths/math.constants";
  49061. export * from "babylonjs/Maths/math.frustum";
  49062. export * from "babylonjs/Maths/math.path";
  49063. export * from "babylonjs/Maths/math.plane";
  49064. export * from "babylonjs/Maths/math.size";
  49065. export * from "babylonjs/Maths/math.vector";
  49066. export * from "babylonjs/Maths/math.vertexFormat";
  49067. export * from "babylonjs/Maths/math.viewport";
  49068. }
  49069. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49070. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49071. /** @hidden */
  49072. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49073. private _genericAttributeLocation;
  49074. private _varyingLocationCount;
  49075. private _varyingLocationMap;
  49076. private _replacements;
  49077. private _textureCount;
  49078. private _uniforms;
  49079. lineProcessor(line: string): string;
  49080. attributeProcessor(attribute: string): string;
  49081. varyingProcessor(varying: string, isFragment: boolean): string;
  49082. uniformProcessor(uniform: string): string;
  49083. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49084. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49085. }
  49086. }
  49087. declare module "babylonjs/Engines/nativeEngine" {
  49088. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49089. import { Engine } from "babylonjs/Engines/engine";
  49090. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49091. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49093. import { Effect } from "babylonjs/Materials/effect";
  49094. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49095. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49096. import { IColor4Like } from "babylonjs/Maths/math.like";
  49097. import { Scene } from "babylonjs/scene";
  49098. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49099. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49100. /**
  49101. * Container for accessors for natively-stored mesh data buffers.
  49102. */
  49103. class NativeDataBuffer extends DataBuffer {
  49104. /**
  49105. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49106. */
  49107. nativeIndexBuffer?: any;
  49108. /**
  49109. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49110. */
  49111. nativeVertexBuffer?: any;
  49112. }
  49113. /** @hidden */
  49114. class NativeTexture extends InternalTexture {
  49115. getInternalTexture(): InternalTexture;
  49116. getViewCount(): number;
  49117. }
  49118. /** @hidden */
  49119. export class NativeEngine extends Engine {
  49120. private readonly _native;
  49121. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49122. private readonly INVALID_HANDLE;
  49123. getHardwareScalingLevel(): number;
  49124. constructor();
  49125. /**
  49126. * Can be used to override the current requestAnimationFrame requester.
  49127. * @hidden
  49128. */
  49129. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49130. /**
  49131. * Override default engine behavior.
  49132. * @param color
  49133. * @param backBuffer
  49134. * @param depth
  49135. * @param stencil
  49136. */
  49137. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49138. /**
  49139. * Gets host document
  49140. * @returns the host document object
  49141. */
  49142. getHostDocument(): Nullable<Document>;
  49143. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49144. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49145. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49146. recordVertexArrayObject(vertexBuffers: {
  49147. [key: string]: VertexBuffer;
  49148. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49149. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49150. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49151. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49152. /**
  49153. * Draw a list of indexed primitives
  49154. * @param fillMode defines the primitive to use
  49155. * @param indexStart defines the starting index
  49156. * @param indexCount defines the number of index to draw
  49157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49158. */
  49159. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49160. /**
  49161. * Draw a list of unindexed primitives
  49162. * @param fillMode defines the primitive to use
  49163. * @param verticesStart defines the index of first vertex to draw
  49164. * @param verticesCount defines the count of vertices to draw
  49165. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49166. */
  49167. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49168. createPipelineContext(): IPipelineContext;
  49169. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49170. /** @hidden */
  49171. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49172. /** @hidden */
  49173. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49174. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49175. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49176. protected _setProgram(program: WebGLProgram): void;
  49177. _releaseEffect(effect: Effect): void;
  49178. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49179. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49180. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49181. bindSamplers(effect: Effect): void;
  49182. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49183. getRenderWidth(useScreen?: boolean): number;
  49184. getRenderHeight(useScreen?: boolean): number;
  49185. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49186. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49187. /**
  49188. * Set the z offset to apply to current rendering
  49189. * @param value defines the offset to apply
  49190. */
  49191. setZOffset(value: number): void;
  49192. /**
  49193. * Gets the current value of the zOffset
  49194. * @returns the current zOffset state
  49195. */
  49196. getZOffset(): number;
  49197. /**
  49198. * Enable or disable depth buffering
  49199. * @param enable defines the state to set
  49200. */
  49201. setDepthBuffer(enable: boolean): void;
  49202. /**
  49203. * Gets a boolean indicating if depth writing is enabled
  49204. * @returns the current depth writing state
  49205. */
  49206. getDepthWrite(): boolean;
  49207. /**
  49208. * Enable or disable depth writing
  49209. * @param enable defines the state to set
  49210. */
  49211. setDepthWrite(enable: boolean): void;
  49212. /**
  49213. * Enable or disable color writing
  49214. * @param enable defines the state to set
  49215. */
  49216. setColorWrite(enable: boolean): void;
  49217. /**
  49218. * Gets a boolean indicating if color writing is enabled
  49219. * @returns the current color writing state
  49220. */
  49221. getColorWrite(): boolean;
  49222. /**
  49223. * Sets alpha constants used by some alpha blending modes
  49224. * @param r defines the red component
  49225. * @param g defines the green component
  49226. * @param b defines the blue component
  49227. * @param a defines the alpha component
  49228. */
  49229. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49230. /**
  49231. * Sets the current alpha mode
  49232. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49233. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49234. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49235. */
  49236. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49237. /**
  49238. * Gets the current alpha mode
  49239. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49240. * @returns the current alpha mode
  49241. */
  49242. getAlphaMode(): number;
  49243. setInt(uniform: WebGLUniformLocation, int: number): void;
  49244. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49245. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49246. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49247. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49248. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49249. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49250. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49251. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49252. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49253. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49254. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49255. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49256. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49257. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49258. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49259. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49260. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49261. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49262. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49263. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49264. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49265. wipeCaches(bruteForce?: boolean): void;
  49266. _createTexture(): WebGLTexture;
  49267. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49268. /**
  49269. * Usually called from BABYLON.Texture.ts.
  49270. * Passed information to create a WebGLTexture
  49271. * @param urlArg defines a value which contains one of the following:
  49272. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49273. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49274. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49275. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49276. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49277. * @param scene needed for loading to the correct scene
  49278. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49279. * @param onLoad optional callback to be called upon successful completion
  49280. * @param onError optional callback to be called upon failure
  49281. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49282. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49283. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49284. * @param forcedExtension defines the extension to use to pick the right loader
  49285. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49286. */
  49287. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  49288. /**
  49289. * Creates a cube texture
  49290. * @param rootUrl defines the url where the files to load is located
  49291. * @param scene defines the current scene
  49292. * @param files defines the list of files to load (1 per face)
  49293. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49294. * @param onLoad defines an optional callback raised when the texture is loaded
  49295. * @param onError defines an optional callback raised if there is an issue to load the texture
  49296. * @param format defines the format of the data
  49297. * @param forcedExtension defines the extension to use to pick the right loader
  49298. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49299. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49300. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49301. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49302. * @returns the cube texture as an InternalTexture
  49303. */
  49304. 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;
  49305. private _getSamplingFilter;
  49306. private static _GetNativeTextureFormat;
  49307. createRenderTargetTexture(size: number | {
  49308. width: number;
  49309. height: number;
  49310. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49311. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49312. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49313. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49314. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49315. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49316. /**
  49317. * Updates a dynamic vertex buffer.
  49318. * @param vertexBuffer the vertex buffer to update
  49319. * @param data the data used to update the vertex buffer
  49320. * @param byteOffset the byte offset of the data (optional)
  49321. * @param byteLength the byte length of the data (optional)
  49322. */
  49323. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49324. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49325. private _updateAnisotropicLevel;
  49326. private _getAddressMode;
  49327. /** @hidden */
  49328. _bindTexture(channel: number, texture: InternalTexture): void;
  49329. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49330. releaseEffects(): void;
  49331. /** @hidden */
  49332. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49333. /** @hidden */
  49334. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49335. /** @hidden */
  49336. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49337. /** @hidden */
  49338. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49339. }
  49340. }
  49341. declare module "babylonjs/Engines/index" {
  49342. export * from "babylonjs/Engines/constants";
  49343. export * from "babylonjs/Engines/engineCapabilities";
  49344. export * from "babylonjs/Engines/instancingAttributeInfo";
  49345. export * from "babylonjs/Engines/thinEngine";
  49346. export * from "babylonjs/Engines/engine";
  49347. export * from "babylonjs/Engines/engineStore";
  49348. export * from "babylonjs/Engines/nullEngine";
  49349. export * from "babylonjs/Engines/Extensions/index";
  49350. export * from "babylonjs/Engines/IPipelineContext";
  49351. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49352. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49353. export * from "babylonjs/Engines/nativeEngine";
  49354. }
  49355. declare module "babylonjs/Events/clipboardEvents" {
  49356. /**
  49357. * Gather the list of clipboard event types as constants.
  49358. */
  49359. export class ClipboardEventTypes {
  49360. /**
  49361. * The clipboard event is fired when a copy command is active (pressed).
  49362. */
  49363. static readonly COPY: number;
  49364. /**
  49365. * The clipboard event is fired when a cut command is active (pressed).
  49366. */
  49367. static readonly CUT: number;
  49368. /**
  49369. * The clipboard event is fired when a paste command is active (pressed).
  49370. */
  49371. static readonly PASTE: number;
  49372. }
  49373. /**
  49374. * This class is used to store clipboard related info for the onClipboardObservable event.
  49375. */
  49376. export class ClipboardInfo {
  49377. /**
  49378. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49379. */
  49380. type: number;
  49381. /**
  49382. * Defines the related dom event
  49383. */
  49384. event: ClipboardEvent;
  49385. /**
  49386. *Creates an instance of ClipboardInfo.
  49387. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49388. * @param event Defines the related dom event
  49389. */
  49390. constructor(
  49391. /**
  49392. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49393. */
  49394. type: number,
  49395. /**
  49396. * Defines the related dom event
  49397. */
  49398. event: ClipboardEvent);
  49399. /**
  49400. * Get the clipboard event's type from the keycode.
  49401. * @param keyCode Defines the keyCode for the current keyboard event.
  49402. * @return {number}
  49403. */
  49404. static GetTypeFromCharacter(keyCode: number): number;
  49405. }
  49406. }
  49407. declare module "babylonjs/Events/index" {
  49408. export * from "babylonjs/Events/keyboardEvents";
  49409. export * from "babylonjs/Events/pointerEvents";
  49410. export * from "babylonjs/Events/clipboardEvents";
  49411. }
  49412. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49413. import { Scene } from "babylonjs/scene";
  49414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49415. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49416. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49417. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49418. /**
  49419. * Google Daydream controller
  49420. */
  49421. export class DaydreamController extends WebVRController {
  49422. /**
  49423. * Base Url for the controller model.
  49424. */
  49425. static MODEL_BASE_URL: string;
  49426. /**
  49427. * File name for the controller model.
  49428. */
  49429. static MODEL_FILENAME: string;
  49430. /**
  49431. * Gamepad Id prefix used to identify Daydream Controller.
  49432. */
  49433. static readonly GAMEPAD_ID_PREFIX: string;
  49434. /**
  49435. * Creates a new DaydreamController from a gamepad
  49436. * @param vrGamepad the gamepad that the controller should be created from
  49437. */
  49438. constructor(vrGamepad: any);
  49439. /**
  49440. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49441. * @param scene scene in which to add meshes
  49442. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49443. */
  49444. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49445. /**
  49446. * Called once for each button that changed state since the last frame
  49447. * @param buttonIdx Which button index changed
  49448. * @param state New state of the button
  49449. * @param changes Which properties on the state changed since last frame
  49450. */
  49451. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49452. }
  49453. }
  49454. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49455. import { Scene } from "babylonjs/scene";
  49456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49457. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49458. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49459. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49460. /**
  49461. * Gear VR Controller
  49462. */
  49463. export class GearVRController extends WebVRController {
  49464. /**
  49465. * Base Url for the controller model.
  49466. */
  49467. static MODEL_BASE_URL: string;
  49468. /**
  49469. * File name for the controller model.
  49470. */
  49471. static MODEL_FILENAME: string;
  49472. /**
  49473. * Gamepad Id prefix used to identify this controller.
  49474. */
  49475. static readonly GAMEPAD_ID_PREFIX: string;
  49476. private readonly _buttonIndexToObservableNameMap;
  49477. /**
  49478. * Creates a new GearVRController from a gamepad
  49479. * @param vrGamepad the gamepad that the controller should be created from
  49480. */
  49481. constructor(vrGamepad: any);
  49482. /**
  49483. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49484. * @param scene scene in which to add meshes
  49485. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49486. */
  49487. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49488. /**
  49489. * Called once for each button that changed state since the last frame
  49490. * @param buttonIdx Which button index changed
  49491. * @param state New state of the button
  49492. * @param changes Which properties on the state changed since last frame
  49493. */
  49494. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49495. }
  49496. }
  49497. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49498. import { Scene } from "babylonjs/scene";
  49499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49500. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49501. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49502. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49503. /**
  49504. * Generic Controller
  49505. */
  49506. export class GenericController extends WebVRController {
  49507. /**
  49508. * Base Url for the controller model.
  49509. */
  49510. static readonly MODEL_BASE_URL: string;
  49511. /**
  49512. * File name for the controller model.
  49513. */
  49514. static readonly MODEL_FILENAME: string;
  49515. /**
  49516. * Creates a new GenericController from a gamepad
  49517. * @param vrGamepad the gamepad that the controller should be created from
  49518. */
  49519. constructor(vrGamepad: any);
  49520. /**
  49521. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49522. * @param scene scene in which to add meshes
  49523. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49524. */
  49525. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49526. /**
  49527. * Called once for each button that changed state since the last frame
  49528. * @param buttonIdx Which button index changed
  49529. * @param state New state of the button
  49530. * @param changes Which properties on the state changed since last frame
  49531. */
  49532. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49533. }
  49534. }
  49535. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49536. import { Observable } from "babylonjs/Misc/observable";
  49537. import { Scene } from "babylonjs/scene";
  49538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49539. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49540. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49541. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49542. /**
  49543. * Oculus Touch Controller
  49544. */
  49545. export class OculusTouchController extends WebVRController {
  49546. /**
  49547. * Base Url for the controller model.
  49548. */
  49549. static MODEL_BASE_URL: string;
  49550. /**
  49551. * File name for the left controller model.
  49552. */
  49553. static MODEL_LEFT_FILENAME: string;
  49554. /**
  49555. * File name for the right controller model.
  49556. */
  49557. static MODEL_RIGHT_FILENAME: string;
  49558. /**
  49559. * Base Url for the Quest controller model.
  49560. */
  49561. static QUEST_MODEL_BASE_URL: string;
  49562. /**
  49563. * @hidden
  49564. * If the controllers are running on a device that needs the updated Quest controller models
  49565. */
  49566. static _IsQuest: boolean;
  49567. /**
  49568. * Fired when the secondary trigger on this controller is modified
  49569. */
  49570. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49571. /**
  49572. * Fired when the thumb rest on this controller is modified
  49573. */
  49574. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49575. /**
  49576. * Creates a new OculusTouchController from a gamepad
  49577. * @param vrGamepad the gamepad that the controller should be created from
  49578. */
  49579. constructor(vrGamepad: any);
  49580. /**
  49581. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49582. * @param scene scene in which to add meshes
  49583. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49584. */
  49585. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49586. /**
  49587. * Fired when the A button on this controller is modified
  49588. */
  49589. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49590. /**
  49591. * Fired when the B button on this controller is modified
  49592. */
  49593. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49594. /**
  49595. * Fired when the X button on this controller is modified
  49596. */
  49597. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49598. /**
  49599. * Fired when the Y button on this controller is modified
  49600. */
  49601. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49602. /**
  49603. * Called once for each button that changed state since the last frame
  49604. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49605. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49606. * 2) secondary trigger (same)
  49607. * 3) A (right) X (left), touch, pressed = value
  49608. * 4) B / Y
  49609. * 5) thumb rest
  49610. * @param buttonIdx Which button index changed
  49611. * @param state New state of the button
  49612. * @param changes Which properties on the state changed since last frame
  49613. */
  49614. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49615. }
  49616. }
  49617. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49618. import { Scene } from "babylonjs/scene";
  49619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49620. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49621. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49622. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49623. import { Observable } from "babylonjs/Misc/observable";
  49624. /**
  49625. * Vive Controller
  49626. */
  49627. export class ViveController extends WebVRController {
  49628. /**
  49629. * Base Url for the controller model.
  49630. */
  49631. static MODEL_BASE_URL: string;
  49632. /**
  49633. * File name for the controller model.
  49634. */
  49635. static MODEL_FILENAME: string;
  49636. /**
  49637. * Creates a new ViveController from a gamepad
  49638. * @param vrGamepad the gamepad that the controller should be created from
  49639. */
  49640. constructor(vrGamepad: any);
  49641. /**
  49642. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49643. * @param scene scene in which to add meshes
  49644. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49645. */
  49646. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49647. /**
  49648. * Fired when the left button on this controller is modified
  49649. */
  49650. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49651. /**
  49652. * Fired when the right button on this controller is modified
  49653. */
  49654. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49655. /**
  49656. * Fired when the menu button on this controller is modified
  49657. */
  49658. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49659. /**
  49660. * Called once for each button that changed state since the last frame
  49661. * Vive mapping:
  49662. * 0: touchpad
  49663. * 1: trigger
  49664. * 2: left AND right buttons
  49665. * 3: menu button
  49666. * @param buttonIdx Which button index changed
  49667. * @param state New state of the button
  49668. * @param changes Which properties on the state changed since last frame
  49669. */
  49670. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49671. }
  49672. }
  49673. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49674. import { Observable } from "babylonjs/Misc/observable";
  49675. import { Scene } from "babylonjs/scene";
  49676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49677. import { Ray } from "babylonjs/Culling/ray";
  49678. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49679. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49680. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49681. /**
  49682. * Defines the WindowsMotionController object that the state of the windows motion controller
  49683. */
  49684. export class WindowsMotionController extends WebVRController {
  49685. /**
  49686. * The base url used to load the left and right controller models
  49687. */
  49688. static MODEL_BASE_URL: string;
  49689. /**
  49690. * The name of the left controller model file
  49691. */
  49692. static MODEL_LEFT_FILENAME: string;
  49693. /**
  49694. * The name of the right controller model file
  49695. */
  49696. static MODEL_RIGHT_FILENAME: string;
  49697. /**
  49698. * The controller name prefix for this controller type
  49699. */
  49700. static readonly GAMEPAD_ID_PREFIX: string;
  49701. /**
  49702. * The controller id pattern for this controller type
  49703. */
  49704. private static readonly GAMEPAD_ID_PATTERN;
  49705. private _loadedMeshInfo;
  49706. protected readonly _mapping: {
  49707. buttons: string[];
  49708. buttonMeshNames: {
  49709. 'trigger': string;
  49710. 'menu': string;
  49711. 'grip': string;
  49712. 'thumbstick': string;
  49713. 'trackpad': string;
  49714. };
  49715. buttonObservableNames: {
  49716. 'trigger': string;
  49717. 'menu': string;
  49718. 'grip': string;
  49719. 'thumbstick': string;
  49720. 'trackpad': string;
  49721. };
  49722. axisMeshNames: string[];
  49723. pointingPoseMeshName: string;
  49724. };
  49725. /**
  49726. * Fired when the trackpad on this controller is clicked
  49727. */
  49728. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49729. /**
  49730. * Fired when the trackpad on this controller is modified
  49731. */
  49732. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49733. /**
  49734. * The current x and y values of this controller's trackpad
  49735. */
  49736. trackpad: StickValues;
  49737. /**
  49738. * Creates a new WindowsMotionController from a gamepad
  49739. * @param vrGamepad the gamepad that the controller should be created from
  49740. */
  49741. constructor(vrGamepad: any);
  49742. /**
  49743. * Fired when the trigger on this controller is modified
  49744. */
  49745. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49746. /**
  49747. * Fired when the menu button on this controller is modified
  49748. */
  49749. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49750. /**
  49751. * Fired when the grip button on this controller is modified
  49752. */
  49753. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49754. /**
  49755. * Fired when the thumbstick button on this controller is modified
  49756. */
  49757. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49758. /**
  49759. * Fired when the touchpad button on this controller is modified
  49760. */
  49761. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49762. /**
  49763. * Fired when the touchpad values on this controller are modified
  49764. */
  49765. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  49766. protected _updateTrackpad(): void;
  49767. /**
  49768. * Called once per frame by the engine.
  49769. */
  49770. update(): void;
  49771. /**
  49772. * Called once for each button that changed state since the last frame
  49773. * @param buttonIdx Which button index changed
  49774. * @param state New state of the button
  49775. * @param changes Which properties on the state changed since last frame
  49776. */
  49777. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49778. /**
  49779. * Moves the buttons on the controller mesh based on their current state
  49780. * @param buttonName the name of the button to move
  49781. * @param buttonValue the value of the button which determines the buttons new position
  49782. */
  49783. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  49784. /**
  49785. * Moves the axis on the controller mesh based on its current state
  49786. * @param axis the index of the axis
  49787. * @param axisValue the value of the axis which determines the meshes new position
  49788. * @hidden
  49789. */
  49790. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  49791. /**
  49792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49793. * @param scene scene in which to add meshes
  49794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49795. */
  49796. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  49797. /**
  49798. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  49799. * can be transformed by button presses and axes values, based on this._mapping.
  49800. *
  49801. * @param scene scene in which the meshes exist
  49802. * @param meshes list of meshes that make up the controller model to process
  49803. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  49804. */
  49805. private processModel;
  49806. private createMeshInfo;
  49807. /**
  49808. * Gets the ray of the controller in the direction the controller is pointing
  49809. * @param length the length the resulting ray should be
  49810. * @returns a ray in the direction the controller is pointing
  49811. */
  49812. getForwardRay(length?: number): Ray;
  49813. /**
  49814. * Disposes of the controller
  49815. */
  49816. dispose(): void;
  49817. }
  49818. /**
  49819. * This class represents a new windows motion controller in XR.
  49820. */
  49821. export class XRWindowsMotionController extends WindowsMotionController {
  49822. /**
  49823. * Changing the original WIndowsMotionController mapping to fir the new mapping
  49824. */
  49825. protected readonly _mapping: {
  49826. buttons: string[];
  49827. buttonMeshNames: {
  49828. 'trigger': string;
  49829. 'menu': string;
  49830. 'grip': string;
  49831. 'thumbstick': string;
  49832. 'trackpad': string;
  49833. };
  49834. buttonObservableNames: {
  49835. 'trigger': string;
  49836. 'menu': string;
  49837. 'grip': string;
  49838. 'thumbstick': string;
  49839. 'trackpad': string;
  49840. };
  49841. axisMeshNames: string[];
  49842. pointingPoseMeshName: string;
  49843. };
  49844. /**
  49845. * Construct a new XR-Based windows motion controller
  49846. *
  49847. * @param gamepadInfo the gamepad object from the browser
  49848. */
  49849. constructor(gamepadInfo: any);
  49850. /**
  49851. * holds the thumbstick values (X,Y)
  49852. */
  49853. thumbstickValues: StickValues;
  49854. /**
  49855. * Fired when the thumbstick on this controller is clicked
  49856. */
  49857. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  49858. /**
  49859. * Fired when the thumbstick on this controller is modified
  49860. */
  49861. onThumbstickValuesChangedObservable: Observable<StickValues>;
  49862. /**
  49863. * Fired when the touchpad button on this controller is modified
  49864. */
  49865. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49866. /**
  49867. * Fired when the touchpad values on this controller are modified
  49868. */
  49869. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49870. /**
  49871. * Fired when the thumbstick button on this controller is modified
  49872. * here to prevent breaking changes
  49873. */
  49874. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49875. /**
  49876. * updating the thumbstick(!) and not the trackpad.
  49877. * This is named this way due to the difference between WebVR and XR and to avoid
  49878. * changing the parent class.
  49879. */
  49880. protected _updateTrackpad(): void;
  49881. /**
  49882. * Disposes the class with joy
  49883. */
  49884. dispose(): void;
  49885. }
  49886. }
  49887. declare module "babylonjs/Gamepads/Controllers/index" {
  49888. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49889. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49890. export * from "babylonjs/Gamepads/Controllers/genericController";
  49891. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49892. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49893. export * from "babylonjs/Gamepads/Controllers/viveController";
  49894. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49895. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49896. }
  49897. declare module "babylonjs/Gamepads/index" {
  49898. export * from "babylonjs/Gamepads/Controllers/index";
  49899. export * from "babylonjs/Gamepads/gamepad";
  49900. export * from "babylonjs/Gamepads/gamepadManager";
  49901. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49902. export * from "babylonjs/Gamepads/xboxGamepad";
  49903. export * from "babylonjs/Gamepads/dualShockGamepad";
  49904. }
  49905. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49906. import { Scene } from "babylonjs/scene";
  49907. import { Vector4 } from "babylonjs/Maths/math.vector";
  49908. import { Color4 } from "babylonjs/Maths/math.color";
  49909. import { Mesh } from "babylonjs/Meshes/mesh";
  49910. import { Nullable } from "babylonjs/types";
  49911. /**
  49912. * Class containing static functions to help procedurally build meshes
  49913. */
  49914. export class PolyhedronBuilder {
  49915. /**
  49916. * Creates a polyhedron mesh
  49917. * * 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
  49918. * * The parameter `size` (positive float, default 1) sets the polygon size
  49919. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49920. * * 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`
  49921. * * 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
  49922. * * 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)`)
  49923. * * 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
  49924. * * 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
  49925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49928. * @param name defines the name of the mesh
  49929. * @param options defines the options used to create the mesh
  49930. * @param scene defines the hosting scene
  49931. * @returns the polyhedron mesh
  49932. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49933. */
  49934. static CreatePolyhedron(name: string, options: {
  49935. type?: number;
  49936. size?: number;
  49937. sizeX?: number;
  49938. sizeY?: number;
  49939. sizeZ?: number;
  49940. custom?: any;
  49941. faceUV?: Vector4[];
  49942. faceColors?: Color4[];
  49943. flat?: boolean;
  49944. updatable?: boolean;
  49945. sideOrientation?: number;
  49946. frontUVs?: Vector4;
  49947. backUVs?: Vector4;
  49948. }, scene?: Nullable<Scene>): Mesh;
  49949. }
  49950. }
  49951. declare module "babylonjs/Gizmos/scaleGizmo" {
  49952. import { Observable } from "babylonjs/Misc/observable";
  49953. import { Nullable } from "babylonjs/types";
  49954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49955. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49956. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49957. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49958. /**
  49959. * Gizmo that enables scaling a mesh along 3 axis
  49960. */
  49961. export class ScaleGizmo extends Gizmo {
  49962. /**
  49963. * Internal gizmo used for interactions on the x axis
  49964. */
  49965. xGizmo: AxisScaleGizmo;
  49966. /**
  49967. * Internal gizmo used for interactions on the y axis
  49968. */
  49969. yGizmo: AxisScaleGizmo;
  49970. /**
  49971. * Internal gizmo used for interactions on the z axis
  49972. */
  49973. zGizmo: AxisScaleGizmo;
  49974. /**
  49975. * Internal gizmo used to scale all axis equally
  49976. */
  49977. uniformScaleGizmo: AxisScaleGizmo;
  49978. private _meshAttached;
  49979. private _updateGizmoRotationToMatchAttachedMesh;
  49980. private _snapDistance;
  49981. private _scaleRatio;
  49982. private _uniformScalingMesh;
  49983. private _octahedron;
  49984. private _sensitivity;
  49985. /** Fires an event when any of it's sub gizmos are dragged */
  49986. onDragStartObservable: Observable<unknown>;
  49987. /** Fires an event when any of it's sub gizmos are released from dragging */
  49988. onDragEndObservable: Observable<unknown>;
  49989. get attachedMesh(): Nullable<AbstractMesh>;
  49990. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49991. /**
  49992. * Creates a ScaleGizmo
  49993. * @param gizmoLayer The utility layer the gizmo will be added to
  49994. */
  49995. constructor(gizmoLayer?: UtilityLayerRenderer);
  49996. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49997. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49998. /**
  49999. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50000. */
  50001. set snapDistance(value: number);
  50002. get snapDistance(): number;
  50003. /**
  50004. * Ratio for the scale of the gizmo (Default: 1)
  50005. */
  50006. set scaleRatio(value: number);
  50007. get scaleRatio(): number;
  50008. /**
  50009. * Sensitivity factor for dragging (Default: 1)
  50010. */
  50011. set sensitivity(value: number);
  50012. get sensitivity(): number;
  50013. /**
  50014. * Disposes of the gizmo
  50015. */
  50016. dispose(): void;
  50017. }
  50018. }
  50019. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50020. import { Observable } from "babylonjs/Misc/observable";
  50021. import { Nullable } from "babylonjs/types";
  50022. import { Vector3 } from "babylonjs/Maths/math.vector";
  50023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50024. import { Mesh } from "babylonjs/Meshes/mesh";
  50025. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50026. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50027. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50028. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50029. import { Color3 } from "babylonjs/Maths/math.color";
  50030. /**
  50031. * Single axis scale gizmo
  50032. */
  50033. export class AxisScaleGizmo extends Gizmo {
  50034. /**
  50035. * Drag behavior responsible for the gizmos dragging interactions
  50036. */
  50037. dragBehavior: PointerDragBehavior;
  50038. private _pointerObserver;
  50039. /**
  50040. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50041. */
  50042. snapDistance: number;
  50043. /**
  50044. * Event that fires each time the gizmo snaps to a new location.
  50045. * * snapDistance is the the change in distance
  50046. */
  50047. onSnapObservable: Observable<{
  50048. snapDistance: number;
  50049. }>;
  50050. /**
  50051. * If the scaling operation should be done on all axis (default: false)
  50052. */
  50053. uniformScaling: boolean;
  50054. /**
  50055. * Custom sensitivity value for the drag strength
  50056. */
  50057. sensitivity: number;
  50058. private _isEnabled;
  50059. private _parent;
  50060. private _arrow;
  50061. private _coloredMaterial;
  50062. private _hoverMaterial;
  50063. /**
  50064. * Creates an AxisScaleGizmo
  50065. * @param gizmoLayer The utility layer the gizmo will be added to
  50066. * @param dragAxis The axis which the gizmo will be able to scale on
  50067. * @param color The color of the gizmo
  50068. */
  50069. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50070. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50071. /**
  50072. * If the gizmo is enabled
  50073. */
  50074. set isEnabled(value: boolean);
  50075. get isEnabled(): boolean;
  50076. /**
  50077. * Disposes of the gizmo
  50078. */
  50079. dispose(): void;
  50080. /**
  50081. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50082. * @param mesh The mesh to replace the default mesh of the gizmo
  50083. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50084. */
  50085. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50086. }
  50087. }
  50088. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50089. import { Observable } from "babylonjs/Misc/observable";
  50090. import { Nullable } from "babylonjs/types";
  50091. import { Vector3 } from "babylonjs/Maths/math.vector";
  50092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50093. import { Mesh } from "babylonjs/Meshes/mesh";
  50094. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50095. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50096. import { Color3 } from "babylonjs/Maths/math.color";
  50097. import "babylonjs/Meshes/Builders/boxBuilder";
  50098. /**
  50099. * Bounding box gizmo
  50100. */
  50101. export class BoundingBoxGizmo extends Gizmo {
  50102. private _lineBoundingBox;
  50103. private _rotateSpheresParent;
  50104. private _scaleBoxesParent;
  50105. private _boundingDimensions;
  50106. private _renderObserver;
  50107. private _pointerObserver;
  50108. private _scaleDragSpeed;
  50109. private _tmpQuaternion;
  50110. private _tmpVector;
  50111. private _tmpRotationMatrix;
  50112. /**
  50113. * 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)
  50114. */
  50115. ignoreChildren: boolean;
  50116. /**
  50117. * 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)
  50118. */
  50119. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50120. /**
  50121. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50122. */
  50123. rotationSphereSize: number;
  50124. /**
  50125. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50126. */
  50127. scaleBoxSize: number;
  50128. /**
  50129. * 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)
  50130. */
  50131. fixedDragMeshScreenSize: boolean;
  50132. /**
  50133. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50134. */
  50135. fixedDragMeshScreenSizeDistanceFactor: number;
  50136. /**
  50137. * Fired when a rotation sphere or scale box is dragged
  50138. */
  50139. onDragStartObservable: Observable<{}>;
  50140. /**
  50141. * Fired when a scale box is dragged
  50142. */
  50143. onScaleBoxDragObservable: Observable<{}>;
  50144. /**
  50145. * Fired when a scale box drag is ended
  50146. */
  50147. onScaleBoxDragEndObservable: Observable<{}>;
  50148. /**
  50149. * Fired when a rotation sphere is dragged
  50150. */
  50151. onRotationSphereDragObservable: Observable<{}>;
  50152. /**
  50153. * Fired when a rotation sphere drag is ended
  50154. */
  50155. onRotationSphereDragEndObservable: Observable<{}>;
  50156. /**
  50157. * 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)
  50158. */
  50159. scalePivot: Nullable<Vector3>;
  50160. /**
  50161. * Mesh used as a pivot to rotate the attached mesh
  50162. */
  50163. private _anchorMesh;
  50164. private _existingMeshScale;
  50165. private _dragMesh;
  50166. private pointerDragBehavior;
  50167. private coloredMaterial;
  50168. private hoverColoredMaterial;
  50169. /**
  50170. * Sets the color of the bounding box gizmo
  50171. * @param color the color to set
  50172. */
  50173. setColor(color: Color3): void;
  50174. /**
  50175. * Creates an BoundingBoxGizmo
  50176. * @param gizmoLayer The utility layer the gizmo will be added to
  50177. * @param color The color of the gizmo
  50178. */
  50179. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50180. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50181. private _selectNode;
  50182. /**
  50183. * Updates the bounding box information for the Gizmo
  50184. */
  50185. updateBoundingBox(): void;
  50186. private _updateRotationSpheres;
  50187. private _updateScaleBoxes;
  50188. /**
  50189. * Enables rotation on the specified axis and disables rotation on the others
  50190. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50191. */
  50192. setEnabledRotationAxis(axis: string): void;
  50193. /**
  50194. * Enables/disables scaling
  50195. * @param enable if scaling should be enabled
  50196. */
  50197. setEnabledScaling(enable: boolean): void;
  50198. private _updateDummy;
  50199. /**
  50200. * Enables a pointer drag behavior on the bounding box of the gizmo
  50201. */
  50202. enableDragBehavior(): void;
  50203. /**
  50204. * Disposes of the gizmo
  50205. */
  50206. dispose(): void;
  50207. /**
  50208. * 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)
  50209. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50210. * @returns the bounding box mesh with the passed in mesh as a child
  50211. */
  50212. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50213. /**
  50214. * CustomMeshes are not supported by this gizmo
  50215. * @param mesh The mesh to replace the default mesh of the gizmo
  50216. */
  50217. setCustomMesh(mesh: Mesh): void;
  50218. }
  50219. }
  50220. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50221. import { Observable } from "babylonjs/Misc/observable";
  50222. import { Nullable } from "babylonjs/types";
  50223. import { Vector3 } from "babylonjs/Maths/math.vector";
  50224. import { Color3 } from "babylonjs/Maths/math.color";
  50225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50226. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50227. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50228. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50229. import "babylonjs/Meshes/Builders/linesBuilder";
  50230. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50231. /**
  50232. * Single plane rotation gizmo
  50233. */
  50234. export class PlaneRotationGizmo extends Gizmo {
  50235. /**
  50236. * Drag behavior responsible for the gizmos dragging interactions
  50237. */
  50238. dragBehavior: PointerDragBehavior;
  50239. private _pointerObserver;
  50240. /**
  50241. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50242. */
  50243. snapDistance: number;
  50244. /**
  50245. * Event that fires each time the gizmo snaps to a new location.
  50246. * * snapDistance is the the change in distance
  50247. */
  50248. onSnapObservable: Observable<{
  50249. snapDistance: number;
  50250. }>;
  50251. private _isEnabled;
  50252. private _parent;
  50253. /**
  50254. * Creates a PlaneRotationGizmo
  50255. * @param gizmoLayer The utility layer the gizmo will be added to
  50256. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50257. * @param color The color of the gizmo
  50258. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50259. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50260. */
  50261. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50262. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50263. /**
  50264. * If the gizmo is enabled
  50265. */
  50266. set isEnabled(value: boolean);
  50267. get isEnabled(): boolean;
  50268. /**
  50269. * Disposes of the gizmo
  50270. */
  50271. dispose(): void;
  50272. }
  50273. }
  50274. declare module "babylonjs/Gizmos/rotationGizmo" {
  50275. import { Observable } from "babylonjs/Misc/observable";
  50276. import { Nullable } from "babylonjs/types";
  50277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50278. import { Mesh } from "babylonjs/Meshes/mesh";
  50279. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50280. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50281. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50282. /**
  50283. * Gizmo that enables rotating a mesh along 3 axis
  50284. */
  50285. export class RotationGizmo extends Gizmo {
  50286. /**
  50287. * Internal gizmo used for interactions on the x axis
  50288. */
  50289. xGizmo: PlaneRotationGizmo;
  50290. /**
  50291. * Internal gizmo used for interactions on the y axis
  50292. */
  50293. yGizmo: PlaneRotationGizmo;
  50294. /**
  50295. * Internal gizmo used for interactions on the z axis
  50296. */
  50297. zGizmo: PlaneRotationGizmo;
  50298. /** Fires an event when any of it's sub gizmos are dragged */
  50299. onDragStartObservable: Observable<unknown>;
  50300. /** Fires an event when any of it's sub gizmos are released from dragging */
  50301. onDragEndObservable: Observable<unknown>;
  50302. private _meshAttached;
  50303. get attachedMesh(): Nullable<AbstractMesh>;
  50304. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50305. /**
  50306. * Creates a RotationGizmo
  50307. * @param gizmoLayer The utility layer the gizmo will be added to
  50308. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50309. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50310. */
  50311. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50312. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50313. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50314. /**
  50315. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50316. */
  50317. set snapDistance(value: number);
  50318. get snapDistance(): number;
  50319. /**
  50320. * Ratio for the scale of the gizmo (Default: 1)
  50321. */
  50322. set scaleRatio(value: number);
  50323. get scaleRatio(): number;
  50324. /**
  50325. * Disposes of the gizmo
  50326. */
  50327. dispose(): void;
  50328. /**
  50329. * CustomMeshes are not supported by this gizmo
  50330. * @param mesh The mesh to replace the default mesh of the gizmo
  50331. */
  50332. setCustomMesh(mesh: Mesh): void;
  50333. }
  50334. }
  50335. declare module "babylonjs/Gizmos/gizmoManager" {
  50336. import { Observable } from "babylonjs/Misc/observable";
  50337. import { Nullable } from "babylonjs/types";
  50338. import { Scene, IDisposable } from "babylonjs/scene";
  50339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50340. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50341. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50342. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50343. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50344. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50345. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50346. /**
  50347. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50348. */
  50349. export class GizmoManager implements IDisposable {
  50350. private scene;
  50351. /**
  50352. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50353. */
  50354. gizmos: {
  50355. positionGizmo: Nullable<PositionGizmo>;
  50356. rotationGizmo: Nullable<RotationGizmo>;
  50357. scaleGizmo: Nullable<ScaleGizmo>;
  50358. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50359. };
  50360. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50361. clearGizmoOnEmptyPointerEvent: boolean;
  50362. /** Fires an event when the manager is attached to a mesh */
  50363. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50364. private _gizmosEnabled;
  50365. private _pointerObserver;
  50366. private _attachedMesh;
  50367. private _boundingBoxColor;
  50368. private _defaultUtilityLayer;
  50369. private _defaultKeepDepthUtilityLayer;
  50370. /**
  50371. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50372. */
  50373. boundingBoxDragBehavior: SixDofDragBehavior;
  50374. /**
  50375. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50376. */
  50377. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50378. /**
  50379. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50380. */
  50381. usePointerToAttachGizmos: boolean;
  50382. /**
  50383. * Utility layer that the bounding box gizmo belongs to
  50384. */
  50385. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50386. /**
  50387. * Utility layer that all gizmos besides bounding box belong to
  50388. */
  50389. get utilityLayer(): UtilityLayerRenderer;
  50390. /**
  50391. * Instatiates a gizmo manager
  50392. * @param scene the scene to overlay the gizmos on top of
  50393. */
  50394. constructor(scene: Scene);
  50395. /**
  50396. * Attaches a set of gizmos to the specified mesh
  50397. * @param mesh The mesh the gizmo's should be attached to
  50398. */
  50399. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50400. /**
  50401. * If the position gizmo is enabled
  50402. */
  50403. set positionGizmoEnabled(value: boolean);
  50404. get positionGizmoEnabled(): boolean;
  50405. /**
  50406. * If the rotation gizmo is enabled
  50407. */
  50408. set rotationGizmoEnabled(value: boolean);
  50409. get rotationGizmoEnabled(): boolean;
  50410. /**
  50411. * If the scale gizmo is enabled
  50412. */
  50413. set scaleGizmoEnabled(value: boolean);
  50414. get scaleGizmoEnabled(): boolean;
  50415. /**
  50416. * If the boundingBox gizmo is enabled
  50417. */
  50418. set boundingBoxGizmoEnabled(value: boolean);
  50419. get boundingBoxGizmoEnabled(): boolean;
  50420. /**
  50421. * Disposes of the gizmo manager
  50422. */
  50423. dispose(): void;
  50424. }
  50425. }
  50426. declare module "babylonjs/Lights/directionalLight" {
  50427. import { Camera } from "babylonjs/Cameras/camera";
  50428. import { Scene } from "babylonjs/scene";
  50429. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50431. import { Light } from "babylonjs/Lights/light";
  50432. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50433. import { Effect } from "babylonjs/Materials/effect";
  50434. /**
  50435. * A directional light is defined by a direction (what a surprise!).
  50436. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50437. * 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.
  50438. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50439. */
  50440. export class DirectionalLight extends ShadowLight {
  50441. private _shadowFrustumSize;
  50442. /**
  50443. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50444. */
  50445. get shadowFrustumSize(): number;
  50446. /**
  50447. * Specifies a fix frustum size for the shadow generation.
  50448. */
  50449. set shadowFrustumSize(value: number);
  50450. private _shadowOrthoScale;
  50451. /**
  50452. * Gets the shadow projection scale against the optimal computed one.
  50453. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50454. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50455. */
  50456. get shadowOrthoScale(): number;
  50457. /**
  50458. * Sets the shadow projection scale against the optimal computed one.
  50459. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50460. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50461. */
  50462. set shadowOrthoScale(value: number);
  50463. /**
  50464. * Automatically compute the projection matrix to best fit (including all the casters)
  50465. * on each frame.
  50466. */
  50467. autoUpdateExtends: boolean;
  50468. /**
  50469. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50470. * on each frame. autoUpdateExtends must be set to true for this to work
  50471. */
  50472. autoCalcShadowZBounds: boolean;
  50473. private _orthoLeft;
  50474. private _orthoRight;
  50475. private _orthoTop;
  50476. private _orthoBottom;
  50477. /**
  50478. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50479. * The directional light is emitted from everywhere in the given direction.
  50480. * It can cast shadows.
  50481. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50482. * @param name The friendly name of the light
  50483. * @param direction The direction of the light
  50484. * @param scene The scene the light belongs to
  50485. */
  50486. constructor(name: string, direction: Vector3, scene: Scene);
  50487. /**
  50488. * Returns the string "DirectionalLight".
  50489. * @return The class name
  50490. */
  50491. getClassName(): string;
  50492. /**
  50493. * Returns the integer 1.
  50494. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50495. */
  50496. getTypeID(): number;
  50497. /**
  50498. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50499. * Returns the DirectionalLight Shadow projection matrix.
  50500. */
  50501. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50502. /**
  50503. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50504. * Returns the DirectionalLight Shadow projection matrix.
  50505. */
  50506. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50507. /**
  50508. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50509. * Returns the DirectionalLight Shadow projection matrix.
  50510. */
  50511. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50512. protected _buildUniformLayout(): void;
  50513. /**
  50514. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50515. * @param effect The effect to update
  50516. * @param lightIndex The index of the light in the effect to update
  50517. * @returns The directional light
  50518. */
  50519. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50520. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50521. /**
  50522. * Gets the minZ used for shadow according to both the scene and the light.
  50523. *
  50524. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50525. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50526. * @param activeCamera The camera we are returning the min for
  50527. * @returns the depth min z
  50528. */
  50529. getDepthMinZ(activeCamera: Camera): number;
  50530. /**
  50531. * Gets the maxZ used for shadow according to both the scene and the light.
  50532. *
  50533. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50534. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50535. * @param activeCamera The camera we are returning the max for
  50536. * @returns the depth max z
  50537. */
  50538. getDepthMaxZ(activeCamera: Camera): number;
  50539. /**
  50540. * Prepares the list of defines specific to the light type.
  50541. * @param defines the list of defines
  50542. * @param lightIndex defines the index of the light for the effect
  50543. */
  50544. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50545. }
  50546. }
  50547. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50548. import { Mesh } from "babylonjs/Meshes/mesh";
  50549. /**
  50550. * Class containing static functions to help procedurally build meshes
  50551. */
  50552. export class HemisphereBuilder {
  50553. /**
  50554. * Creates a hemisphere mesh
  50555. * @param name defines the name of the mesh
  50556. * @param options defines the options used to create the mesh
  50557. * @param scene defines the hosting scene
  50558. * @returns the hemisphere mesh
  50559. */
  50560. static CreateHemisphere(name: string, options: {
  50561. segments?: number;
  50562. diameter?: number;
  50563. sideOrientation?: number;
  50564. }, scene: any): Mesh;
  50565. }
  50566. }
  50567. declare module "babylonjs/Lights/spotLight" {
  50568. import { Nullable } from "babylonjs/types";
  50569. import { Scene } from "babylonjs/scene";
  50570. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50572. import { Effect } from "babylonjs/Materials/effect";
  50573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50574. import { Light } from "babylonjs/Lights/light";
  50575. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50576. /**
  50577. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50578. * These values define a cone of light starting from the position, emitting toward the direction.
  50579. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50580. * and the exponent defines the speed of the decay of the light with distance (reach).
  50581. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50582. */
  50583. export class SpotLight extends ShadowLight {
  50584. private _angle;
  50585. private _innerAngle;
  50586. private _cosHalfAngle;
  50587. private _lightAngleScale;
  50588. private _lightAngleOffset;
  50589. /**
  50590. * Gets the cone angle of the spot light in Radians.
  50591. */
  50592. get angle(): number;
  50593. /**
  50594. * Sets the cone angle of the spot light in Radians.
  50595. */
  50596. set angle(value: number);
  50597. /**
  50598. * Only used in gltf falloff mode, this defines the angle where
  50599. * the directional falloff will start before cutting at angle which could be seen
  50600. * as outer angle.
  50601. */
  50602. get innerAngle(): number;
  50603. /**
  50604. * Only used in gltf falloff mode, this defines the angle where
  50605. * the directional falloff will start before cutting at angle which could be seen
  50606. * as outer angle.
  50607. */
  50608. set innerAngle(value: number);
  50609. private _shadowAngleScale;
  50610. /**
  50611. * Allows scaling the angle of the light for shadow generation only.
  50612. */
  50613. get shadowAngleScale(): number;
  50614. /**
  50615. * Allows scaling the angle of the light for shadow generation only.
  50616. */
  50617. set shadowAngleScale(value: number);
  50618. /**
  50619. * The light decay speed with the distance from the emission spot.
  50620. */
  50621. exponent: number;
  50622. private _projectionTextureMatrix;
  50623. /**
  50624. * Allows reading the projecton texture
  50625. */
  50626. get projectionTextureMatrix(): Matrix;
  50627. protected _projectionTextureLightNear: number;
  50628. /**
  50629. * Gets the near clip of the Spotlight for texture projection.
  50630. */
  50631. get projectionTextureLightNear(): number;
  50632. /**
  50633. * Sets the near clip of the Spotlight for texture projection.
  50634. */
  50635. set projectionTextureLightNear(value: number);
  50636. protected _projectionTextureLightFar: number;
  50637. /**
  50638. * Gets the far clip of the Spotlight for texture projection.
  50639. */
  50640. get projectionTextureLightFar(): number;
  50641. /**
  50642. * Sets the far clip of the Spotlight for texture projection.
  50643. */
  50644. set projectionTextureLightFar(value: number);
  50645. protected _projectionTextureUpDirection: Vector3;
  50646. /**
  50647. * Gets the Up vector of the Spotlight for texture projection.
  50648. */
  50649. get projectionTextureUpDirection(): Vector3;
  50650. /**
  50651. * Sets the Up vector of the Spotlight for texture projection.
  50652. */
  50653. set projectionTextureUpDirection(value: Vector3);
  50654. private _projectionTexture;
  50655. /**
  50656. * Gets the projection texture of the light.
  50657. */
  50658. get projectionTexture(): Nullable<BaseTexture>;
  50659. /**
  50660. * Sets the projection texture of the light.
  50661. */
  50662. set projectionTexture(value: Nullable<BaseTexture>);
  50663. private _projectionTextureViewLightDirty;
  50664. private _projectionTextureProjectionLightDirty;
  50665. private _projectionTextureDirty;
  50666. private _projectionTextureViewTargetVector;
  50667. private _projectionTextureViewLightMatrix;
  50668. private _projectionTextureProjectionLightMatrix;
  50669. private _projectionTextureScalingMatrix;
  50670. /**
  50671. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50672. * It can cast shadows.
  50673. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50674. * @param name The light friendly name
  50675. * @param position The position of the spot light in the scene
  50676. * @param direction The direction of the light in the scene
  50677. * @param angle The cone angle of the light in Radians
  50678. * @param exponent The light decay speed with the distance from the emission spot
  50679. * @param scene The scene the lights belongs to
  50680. */
  50681. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50682. /**
  50683. * Returns the string "SpotLight".
  50684. * @returns the class name
  50685. */
  50686. getClassName(): string;
  50687. /**
  50688. * Returns the integer 2.
  50689. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50690. */
  50691. getTypeID(): number;
  50692. /**
  50693. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50694. */
  50695. protected _setDirection(value: Vector3): void;
  50696. /**
  50697. * Overrides the position setter to recompute the projection texture view light Matrix.
  50698. */
  50699. protected _setPosition(value: Vector3): void;
  50700. /**
  50701. * 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.
  50702. * Returns the SpotLight.
  50703. */
  50704. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50705. protected _computeProjectionTextureViewLightMatrix(): void;
  50706. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50707. /**
  50708. * Main function for light texture projection matrix computing.
  50709. */
  50710. protected _computeProjectionTextureMatrix(): void;
  50711. protected _buildUniformLayout(): void;
  50712. private _computeAngleValues;
  50713. /**
  50714. * Sets the passed Effect "effect" with the Light textures.
  50715. * @param effect The effect to update
  50716. * @param lightIndex The index of the light in the effect to update
  50717. * @returns The light
  50718. */
  50719. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50720. /**
  50721. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50722. * @param effect The effect to update
  50723. * @param lightIndex The index of the light in the effect to update
  50724. * @returns The spot light
  50725. */
  50726. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50727. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50728. /**
  50729. * Disposes the light and the associated resources.
  50730. */
  50731. dispose(): void;
  50732. /**
  50733. * Prepares the list of defines specific to the light type.
  50734. * @param defines the list of defines
  50735. * @param lightIndex defines the index of the light for the effect
  50736. */
  50737. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50738. }
  50739. }
  50740. declare module "babylonjs/Gizmos/lightGizmo" {
  50741. import { Nullable } from "babylonjs/types";
  50742. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50743. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50744. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50745. import { Light } from "babylonjs/Lights/light";
  50746. /**
  50747. * Gizmo that enables viewing a light
  50748. */
  50749. export class LightGizmo extends Gizmo {
  50750. private _lightMesh;
  50751. private _material;
  50752. private _cachedPosition;
  50753. private _cachedForward;
  50754. private _attachedMeshParent;
  50755. /**
  50756. * Creates a LightGizmo
  50757. * @param gizmoLayer The utility layer the gizmo will be added to
  50758. */
  50759. constructor(gizmoLayer?: UtilityLayerRenderer);
  50760. private _light;
  50761. /**
  50762. * The light that the gizmo is attached to
  50763. */
  50764. set light(light: Nullable<Light>);
  50765. get light(): Nullable<Light>;
  50766. /**
  50767. * Gets the material used to render the light gizmo
  50768. */
  50769. get material(): StandardMaterial;
  50770. /**
  50771. * @hidden
  50772. * Updates the gizmo to match the attached mesh's position/rotation
  50773. */
  50774. protected _update(): void;
  50775. private static _Scale;
  50776. /**
  50777. * Creates the lines for a light mesh
  50778. */
  50779. private static _CreateLightLines;
  50780. /**
  50781. * Disposes of the light gizmo
  50782. */
  50783. dispose(): void;
  50784. private static _CreateHemisphericLightMesh;
  50785. private static _CreatePointLightMesh;
  50786. private static _CreateSpotLightMesh;
  50787. private static _CreateDirectionalLightMesh;
  50788. }
  50789. }
  50790. declare module "babylonjs/Gizmos/index" {
  50791. export * from "babylonjs/Gizmos/axisDragGizmo";
  50792. export * from "babylonjs/Gizmos/axisScaleGizmo";
  50793. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  50794. export * from "babylonjs/Gizmos/gizmo";
  50795. export * from "babylonjs/Gizmos/gizmoManager";
  50796. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50797. export * from "babylonjs/Gizmos/positionGizmo";
  50798. export * from "babylonjs/Gizmos/rotationGizmo";
  50799. export * from "babylonjs/Gizmos/scaleGizmo";
  50800. export * from "babylonjs/Gizmos/lightGizmo";
  50801. export * from "babylonjs/Gizmos/planeDragGizmo";
  50802. }
  50803. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50804. /** @hidden */
  50805. export var backgroundFragmentDeclaration: {
  50806. name: string;
  50807. shader: string;
  50808. };
  50809. }
  50810. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50811. /** @hidden */
  50812. export var backgroundUboDeclaration: {
  50813. name: string;
  50814. shader: string;
  50815. };
  50816. }
  50817. declare module "babylonjs/Shaders/background.fragment" {
  50818. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50819. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50820. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50821. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50822. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50823. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50824. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50825. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50826. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50827. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50828. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50829. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50830. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50831. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50832. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50833. /** @hidden */
  50834. export var backgroundPixelShader: {
  50835. name: string;
  50836. shader: string;
  50837. };
  50838. }
  50839. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50840. /** @hidden */
  50841. export var backgroundVertexDeclaration: {
  50842. name: string;
  50843. shader: string;
  50844. };
  50845. }
  50846. declare module "babylonjs/Shaders/background.vertex" {
  50847. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50848. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50849. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50850. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50851. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50852. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50853. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50854. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50855. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50856. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50857. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50858. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50859. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50860. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50861. /** @hidden */
  50862. export var backgroundVertexShader: {
  50863. name: string;
  50864. shader: string;
  50865. };
  50866. }
  50867. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50868. import { Nullable, int, float } from "babylonjs/types";
  50869. import { Scene } from "babylonjs/scene";
  50870. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50871. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50873. import { Mesh } from "babylonjs/Meshes/mesh";
  50874. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50875. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50876. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50878. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50879. import { Color3 } from "babylonjs/Maths/math.color";
  50880. import "babylonjs/Shaders/background.fragment";
  50881. import "babylonjs/Shaders/background.vertex";
  50882. /**
  50883. * Background material used to create an efficient environement around your scene.
  50884. */
  50885. export class BackgroundMaterial extends PushMaterial {
  50886. /**
  50887. * Standard reflectance value at parallel view angle.
  50888. */
  50889. static StandardReflectance0: number;
  50890. /**
  50891. * Standard reflectance value at grazing angle.
  50892. */
  50893. static StandardReflectance90: number;
  50894. protected _primaryColor: Color3;
  50895. /**
  50896. * Key light Color (multiply against the environement texture)
  50897. */
  50898. primaryColor: Color3;
  50899. protected __perceptualColor: Nullable<Color3>;
  50900. /**
  50901. * Experimental Internal Use Only.
  50902. *
  50903. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50904. * This acts as a helper to set the primary color to a more "human friendly" value.
  50905. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50906. * output color as close as possible from the chosen value.
  50907. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50908. * part of lighting setup.)
  50909. */
  50910. get _perceptualColor(): Nullable<Color3>;
  50911. set _perceptualColor(value: Nullable<Color3>);
  50912. protected _primaryColorShadowLevel: float;
  50913. /**
  50914. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50915. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50916. */
  50917. get primaryColorShadowLevel(): float;
  50918. set primaryColorShadowLevel(value: float);
  50919. protected _primaryColorHighlightLevel: float;
  50920. /**
  50921. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50922. * The primary color is used at the level chosen to define what the white area would look.
  50923. */
  50924. get primaryColorHighlightLevel(): float;
  50925. set primaryColorHighlightLevel(value: float);
  50926. protected _reflectionTexture: Nullable<BaseTexture>;
  50927. /**
  50928. * Reflection Texture used in the material.
  50929. * Should be author in a specific way for the best result (refer to the documentation).
  50930. */
  50931. reflectionTexture: Nullable<BaseTexture>;
  50932. protected _reflectionBlur: float;
  50933. /**
  50934. * Reflection Texture level of blur.
  50935. *
  50936. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50937. * texture twice.
  50938. */
  50939. reflectionBlur: float;
  50940. protected _diffuseTexture: Nullable<BaseTexture>;
  50941. /**
  50942. * Diffuse Texture used in the material.
  50943. * Should be author in a specific way for the best result (refer to the documentation).
  50944. */
  50945. diffuseTexture: Nullable<BaseTexture>;
  50946. protected _shadowLights: Nullable<IShadowLight[]>;
  50947. /**
  50948. * Specify the list of lights casting shadow on the material.
  50949. * All scene shadow lights will be included if null.
  50950. */
  50951. shadowLights: Nullable<IShadowLight[]>;
  50952. protected _shadowLevel: float;
  50953. /**
  50954. * Helps adjusting the shadow to a softer level if required.
  50955. * 0 means black shadows and 1 means no shadows.
  50956. */
  50957. shadowLevel: float;
  50958. protected _sceneCenter: Vector3;
  50959. /**
  50960. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50961. * It is usually zero but might be interesting to modify according to your setup.
  50962. */
  50963. sceneCenter: Vector3;
  50964. protected _opacityFresnel: boolean;
  50965. /**
  50966. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50967. * This helps ensuring a nice transition when the camera goes under the ground.
  50968. */
  50969. opacityFresnel: boolean;
  50970. protected _reflectionFresnel: boolean;
  50971. /**
  50972. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50973. * This helps adding a mirror texture on the ground.
  50974. */
  50975. reflectionFresnel: boolean;
  50976. protected _reflectionFalloffDistance: number;
  50977. /**
  50978. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50979. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50980. */
  50981. reflectionFalloffDistance: number;
  50982. protected _reflectionAmount: number;
  50983. /**
  50984. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50985. */
  50986. reflectionAmount: number;
  50987. protected _reflectionReflectance0: number;
  50988. /**
  50989. * This specifies the weight of the reflection at grazing angle.
  50990. */
  50991. reflectionReflectance0: number;
  50992. protected _reflectionReflectance90: number;
  50993. /**
  50994. * This specifies the weight of the reflection at a perpendicular point of view.
  50995. */
  50996. reflectionReflectance90: number;
  50997. /**
  50998. * Sets the reflection reflectance fresnel values according to the default standard
  50999. * empirically know to work well :-)
  51000. */
  51001. set reflectionStandardFresnelWeight(value: number);
  51002. protected _useRGBColor: boolean;
  51003. /**
  51004. * Helps to directly use the maps channels instead of their level.
  51005. */
  51006. useRGBColor: boolean;
  51007. protected _enableNoise: boolean;
  51008. /**
  51009. * This helps reducing the banding effect that could occur on the background.
  51010. */
  51011. enableNoise: boolean;
  51012. /**
  51013. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51014. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51015. * Recommended to be keep at 1.0 except for special cases.
  51016. */
  51017. get fovMultiplier(): number;
  51018. set fovMultiplier(value: number);
  51019. private _fovMultiplier;
  51020. /**
  51021. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51022. */
  51023. useEquirectangularFOV: boolean;
  51024. private _maxSimultaneousLights;
  51025. /**
  51026. * Number of Simultaneous lights allowed on the material.
  51027. */
  51028. maxSimultaneousLights: int;
  51029. /**
  51030. * Default configuration related to image processing available in the Background Material.
  51031. */
  51032. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51033. /**
  51034. * Keep track of the image processing observer to allow dispose and replace.
  51035. */
  51036. private _imageProcessingObserver;
  51037. /**
  51038. * Attaches a new image processing configuration to the PBR Material.
  51039. * @param configuration (if null the scene configuration will be use)
  51040. */
  51041. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51042. /**
  51043. * Gets the image processing configuration used either in this material.
  51044. */
  51045. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51046. /**
  51047. * Sets the Default image processing configuration used either in the this material.
  51048. *
  51049. * If sets to null, the scene one is in use.
  51050. */
  51051. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51052. /**
  51053. * Gets wether the color curves effect is enabled.
  51054. */
  51055. get cameraColorCurvesEnabled(): boolean;
  51056. /**
  51057. * Sets wether the color curves effect is enabled.
  51058. */
  51059. set cameraColorCurvesEnabled(value: boolean);
  51060. /**
  51061. * Gets wether the color grading effect is enabled.
  51062. */
  51063. get cameraColorGradingEnabled(): boolean;
  51064. /**
  51065. * Gets wether the color grading effect is enabled.
  51066. */
  51067. set cameraColorGradingEnabled(value: boolean);
  51068. /**
  51069. * Gets wether tonemapping is enabled or not.
  51070. */
  51071. get cameraToneMappingEnabled(): boolean;
  51072. /**
  51073. * Sets wether tonemapping is enabled or not
  51074. */
  51075. set cameraToneMappingEnabled(value: boolean);
  51076. /**
  51077. * The camera exposure used on this material.
  51078. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51079. * This corresponds to a photographic exposure.
  51080. */
  51081. get cameraExposure(): float;
  51082. /**
  51083. * The camera exposure used on this material.
  51084. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51085. * This corresponds to a photographic exposure.
  51086. */
  51087. set cameraExposure(value: float);
  51088. /**
  51089. * Gets The camera contrast used on this material.
  51090. */
  51091. get cameraContrast(): float;
  51092. /**
  51093. * Sets The camera contrast used on this material.
  51094. */
  51095. set cameraContrast(value: float);
  51096. /**
  51097. * Gets the Color Grading 2D Lookup Texture.
  51098. */
  51099. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51100. /**
  51101. * Sets the Color Grading 2D Lookup Texture.
  51102. */
  51103. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51104. /**
  51105. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51106. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51107. * 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;
  51108. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51109. */
  51110. get cameraColorCurves(): Nullable<ColorCurves>;
  51111. /**
  51112. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51113. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51114. * 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;
  51115. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51116. */
  51117. set cameraColorCurves(value: Nullable<ColorCurves>);
  51118. /**
  51119. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51120. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51121. */
  51122. switchToBGR: boolean;
  51123. private _renderTargets;
  51124. private _reflectionControls;
  51125. private _white;
  51126. private _primaryShadowColor;
  51127. private _primaryHighlightColor;
  51128. /**
  51129. * Instantiates a Background Material in the given scene
  51130. * @param name The friendly name of the material
  51131. * @param scene The scene to add the material to
  51132. */
  51133. constructor(name: string, scene: Scene);
  51134. /**
  51135. * Gets a boolean indicating that current material needs to register RTT
  51136. */
  51137. get hasRenderTargetTextures(): boolean;
  51138. /**
  51139. * The entire material has been created in order to prevent overdraw.
  51140. * @returns false
  51141. */
  51142. needAlphaTesting(): boolean;
  51143. /**
  51144. * The entire material has been created in order to prevent overdraw.
  51145. * @returns true if blending is enable
  51146. */
  51147. needAlphaBlending(): boolean;
  51148. /**
  51149. * Checks wether the material is ready to be rendered for a given mesh.
  51150. * @param mesh The mesh to render
  51151. * @param subMesh The submesh to check against
  51152. * @param useInstances Specify wether or not the material is used with instances
  51153. * @returns true if all the dependencies are ready (Textures, Effects...)
  51154. */
  51155. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51156. /**
  51157. * Compute the primary color according to the chosen perceptual color.
  51158. */
  51159. private _computePrimaryColorFromPerceptualColor;
  51160. /**
  51161. * Compute the highlights and shadow colors according to their chosen levels.
  51162. */
  51163. private _computePrimaryColors;
  51164. /**
  51165. * Build the uniform buffer used in the material.
  51166. */
  51167. buildUniformLayout(): void;
  51168. /**
  51169. * Unbind the material.
  51170. */
  51171. unbind(): void;
  51172. /**
  51173. * Bind only the world matrix to the material.
  51174. * @param world The world matrix to bind.
  51175. */
  51176. bindOnlyWorldMatrix(world: Matrix): void;
  51177. /**
  51178. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51179. * @param world The world matrix to bind.
  51180. * @param subMesh The submesh to bind for.
  51181. */
  51182. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51183. /**
  51184. * Checks to see if a texture is used in the material.
  51185. * @param texture - Base texture to use.
  51186. * @returns - Boolean specifying if a texture is used in the material.
  51187. */
  51188. hasTexture(texture: BaseTexture): boolean;
  51189. /**
  51190. * Dispose the material.
  51191. * @param forceDisposeEffect Force disposal of the associated effect.
  51192. * @param forceDisposeTextures Force disposal of the associated textures.
  51193. */
  51194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51195. /**
  51196. * Clones the material.
  51197. * @param name The cloned name.
  51198. * @returns The cloned material.
  51199. */
  51200. clone(name: string): BackgroundMaterial;
  51201. /**
  51202. * Serializes the current material to its JSON representation.
  51203. * @returns The JSON representation.
  51204. */
  51205. serialize(): any;
  51206. /**
  51207. * Gets the class name of the material
  51208. * @returns "BackgroundMaterial"
  51209. */
  51210. getClassName(): string;
  51211. /**
  51212. * Parse a JSON input to create back a background material.
  51213. * @param source The JSON data to parse
  51214. * @param scene The scene to create the parsed material in
  51215. * @param rootUrl The root url of the assets the material depends upon
  51216. * @returns the instantiated BackgroundMaterial.
  51217. */
  51218. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51219. }
  51220. }
  51221. declare module "babylonjs/Helpers/environmentHelper" {
  51222. import { Observable } from "babylonjs/Misc/observable";
  51223. import { Nullable } from "babylonjs/types";
  51224. import { Scene } from "babylonjs/scene";
  51225. import { Vector3 } from "babylonjs/Maths/math.vector";
  51226. import { Color3 } from "babylonjs/Maths/math.color";
  51227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51228. import { Mesh } from "babylonjs/Meshes/mesh";
  51229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51230. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51231. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51232. import "babylonjs/Meshes/Builders/planeBuilder";
  51233. import "babylonjs/Meshes/Builders/boxBuilder";
  51234. /**
  51235. * Represents the different options available during the creation of
  51236. * a Environment helper.
  51237. *
  51238. * This can control the default ground, skybox and image processing setup of your scene.
  51239. */
  51240. export interface IEnvironmentHelperOptions {
  51241. /**
  51242. * Specifies wether or not to create a ground.
  51243. * True by default.
  51244. */
  51245. createGround: boolean;
  51246. /**
  51247. * Specifies the ground size.
  51248. * 15 by default.
  51249. */
  51250. groundSize: number;
  51251. /**
  51252. * The texture used on the ground for the main color.
  51253. * Comes from the BabylonJS CDN by default.
  51254. *
  51255. * Remarks: Can be either a texture or a url.
  51256. */
  51257. groundTexture: string | BaseTexture;
  51258. /**
  51259. * The color mixed in the ground texture by default.
  51260. * BabylonJS clearColor by default.
  51261. */
  51262. groundColor: Color3;
  51263. /**
  51264. * Specifies the ground opacity.
  51265. * 1 by default.
  51266. */
  51267. groundOpacity: number;
  51268. /**
  51269. * Enables the ground to receive shadows.
  51270. * True by default.
  51271. */
  51272. enableGroundShadow: boolean;
  51273. /**
  51274. * Helps preventing the shadow to be fully black on the ground.
  51275. * 0.5 by default.
  51276. */
  51277. groundShadowLevel: number;
  51278. /**
  51279. * Creates a mirror texture attach to the ground.
  51280. * false by default.
  51281. */
  51282. enableGroundMirror: boolean;
  51283. /**
  51284. * Specifies the ground mirror size ratio.
  51285. * 0.3 by default as the default kernel is 64.
  51286. */
  51287. groundMirrorSizeRatio: number;
  51288. /**
  51289. * Specifies the ground mirror blur kernel size.
  51290. * 64 by default.
  51291. */
  51292. groundMirrorBlurKernel: number;
  51293. /**
  51294. * Specifies the ground mirror visibility amount.
  51295. * 1 by default
  51296. */
  51297. groundMirrorAmount: number;
  51298. /**
  51299. * Specifies the ground mirror reflectance weight.
  51300. * This uses the standard weight of the background material to setup the fresnel effect
  51301. * of the mirror.
  51302. * 1 by default.
  51303. */
  51304. groundMirrorFresnelWeight: number;
  51305. /**
  51306. * Specifies the ground mirror Falloff distance.
  51307. * This can helps reducing the size of the reflection.
  51308. * 0 by Default.
  51309. */
  51310. groundMirrorFallOffDistance: number;
  51311. /**
  51312. * Specifies the ground mirror texture type.
  51313. * Unsigned Int by Default.
  51314. */
  51315. groundMirrorTextureType: number;
  51316. /**
  51317. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51318. * the shown objects.
  51319. */
  51320. groundYBias: number;
  51321. /**
  51322. * Specifies wether or not to create a skybox.
  51323. * True by default.
  51324. */
  51325. createSkybox: boolean;
  51326. /**
  51327. * Specifies the skybox size.
  51328. * 20 by default.
  51329. */
  51330. skyboxSize: number;
  51331. /**
  51332. * The texture used on the skybox for the main color.
  51333. * Comes from the BabylonJS CDN by default.
  51334. *
  51335. * Remarks: Can be either a texture or a url.
  51336. */
  51337. skyboxTexture: string | BaseTexture;
  51338. /**
  51339. * The color mixed in the skybox texture by default.
  51340. * BabylonJS clearColor by default.
  51341. */
  51342. skyboxColor: Color3;
  51343. /**
  51344. * The background rotation around the Y axis of the scene.
  51345. * This helps aligning the key lights of your scene with the background.
  51346. * 0 by default.
  51347. */
  51348. backgroundYRotation: number;
  51349. /**
  51350. * Compute automatically the size of the elements to best fit with the scene.
  51351. */
  51352. sizeAuto: boolean;
  51353. /**
  51354. * Default position of the rootMesh if autoSize is not true.
  51355. */
  51356. rootPosition: Vector3;
  51357. /**
  51358. * Sets up the image processing in the scene.
  51359. * true by default.
  51360. */
  51361. setupImageProcessing: boolean;
  51362. /**
  51363. * The texture used as your environment texture in the scene.
  51364. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51365. *
  51366. * Remarks: Can be either a texture or a url.
  51367. */
  51368. environmentTexture: string | BaseTexture;
  51369. /**
  51370. * The value of the exposure to apply to the scene.
  51371. * 0.6 by default if setupImageProcessing is true.
  51372. */
  51373. cameraExposure: number;
  51374. /**
  51375. * The value of the contrast to apply to the scene.
  51376. * 1.6 by default if setupImageProcessing is true.
  51377. */
  51378. cameraContrast: number;
  51379. /**
  51380. * Specifies wether or not tonemapping should be enabled in the scene.
  51381. * true by default if setupImageProcessing is true.
  51382. */
  51383. toneMappingEnabled: boolean;
  51384. }
  51385. /**
  51386. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51387. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51388. * It also helps with the default setup of your imageProcessing configuration.
  51389. */
  51390. export class EnvironmentHelper {
  51391. /**
  51392. * Default ground texture URL.
  51393. */
  51394. private static _groundTextureCDNUrl;
  51395. /**
  51396. * Default skybox texture URL.
  51397. */
  51398. private static _skyboxTextureCDNUrl;
  51399. /**
  51400. * Default environment texture URL.
  51401. */
  51402. private static _environmentTextureCDNUrl;
  51403. /**
  51404. * Creates the default options for the helper.
  51405. */
  51406. private static _getDefaultOptions;
  51407. private _rootMesh;
  51408. /**
  51409. * Gets the root mesh created by the helper.
  51410. */
  51411. get rootMesh(): Mesh;
  51412. private _skybox;
  51413. /**
  51414. * Gets the skybox created by the helper.
  51415. */
  51416. get skybox(): Nullable<Mesh>;
  51417. private _skyboxTexture;
  51418. /**
  51419. * Gets the skybox texture created by the helper.
  51420. */
  51421. get skyboxTexture(): Nullable<BaseTexture>;
  51422. private _skyboxMaterial;
  51423. /**
  51424. * Gets the skybox material created by the helper.
  51425. */
  51426. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51427. private _ground;
  51428. /**
  51429. * Gets the ground mesh created by the helper.
  51430. */
  51431. get ground(): Nullable<Mesh>;
  51432. private _groundTexture;
  51433. /**
  51434. * Gets the ground texture created by the helper.
  51435. */
  51436. get groundTexture(): Nullable<BaseTexture>;
  51437. private _groundMirror;
  51438. /**
  51439. * Gets the ground mirror created by the helper.
  51440. */
  51441. get groundMirror(): Nullable<MirrorTexture>;
  51442. /**
  51443. * Gets the ground mirror render list to helps pushing the meshes
  51444. * you wish in the ground reflection.
  51445. */
  51446. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51447. private _groundMaterial;
  51448. /**
  51449. * Gets the ground material created by the helper.
  51450. */
  51451. get groundMaterial(): Nullable<BackgroundMaterial>;
  51452. /**
  51453. * Stores the creation options.
  51454. */
  51455. private readonly _scene;
  51456. private _options;
  51457. /**
  51458. * This observable will be notified with any error during the creation of the environment,
  51459. * mainly texture creation errors.
  51460. */
  51461. onErrorObservable: Observable<{
  51462. message?: string;
  51463. exception?: any;
  51464. }>;
  51465. /**
  51466. * constructor
  51467. * @param options Defines the options we want to customize the helper
  51468. * @param scene The scene to add the material to
  51469. */
  51470. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51471. /**
  51472. * Updates the background according to the new options
  51473. * @param options
  51474. */
  51475. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51476. /**
  51477. * Sets the primary color of all the available elements.
  51478. * @param color the main color to affect to the ground and the background
  51479. */
  51480. setMainColor(color: Color3): void;
  51481. /**
  51482. * Setup the image processing according to the specified options.
  51483. */
  51484. private _setupImageProcessing;
  51485. /**
  51486. * Setup the environment texture according to the specified options.
  51487. */
  51488. private _setupEnvironmentTexture;
  51489. /**
  51490. * Setup the background according to the specified options.
  51491. */
  51492. private _setupBackground;
  51493. /**
  51494. * Get the scene sizes according to the setup.
  51495. */
  51496. private _getSceneSize;
  51497. /**
  51498. * Setup the ground according to the specified options.
  51499. */
  51500. private _setupGround;
  51501. /**
  51502. * Setup the ground material according to the specified options.
  51503. */
  51504. private _setupGroundMaterial;
  51505. /**
  51506. * Setup the ground diffuse texture according to the specified options.
  51507. */
  51508. private _setupGroundDiffuseTexture;
  51509. /**
  51510. * Setup the ground mirror texture according to the specified options.
  51511. */
  51512. private _setupGroundMirrorTexture;
  51513. /**
  51514. * Setup the ground to receive the mirror texture.
  51515. */
  51516. private _setupMirrorInGroundMaterial;
  51517. /**
  51518. * Setup the skybox according to the specified options.
  51519. */
  51520. private _setupSkybox;
  51521. /**
  51522. * Setup the skybox material according to the specified options.
  51523. */
  51524. private _setupSkyboxMaterial;
  51525. /**
  51526. * Setup the skybox reflection texture according to the specified options.
  51527. */
  51528. private _setupSkyboxReflectionTexture;
  51529. private _errorHandler;
  51530. /**
  51531. * Dispose all the elements created by the Helper.
  51532. */
  51533. dispose(): void;
  51534. }
  51535. }
  51536. declare module "babylonjs/Helpers/photoDome" {
  51537. import { Observable } from "babylonjs/Misc/observable";
  51538. import { Nullable } from "babylonjs/types";
  51539. import { Scene } from "babylonjs/scene";
  51540. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51541. import { Mesh } from "babylonjs/Meshes/mesh";
  51542. import { Texture } from "babylonjs/Materials/Textures/texture";
  51543. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51544. import "babylonjs/Meshes/Builders/sphereBuilder";
  51545. /**
  51546. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51547. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51548. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51549. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51550. */
  51551. export class PhotoDome extends TransformNode {
  51552. /**
  51553. * Define the image as a Monoscopic panoramic 360 image.
  51554. */
  51555. static readonly MODE_MONOSCOPIC: number;
  51556. /**
  51557. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51558. */
  51559. static readonly MODE_TOPBOTTOM: number;
  51560. /**
  51561. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51562. */
  51563. static readonly MODE_SIDEBYSIDE: number;
  51564. private _useDirectMapping;
  51565. /**
  51566. * The texture being displayed on the sphere
  51567. */
  51568. protected _photoTexture: Texture;
  51569. /**
  51570. * Gets or sets the texture being displayed on the sphere
  51571. */
  51572. get photoTexture(): Texture;
  51573. set photoTexture(value: Texture);
  51574. /**
  51575. * Observable raised when an error occured while loading the 360 image
  51576. */
  51577. onLoadErrorObservable: Observable<string>;
  51578. /**
  51579. * The skybox material
  51580. */
  51581. protected _material: BackgroundMaterial;
  51582. /**
  51583. * The surface used for the skybox
  51584. */
  51585. protected _mesh: Mesh;
  51586. /**
  51587. * Gets the mesh used for the skybox.
  51588. */
  51589. get mesh(): Mesh;
  51590. /**
  51591. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51592. * Also see the options.resolution property.
  51593. */
  51594. get fovMultiplier(): number;
  51595. set fovMultiplier(value: number);
  51596. private _imageMode;
  51597. /**
  51598. * Gets or set the current video mode for the video. It can be:
  51599. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51600. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51601. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51602. */
  51603. get imageMode(): number;
  51604. set imageMode(value: number);
  51605. /**
  51606. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51607. * @param name Element's name, child elements will append suffixes for their own names.
  51608. * @param urlsOfPhoto defines the url of the photo to display
  51609. * @param options defines an object containing optional or exposed sub element properties
  51610. * @param onError defines a callback called when an error occured while loading the texture
  51611. */
  51612. constructor(name: string, urlOfPhoto: string, options: {
  51613. resolution?: number;
  51614. size?: number;
  51615. useDirectMapping?: boolean;
  51616. faceForward?: boolean;
  51617. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51618. private _onBeforeCameraRenderObserver;
  51619. private _changeImageMode;
  51620. /**
  51621. * Releases resources associated with this node.
  51622. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51623. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51624. */
  51625. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51626. }
  51627. }
  51628. declare module "babylonjs/Misc/rgbdTextureTools" {
  51629. import "babylonjs/Shaders/rgbdDecode.fragment";
  51630. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51631. import { Texture } from "babylonjs/Materials/Textures/texture";
  51632. /**
  51633. * Class used to host RGBD texture specific utilities
  51634. */
  51635. export class RGBDTextureTools {
  51636. /**
  51637. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51638. * @param texture the texture to expand.
  51639. */
  51640. static ExpandRGBDTexture(texture: Texture): void;
  51641. }
  51642. }
  51643. declare module "babylonjs/Misc/brdfTextureTools" {
  51644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51645. import { Scene } from "babylonjs/scene";
  51646. /**
  51647. * Class used to host texture specific utilities
  51648. */
  51649. export class BRDFTextureTools {
  51650. /**
  51651. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51652. * @param scene defines the hosting scene
  51653. * @returns the environment BRDF texture
  51654. */
  51655. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51656. private static _environmentBRDFBase64Texture;
  51657. }
  51658. }
  51659. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51660. import { Nullable } from "babylonjs/types";
  51661. import { Color3 } from "babylonjs/Maths/math.color";
  51662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51663. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51664. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51665. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51666. import { Engine } from "babylonjs/Engines/engine";
  51667. import { Scene } from "babylonjs/scene";
  51668. /**
  51669. * @hidden
  51670. */
  51671. export interface IMaterialClearCoatDefines {
  51672. CLEARCOAT: boolean;
  51673. CLEARCOAT_DEFAULTIOR: boolean;
  51674. CLEARCOAT_TEXTURE: boolean;
  51675. CLEARCOAT_TEXTUREDIRECTUV: number;
  51676. CLEARCOAT_BUMP: boolean;
  51677. CLEARCOAT_BUMPDIRECTUV: number;
  51678. CLEARCOAT_TINT: boolean;
  51679. CLEARCOAT_TINT_TEXTURE: boolean;
  51680. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51681. /** @hidden */
  51682. _areTexturesDirty: boolean;
  51683. }
  51684. /**
  51685. * Define the code related to the clear coat parameters of the pbr material.
  51686. */
  51687. export class PBRClearCoatConfiguration {
  51688. /**
  51689. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51690. * The default fits with a polyurethane material.
  51691. */
  51692. private static readonly _DefaultIndexOfRefraction;
  51693. private _isEnabled;
  51694. /**
  51695. * Defines if the clear coat is enabled in the material.
  51696. */
  51697. isEnabled: boolean;
  51698. /**
  51699. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51700. */
  51701. intensity: number;
  51702. /**
  51703. * Defines the clear coat layer roughness.
  51704. */
  51705. roughness: number;
  51706. private _indexOfRefraction;
  51707. /**
  51708. * Defines the index of refraction of the clear coat.
  51709. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51710. * The default fits with a polyurethane material.
  51711. * Changing the default value is more performance intensive.
  51712. */
  51713. indexOfRefraction: number;
  51714. private _texture;
  51715. /**
  51716. * Stores the clear coat values in a texture.
  51717. */
  51718. texture: Nullable<BaseTexture>;
  51719. private _bumpTexture;
  51720. /**
  51721. * Define the clear coat specific bump texture.
  51722. */
  51723. bumpTexture: Nullable<BaseTexture>;
  51724. private _isTintEnabled;
  51725. /**
  51726. * Defines if the clear coat tint is enabled in the material.
  51727. */
  51728. isTintEnabled: boolean;
  51729. /**
  51730. * Defines the clear coat tint of the material.
  51731. * This is only use if tint is enabled
  51732. */
  51733. tintColor: Color3;
  51734. /**
  51735. * Defines the distance at which the tint color should be found in the
  51736. * clear coat media.
  51737. * This is only use if tint is enabled
  51738. */
  51739. tintColorAtDistance: number;
  51740. /**
  51741. * Defines the clear coat layer thickness.
  51742. * This is only use if tint is enabled
  51743. */
  51744. tintThickness: number;
  51745. private _tintTexture;
  51746. /**
  51747. * Stores the clear tint values in a texture.
  51748. * rgb is tint
  51749. * a is a thickness factor
  51750. */
  51751. tintTexture: Nullable<BaseTexture>;
  51752. /** @hidden */
  51753. private _internalMarkAllSubMeshesAsTexturesDirty;
  51754. /** @hidden */
  51755. _markAllSubMeshesAsTexturesDirty(): void;
  51756. /**
  51757. * Instantiate a new istance of clear coat configuration.
  51758. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51759. */
  51760. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51761. /**
  51762. * Gets wehter the submesh is ready to be used or not.
  51763. * @param defines the list of "defines" to update.
  51764. * @param scene defines the scene the material belongs to.
  51765. * @param engine defines the engine the material belongs to.
  51766. * @param disableBumpMap defines wether the material disables bump or not.
  51767. * @returns - boolean indicating that the submesh is ready or not.
  51768. */
  51769. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  51770. /**
  51771. * Checks to see if a texture is used in the material.
  51772. * @param defines the list of "defines" to update.
  51773. * @param scene defines the scene to the material belongs to.
  51774. */
  51775. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  51776. /**
  51777. * Binds the material data.
  51778. * @param uniformBuffer defines the Uniform buffer to fill in.
  51779. * @param scene defines the scene the material belongs to.
  51780. * @param engine defines the engine the material belongs to.
  51781. * @param disableBumpMap defines wether the material disables bump or not.
  51782. * @param isFrozen defines wether the material is frozen or not.
  51783. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51784. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51785. */
  51786. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  51787. /**
  51788. * Checks to see if a texture is used in the material.
  51789. * @param texture - Base texture to use.
  51790. * @returns - Boolean specifying if a texture is used in the material.
  51791. */
  51792. hasTexture(texture: BaseTexture): boolean;
  51793. /**
  51794. * Returns an array of the actively used textures.
  51795. * @param activeTextures Array of BaseTextures
  51796. */
  51797. getActiveTextures(activeTextures: BaseTexture[]): void;
  51798. /**
  51799. * Returns the animatable textures.
  51800. * @param animatables Array of animatable textures.
  51801. */
  51802. getAnimatables(animatables: IAnimatable[]): void;
  51803. /**
  51804. * Disposes the resources of the material.
  51805. * @param forceDisposeTextures - Forces the disposal of all textures.
  51806. */
  51807. dispose(forceDisposeTextures?: boolean): void;
  51808. /**
  51809. * Get the current class name of the texture useful for serialization or dynamic coding.
  51810. * @returns "PBRClearCoatConfiguration"
  51811. */
  51812. getClassName(): string;
  51813. /**
  51814. * Add fallbacks to the effect fallbacks list.
  51815. * @param defines defines the Base texture to use.
  51816. * @param fallbacks defines the current fallback list.
  51817. * @param currentRank defines the current fallback rank.
  51818. * @returns the new fallback rank.
  51819. */
  51820. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51821. /**
  51822. * Add the required uniforms to the current list.
  51823. * @param uniforms defines the current uniform list.
  51824. */
  51825. static AddUniforms(uniforms: string[]): void;
  51826. /**
  51827. * Add the required samplers to the current list.
  51828. * @param samplers defines the current sampler list.
  51829. */
  51830. static AddSamplers(samplers: string[]): void;
  51831. /**
  51832. * Add the required uniforms to the current buffer.
  51833. * @param uniformBuffer defines the current uniform buffer.
  51834. */
  51835. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51836. /**
  51837. * Makes a duplicate of the current configuration into another one.
  51838. * @param clearCoatConfiguration define the config where to copy the info
  51839. */
  51840. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51841. /**
  51842. * Serializes this clear coat configuration.
  51843. * @returns - An object with the serialized config.
  51844. */
  51845. serialize(): any;
  51846. /**
  51847. * Parses a anisotropy Configuration from a serialized object.
  51848. * @param source - Serialized object.
  51849. * @param scene Defines the scene we are parsing for
  51850. * @param rootUrl Defines the rootUrl to load from
  51851. */
  51852. parse(source: any, scene: Scene, rootUrl: string): void;
  51853. }
  51854. }
  51855. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51856. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51858. import { Vector2 } from "babylonjs/Maths/math.vector";
  51859. import { Scene } from "babylonjs/scene";
  51860. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51861. import { Nullable } from "babylonjs/types";
  51862. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51863. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51864. /**
  51865. * @hidden
  51866. */
  51867. export interface IMaterialAnisotropicDefines {
  51868. ANISOTROPIC: boolean;
  51869. ANISOTROPIC_TEXTURE: boolean;
  51870. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51871. MAINUV1: boolean;
  51872. _areTexturesDirty: boolean;
  51873. _needUVs: boolean;
  51874. }
  51875. /**
  51876. * Define the code related to the anisotropic parameters of the pbr material.
  51877. */
  51878. export class PBRAnisotropicConfiguration {
  51879. private _isEnabled;
  51880. /**
  51881. * Defines if the anisotropy is enabled in the material.
  51882. */
  51883. isEnabled: boolean;
  51884. /**
  51885. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51886. */
  51887. intensity: number;
  51888. /**
  51889. * Defines if the effect is along the tangents, bitangents or in between.
  51890. * By default, the effect is "strectching" the highlights along the tangents.
  51891. */
  51892. direction: Vector2;
  51893. private _texture;
  51894. /**
  51895. * Stores the anisotropy values in a texture.
  51896. * rg is direction (like normal from -1 to 1)
  51897. * b is a intensity
  51898. */
  51899. texture: Nullable<BaseTexture>;
  51900. /** @hidden */
  51901. private _internalMarkAllSubMeshesAsTexturesDirty;
  51902. /** @hidden */
  51903. _markAllSubMeshesAsTexturesDirty(): void;
  51904. /**
  51905. * Instantiate a new istance of anisotropy configuration.
  51906. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51907. */
  51908. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51909. /**
  51910. * Specifies that the submesh is ready to be used.
  51911. * @param defines the list of "defines" to update.
  51912. * @param scene defines the scene the material belongs to.
  51913. * @returns - boolean indicating that the submesh is ready or not.
  51914. */
  51915. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51916. /**
  51917. * Checks to see if a texture is used in the material.
  51918. * @param defines the list of "defines" to update.
  51919. * @param mesh the mesh we are preparing the defines for.
  51920. * @param scene defines the scene the material belongs to.
  51921. */
  51922. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51923. /**
  51924. * Binds the material data.
  51925. * @param uniformBuffer defines the Uniform buffer to fill in.
  51926. * @param scene defines the scene the material belongs to.
  51927. * @param isFrozen defines wether the material is frozen or not.
  51928. */
  51929. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51930. /**
  51931. * Checks to see if a texture is used in the material.
  51932. * @param texture - Base texture to use.
  51933. * @returns - Boolean specifying if a texture is used in the material.
  51934. */
  51935. hasTexture(texture: BaseTexture): boolean;
  51936. /**
  51937. * Returns an array of the actively used textures.
  51938. * @param activeTextures Array of BaseTextures
  51939. */
  51940. getActiveTextures(activeTextures: BaseTexture[]): void;
  51941. /**
  51942. * Returns the animatable textures.
  51943. * @param animatables Array of animatable textures.
  51944. */
  51945. getAnimatables(animatables: IAnimatable[]): void;
  51946. /**
  51947. * Disposes the resources of the material.
  51948. * @param forceDisposeTextures - Forces the disposal of all textures.
  51949. */
  51950. dispose(forceDisposeTextures?: boolean): void;
  51951. /**
  51952. * Get the current class name of the texture useful for serialization or dynamic coding.
  51953. * @returns "PBRAnisotropicConfiguration"
  51954. */
  51955. getClassName(): string;
  51956. /**
  51957. * Add fallbacks to the effect fallbacks list.
  51958. * @param defines defines the Base texture to use.
  51959. * @param fallbacks defines the current fallback list.
  51960. * @param currentRank defines the current fallback rank.
  51961. * @returns the new fallback rank.
  51962. */
  51963. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51964. /**
  51965. * Add the required uniforms to the current list.
  51966. * @param uniforms defines the current uniform list.
  51967. */
  51968. static AddUniforms(uniforms: string[]): void;
  51969. /**
  51970. * Add the required uniforms to the current buffer.
  51971. * @param uniformBuffer defines the current uniform buffer.
  51972. */
  51973. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51974. /**
  51975. * Add the required samplers to the current list.
  51976. * @param samplers defines the current sampler list.
  51977. */
  51978. static AddSamplers(samplers: string[]): void;
  51979. /**
  51980. * Makes a duplicate of the current configuration into another one.
  51981. * @param anisotropicConfiguration define the config where to copy the info
  51982. */
  51983. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51984. /**
  51985. * Serializes this anisotropy configuration.
  51986. * @returns - An object with the serialized config.
  51987. */
  51988. serialize(): any;
  51989. /**
  51990. * Parses a anisotropy Configuration from a serialized object.
  51991. * @param source - Serialized object.
  51992. * @param scene Defines the scene we are parsing for
  51993. * @param rootUrl Defines the rootUrl to load from
  51994. */
  51995. parse(source: any, scene: Scene, rootUrl: string): void;
  51996. }
  51997. }
  51998. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  51999. import { Scene } from "babylonjs/scene";
  52000. /**
  52001. * @hidden
  52002. */
  52003. export interface IMaterialBRDFDefines {
  52004. BRDF_V_HEIGHT_CORRELATED: boolean;
  52005. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52006. SPHERICAL_HARMONICS: boolean;
  52007. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52008. /** @hidden */
  52009. _areMiscDirty: boolean;
  52010. }
  52011. /**
  52012. * Define the code related to the BRDF parameters of the pbr material.
  52013. */
  52014. export class PBRBRDFConfiguration {
  52015. /**
  52016. * Default value used for the energy conservation.
  52017. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52018. */
  52019. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52020. /**
  52021. * Default value used for the Smith Visibility Height Correlated mode.
  52022. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52023. */
  52024. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52025. /**
  52026. * Default value used for the IBL diffuse part.
  52027. * This can help switching back to the polynomials mode globally which is a tiny bit
  52028. * less GPU intensive at the drawback of a lower quality.
  52029. */
  52030. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52031. /**
  52032. * Default value used for activating energy conservation for the specular workflow.
  52033. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52034. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52035. */
  52036. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52037. private _useEnergyConservation;
  52038. /**
  52039. * Defines if the material uses energy conservation.
  52040. */
  52041. useEnergyConservation: boolean;
  52042. private _useSmithVisibilityHeightCorrelated;
  52043. /**
  52044. * LEGACY Mode set to false
  52045. * Defines if the material uses height smith correlated visibility term.
  52046. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52047. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52048. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52049. * Not relying on height correlated will also disable energy conservation.
  52050. */
  52051. useSmithVisibilityHeightCorrelated: boolean;
  52052. private _useSphericalHarmonics;
  52053. /**
  52054. * LEGACY Mode set to false
  52055. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52056. * diffuse part of the IBL.
  52057. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52058. * to the ground truth.
  52059. */
  52060. useSphericalHarmonics: boolean;
  52061. private _useSpecularGlossinessInputEnergyConservation;
  52062. /**
  52063. * Defines if the material uses energy conservation, when the specular workflow is active.
  52064. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52065. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52066. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52067. */
  52068. useSpecularGlossinessInputEnergyConservation: boolean;
  52069. /** @hidden */
  52070. private _internalMarkAllSubMeshesAsMiscDirty;
  52071. /** @hidden */
  52072. _markAllSubMeshesAsMiscDirty(): void;
  52073. /**
  52074. * Instantiate a new istance of clear coat configuration.
  52075. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52076. */
  52077. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52078. /**
  52079. * Checks to see if a texture is used in the material.
  52080. * @param defines the list of "defines" to update.
  52081. */
  52082. prepareDefines(defines: IMaterialBRDFDefines): void;
  52083. /**
  52084. * Get the current class name of the texture useful for serialization or dynamic coding.
  52085. * @returns "PBRClearCoatConfiguration"
  52086. */
  52087. getClassName(): string;
  52088. /**
  52089. * Makes a duplicate of the current configuration into another one.
  52090. * @param brdfConfiguration define the config where to copy the info
  52091. */
  52092. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52093. /**
  52094. * Serializes this BRDF configuration.
  52095. * @returns - An object with the serialized config.
  52096. */
  52097. serialize(): any;
  52098. /**
  52099. * Parses a anisotropy Configuration from a serialized object.
  52100. * @param source - Serialized object.
  52101. * @param scene Defines the scene we are parsing for
  52102. * @param rootUrl Defines the rootUrl to load from
  52103. */
  52104. parse(source: any, scene: Scene, rootUrl: string): void;
  52105. }
  52106. }
  52107. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52108. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52109. import { Color3 } from "babylonjs/Maths/math.color";
  52110. import { Scene } from "babylonjs/scene";
  52111. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52112. import { Nullable } from "babylonjs/types";
  52113. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52114. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52115. /**
  52116. * @hidden
  52117. */
  52118. export interface IMaterialSheenDefines {
  52119. SHEEN: boolean;
  52120. SHEEN_TEXTURE: boolean;
  52121. SHEEN_TEXTUREDIRECTUV: number;
  52122. SHEEN_LINKWITHALBEDO: boolean;
  52123. /** @hidden */
  52124. _areTexturesDirty: boolean;
  52125. }
  52126. /**
  52127. * Define the code related to the Sheen parameters of the pbr material.
  52128. */
  52129. export class PBRSheenConfiguration {
  52130. private _isEnabled;
  52131. /**
  52132. * Defines if the material uses sheen.
  52133. */
  52134. isEnabled: boolean;
  52135. private _linkSheenWithAlbedo;
  52136. /**
  52137. * Defines if the sheen is linked to the sheen color.
  52138. */
  52139. linkSheenWithAlbedo: boolean;
  52140. /**
  52141. * Defines the sheen intensity.
  52142. */
  52143. intensity: number;
  52144. /**
  52145. * Defines the sheen color.
  52146. */
  52147. color: Color3;
  52148. private _texture;
  52149. /**
  52150. * Stores the sheen tint values in a texture.
  52151. * rgb is tint
  52152. * a is a intensity
  52153. */
  52154. texture: Nullable<BaseTexture>;
  52155. /** @hidden */
  52156. private _internalMarkAllSubMeshesAsTexturesDirty;
  52157. /** @hidden */
  52158. _markAllSubMeshesAsTexturesDirty(): void;
  52159. /**
  52160. * Instantiate a new istance of clear coat configuration.
  52161. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52162. */
  52163. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52164. /**
  52165. * Specifies that the submesh is ready to be used.
  52166. * @param defines the list of "defines" to update.
  52167. * @param scene defines the scene the material belongs to.
  52168. * @returns - boolean indicating that the submesh is ready or not.
  52169. */
  52170. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52171. /**
  52172. * Checks to see if a texture is used in the material.
  52173. * @param defines the list of "defines" to update.
  52174. * @param scene defines the scene the material belongs to.
  52175. */
  52176. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52177. /**
  52178. * Binds the material data.
  52179. * @param uniformBuffer defines the Uniform buffer to fill in.
  52180. * @param scene defines the scene the material belongs to.
  52181. * @param isFrozen defines wether the material is frozen or not.
  52182. */
  52183. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52184. /**
  52185. * Checks to see if a texture is used in the material.
  52186. * @param texture - Base texture to use.
  52187. * @returns - Boolean specifying if a texture is used in the material.
  52188. */
  52189. hasTexture(texture: BaseTexture): boolean;
  52190. /**
  52191. * Returns an array of the actively used textures.
  52192. * @param activeTextures Array of BaseTextures
  52193. */
  52194. getActiveTextures(activeTextures: BaseTexture[]): void;
  52195. /**
  52196. * Returns the animatable textures.
  52197. * @param animatables Array of animatable textures.
  52198. */
  52199. getAnimatables(animatables: IAnimatable[]): void;
  52200. /**
  52201. * Disposes the resources of the material.
  52202. * @param forceDisposeTextures - Forces the disposal of all textures.
  52203. */
  52204. dispose(forceDisposeTextures?: boolean): void;
  52205. /**
  52206. * Get the current class name of the texture useful for serialization or dynamic coding.
  52207. * @returns "PBRSheenConfiguration"
  52208. */
  52209. getClassName(): string;
  52210. /**
  52211. * Add fallbacks to the effect fallbacks list.
  52212. * @param defines defines the Base texture to use.
  52213. * @param fallbacks defines the current fallback list.
  52214. * @param currentRank defines the current fallback rank.
  52215. * @returns the new fallback rank.
  52216. */
  52217. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52218. /**
  52219. * Add the required uniforms to the current list.
  52220. * @param uniforms defines the current uniform list.
  52221. */
  52222. static AddUniforms(uniforms: string[]): void;
  52223. /**
  52224. * Add the required uniforms to the current buffer.
  52225. * @param uniformBuffer defines the current uniform buffer.
  52226. */
  52227. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52228. /**
  52229. * Add the required samplers to the current list.
  52230. * @param samplers defines the current sampler list.
  52231. */
  52232. static AddSamplers(samplers: string[]): void;
  52233. /**
  52234. * Makes a duplicate of the current configuration into another one.
  52235. * @param sheenConfiguration define the config where to copy the info
  52236. */
  52237. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52238. /**
  52239. * Serializes this BRDF configuration.
  52240. * @returns - An object with the serialized config.
  52241. */
  52242. serialize(): any;
  52243. /**
  52244. * Parses a anisotropy Configuration from a serialized object.
  52245. * @param source - Serialized object.
  52246. * @param scene Defines the scene we are parsing for
  52247. * @param rootUrl Defines the rootUrl to load from
  52248. */
  52249. parse(source: any, scene: Scene, rootUrl: string): void;
  52250. }
  52251. }
  52252. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52253. import { Nullable } from "babylonjs/types";
  52254. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52255. import { Color3 } from "babylonjs/Maths/math.color";
  52256. import { SmartArray } from "babylonjs/Misc/smartArray";
  52257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52258. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52259. import { Effect } from "babylonjs/Materials/effect";
  52260. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52261. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52262. import { Engine } from "babylonjs/Engines/engine";
  52263. import { Scene } from "babylonjs/scene";
  52264. /**
  52265. * @hidden
  52266. */
  52267. export interface IMaterialSubSurfaceDefines {
  52268. SUBSURFACE: boolean;
  52269. SS_REFRACTION: boolean;
  52270. SS_TRANSLUCENCY: boolean;
  52271. SS_SCATERRING: boolean;
  52272. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52273. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52274. SS_REFRACTIONMAP_3D: boolean;
  52275. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52276. SS_LODINREFRACTIONALPHA: boolean;
  52277. SS_GAMMAREFRACTION: boolean;
  52278. SS_RGBDREFRACTION: boolean;
  52279. SS_LINEARSPECULARREFRACTION: boolean;
  52280. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52281. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52282. /** @hidden */
  52283. _areTexturesDirty: boolean;
  52284. }
  52285. /**
  52286. * Define the code related to the sub surface parameters of the pbr material.
  52287. */
  52288. export class PBRSubSurfaceConfiguration {
  52289. private _isRefractionEnabled;
  52290. /**
  52291. * Defines if the refraction is enabled in the material.
  52292. */
  52293. isRefractionEnabled: boolean;
  52294. private _isTranslucencyEnabled;
  52295. /**
  52296. * Defines if the translucency is enabled in the material.
  52297. */
  52298. isTranslucencyEnabled: boolean;
  52299. private _isScatteringEnabled;
  52300. /**
  52301. * Defines the refraction intensity of the material.
  52302. * The refraction when enabled replaces the Diffuse part of the material.
  52303. * The intensity helps transitionning between diffuse and refraction.
  52304. */
  52305. refractionIntensity: number;
  52306. /**
  52307. * Defines the translucency intensity of the material.
  52308. * When translucency has been enabled, this defines how much of the "translucency"
  52309. * is addded to the diffuse part of the material.
  52310. */
  52311. translucencyIntensity: number;
  52312. /**
  52313. * Defines the scattering intensity of the material.
  52314. * When scattering has been enabled, this defines how much of the "scattered light"
  52315. * is addded to the diffuse part of the material.
  52316. */
  52317. scatteringIntensity: number;
  52318. private _thicknessTexture;
  52319. /**
  52320. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52321. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52322. * 0 would mean minimumThickness
  52323. * 1 would mean maximumThickness
  52324. * The other channels might be use as a mask to vary the different effects intensity.
  52325. */
  52326. thicknessTexture: Nullable<BaseTexture>;
  52327. private _refractionTexture;
  52328. /**
  52329. * Defines the texture to use for refraction.
  52330. */
  52331. refractionTexture: Nullable<BaseTexture>;
  52332. private _indexOfRefraction;
  52333. /**
  52334. * Defines the index of refraction used in the material.
  52335. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52336. */
  52337. indexOfRefraction: number;
  52338. private _invertRefractionY;
  52339. /**
  52340. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52341. */
  52342. invertRefractionY: boolean;
  52343. private _linkRefractionWithTransparency;
  52344. /**
  52345. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52346. * Materials half opaque for instance using refraction could benefit from this control.
  52347. */
  52348. linkRefractionWithTransparency: boolean;
  52349. /**
  52350. * Defines the minimum thickness stored in the thickness map.
  52351. * If no thickness map is defined, this value will be used to simulate thickness.
  52352. */
  52353. minimumThickness: number;
  52354. /**
  52355. * Defines the maximum thickness stored in the thickness map.
  52356. */
  52357. maximumThickness: number;
  52358. /**
  52359. * Defines the volume tint of the material.
  52360. * This is used for both translucency and scattering.
  52361. */
  52362. tintColor: Color3;
  52363. /**
  52364. * Defines the distance at which the tint color should be found in the media.
  52365. * This is used for refraction only.
  52366. */
  52367. tintColorAtDistance: number;
  52368. /**
  52369. * Defines how far each channel transmit through the media.
  52370. * It is defined as a color to simplify it selection.
  52371. */
  52372. diffusionDistance: Color3;
  52373. private _useMaskFromThicknessTexture;
  52374. /**
  52375. * Stores the intensity of the different subsurface effects in the thickness texture.
  52376. * * the green channel is the translucency intensity.
  52377. * * the blue channel is the scattering intensity.
  52378. * * the alpha channel is the refraction intensity.
  52379. */
  52380. useMaskFromThicknessTexture: boolean;
  52381. /** @hidden */
  52382. private _internalMarkAllSubMeshesAsTexturesDirty;
  52383. /** @hidden */
  52384. _markAllSubMeshesAsTexturesDirty(): void;
  52385. /**
  52386. * Instantiate a new istance of sub surface configuration.
  52387. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52388. */
  52389. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52390. /**
  52391. * Gets wehter the submesh is ready to be used or not.
  52392. * @param defines the list of "defines" to update.
  52393. * @param scene defines the scene the material belongs to.
  52394. * @returns - boolean indicating that the submesh is ready or not.
  52395. */
  52396. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52397. /**
  52398. * Checks to see if a texture is used in the material.
  52399. * @param defines the list of "defines" to update.
  52400. * @param scene defines the scene to the material belongs to.
  52401. */
  52402. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52403. /**
  52404. * Binds the material data.
  52405. * @param uniformBuffer defines the Uniform buffer to fill in.
  52406. * @param scene defines the scene the material belongs to.
  52407. * @param engine defines the engine the material belongs to.
  52408. * @param isFrozen defines wether the material is frozen or not.
  52409. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52410. */
  52411. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52412. /**
  52413. * Unbinds the material from the mesh.
  52414. * @param activeEffect defines the effect that should be unbound from.
  52415. * @returns true if unbound, otherwise false
  52416. */
  52417. unbind(activeEffect: Effect): boolean;
  52418. /**
  52419. * Returns the texture used for refraction or null if none is used.
  52420. * @param scene defines the scene the material belongs to.
  52421. * @returns - Refraction texture if present. If no refraction texture and refraction
  52422. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52423. */
  52424. private _getRefractionTexture;
  52425. /**
  52426. * Returns true if alpha blending should be disabled.
  52427. */
  52428. get disableAlphaBlending(): boolean;
  52429. /**
  52430. * Fills the list of render target textures.
  52431. * @param renderTargets the list of render targets to update
  52432. */
  52433. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52434. /**
  52435. * Checks to see if a texture is used in the material.
  52436. * @param texture - Base texture to use.
  52437. * @returns - Boolean specifying if a texture is used in the material.
  52438. */
  52439. hasTexture(texture: BaseTexture): boolean;
  52440. /**
  52441. * Gets a boolean indicating that current material needs to register RTT
  52442. * @returns true if this uses a render target otherwise false.
  52443. */
  52444. hasRenderTargetTextures(): boolean;
  52445. /**
  52446. * Returns an array of the actively used textures.
  52447. * @param activeTextures Array of BaseTextures
  52448. */
  52449. getActiveTextures(activeTextures: BaseTexture[]): void;
  52450. /**
  52451. * Returns the animatable textures.
  52452. * @param animatables Array of animatable textures.
  52453. */
  52454. getAnimatables(animatables: IAnimatable[]): void;
  52455. /**
  52456. * Disposes the resources of the material.
  52457. * @param forceDisposeTextures - Forces the disposal of all textures.
  52458. */
  52459. dispose(forceDisposeTextures?: boolean): void;
  52460. /**
  52461. * Get the current class name of the texture useful for serialization or dynamic coding.
  52462. * @returns "PBRSubSurfaceConfiguration"
  52463. */
  52464. getClassName(): string;
  52465. /**
  52466. * Add fallbacks to the effect fallbacks list.
  52467. * @param defines defines the Base texture to use.
  52468. * @param fallbacks defines the current fallback list.
  52469. * @param currentRank defines the current fallback rank.
  52470. * @returns the new fallback rank.
  52471. */
  52472. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52473. /**
  52474. * Add the required uniforms to the current list.
  52475. * @param uniforms defines the current uniform list.
  52476. */
  52477. static AddUniforms(uniforms: string[]): void;
  52478. /**
  52479. * Add the required samplers to the current list.
  52480. * @param samplers defines the current sampler list.
  52481. */
  52482. static AddSamplers(samplers: string[]): void;
  52483. /**
  52484. * Add the required uniforms to the current buffer.
  52485. * @param uniformBuffer defines the current uniform buffer.
  52486. */
  52487. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52488. /**
  52489. * Makes a duplicate of the current configuration into another one.
  52490. * @param configuration define the config where to copy the info
  52491. */
  52492. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52493. /**
  52494. * Serializes this Sub Surface configuration.
  52495. * @returns - An object with the serialized config.
  52496. */
  52497. serialize(): any;
  52498. /**
  52499. * Parses a anisotropy Configuration from a serialized object.
  52500. * @param source - Serialized object.
  52501. * @param scene Defines the scene we are parsing for
  52502. * @param rootUrl Defines the rootUrl to load from
  52503. */
  52504. parse(source: any, scene: Scene, rootUrl: string): void;
  52505. }
  52506. }
  52507. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52508. /** @hidden */
  52509. export var pbrFragmentDeclaration: {
  52510. name: string;
  52511. shader: string;
  52512. };
  52513. }
  52514. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52515. /** @hidden */
  52516. export var pbrUboDeclaration: {
  52517. name: string;
  52518. shader: string;
  52519. };
  52520. }
  52521. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52522. /** @hidden */
  52523. export var pbrFragmentExtraDeclaration: {
  52524. name: string;
  52525. shader: string;
  52526. };
  52527. }
  52528. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52529. /** @hidden */
  52530. export var pbrFragmentSamplersDeclaration: {
  52531. name: string;
  52532. shader: string;
  52533. };
  52534. }
  52535. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52536. /** @hidden */
  52537. export var pbrHelperFunctions: {
  52538. name: string;
  52539. shader: string;
  52540. };
  52541. }
  52542. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52543. /** @hidden */
  52544. export var harmonicsFunctions: {
  52545. name: string;
  52546. shader: string;
  52547. };
  52548. }
  52549. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52550. /** @hidden */
  52551. export var pbrDirectLightingSetupFunctions: {
  52552. name: string;
  52553. shader: string;
  52554. };
  52555. }
  52556. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52557. /** @hidden */
  52558. export var pbrDirectLightingFalloffFunctions: {
  52559. name: string;
  52560. shader: string;
  52561. };
  52562. }
  52563. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52564. /** @hidden */
  52565. export var pbrBRDFFunctions: {
  52566. name: string;
  52567. shader: string;
  52568. };
  52569. }
  52570. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52571. /** @hidden */
  52572. export var pbrDirectLightingFunctions: {
  52573. name: string;
  52574. shader: string;
  52575. };
  52576. }
  52577. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52578. /** @hidden */
  52579. export var pbrIBLFunctions: {
  52580. name: string;
  52581. shader: string;
  52582. };
  52583. }
  52584. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52585. /** @hidden */
  52586. export var pbrDebug: {
  52587. name: string;
  52588. shader: string;
  52589. };
  52590. }
  52591. declare module "babylonjs/Shaders/pbr.fragment" {
  52592. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52593. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52594. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52595. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52596. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52597. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52598. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52599. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52600. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52601. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52602. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52603. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52604. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52605. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52606. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52607. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52608. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52609. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52610. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52611. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52612. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52613. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52615. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52616. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52617. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52618. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52619. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52620. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52621. /** @hidden */
  52622. export var pbrPixelShader: {
  52623. name: string;
  52624. shader: string;
  52625. };
  52626. }
  52627. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52628. /** @hidden */
  52629. export var pbrVertexDeclaration: {
  52630. name: string;
  52631. shader: string;
  52632. };
  52633. }
  52634. declare module "babylonjs/Shaders/pbr.vertex" {
  52635. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52636. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52637. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52638. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52639. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52640. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52641. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52642. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52643. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52644. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52645. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52646. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52647. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52648. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52649. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52650. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52651. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52652. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52653. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52654. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52655. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52656. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52657. /** @hidden */
  52658. export var pbrVertexShader: {
  52659. name: string;
  52660. shader: string;
  52661. };
  52662. }
  52663. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52664. import { Nullable } from "babylonjs/types";
  52665. import { Scene } from "babylonjs/scene";
  52666. import { Matrix } from "babylonjs/Maths/math.vector";
  52667. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52669. import { Mesh } from "babylonjs/Meshes/mesh";
  52670. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52671. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52672. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52673. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52674. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52675. import { Color3 } from "babylonjs/Maths/math.color";
  52676. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52677. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52678. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52679. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52681. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52682. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52683. import "babylonjs/Shaders/pbr.fragment";
  52684. import "babylonjs/Shaders/pbr.vertex";
  52685. /**
  52686. * Manages the defines for the PBR Material.
  52687. * @hidden
  52688. */
  52689. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52690. PBR: boolean;
  52691. MAINUV1: boolean;
  52692. MAINUV2: boolean;
  52693. UV1: boolean;
  52694. UV2: boolean;
  52695. ALBEDO: boolean;
  52696. ALBEDODIRECTUV: number;
  52697. VERTEXCOLOR: boolean;
  52698. AMBIENT: boolean;
  52699. AMBIENTDIRECTUV: number;
  52700. AMBIENTINGRAYSCALE: boolean;
  52701. OPACITY: boolean;
  52702. VERTEXALPHA: boolean;
  52703. OPACITYDIRECTUV: number;
  52704. OPACITYRGB: boolean;
  52705. ALPHATEST: boolean;
  52706. DEPTHPREPASS: boolean;
  52707. ALPHABLEND: boolean;
  52708. ALPHAFROMALBEDO: boolean;
  52709. ALPHATESTVALUE: string;
  52710. SPECULAROVERALPHA: boolean;
  52711. RADIANCEOVERALPHA: boolean;
  52712. ALPHAFRESNEL: boolean;
  52713. LINEARALPHAFRESNEL: boolean;
  52714. PREMULTIPLYALPHA: boolean;
  52715. EMISSIVE: boolean;
  52716. EMISSIVEDIRECTUV: number;
  52717. REFLECTIVITY: boolean;
  52718. REFLECTIVITYDIRECTUV: number;
  52719. SPECULARTERM: boolean;
  52720. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52721. MICROSURFACEAUTOMATIC: boolean;
  52722. LODBASEDMICROSFURACE: boolean;
  52723. MICROSURFACEMAP: boolean;
  52724. MICROSURFACEMAPDIRECTUV: number;
  52725. METALLICWORKFLOW: boolean;
  52726. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52727. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52728. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52729. AOSTOREINMETALMAPRED: boolean;
  52730. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52731. ENVIRONMENTBRDF: boolean;
  52732. ENVIRONMENTBRDF_RGBD: boolean;
  52733. NORMAL: boolean;
  52734. TANGENT: boolean;
  52735. BUMP: boolean;
  52736. BUMPDIRECTUV: number;
  52737. OBJECTSPACE_NORMALMAP: boolean;
  52738. PARALLAX: boolean;
  52739. PARALLAXOCCLUSION: boolean;
  52740. NORMALXYSCALE: boolean;
  52741. LIGHTMAP: boolean;
  52742. LIGHTMAPDIRECTUV: number;
  52743. USELIGHTMAPASSHADOWMAP: boolean;
  52744. GAMMALIGHTMAP: boolean;
  52745. RGBDLIGHTMAP: boolean;
  52746. REFLECTION: boolean;
  52747. REFLECTIONMAP_3D: boolean;
  52748. REFLECTIONMAP_SPHERICAL: boolean;
  52749. REFLECTIONMAP_PLANAR: boolean;
  52750. REFLECTIONMAP_CUBIC: boolean;
  52751. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  52752. REFLECTIONMAP_PROJECTION: boolean;
  52753. REFLECTIONMAP_SKYBOX: boolean;
  52754. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  52755. REFLECTIONMAP_EXPLICIT: boolean;
  52756. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  52757. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  52758. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  52759. INVERTCUBICMAP: boolean;
  52760. USESPHERICALFROMREFLECTIONMAP: boolean;
  52761. USEIRRADIANCEMAP: boolean;
  52762. SPHERICAL_HARMONICS: boolean;
  52763. USESPHERICALINVERTEX: boolean;
  52764. REFLECTIONMAP_OPPOSITEZ: boolean;
  52765. LODINREFLECTIONALPHA: boolean;
  52766. GAMMAREFLECTION: boolean;
  52767. RGBDREFLECTION: boolean;
  52768. LINEARSPECULARREFLECTION: boolean;
  52769. RADIANCEOCCLUSION: boolean;
  52770. HORIZONOCCLUSION: boolean;
  52771. INSTANCES: boolean;
  52772. NUM_BONE_INFLUENCERS: number;
  52773. BonesPerMesh: number;
  52774. BONETEXTURE: boolean;
  52775. NONUNIFORMSCALING: boolean;
  52776. MORPHTARGETS: boolean;
  52777. MORPHTARGETS_NORMAL: boolean;
  52778. MORPHTARGETS_TANGENT: boolean;
  52779. MORPHTARGETS_UV: boolean;
  52780. NUM_MORPH_INFLUENCERS: number;
  52781. IMAGEPROCESSING: boolean;
  52782. VIGNETTE: boolean;
  52783. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52784. VIGNETTEBLENDMODEOPAQUE: boolean;
  52785. TONEMAPPING: boolean;
  52786. TONEMAPPING_ACES: boolean;
  52787. CONTRAST: boolean;
  52788. COLORCURVES: boolean;
  52789. COLORGRADING: boolean;
  52790. COLORGRADING3D: boolean;
  52791. SAMPLER3DGREENDEPTH: boolean;
  52792. SAMPLER3DBGRMAP: boolean;
  52793. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52794. EXPOSURE: boolean;
  52795. MULTIVIEW: boolean;
  52796. USEPHYSICALLIGHTFALLOFF: boolean;
  52797. USEGLTFLIGHTFALLOFF: boolean;
  52798. TWOSIDEDLIGHTING: boolean;
  52799. SHADOWFLOAT: boolean;
  52800. CLIPPLANE: boolean;
  52801. CLIPPLANE2: boolean;
  52802. CLIPPLANE3: boolean;
  52803. CLIPPLANE4: boolean;
  52804. CLIPPLANE5: boolean;
  52805. CLIPPLANE6: boolean;
  52806. POINTSIZE: boolean;
  52807. FOG: boolean;
  52808. LOGARITHMICDEPTH: boolean;
  52809. FORCENORMALFORWARD: boolean;
  52810. SPECULARAA: boolean;
  52811. CLEARCOAT: boolean;
  52812. CLEARCOAT_DEFAULTIOR: boolean;
  52813. CLEARCOAT_TEXTURE: boolean;
  52814. CLEARCOAT_TEXTUREDIRECTUV: number;
  52815. CLEARCOAT_BUMP: boolean;
  52816. CLEARCOAT_BUMPDIRECTUV: number;
  52817. CLEARCOAT_TINT: boolean;
  52818. CLEARCOAT_TINT_TEXTURE: boolean;
  52819. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52820. ANISOTROPIC: boolean;
  52821. ANISOTROPIC_TEXTURE: boolean;
  52822. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52823. BRDF_V_HEIGHT_CORRELATED: boolean;
  52824. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52825. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52826. SHEEN: boolean;
  52827. SHEEN_TEXTURE: boolean;
  52828. SHEEN_TEXTUREDIRECTUV: number;
  52829. SHEEN_LINKWITHALBEDO: boolean;
  52830. SUBSURFACE: boolean;
  52831. SS_REFRACTION: boolean;
  52832. SS_TRANSLUCENCY: boolean;
  52833. SS_SCATERRING: boolean;
  52834. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52835. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52836. SS_REFRACTIONMAP_3D: boolean;
  52837. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52838. SS_LODINREFRACTIONALPHA: boolean;
  52839. SS_GAMMAREFRACTION: boolean;
  52840. SS_RGBDREFRACTION: boolean;
  52841. SS_LINEARSPECULARREFRACTION: boolean;
  52842. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52843. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52844. UNLIT: boolean;
  52845. DEBUGMODE: number;
  52846. /**
  52847. * Initializes the PBR Material defines.
  52848. */
  52849. constructor();
  52850. /**
  52851. * Resets the PBR Material defines.
  52852. */
  52853. reset(): void;
  52854. }
  52855. /**
  52856. * The Physically based material base class of BJS.
  52857. *
  52858. * This offers the main features of a standard PBR material.
  52859. * For more information, please refer to the documentation :
  52860. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52861. */
  52862. export abstract class PBRBaseMaterial extends PushMaterial {
  52863. /**
  52864. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52865. */
  52866. static readonly PBRMATERIAL_OPAQUE: number;
  52867. /**
  52868. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52869. */
  52870. static readonly PBRMATERIAL_ALPHATEST: number;
  52871. /**
  52872. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52873. */
  52874. static readonly PBRMATERIAL_ALPHABLEND: number;
  52875. /**
  52876. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52877. * They are also discarded below the alpha cutoff threshold to improve performances.
  52878. */
  52879. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52880. /**
  52881. * Defines the default value of how much AO map is occluding the analytical lights
  52882. * (point spot...).
  52883. */
  52884. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52885. /**
  52886. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52887. */
  52888. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52889. /**
  52890. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52891. * to enhance interoperability with other engines.
  52892. */
  52893. static readonly LIGHTFALLOFF_GLTF: number;
  52894. /**
  52895. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52896. * to enhance interoperability with other materials.
  52897. */
  52898. static readonly LIGHTFALLOFF_STANDARD: number;
  52899. /**
  52900. * Intensity of the direct lights e.g. the four lights available in your scene.
  52901. * This impacts both the direct diffuse and specular highlights.
  52902. */
  52903. protected _directIntensity: number;
  52904. /**
  52905. * Intensity of the emissive part of the material.
  52906. * This helps controlling the emissive effect without modifying the emissive color.
  52907. */
  52908. protected _emissiveIntensity: number;
  52909. /**
  52910. * Intensity of the environment e.g. how much the environment will light the object
  52911. * either through harmonics for rough material or through the refelction for shiny ones.
  52912. */
  52913. protected _environmentIntensity: number;
  52914. /**
  52915. * This is a special control allowing the reduction of the specular highlights coming from the
  52916. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52917. */
  52918. protected _specularIntensity: number;
  52919. /**
  52920. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52921. */
  52922. private _lightingInfos;
  52923. /**
  52924. * Debug Control allowing disabling the bump map on this material.
  52925. */
  52926. protected _disableBumpMap: boolean;
  52927. /**
  52928. * AKA Diffuse Texture in standard nomenclature.
  52929. */
  52930. protected _albedoTexture: Nullable<BaseTexture>;
  52931. /**
  52932. * AKA Occlusion Texture in other nomenclature.
  52933. */
  52934. protected _ambientTexture: Nullable<BaseTexture>;
  52935. /**
  52936. * AKA Occlusion Texture Intensity in other nomenclature.
  52937. */
  52938. protected _ambientTextureStrength: number;
  52939. /**
  52940. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52941. * 1 means it completely occludes it
  52942. * 0 mean it has no impact
  52943. */
  52944. protected _ambientTextureImpactOnAnalyticalLights: number;
  52945. /**
  52946. * Stores the alpha values in a texture.
  52947. */
  52948. protected _opacityTexture: Nullable<BaseTexture>;
  52949. /**
  52950. * Stores the reflection values in a texture.
  52951. */
  52952. protected _reflectionTexture: Nullable<BaseTexture>;
  52953. /**
  52954. * Stores the emissive values in a texture.
  52955. */
  52956. protected _emissiveTexture: Nullable<BaseTexture>;
  52957. /**
  52958. * AKA Specular texture in other nomenclature.
  52959. */
  52960. protected _reflectivityTexture: Nullable<BaseTexture>;
  52961. /**
  52962. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52963. */
  52964. protected _metallicTexture: Nullable<BaseTexture>;
  52965. /**
  52966. * Specifies the metallic scalar of the metallic/roughness workflow.
  52967. * Can also be used to scale the metalness values of the metallic texture.
  52968. */
  52969. protected _metallic: Nullable<number>;
  52970. /**
  52971. * Specifies the roughness scalar of the metallic/roughness workflow.
  52972. * Can also be used to scale the roughness values of the metallic texture.
  52973. */
  52974. protected _roughness: Nullable<number>;
  52975. /**
  52976. * Specifies the an F0 factor to help configuring the material F0.
  52977. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52978. * to 0.5 the previously hard coded value stays the same.
  52979. * Can also be used to scale the F0 values of the metallic texture.
  52980. */
  52981. protected _metallicF0Factor: number;
  52982. /**
  52983. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52984. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52985. * your expectation as it multiplies with the texture data.
  52986. */
  52987. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52988. /**
  52989. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52990. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52991. */
  52992. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52993. /**
  52994. * Stores surface normal data used to displace a mesh in a texture.
  52995. */
  52996. protected _bumpTexture: Nullable<BaseTexture>;
  52997. /**
  52998. * Stores the pre-calculated light information of a mesh in a texture.
  52999. */
  53000. protected _lightmapTexture: Nullable<BaseTexture>;
  53001. /**
  53002. * The color of a material in ambient lighting.
  53003. */
  53004. protected _ambientColor: Color3;
  53005. /**
  53006. * AKA Diffuse Color in other nomenclature.
  53007. */
  53008. protected _albedoColor: Color3;
  53009. /**
  53010. * AKA Specular Color in other nomenclature.
  53011. */
  53012. protected _reflectivityColor: Color3;
  53013. /**
  53014. * The color applied when light is reflected from a material.
  53015. */
  53016. protected _reflectionColor: Color3;
  53017. /**
  53018. * The color applied when light is emitted from a material.
  53019. */
  53020. protected _emissiveColor: Color3;
  53021. /**
  53022. * AKA Glossiness in other nomenclature.
  53023. */
  53024. protected _microSurface: number;
  53025. /**
  53026. * Specifies that the material will use the light map as a show map.
  53027. */
  53028. protected _useLightmapAsShadowmap: boolean;
  53029. /**
  53030. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53031. * makes the reflect vector face the model (under horizon).
  53032. */
  53033. protected _useHorizonOcclusion: boolean;
  53034. /**
  53035. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53036. * too much the area relying on ambient texture to define their ambient occlusion.
  53037. */
  53038. protected _useRadianceOcclusion: boolean;
  53039. /**
  53040. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53041. */
  53042. protected _useAlphaFromAlbedoTexture: boolean;
  53043. /**
  53044. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53045. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53046. */
  53047. protected _useSpecularOverAlpha: boolean;
  53048. /**
  53049. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53050. */
  53051. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53052. /**
  53053. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53054. */
  53055. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53056. /**
  53057. * Specifies if the metallic texture contains the roughness information in its green channel.
  53058. */
  53059. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53060. /**
  53061. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53062. */
  53063. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53064. /**
  53065. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53066. */
  53067. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53068. /**
  53069. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53070. */
  53071. protected _useAmbientInGrayScale: boolean;
  53072. /**
  53073. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53074. * The material will try to infer what glossiness each pixel should be.
  53075. */
  53076. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53077. /**
  53078. * Defines the falloff type used in this material.
  53079. * It by default is Physical.
  53080. */
  53081. protected _lightFalloff: number;
  53082. /**
  53083. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53084. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53085. */
  53086. protected _useRadianceOverAlpha: boolean;
  53087. /**
  53088. * Allows using an object space normal map (instead of tangent space).
  53089. */
  53090. protected _useObjectSpaceNormalMap: boolean;
  53091. /**
  53092. * Allows using the bump map in parallax mode.
  53093. */
  53094. protected _useParallax: boolean;
  53095. /**
  53096. * Allows using the bump map in parallax occlusion mode.
  53097. */
  53098. protected _useParallaxOcclusion: boolean;
  53099. /**
  53100. * Controls the scale bias of the parallax mode.
  53101. */
  53102. protected _parallaxScaleBias: number;
  53103. /**
  53104. * If sets to true, disables all the lights affecting the material.
  53105. */
  53106. protected _disableLighting: boolean;
  53107. /**
  53108. * Number of Simultaneous lights allowed on the material.
  53109. */
  53110. protected _maxSimultaneousLights: number;
  53111. /**
  53112. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53113. */
  53114. protected _invertNormalMapX: boolean;
  53115. /**
  53116. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53117. */
  53118. protected _invertNormalMapY: boolean;
  53119. /**
  53120. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53121. */
  53122. protected _twoSidedLighting: boolean;
  53123. /**
  53124. * Defines the alpha limits in alpha test mode.
  53125. */
  53126. protected _alphaCutOff: number;
  53127. /**
  53128. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53129. */
  53130. protected _forceAlphaTest: boolean;
  53131. /**
  53132. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53133. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53134. */
  53135. protected _useAlphaFresnel: boolean;
  53136. /**
  53137. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53138. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53139. */
  53140. protected _useLinearAlphaFresnel: boolean;
  53141. /**
  53142. * The transparency mode of the material.
  53143. */
  53144. protected _transparencyMode: Nullable<number>;
  53145. /**
  53146. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53147. * from cos thetav and roughness:
  53148. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53149. */
  53150. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53151. /**
  53152. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53153. */
  53154. protected _forceIrradianceInFragment: boolean;
  53155. /**
  53156. * Force normal to face away from face.
  53157. */
  53158. protected _forceNormalForward: boolean;
  53159. /**
  53160. * Enables specular anti aliasing in the PBR shader.
  53161. * It will both interacts on the Geometry for analytical and IBL lighting.
  53162. * It also prefilter the roughness map based on the bump values.
  53163. */
  53164. protected _enableSpecularAntiAliasing: boolean;
  53165. /**
  53166. * Default configuration related to image processing available in the PBR Material.
  53167. */
  53168. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53169. /**
  53170. * Keep track of the image processing observer to allow dispose and replace.
  53171. */
  53172. private _imageProcessingObserver;
  53173. /**
  53174. * Attaches a new image processing configuration to the PBR Material.
  53175. * @param configuration
  53176. */
  53177. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53178. /**
  53179. * Stores the available render targets.
  53180. */
  53181. private _renderTargets;
  53182. /**
  53183. * Sets the global ambient color for the material used in lighting calculations.
  53184. */
  53185. private _globalAmbientColor;
  53186. /**
  53187. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53188. */
  53189. private _useLogarithmicDepth;
  53190. /**
  53191. * If set to true, no lighting calculations will be applied.
  53192. */
  53193. private _unlit;
  53194. private _debugMode;
  53195. /**
  53196. * @hidden
  53197. * This is reserved for the inspector.
  53198. * Defines the material debug mode.
  53199. * It helps seeing only some components of the material while troubleshooting.
  53200. */
  53201. debugMode: number;
  53202. /**
  53203. * @hidden
  53204. * This is reserved for the inspector.
  53205. * Specify from where on screen the debug mode should start.
  53206. * The value goes from -1 (full screen) to 1 (not visible)
  53207. * It helps with side by side comparison against the final render
  53208. * This defaults to -1
  53209. */
  53210. private debugLimit;
  53211. /**
  53212. * @hidden
  53213. * This is reserved for the inspector.
  53214. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53215. * You can use the factor to better multiply the final value.
  53216. */
  53217. private debugFactor;
  53218. /**
  53219. * Defines the clear coat layer parameters for the material.
  53220. */
  53221. readonly clearCoat: PBRClearCoatConfiguration;
  53222. /**
  53223. * Defines the anisotropic parameters for the material.
  53224. */
  53225. readonly anisotropy: PBRAnisotropicConfiguration;
  53226. /**
  53227. * Defines the BRDF parameters for the material.
  53228. */
  53229. readonly brdf: PBRBRDFConfiguration;
  53230. /**
  53231. * Defines the Sheen parameters for the material.
  53232. */
  53233. readonly sheen: PBRSheenConfiguration;
  53234. /**
  53235. * Defines the SubSurface parameters for the material.
  53236. */
  53237. readonly subSurface: PBRSubSurfaceConfiguration;
  53238. /**
  53239. * Custom callback helping to override the default shader used in the material.
  53240. */
  53241. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53242. protected _rebuildInParallel: boolean;
  53243. /**
  53244. * Instantiates a new PBRMaterial instance.
  53245. *
  53246. * @param name The material name
  53247. * @param scene The scene the material will be use in.
  53248. */
  53249. constructor(name: string, scene: Scene);
  53250. /**
  53251. * Gets a boolean indicating that current material needs to register RTT
  53252. */
  53253. get hasRenderTargetTextures(): boolean;
  53254. /**
  53255. * Gets the name of the material class.
  53256. */
  53257. getClassName(): string;
  53258. /**
  53259. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53260. */
  53261. get useLogarithmicDepth(): boolean;
  53262. /**
  53263. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53264. */
  53265. set useLogarithmicDepth(value: boolean);
  53266. /**
  53267. * Gets the current transparency mode.
  53268. */
  53269. get transparencyMode(): Nullable<number>;
  53270. /**
  53271. * Sets the transparency mode of the material.
  53272. *
  53273. * | Value | Type | Description |
  53274. * | ----- | ----------------------------------- | ----------- |
  53275. * | 0 | OPAQUE | |
  53276. * | 1 | ALPHATEST | |
  53277. * | 2 | ALPHABLEND | |
  53278. * | 3 | ALPHATESTANDBLEND | |
  53279. *
  53280. */
  53281. set transparencyMode(value: Nullable<number>);
  53282. /**
  53283. * Returns true if alpha blending should be disabled.
  53284. */
  53285. private get _disableAlphaBlending();
  53286. /**
  53287. * Specifies whether or not this material should be rendered in alpha blend mode.
  53288. */
  53289. needAlphaBlending(): boolean;
  53290. /**
  53291. * Specifies if the mesh will require alpha blending.
  53292. * @param mesh - BJS mesh.
  53293. */
  53294. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53295. /**
  53296. * Specifies whether or not this material should be rendered in alpha test mode.
  53297. */
  53298. needAlphaTesting(): boolean;
  53299. /**
  53300. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53301. */
  53302. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53303. /**
  53304. * Gets the texture used for the alpha test.
  53305. */
  53306. getAlphaTestTexture(): Nullable<BaseTexture>;
  53307. /**
  53308. * Specifies that the submesh is ready to be used.
  53309. * @param mesh - BJS mesh.
  53310. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53311. * @param useInstances - Specifies that instances should be used.
  53312. * @returns - boolean indicating that the submesh is ready or not.
  53313. */
  53314. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53315. /**
  53316. * Specifies if the material uses metallic roughness workflow.
  53317. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53318. */
  53319. isMetallicWorkflow(): boolean;
  53320. private _prepareEffect;
  53321. private _prepareDefines;
  53322. /**
  53323. * Force shader compilation
  53324. */
  53325. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53326. /**
  53327. * Initializes the uniform buffer layout for the shader.
  53328. */
  53329. buildUniformLayout(): void;
  53330. /**
  53331. * Unbinds the material from the mesh
  53332. */
  53333. unbind(): void;
  53334. /**
  53335. * Binds the submesh data.
  53336. * @param world - The world matrix.
  53337. * @param mesh - The BJS mesh.
  53338. * @param subMesh - A submesh of the BJS mesh.
  53339. */
  53340. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53341. /**
  53342. * Returns the animatable textures.
  53343. * @returns - Array of animatable textures.
  53344. */
  53345. getAnimatables(): IAnimatable[];
  53346. /**
  53347. * Returns the texture used for reflections.
  53348. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53349. */
  53350. private _getReflectionTexture;
  53351. /**
  53352. * Returns an array of the actively used textures.
  53353. * @returns - Array of BaseTextures
  53354. */
  53355. getActiveTextures(): BaseTexture[];
  53356. /**
  53357. * Checks to see if a texture is used in the material.
  53358. * @param texture - Base texture to use.
  53359. * @returns - Boolean specifying if a texture is used in the material.
  53360. */
  53361. hasTexture(texture: BaseTexture): boolean;
  53362. /**
  53363. * Disposes the resources of the material.
  53364. * @param forceDisposeEffect - Forces the disposal of effects.
  53365. * @param forceDisposeTextures - Forces the disposal of all textures.
  53366. */
  53367. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53368. }
  53369. }
  53370. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53371. import { Nullable } from "babylonjs/types";
  53372. import { Scene } from "babylonjs/scene";
  53373. import { Color3 } from "babylonjs/Maths/math.color";
  53374. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53375. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53377. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53378. /**
  53379. * The Physically based material of BJS.
  53380. *
  53381. * This offers the main features of a standard PBR material.
  53382. * For more information, please refer to the documentation :
  53383. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53384. */
  53385. export class PBRMaterial extends PBRBaseMaterial {
  53386. /**
  53387. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53388. */
  53389. static readonly PBRMATERIAL_OPAQUE: number;
  53390. /**
  53391. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53392. */
  53393. static readonly PBRMATERIAL_ALPHATEST: number;
  53394. /**
  53395. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53396. */
  53397. static readonly PBRMATERIAL_ALPHABLEND: number;
  53398. /**
  53399. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53400. * They are also discarded below the alpha cutoff threshold to improve performances.
  53401. */
  53402. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53403. /**
  53404. * Defines the default value of how much AO map is occluding the analytical lights
  53405. * (point spot...).
  53406. */
  53407. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53408. /**
  53409. * Intensity of the direct lights e.g. the four lights available in your scene.
  53410. * This impacts both the direct diffuse and specular highlights.
  53411. */
  53412. directIntensity: number;
  53413. /**
  53414. * Intensity of the emissive part of the material.
  53415. * This helps controlling the emissive effect without modifying the emissive color.
  53416. */
  53417. emissiveIntensity: number;
  53418. /**
  53419. * Intensity of the environment e.g. how much the environment will light the object
  53420. * either through harmonics for rough material or through the refelction for shiny ones.
  53421. */
  53422. environmentIntensity: number;
  53423. /**
  53424. * This is a special control allowing the reduction of the specular highlights coming from the
  53425. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53426. */
  53427. specularIntensity: number;
  53428. /**
  53429. * Debug Control allowing disabling the bump map on this material.
  53430. */
  53431. disableBumpMap: boolean;
  53432. /**
  53433. * AKA Diffuse Texture in standard nomenclature.
  53434. */
  53435. albedoTexture: BaseTexture;
  53436. /**
  53437. * AKA Occlusion Texture in other nomenclature.
  53438. */
  53439. ambientTexture: BaseTexture;
  53440. /**
  53441. * AKA Occlusion Texture Intensity in other nomenclature.
  53442. */
  53443. ambientTextureStrength: number;
  53444. /**
  53445. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53446. * 1 means it completely occludes it
  53447. * 0 mean it has no impact
  53448. */
  53449. ambientTextureImpactOnAnalyticalLights: number;
  53450. /**
  53451. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53452. */
  53453. opacityTexture: BaseTexture;
  53454. /**
  53455. * Stores the reflection values in a texture.
  53456. */
  53457. reflectionTexture: Nullable<BaseTexture>;
  53458. /**
  53459. * Stores the emissive values in a texture.
  53460. */
  53461. emissiveTexture: BaseTexture;
  53462. /**
  53463. * AKA Specular texture in other nomenclature.
  53464. */
  53465. reflectivityTexture: BaseTexture;
  53466. /**
  53467. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53468. */
  53469. metallicTexture: BaseTexture;
  53470. /**
  53471. * Specifies the metallic scalar of the metallic/roughness workflow.
  53472. * Can also be used to scale the metalness values of the metallic texture.
  53473. */
  53474. metallic: Nullable<number>;
  53475. /**
  53476. * Specifies the roughness scalar of the metallic/roughness workflow.
  53477. * Can also be used to scale the roughness values of the metallic texture.
  53478. */
  53479. roughness: Nullable<number>;
  53480. /**
  53481. * Specifies the an F0 factor to help configuring the material F0.
  53482. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53483. * to 0.5 the previously hard coded value stays the same.
  53484. * Can also be used to scale the F0 values of the metallic texture.
  53485. */
  53486. metallicF0Factor: number;
  53487. /**
  53488. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53489. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53490. * your expectation as it multiplies with the texture data.
  53491. */
  53492. useMetallicF0FactorFromMetallicTexture: boolean;
  53493. /**
  53494. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53495. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53496. */
  53497. microSurfaceTexture: BaseTexture;
  53498. /**
  53499. * Stores surface normal data used to displace a mesh in a texture.
  53500. */
  53501. bumpTexture: BaseTexture;
  53502. /**
  53503. * Stores the pre-calculated light information of a mesh in a texture.
  53504. */
  53505. lightmapTexture: BaseTexture;
  53506. /**
  53507. * Stores the refracted light information in a texture.
  53508. */
  53509. get refractionTexture(): Nullable<BaseTexture>;
  53510. set refractionTexture(value: Nullable<BaseTexture>);
  53511. /**
  53512. * The color of a material in ambient lighting.
  53513. */
  53514. ambientColor: Color3;
  53515. /**
  53516. * AKA Diffuse Color in other nomenclature.
  53517. */
  53518. albedoColor: Color3;
  53519. /**
  53520. * AKA Specular Color in other nomenclature.
  53521. */
  53522. reflectivityColor: Color3;
  53523. /**
  53524. * The color reflected from the material.
  53525. */
  53526. reflectionColor: Color3;
  53527. /**
  53528. * The color emitted from the material.
  53529. */
  53530. emissiveColor: Color3;
  53531. /**
  53532. * AKA Glossiness in other nomenclature.
  53533. */
  53534. microSurface: number;
  53535. /**
  53536. * source material index of refraction (IOR)' / 'destination material IOR.
  53537. */
  53538. get indexOfRefraction(): number;
  53539. set indexOfRefraction(value: number);
  53540. /**
  53541. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53542. */
  53543. get invertRefractionY(): boolean;
  53544. set invertRefractionY(value: boolean);
  53545. /**
  53546. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53547. * Materials half opaque for instance using refraction could benefit from this control.
  53548. */
  53549. get linkRefractionWithTransparency(): boolean;
  53550. set linkRefractionWithTransparency(value: boolean);
  53551. /**
  53552. * If true, the light map contains occlusion information instead of lighting info.
  53553. */
  53554. useLightmapAsShadowmap: boolean;
  53555. /**
  53556. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53557. */
  53558. useAlphaFromAlbedoTexture: boolean;
  53559. /**
  53560. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53561. */
  53562. forceAlphaTest: boolean;
  53563. /**
  53564. * Defines the alpha limits in alpha test mode.
  53565. */
  53566. alphaCutOff: number;
  53567. /**
  53568. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53569. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53570. */
  53571. useSpecularOverAlpha: boolean;
  53572. /**
  53573. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53574. */
  53575. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53576. /**
  53577. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53578. */
  53579. useRoughnessFromMetallicTextureAlpha: boolean;
  53580. /**
  53581. * Specifies if the metallic texture contains the roughness information in its green channel.
  53582. */
  53583. useRoughnessFromMetallicTextureGreen: boolean;
  53584. /**
  53585. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53586. */
  53587. useMetallnessFromMetallicTextureBlue: boolean;
  53588. /**
  53589. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53590. */
  53591. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53592. /**
  53593. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53594. */
  53595. useAmbientInGrayScale: boolean;
  53596. /**
  53597. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53598. * The material will try to infer what glossiness each pixel should be.
  53599. */
  53600. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53601. /**
  53602. * BJS is using an harcoded light falloff based on a manually sets up range.
  53603. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53604. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53605. */
  53606. get usePhysicalLightFalloff(): boolean;
  53607. /**
  53608. * BJS is using an harcoded light falloff based on a manually sets up range.
  53609. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53610. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53611. */
  53612. set usePhysicalLightFalloff(value: boolean);
  53613. /**
  53614. * In order to support the falloff compatibility with gltf, a special mode has been added
  53615. * to reproduce the gltf light falloff.
  53616. */
  53617. get useGLTFLightFalloff(): boolean;
  53618. /**
  53619. * In order to support the falloff compatibility with gltf, a special mode has been added
  53620. * to reproduce the gltf light falloff.
  53621. */
  53622. set useGLTFLightFalloff(value: boolean);
  53623. /**
  53624. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53625. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53626. */
  53627. useRadianceOverAlpha: boolean;
  53628. /**
  53629. * Allows using an object space normal map (instead of tangent space).
  53630. */
  53631. useObjectSpaceNormalMap: boolean;
  53632. /**
  53633. * Allows using the bump map in parallax mode.
  53634. */
  53635. useParallax: boolean;
  53636. /**
  53637. * Allows using the bump map in parallax occlusion mode.
  53638. */
  53639. useParallaxOcclusion: boolean;
  53640. /**
  53641. * Controls the scale bias of the parallax mode.
  53642. */
  53643. parallaxScaleBias: number;
  53644. /**
  53645. * If sets to true, disables all the lights affecting the material.
  53646. */
  53647. disableLighting: boolean;
  53648. /**
  53649. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53650. */
  53651. forceIrradianceInFragment: boolean;
  53652. /**
  53653. * Number of Simultaneous lights allowed on the material.
  53654. */
  53655. maxSimultaneousLights: number;
  53656. /**
  53657. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53658. */
  53659. invertNormalMapX: boolean;
  53660. /**
  53661. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53662. */
  53663. invertNormalMapY: boolean;
  53664. /**
  53665. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53666. */
  53667. twoSidedLighting: boolean;
  53668. /**
  53669. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53670. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53671. */
  53672. useAlphaFresnel: 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 stays linear to compute the fresnel)
  53676. */
  53677. useLinearAlphaFresnel: boolean;
  53678. /**
  53679. * Let user defines the brdf lookup texture used for IBL.
  53680. * A default 8bit version is embedded but you could point at :
  53681. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53682. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53683. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53684. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53685. */
  53686. environmentBRDFTexture: Nullable<BaseTexture>;
  53687. /**
  53688. * Force normal to face away from face.
  53689. */
  53690. forceNormalForward: boolean;
  53691. /**
  53692. * Enables specular anti aliasing in the PBR shader.
  53693. * It will both interacts on the Geometry for analytical and IBL lighting.
  53694. * It also prefilter the roughness map based on the bump values.
  53695. */
  53696. enableSpecularAntiAliasing: boolean;
  53697. /**
  53698. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53699. * makes the reflect vector face the model (under horizon).
  53700. */
  53701. useHorizonOcclusion: boolean;
  53702. /**
  53703. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53704. * too much the area relying on ambient texture to define their ambient occlusion.
  53705. */
  53706. useRadianceOcclusion: boolean;
  53707. /**
  53708. * If set to true, no lighting calculations will be applied.
  53709. */
  53710. unlit: boolean;
  53711. /**
  53712. * Gets the image processing configuration used either in this material.
  53713. */
  53714. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53715. /**
  53716. * Sets the Default image processing configuration used either in the this material.
  53717. *
  53718. * If sets to null, the scene one is in use.
  53719. */
  53720. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53721. /**
  53722. * Gets wether the color curves effect is enabled.
  53723. */
  53724. get cameraColorCurvesEnabled(): boolean;
  53725. /**
  53726. * Sets wether the color curves effect is enabled.
  53727. */
  53728. set cameraColorCurvesEnabled(value: boolean);
  53729. /**
  53730. * Gets wether the color grading effect is enabled.
  53731. */
  53732. get cameraColorGradingEnabled(): boolean;
  53733. /**
  53734. * Gets wether the color grading effect is enabled.
  53735. */
  53736. set cameraColorGradingEnabled(value: boolean);
  53737. /**
  53738. * Gets wether tonemapping is enabled or not.
  53739. */
  53740. get cameraToneMappingEnabled(): boolean;
  53741. /**
  53742. * Sets wether tonemapping is enabled or not
  53743. */
  53744. set cameraToneMappingEnabled(value: boolean);
  53745. /**
  53746. * The camera exposure used on this material.
  53747. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53748. * This corresponds to a photographic exposure.
  53749. */
  53750. get cameraExposure(): number;
  53751. /**
  53752. * The camera exposure used on this material.
  53753. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53754. * This corresponds to a photographic exposure.
  53755. */
  53756. set cameraExposure(value: number);
  53757. /**
  53758. * Gets The camera contrast used on this material.
  53759. */
  53760. get cameraContrast(): number;
  53761. /**
  53762. * Sets The camera contrast used on this material.
  53763. */
  53764. set cameraContrast(value: number);
  53765. /**
  53766. * Gets the Color Grading 2D Lookup Texture.
  53767. */
  53768. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53769. /**
  53770. * Sets the Color Grading 2D Lookup Texture.
  53771. */
  53772. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53773. /**
  53774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53776. * 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;
  53777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53778. */
  53779. get cameraColorCurves(): Nullable<ColorCurves>;
  53780. /**
  53781. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53782. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53783. * 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;
  53784. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53785. */
  53786. set cameraColorCurves(value: Nullable<ColorCurves>);
  53787. /**
  53788. * Instantiates a new PBRMaterial instance.
  53789. *
  53790. * @param name The material name
  53791. * @param scene The scene the material will be use in.
  53792. */
  53793. constructor(name: string, scene: Scene);
  53794. /**
  53795. * Returns the name of this material class.
  53796. */
  53797. getClassName(): string;
  53798. /**
  53799. * Makes a duplicate of the current material.
  53800. * @param name - name to use for the new material.
  53801. */
  53802. clone(name: string): PBRMaterial;
  53803. /**
  53804. * Serializes this PBR Material.
  53805. * @returns - An object with the serialized material.
  53806. */
  53807. serialize(): any;
  53808. /**
  53809. * Parses a PBR Material from a serialized object.
  53810. * @param source - Serialized object.
  53811. * @param scene - BJS scene instance.
  53812. * @param rootUrl - url for the scene object
  53813. * @returns - PBRMaterial
  53814. */
  53815. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53816. }
  53817. }
  53818. declare module "babylonjs/Misc/dds" {
  53819. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53820. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53821. import { Nullable } from "babylonjs/types";
  53822. import { Scene } from "babylonjs/scene";
  53823. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53824. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53825. /**
  53826. * Direct draw surface info
  53827. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53828. */
  53829. export interface DDSInfo {
  53830. /**
  53831. * Width of the texture
  53832. */
  53833. width: number;
  53834. /**
  53835. * Width of the texture
  53836. */
  53837. height: number;
  53838. /**
  53839. * Number of Mipmaps for the texture
  53840. * @see https://en.wikipedia.org/wiki/Mipmap
  53841. */
  53842. mipmapCount: number;
  53843. /**
  53844. * If the textures format is a known fourCC format
  53845. * @see https://www.fourcc.org/
  53846. */
  53847. isFourCC: boolean;
  53848. /**
  53849. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53850. */
  53851. isRGB: boolean;
  53852. /**
  53853. * If the texture is a lumincance format
  53854. */
  53855. isLuminance: boolean;
  53856. /**
  53857. * If this is a cube texture
  53858. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53859. */
  53860. isCube: boolean;
  53861. /**
  53862. * If the texture is a compressed format eg. FOURCC_DXT1
  53863. */
  53864. isCompressed: boolean;
  53865. /**
  53866. * The dxgiFormat of the texture
  53867. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53868. */
  53869. dxgiFormat: number;
  53870. /**
  53871. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53872. */
  53873. textureType: number;
  53874. /**
  53875. * Sphericle polynomial created for the dds texture
  53876. */
  53877. sphericalPolynomial?: SphericalPolynomial;
  53878. }
  53879. /**
  53880. * Class used to provide DDS decompression tools
  53881. */
  53882. export class DDSTools {
  53883. /**
  53884. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53885. */
  53886. static StoreLODInAlphaChannel: boolean;
  53887. /**
  53888. * Gets DDS information from an array buffer
  53889. * @param arrayBuffer defines the array buffer to read data from
  53890. * @returns the DDS information
  53891. */
  53892. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53893. private static _FloatView;
  53894. private static _Int32View;
  53895. private static _ToHalfFloat;
  53896. private static _FromHalfFloat;
  53897. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53898. private static _GetHalfFloatRGBAArrayBuffer;
  53899. private static _GetFloatRGBAArrayBuffer;
  53900. private static _GetFloatAsUIntRGBAArrayBuffer;
  53901. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53902. private static _GetRGBAArrayBuffer;
  53903. private static _ExtractLongWordOrder;
  53904. private static _GetRGBArrayBuffer;
  53905. private static _GetLuminanceArrayBuffer;
  53906. /**
  53907. * Uploads DDS Levels to a Babylon Texture
  53908. * @hidden
  53909. */
  53910. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53911. }
  53912. module "babylonjs/Engines/thinEngine" {
  53913. interface ThinEngine {
  53914. /**
  53915. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53916. * @param rootUrl defines the url where the file to load is located
  53917. * @param scene defines the current scene
  53918. * @param lodScale defines scale to apply to the mip map selection
  53919. * @param lodOffset defines offset to apply to the mip map selection
  53920. * @param onLoad defines an optional callback raised when the texture is loaded
  53921. * @param onError defines an optional callback raised if there is an issue to load the texture
  53922. * @param format defines the format of the data
  53923. * @param forcedExtension defines the extension to use to pick the right loader
  53924. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53925. * @returns the cube texture as an InternalTexture
  53926. */
  53927. 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;
  53928. }
  53929. }
  53930. }
  53931. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53932. import { Nullable } from "babylonjs/types";
  53933. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53934. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53935. /**
  53936. * Implementation of the DDS Texture Loader.
  53937. * @hidden
  53938. */
  53939. export class _DDSTextureLoader implements IInternalTextureLoader {
  53940. /**
  53941. * Defines wether the loader supports cascade loading the different faces.
  53942. */
  53943. readonly supportCascades: boolean;
  53944. /**
  53945. * This returns if the loader support the current file information.
  53946. * @param extension defines the file extension of the file being loaded
  53947. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53948. * @param fallback defines the fallback internal texture if any
  53949. * @param isBase64 defines whether the texture is encoded as a base64
  53950. * @param isBuffer defines whether the texture data are stored as a buffer
  53951. * @returns true if the loader can load the specified file
  53952. */
  53953. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53954. /**
  53955. * Transform the url before loading if required.
  53956. * @param rootUrl the url of the texture
  53957. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53958. * @returns the transformed texture
  53959. */
  53960. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53961. /**
  53962. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53963. * @param rootUrl the url of the texture
  53964. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53965. * @returns the fallback texture
  53966. */
  53967. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53968. /**
  53969. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53970. * @param data contains the texture data
  53971. * @param texture defines the BabylonJS internal texture
  53972. * @param createPolynomials will be true if polynomials have been requested
  53973. * @param onLoad defines the callback to trigger once the texture is ready
  53974. * @param onError defines the callback to trigger in case of error
  53975. */
  53976. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53977. /**
  53978. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53979. * @param data contains the texture data
  53980. * @param texture defines the BabylonJS internal texture
  53981. * @param callback defines the method to call once ready to upload
  53982. */
  53983. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53984. }
  53985. }
  53986. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53987. import { Nullable } from "babylonjs/types";
  53988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53989. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53990. /**
  53991. * Implementation of the ENV Texture Loader.
  53992. * @hidden
  53993. */
  53994. export class _ENVTextureLoader implements IInternalTextureLoader {
  53995. /**
  53996. * Defines wether the loader supports cascade loading the different faces.
  53997. */
  53998. readonly supportCascades: boolean;
  53999. /**
  54000. * This returns if the loader support the current file information.
  54001. * @param extension defines the file extension of the file being loaded
  54002. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54003. * @param fallback defines the fallback internal texture if any
  54004. * @param isBase64 defines whether the texture is encoded as a base64
  54005. * @param isBuffer defines whether the texture data are stored as a buffer
  54006. * @returns true if the loader can load the specified file
  54007. */
  54008. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54009. /**
  54010. * Transform the url before loading if required.
  54011. * @param rootUrl the url of the texture
  54012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54013. * @returns the transformed texture
  54014. */
  54015. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54016. /**
  54017. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54018. * @param rootUrl the url of the texture
  54019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54020. * @returns the fallback texture
  54021. */
  54022. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54023. /**
  54024. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54025. * @param data contains the texture data
  54026. * @param texture defines the BabylonJS internal texture
  54027. * @param createPolynomials will be true if polynomials have been requested
  54028. * @param onLoad defines the callback to trigger once the texture is ready
  54029. * @param onError defines the callback to trigger in case of error
  54030. */
  54031. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54032. /**
  54033. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54034. * @param data contains the texture data
  54035. * @param texture defines the BabylonJS internal texture
  54036. * @param callback defines the method to call once ready to upload
  54037. */
  54038. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54039. }
  54040. }
  54041. declare module "babylonjs/Misc/khronosTextureContainer" {
  54042. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54043. /**
  54044. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54045. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54046. */
  54047. export class KhronosTextureContainer {
  54048. /** contents of the KTX container file */
  54049. arrayBuffer: any;
  54050. private static HEADER_LEN;
  54051. private static COMPRESSED_2D;
  54052. private static COMPRESSED_3D;
  54053. private static TEX_2D;
  54054. private static TEX_3D;
  54055. /**
  54056. * Gets the openGL type
  54057. */
  54058. glType: number;
  54059. /**
  54060. * Gets the openGL type size
  54061. */
  54062. glTypeSize: number;
  54063. /**
  54064. * Gets the openGL format
  54065. */
  54066. glFormat: number;
  54067. /**
  54068. * Gets the openGL internal format
  54069. */
  54070. glInternalFormat: number;
  54071. /**
  54072. * Gets the base internal format
  54073. */
  54074. glBaseInternalFormat: number;
  54075. /**
  54076. * Gets image width in pixel
  54077. */
  54078. pixelWidth: number;
  54079. /**
  54080. * Gets image height in pixel
  54081. */
  54082. pixelHeight: number;
  54083. /**
  54084. * Gets image depth in pixels
  54085. */
  54086. pixelDepth: number;
  54087. /**
  54088. * Gets the number of array elements
  54089. */
  54090. numberOfArrayElements: number;
  54091. /**
  54092. * Gets the number of faces
  54093. */
  54094. numberOfFaces: number;
  54095. /**
  54096. * Gets the number of mipmap levels
  54097. */
  54098. numberOfMipmapLevels: number;
  54099. /**
  54100. * Gets the bytes of key value data
  54101. */
  54102. bytesOfKeyValueData: number;
  54103. /**
  54104. * Gets the load type
  54105. */
  54106. loadType: number;
  54107. /**
  54108. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54109. */
  54110. isInvalid: boolean;
  54111. /**
  54112. * Creates a new KhronosTextureContainer
  54113. * @param arrayBuffer contents of the KTX container file
  54114. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54115. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54116. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54117. */
  54118. constructor(
  54119. /** contents of the KTX container file */
  54120. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54121. /**
  54122. * Uploads KTX content to a Babylon Texture.
  54123. * It is assumed that the texture has already been created & is currently bound
  54124. * @hidden
  54125. */
  54126. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54127. private _upload2DCompressedLevels;
  54128. }
  54129. }
  54130. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54131. import { Nullable } from "babylonjs/types";
  54132. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54133. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54134. /**
  54135. * Implementation of the KTX Texture Loader.
  54136. * @hidden
  54137. */
  54138. export class _KTXTextureLoader implements IInternalTextureLoader {
  54139. /**
  54140. * Defines wether the loader supports cascade loading the different faces.
  54141. */
  54142. readonly supportCascades: boolean;
  54143. /**
  54144. * This returns if the loader support the current file information.
  54145. * @param extension defines the file extension of the file being loaded
  54146. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54147. * @param fallback defines the fallback internal texture if any
  54148. * @param isBase64 defines whether the texture is encoded as a base64
  54149. * @param isBuffer defines whether the texture data are stored as a buffer
  54150. * @returns true if the loader can load the specified file
  54151. */
  54152. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54153. /**
  54154. * Transform the url before loading if required.
  54155. * @param rootUrl the url of the texture
  54156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54157. * @returns the transformed texture
  54158. */
  54159. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54160. /**
  54161. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54162. * @param rootUrl the url of the texture
  54163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54164. * @returns the fallback texture
  54165. */
  54166. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54167. /**
  54168. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54169. * @param data contains the texture data
  54170. * @param texture defines the BabylonJS internal texture
  54171. * @param createPolynomials will be true if polynomials have been requested
  54172. * @param onLoad defines the callback to trigger once the texture is ready
  54173. * @param onError defines the callback to trigger in case of error
  54174. */
  54175. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54176. /**
  54177. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54178. * @param data contains the texture data
  54179. * @param texture defines the BabylonJS internal texture
  54180. * @param callback defines the method to call once ready to upload
  54181. */
  54182. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54183. }
  54184. }
  54185. declare module "babylonjs/Helpers/sceneHelpers" {
  54186. import { Nullable } from "babylonjs/types";
  54187. import { Mesh } from "babylonjs/Meshes/mesh";
  54188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54189. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54190. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54191. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54192. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54193. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54194. import "babylonjs/Meshes/Builders/boxBuilder";
  54195. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  54196. /** @hidden */
  54197. export var _forceSceneHelpersToBundle: boolean;
  54198. module "babylonjs/scene" {
  54199. interface Scene {
  54200. /**
  54201. * Creates a default light for the scene.
  54202. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54203. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54204. */
  54205. createDefaultLight(replace?: boolean): void;
  54206. /**
  54207. * Creates a default camera for the scene.
  54208. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54209. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54210. * @param replace has default false, when true replaces the active camera in the scene
  54211. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54212. */
  54213. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54214. /**
  54215. * Creates a default camera and a default light.
  54216. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54217. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54218. * @param replace has the default false, when true replaces the active camera/light in the scene
  54219. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54220. */
  54221. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54222. /**
  54223. * Creates a new sky box
  54224. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54225. * @param environmentTexture defines the texture to use as environment texture
  54226. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54227. * @param scale defines the overall scale of the skybox
  54228. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54229. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54230. * @returns a new mesh holding the sky box
  54231. */
  54232. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54233. /**
  54234. * Creates a new environment
  54235. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54236. * @param options defines the options you can use to configure the environment
  54237. * @returns the new EnvironmentHelper
  54238. */
  54239. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54240. /**
  54241. * Creates a new VREXperienceHelper
  54242. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54243. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54244. * @returns a new VREXperienceHelper
  54245. */
  54246. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54247. /**
  54248. * Creates a new WebXRDefaultExperience
  54249. * @see http://doc.babylonjs.com/how_to/webxr
  54250. * @param options experience options
  54251. * @returns a promise for a new WebXRDefaultExperience
  54252. */
  54253. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54254. }
  54255. }
  54256. }
  54257. declare module "babylonjs/Helpers/videoDome" {
  54258. import { Scene } from "babylonjs/scene";
  54259. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54260. import { Mesh } from "babylonjs/Meshes/mesh";
  54261. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54262. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54263. import "babylonjs/Meshes/Builders/sphereBuilder";
  54264. /**
  54265. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54266. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54267. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54268. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54269. */
  54270. export class VideoDome extends TransformNode {
  54271. /**
  54272. * Define the video source as a Monoscopic panoramic 360 video.
  54273. */
  54274. static readonly MODE_MONOSCOPIC: number;
  54275. /**
  54276. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54277. */
  54278. static readonly MODE_TOPBOTTOM: number;
  54279. /**
  54280. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54281. */
  54282. static readonly MODE_SIDEBYSIDE: number;
  54283. private _halfDome;
  54284. private _useDirectMapping;
  54285. /**
  54286. * The video texture being displayed on the sphere
  54287. */
  54288. protected _videoTexture: VideoTexture;
  54289. /**
  54290. * Gets the video texture being displayed on the sphere
  54291. */
  54292. get videoTexture(): VideoTexture;
  54293. /**
  54294. * The skybox material
  54295. */
  54296. protected _material: BackgroundMaterial;
  54297. /**
  54298. * The surface used for the skybox
  54299. */
  54300. protected _mesh: Mesh;
  54301. /**
  54302. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54303. */
  54304. private _halfDomeMask;
  54305. /**
  54306. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54307. * Also see the options.resolution property.
  54308. */
  54309. get fovMultiplier(): number;
  54310. set fovMultiplier(value: number);
  54311. private _videoMode;
  54312. /**
  54313. * Gets or set the current video mode for the video. It can be:
  54314. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54315. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54316. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54317. */
  54318. get videoMode(): number;
  54319. set videoMode(value: number);
  54320. /**
  54321. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54322. *
  54323. */
  54324. get halfDome(): boolean;
  54325. /**
  54326. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54327. */
  54328. set halfDome(enabled: boolean);
  54329. /**
  54330. * Oberserver used in Stereoscopic VR Mode.
  54331. */
  54332. private _onBeforeCameraRenderObserver;
  54333. /**
  54334. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54335. * @param name Element's name, child elements will append suffixes for their own names.
  54336. * @param urlsOrVideo defines the url(s) or the video element to use
  54337. * @param options An object containing optional or exposed sub element properties
  54338. */
  54339. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54340. resolution?: number;
  54341. clickToPlay?: boolean;
  54342. autoPlay?: boolean;
  54343. loop?: boolean;
  54344. size?: number;
  54345. poster?: string;
  54346. faceForward?: boolean;
  54347. useDirectMapping?: boolean;
  54348. halfDomeMode?: boolean;
  54349. }, scene: Scene);
  54350. private _changeVideoMode;
  54351. /**
  54352. * Releases resources associated with this node.
  54353. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54354. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54355. */
  54356. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54357. }
  54358. }
  54359. declare module "babylonjs/Helpers/index" {
  54360. export * from "babylonjs/Helpers/environmentHelper";
  54361. export * from "babylonjs/Helpers/photoDome";
  54362. export * from "babylonjs/Helpers/sceneHelpers";
  54363. export * from "babylonjs/Helpers/videoDome";
  54364. }
  54365. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54366. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54367. import { IDisposable } from "babylonjs/scene";
  54368. import { Engine } from "babylonjs/Engines/engine";
  54369. /**
  54370. * This class can be used to get instrumentation data from a Babylon engine
  54371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54372. */
  54373. export class EngineInstrumentation implements IDisposable {
  54374. /**
  54375. * Define the instrumented engine.
  54376. */
  54377. engine: Engine;
  54378. private _captureGPUFrameTime;
  54379. private _gpuFrameTimeToken;
  54380. private _gpuFrameTime;
  54381. private _captureShaderCompilationTime;
  54382. private _shaderCompilationTime;
  54383. private _onBeginFrameObserver;
  54384. private _onEndFrameObserver;
  54385. private _onBeforeShaderCompilationObserver;
  54386. private _onAfterShaderCompilationObserver;
  54387. /**
  54388. * Gets the perf counter used for GPU frame time
  54389. */
  54390. get gpuFrameTimeCounter(): PerfCounter;
  54391. /**
  54392. * Gets the GPU frame time capture status
  54393. */
  54394. get captureGPUFrameTime(): boolean;
  54395. /**
  54396. * Enable or disable the GPU frame time capture
  54397. */
  54398. set captureGPUFrameTime(value: boolean);
  54399. /**
  54400. * Gets the perf counter used for shader compilation time
  54401. */
  54402. get shaderCompilationTimeCounter(): PerfCounter;
  54403. /**
  54404. * Gets the shader compilation time capture status
  54405. */
  54406. get captureShaderCompilationTime(): boolean;
  54407. /**
  54408. * Enable or disable the shader compilation time capture
  54409. */
  54410. set captureShaderCompilationTime(value: boolean);
  54411. /**
  54412. * Instantiates a new engine instrumentation.
  54413. * This class can be used to get instrumentation data from a Babylon engine
  54414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54415. * @param engine Defines the engine to instrument
  54416. */
  54417. constructor(
  54418. /**
  54419. * Define the instrumented engine.
  54420. */
  54421. engine: Engine);
  54422. /**
  54423. * Dispose and release associated resources.
  54424. */
  54425. dispose(): void;
  54426. }
  54427. }
  54428. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54429. import { Scene, IDisposable } from "babylonjs/scene";
  54430. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54431. /**
  54432. * This class can be used to get instrumentation data from a Babylon engine
  54433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54434. */
  54435. export class SceneInstrumentation implements IDisposable {
  54436. /**
  54437. * Defines the scene to instrument
  54438. */
  54439. scene: Scene;
  54440. private _captureActiveMeshesEvaluationTime;
  54441. private _activeMeshesEvaluationTime;
  54442. private _captureRenderTargetsRenderTime;
  54443. private _renderTargetsRenderTime;
  54444. private _captureFrameTime;
  54445. private _frameTime;
  54446. private _captureRenderTime;
  54447. private _renderTime;
  54448. private _captureInterFrameTime;
  54449. private _interFrameTime;
  54450. private _captureParticlesRenderTime;
  54451. private _particlesRenderTime;
  54452. private _captureSpritesRenderTime;
  54453. private _spritesRenderTime;
  54454. private _capturePhysicsTime;
  54455. private _physicsTime;
  54456. private _captureAnimationsTime;
  54457. private _animationsTime;
  54458. private _captureCameraRenderTime;
  54459. private _cameraRenderTime;
  54460. private _onBeforeActiveMeshesEvaluationObserver;
  54461. private _onAfterActiveMeshesEvaluationObserver;
  54462. private _onBeforeRenderTargetsRenderObserver;
  54463. private _onAfterRenderTargetsRenderObserver;
  54464. private _onAfterRenderObserver;
  54465. private _onBeforeDrawPhaseObserver;
  54466. private _onAfterDrawPhaseObserver;
  54467. private _onBeforeAnimationsObserver;
  54468. private _onBeforeParticlesRenderingObserver;
  54469. private _onAfterParticlesRenderingObserver;
  54470. private _onBeforeSpritesRenderingObserver;
  54471. private _onAfterSpritesRenderingObserver;
  54472. private _onBeforePhysicsObserver;
  54473. private _onAfterPhysicsObserver;
  54474. private _onAfterAnimationsObserver;
  54475. private _onBeforeCameraRenderObserver;
  54476. private _onAfterCameraRenderObserver;
  54477. /**
  54478. * Gets the perf counter used for active meshes evaluation time
  54479. */
  54480. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54481. /**
  54482. * Gets the active meshes evaluation time capture status
  54483. */
  54484. get captureActiveMeshesEvaluationTime(): boolean;
  54485. /**
  54486. * Enable or disable the active meshes evaluation time capture
  54487. */
  54488. set captureActiveMeshesEvaluationTime(value: boolean);
  54489. /**
  54490. * Gets the perf counter used for render targets render time
  54491. */
  54492. get renderTargetsRenderTimeCounter(): PerfCounter;
  54493. /**
  54494. * Gets the render targets render time capture status
  54495. */
  54496. get captureRenderTargetsRenderTime(): boolean;
  54497. /**
  54498. * Enable or disable the render targets render time capture
  54499. */
  54500. set captureRenderTargetsRenderTime(value: boolean);
  54501. /**
  54502. * Gets the perf counter used for particles render time
  54503. */
  54504. get particlesRenderTimeCounter(): PerfCounter;
  54505. /**
  54506. * Gets the particles render time capture status
  54507. */
  54508. get captureParticlesRenderTime(): boolean;
  54509. /**
  54510. * Enable or disable the particles render time capture
  54511. */
  54512. set captureParticlesRenderTime(value: boolean);
  54513. /**
  54514. * Gets the perf counter used for sprites render time
  54515. */
  54516. get spritesRenderTimeCounter(): PerfCounter;
  54517. /**
  54518. * Gets the sprites render time capture status
  54519. */
  54520. get captureSpritesRenderTime(): boolean;
  54521. /**
  54522. * Enable or disable the sprites render time capture
  54523. */
  54524. set captureSpritesRenderTime(value: boolean);
  54525. /**
  54526. * Gets the perf counter used for physics time
  54527. */
  54528. get physicsTimeCounter(): PerfCounter;
  54529. /**
  54530. * Gets the physics time capture status
  54531. */
  54532. get capturePhysicsTime(): boolean;
  54533. /**
  54534. * Enable or disable the physics time capture
  54535. */
  54536. set capturePhysicsTime(value: boolean);
  54537. /**
  54538. * Gets the perf counter used for animations time
  54539. */
  54540. get animationsTimeCounter(): PerfCounter;
  54541. /**
  54542. * Gets the animations time capture status
  54543. */
  54544. get captureAnimationsTime(): boolean;
  54545. /**
  54546. * Enable or disable the animations time capture
  54547. */
  54548. set captureAnimationsTime(value: boolean);
  54549. /**
  54550. * Gets the perf counter used for frame time capture
  54551. */
  54552. get frameTimeCounter(): PerfCounter;
  54553. /**
  54554. * Gets the frame time capture status
  54555. */
  54556. get captureFrameTime(): boolean;
  54557. /**
  54558. * Enable or disable the frame time capture
  54559. */
  54560. set captureFrameTime(value: boolean);
  54561. /**
  54562. * Gets the perf counter used for inter-frames time capture
  54563. */
  54564. get interFrameTimeCounter(): PerfCounter;
  54565. /**
  54566. * Gets the inter-frames time capture status
  54567. */
  54568. get captureInterFrameTime(): boolean;
  54569. /**
  54570. * Enable or disable the inter-frames time capture
  54571. */
  54572. set captureInterFrameTime(value: boolean);
  54573. /**
  54574. * Gets the perf counter used for render time capture
  54575. */
  54576. get renderTimeCounter(): PerfCounter;
  54577. /**
  54578. * Gets the render time capture status
  54579. */
  54580. get captureRenderTime(): boolean;
  54581. /**
  54582. * Enable or disable the render time capture
  54583. */
  54584. set captureRenderTime(value: boolean);
  54585. /**
  54586. * Gets the perf counter used for camera render time capture
  54587. */
  54588. get cameraRenderTimeCounter(): PerfCounter;
  54589. /**
  54590. * Gets the camera render time capture status
  54591. */
  54592. get captureCameraRenderTime(): boolean;
  54593. /**
  54594. * Enable or disable the camera render time capture
  54595. */
  54596. set captureCameraRenderTime(value: boolean);
  54597. /**
  54598. * Gets the perf counter used for draw calls
  54599. */
  54600. get drawCallsCounter(): PerfCounter;
  54601. /**
  54602. * Instantiates a new scene instrumentation.
  54603. * This class can be used to get instrumentation data from a Babylon engine
  54604. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54605. * @param scene Defines the scene to instrument
  54606. */
  54607. constructor(
  54608. /**
  54609. * Defines the scene to instrument
  54610. */
  54611. scene: Scene);
  54612. /**
  54613. * Dispose and release associated resources.
  54614. */
  54615. dispose(): void;
  54616. }
  54617. }
  54618. declare module "babylonjs/Instrumentation/index" {
  54619. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54620. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54621. export * from "babylonjs/Instrumentation/timeToken";
  54622. }
  54623. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54624. /** @hidden */
  54625. export var glowMapGenerationPixelShader: {
  54626. name: string;
  54627. shader: string;
  54628. };
  54629. }
  54630. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54631. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54632. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54633. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54634. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54635. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54636. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54637. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54638. /** @hidden */
  54639. export var glowMapGenerationVertexShader: {
  54640. name: string;
  54641. shader: string;
  54642. };
  54643. }
  54644. declare module "babylonjs/Layers/effectLayer" {
  54645. import { Observable } from "babylonjs/Misc/observable";
  54646. import { Nullable } from "babylonjs/types";
  54647. import { Camera } from "babylonjs/Cameras/camera";
  54648. import { Scene } from "babylonjs/scene";
  54649. import { ISize } from "babylonjs/Maths/math.size";
  54650. import { Color4 } from "babylonjs/Maths/math.color";
  54651. import { Engine } from "babylonjs/Engines/engine";
  54652. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54654. import { Mesh } from "babylonjs/Meshes/mesh";
  54655. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54657. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54658. import { Effect } from "babylonjs/Materials/effect";
  54659. import { Material } from "babylonjs/Materials/material";
  54660. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54661. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54662. /**
  54663. * Effect layer options. This helps customizing the behaviour
  54664. * of the effect layer.
  54665. */
  54666. export interface IEffectLayerOptions {
  54667. /**
  54668. * Multiplication factor apply to the canvas size to compute the render target size
  54669. * used to generated the objects (the smaller the faster).
  54670. */
  54671. mainTextureRatio: number;
  54672. /**
  54673. * Enforces a fixed size texture to ensure effect stability across devices.
  54674. */
  54675. mainTextureFixedSize?: number;
  54676. /**
  54677. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54678. */
  54679. alphaBlendingMode: number;
  54680. /**
  54681. * The camera attached to the layer.
  54682. */
  54683. camera: Nullable<Camera>;
  54684. /**
  54685. * The rendering group to draw the layer in.
  54686. */
  54687. renderingGroupId: number;
  54688. }
  54689. /**
  54690. * The effect layer Helps adding post process effect blended with the main pass.
  54691. *
  54692. * This can be for instance use to generate glow or higlight effects on the scene.
  54693. *
  54694. * The effect layer class can not be used directly and is intented to inherited from to be
  54695. * customized per effects.
  54696. */
  54697. export abstract class EffectLayer {
  54698. private _vertexBuffers;
  54699. private _indexBuffer;
  54700. private _cachedDefines;
  54701. private _effectLayerMapGenerationEffect;
  54702. private _effectLayerOptions;
  54703. private _mergeEffect;
  54704. protected _scene: Scene;
  54705. protected _engine: Engine;
  54706. protected _maxSize: number;
  54707. protected _mainTextureDesiredSize: ISize;
  54708. protected _mainTexture: RenderTargetTexture;
  54709. protected _shouldRender: boolean;
  54710. protected _postProcesses: PostProcess[];
  54711. protected _textures: BaseTexture[];
  54712. protected _emissiveTextureAndColor: {
  54713. texture: Nullable<BaseTexture>;
  54714. color: Color4;
  54715. };
  54716. /**
  54717. * The name of the layer
  54718. */
  54719. name: string;
  54720. /**
  54721. * The clear color of the texture used to generate the glow map.
  54722. */
  54723. neutralColor: Color4;
  54724. /**
  54725. * Specifies wether the highlight layer is enabled or not.
  54726. */
  54727. isEnabled: boolean;
  54728. /**
  54729. * Gets the camera attached to the layer.
  54730. */
  54731. get camera(): Nullable<Camera>;
  54732. /**
  54733. * Gets the rendering group id the layer should render in.
  54734. */
  54735. get renderingGroupId(): number;
  54736. set renderingGroupId(renderingGroupId: number);
  54737. /**
  54738. * An event triggered when the effect layer has been disposed.
  54739. */
  54740. onDisposeObservable: Observable<EffectLayer>;
  54741. /**
  54742. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54743. */
  54744. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54745. /**
  54746. * An event triggered when the generated texture is being merged in the scene.
  54747. */
  54748. onBeforeComposeObservable: Observable<EffectLayer>;
  54749. /**
  54750. * An event triggered when the mesh is rendered into the effect render target.
  54751. */
  54752. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54753. /**
  54754. * An event triggered after the mesh has been rendered into the effect render target.
  54755. */
  54756. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54757. /**
  54758. * An event triggered when the generated texture has been merged in the scene.
  54759. */
  54760. onAfterComposeObservable: Observable<EffectLayer>;
  54761. /**
  54762. * An event triggered when the efffect layer changes its size.
  54763. */
  54764. onSizeChangedObservable: Observable<EffectLayer>;
  54765. /** @hidden */
  54766. static _SceneComponentInitialization: (scene: Scene) => void;
  54767. /**
  54768. * Instantiates a new effect Layer and references it in the scene.
  54769. * @param name The name of the layer
  54770. * @param scene The scene to use the layer in
  54771. */
  54772. constructor(
  54773. /** The Friendly of the effect in the scene */
  54774. name: string, scene: Scene);
  54775. /**
  54776. * Get the effect name of the layer.
  54777. * @return The effect name
  54778. */
  54779. abstract getEffectName(): string;
  54780. /**
  54781. * Checks for the readiness of the element composing the layer.
  54782. * @param subMesh the mesh to check for
  54783. * @param useInstances specify wether or not to use instances to render the mesh
  54784. * @return true if ready otherwise, false
  54785. */
  54786. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54787. /**
  54788. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54789. * @returns true if the effect requires stencil during the main canvas render pass.
  54790. */
  54791. abstract needStencil(): boolean;
  54792. /**
  54793. * Create the merge effect. This is the shader use to blit the information back
  54794. * to the main canvas at the end of the scene rendering.
  54795. * @returns The effect containing the shader used to merge the effect on the main canvas
  54796. */
  54797. protected abstract _createMergeEffect(): Effect;
  54798. /**
  54799. * Creates the render target textures and post processes used in the effect layer.
  54800. */
  54801. protected abstract _createTextureAndPostProcesses(): void;
  54802. /**
  54803. * Implementation specific of rendering the generating effect on the main canvas.
  54804. * @param effect The effect used to render through
  54805. */
  54806. protected abstract _internalRender(effect: Effect): void;
  54807. /**
  54808. * Sets the required values for both the emissive texture and and the main color.
  54809. */
  54810. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54811. /**
  54812. * Free any resources and references associated to a mesh.
  54813. * Internal use
  54814. * @param mesh The mesh to free.
  54815. */
  54816. abstract _disposeMesh(mesh: Mesh): void;
  54817. /**
  54818. * Serializes this layer (Glow or Highlight for example)
  54819. * @returns a serialized layer object
  54820. */
  54821. abstract serialize?(): any;
  54822. /**
  54823. * Initializes the effect layer with the required options.
  54824. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54825. */
  54826. protected _init(options: Partial<IEffectLayerOptions>): void;
  54827. /**
  54828. * Generates the index buffer of the full screen quad blending to the main canvas.
  54829. */
  54830. private _generateIndexBuffer;
  54831. /**
  54832. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54833. */
  54834. private _generateVertexBuffer;
  54835. /**
  54836. * Sets the main texture desired size which is the closest power of two
  54837. * of the engine canvas size.
  54838. */
  54839. private _setMainTextureSize;
  54840. /**
  54841. * Creates the main texture for the effect layer.
  54842. */
  54843. protected _createMainTexture(): void;
  54844. /**
  54845. * Adds specific effects defines.
  54846. * @param defines The defines to add specifics to.
  54847. */
  54848. protected _addCustomEffectDefines(defines: string[]): void;
  54849. /**
  54850. * Checks for the readiness of the element composing the layer.
  54851. * @param subMesh the mesh to check for
  54852. * @param useInstances specify wether or not to use instances to render the mesh
  54853. * @param emissiveTexture the associated emissive texture used to generate the glow
  54854. * @return true if ready otherwise, false
  54855. */
  54856. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54857. /**
  54858. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54859. */
  54860. render(): void;
  54861. /**
  54862. * Determine if a given mesh will be used in the current effect.
  54863. * @param mesh mesh to test
  54864. * @returns true if the mesh will be used
  54865. */
  54866. hasMesh(mesh: AbstractMesh): boolean;
  54867. /**
  54868. * Returns true if the layer contains information to display, otherwise false.
  54869. * @returns true if the glow layer should be rendered
  54870. */
  54871. shouldRender(): boolean;
  54872. /**
  54873. * Returns true if the mesh should render, otherwise false.
  54874. * @param mesh The mesh to render
  54875. * @returns true if it should render otherwise false
  54876. */
  54877. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54878. /**
  54879. * Returns true if the mesh can be rendered, otherwise false.
  54880. * @param mesh The mesh to render
  54881. * @param material The material used on the mesh
  54882. * @returns true if it can be rendered otherwise false
  54883. */
  54884. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54885. /**
  54886. * Returns true if the mesh should render, otherwise false.
  54887. * @param mesh The mesh to render
  54888. * @returns true if it should render otherwise false
  54889. */
  54890. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54891. /**
  54892. * Renders the submesh passed in parameter to the generation map.
  54893. */
  54894. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54895. /**
  54896. * Defines wether the current material of the mesh should be use to render the effect.
  54897. * @param mesh defines the current mesh to render
  54898. */
  54899. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54900. /**
  54901. * Rebuild the required buffers.
  54902. * @hidden Internal use only.
  54903. */
  54904. _rebuild(): void;
  54905. /**
  54906. * Dispose only the render target textures and post process.
  54907. */
  54908. private _disposeTextureAndPostProcesses;
  54909. /**
  54910. * Dispose the highlight layer and free resources.
  54911. */
  54912. dispose(): void;
  54913. /**
  54914. * Gets the class name of the effect layer
  54915. * @returns the string with the class name of the effect layer
  54916. */
  54917. getClassName(): string;
  54918. /**
  54919. * Creates an effect layer from parsed effect layer data
  54920. * @param parsedEffectLayer defines effect layer data
  54921. * @param scene defines the current scene
  54922. * @param rootUrl defines the root URL containing the effect layer information
  54923. * @returns a parsed effect Layer
  54924. */
  54925. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54926. }
  54927. }
  54928. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54929. import { Scene } from "babylonjs/scene";
  54930. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54931. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54932. import { AbstractScene } from "babylonjs/abstractScene";
  54933. module "babylonjs/abstractScene" {
  54934. interface AbstractScene {
  54935. /**
  54936. * The list of effect layers (highlights/glow) added to the scene
  54937. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54938. * @see http://doc.babylonjs.com/how_to/glow_layer
  54939. */
  54940. effectLayers: Array<EffectLayer>;
  54941. /**
  54942. * Removes the given effect layer from this scene.
  54943. * @param toRemove defines the effect layer to remove
  54944. * @returns the index of the removed effect layer
  54945. */
  54946. removeEffectLayer(toRemove: EffectLayer): number;
  54947. /**
  54948. * Adds the given effect layer to this scene
  54949. * @param newEffectLayer defines the effect layer to add
  54950. */
  54951. addEffectLayer(newEffectLayer: EffectLayer): void;
  54952. }
  54953. }
  54954. /**
  54955. * Defines the layer scene component responsible to manage any effect layers
  54956. * in a given scene.
  54957. */
  54958. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54959. /**
  54960. * The component name helpfull to identify the component in the list of scene components.
  54961. */
  54962. readonly name: string;
  54963. /**
  54964. * The scene the component belongs to.
  54965. */
  54966. scene: Scene;
  54967. private _engine;
  54968. private _renderEffects;
  54969. private _needStencil;
  54970. private _previousStencilState;
  54971. /**
  54972. * Creates a new instance of the component for the given scene
  54973. * @param scene Defines the scene to register the component in
  54974. */
  54975. constructor(scene: Scene);
  54976. /**
  54977. * Registers the component in a given scene
  54978. */
  54979. register(): void;
  54980. /**
  54981. * Rebuilds the elements related to this component in case of
  54982. * context lost for instance.
  54983. */
  54984. rebuild(): void;
  54985. /**
  54986. * Serializes the component data to the specified json object
  54987. * @param serializationObject The object to serialize to
  54988. */
  54989. serialize(serializationObject: any): void;
  54990. /**
  54991. * Adds all the elements from the container to the scene
  54992. * @param container the container holding the elements
  54993. */
  54994. addFromContainer(container: AbstractScene): void;
  54995. /**
  54996. * Removes all the elements in the container from the scene
  54997. * @param container contains the elements to remove
  54998. * @param dispose if the removed element should be disposed (default: false)
  54999. */
  55000. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55001. /**
  55002. * Disposes the component and the associated ressources.
  55003. */
  55004. dispose(): void;
  55005. private _isReadyForMesh;
  55006. private _renderMainTexture;
  55007. private _setStencil;
  55008. private _setStencilBack;
  55009. private _draw;
  55010. private _drawCamera;
  55011. private _drawRenderingGroup;
  55012. }
  55013. }
  55014. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55015. /** @hidden */
  55016. export var glowMapMergePixelShader: {
  55017. name: string;
  55018. shader: string;
  55019. };
  55020. }
  55021. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55022. /** @hidden */
  55023. export var glowMapMergeVertexShader: {
  55024. name: string;
  55025. shader: string;
  55026. };
  55027. }
  55028. declare module "babylonjs/Layers/glowLayer" {
  55029. import { Nullable } from "babylonjs/types";
  55030. import { Camera } from "babylonjs/Cameras/camera";
  55031. import { Scene } from "babylonjs/scene";
  55032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55034. import { Mesh } from "babylonjs/Meshes/mesh";
  55035. import { Texture } from "babylonjs/Materials/Textures/texture";
  55036. import { Effect } from "babylonjs/Materials/effect";
  55037. import { Material } from "babylonjs/Materials/material";
  55038. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55039. import { Color4 } from "babylonjs/Maths/math.color";
  55040. import "babylonjs/Shaders/glowMapMerge.fragment";
  55041. import "babylonjs/Shaders/glowMapMerge.vertex";
  55042. import "babylonjs/Layers/effectLayerSceneComponent";
  55043. module "babylonjs/abstractScene" {
  55044. interface AbstractScene {
  55045. /**
  55046. * Return a the first highlight layer of the scene with a given name.
  55047. * @param name The name of the highlight layer to look for.
  55048. * @return The highlight layer if found otherwise null.
  55049. */
  55050. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55051. }
  55052. }
  55053. /**
  55054. * Glow layer options. This helps customizing the behaviour
  55055. * of the glow layer.
  55056. */
  55057. export interface IGlowLayerOptions {
  55058. /**
  55059. * Multiplication factor apply to the canvas size to compute the render target size
  55060. * used to generated the glowing objects (the smaller the faster).
  55061. */
  55062. mainTextureRatio: number;
  55063. /**
  55064. * Enforces a fixed size texture to ensure resize independant blur.
  55065. */
  55066. mainTextureFixedSize?: number;
  55067. /**
  55068. * How big is the kernel of the blur texture.
  55069. */
  55070. blurKernelSize: number;
  55071. /**
  55072. * The camera attached to the layer.
  55073. */
  55074. camera: Nullable<Camera>;
  55075. /**
  55076. * Enable MSAA by chosing the number of samples.
  55077. */
  55078. mainTextureSamples?: number;
  55079. /**
  55080. * The rendering group to draw the layer in.
  55081. */
  55082. renderingGroupId: number;
  55083. }
  55084. /**
  55085. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55086. *
  55087. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55088. *
  55089. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55090. */
  55091. export class GlowLayer extends EffectLayer {
  55092. /**
  55093. * Effect Name of the layer.
  55094. */
  55095. static readonly EffectName: string;
  55096. /**
  55097. * The default blur kernel size used for the glow.
  55098. */
  55099. static DefaultBlurKernelSize: number;
  55100. /**
  55101. * The default texture size ratio used for the glow.
  55102. */
  55103. static DefaultTextureRatio: number;
  55104. /**
  55105. * Sets the kernel size of the blur.
  55106. */
  55107. set blurKernelSize(value: number);
  55108. /**
  55109. * Gets the kernel size of the blur.
  55110. */
  55111. get blurKernelSize(): number;
  55112. /**
  55113. * Sets the glow intensity.
  55114. */
  55115. set intensity(value: number);
  55116. /**
  55117. * Gets the glow intensity.
  55118. */
  55119. get intensity(): number;
  55120. private _options;
  55121. private _intensity;
  55122. private _horizontalBlurPostprocess1;
  55123. private _verticalBlurPostprocess1;
  55124. private _horizontalBlurPostprocess2;
  55125. private _verticalBlurPostprocess2;
  55126. private _blurTexture1;
  55127. private _blurTexture2;
  55128. private _postProcesses1;
  55129. private _postProcesses2;
  55130. private _includedOnlyMeshes;
  55131. private _excludedMeshes;
  55132. private _meshesUsingTheirOwnMaterials;
  55133. /**
  55134. * Callback used to let the user override the color selection on a per mesh basis
  55135. */
  55136. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55137. /**
  55138. * Callback used to let the user override the texture selection on a per mesh basis
  55139. */
  55140. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55141. /**
  55142. * Instantiates a new glow Layer and references it to the scene.
  55143. * @param name The name of the layer
  55144. * @param scene The scene to use the layer in
  55145. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55146. */
  55147. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55148. /**
  55149. * Get the effect name of the layer.
  55150. * @return The effect name
  55151. */
  55152. getEffectName(): string;
  55153. /**
  55154. * Create the merge effect. This is the shader use to blit the information back
  55155. * to the main canvas at the end of the scene rendering.
  55156. */
  55157. protected _createMergeEffect(): Effect;
  55158. /**
  55159. * Creates the render target textures and post processes used in the glow layer.
  55160. */
  55161. protected _createTextureAndPostProcesses(): void;
  55162. /**
  55163. * Checks for the readiness of the element composing the layer.
  55164. * @param subMesh the mesh to check for
  55165. * @param useInstances specify wether or not to use instances to render the mesh
  55166. * @param emissiveTexture the associated emissive texture used to generate the glow
  55167. * @return true if ready otherwise, false
  55168. */
  55169. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55170. /**
  55171. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55172. */
  55173. needStencil(): boolean;
  55174. /**
  55175. * Returns true if the mesh can be rendered, otherwise false.
  55176. * @param mesh The mesh to render
  55177. * @param material The material used on the mesh
  55178. * @returns true if it can be rendered otherwise false
  55179. */
  55180. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55181. /**
  55182. * Implementation specific of rendering the generating effect on the main canvas.
  55183. * @param effect The effect used to render through
  55184. */
  55185. protected _internalRender(effect: Effect): void;
  55186. /**
  55187. * Sets the required values for both the emissive texture and and the main color.
  55188. */
  55189. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55190. /**
  55191. * Returns true if the mesh should render, otherwise false.
  55192. * @param mesh The mesh to render
  55193. * @returns true if it should render otherwise false
  55194. */
  55195. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55196. /**
  55197. * Adds specific effects defines.
  55198. * @param defines The defines to add specifics to.
  55199. */
  55200. protected _addCustomEffectDefines(defines: string[]): void;
  55201. /**
  55202. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55203. * @param mesh The mesh to exclude from the glow layer
  55204. */
  55205. addExcludedMesh(mesh: Mesh): void;
  55206. /**
  55207. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55208. * @param mesh The mesh to remove
  55209. */
  55210. removeExcludedMesh(mesh: Mesh): void;
  55211. /**
  55212. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55213. * @param mesh The mesh to include in the glow layer
  55214. */
  55215. addIncludedOnlyMesh(mesh: Mesh): void;
  55216. /**
  55217. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55218. * @param mesh The mesh to remove
  55219. */
  55220. removeIncludedOnlyMesh(mesh: Mesh): void;
  55221. /**
  55222. * Determine if a given mesh will be used in the glow layer
  55223. * @param mesh The mesh to test
  55224. * @returns true if the mesh will be highlighted by the current glow layer
  55225. */
  55226. hasMesh(mesh: AbstractMesh): boolean;
  55227. /**
  55228. * Defines wether the current material of the mesh should be use to render the effect.
  55229. * @param mesh defines the current mesh to render
  55230. */
  55231. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55232. /**
  55233. * Add a mesh to be rendered through its own material and not with emissive only.
  55234. * @param mesh The mesh for which we need to use its material
  55235. */
  55236. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55237. /**
  55238. * Remove a mesh from being rendered through its own material and not with emissive only.
  55239. * @param mesh The mesh for which we need to not use its material
  55240. */
  55241. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55242. /**
  55243. * Free any resources and references associated to a mesh.
  55244. * Internal use
  55245. * @param mesh The mesh to free.
  55246. * @hidden
  55247. */
  55248. _disposeMesh(mesh: Mesh): void;
  55249. /**
  55250. * Gets the class name of the effect layer
  55251. * @returns the string with the class name of the effect layer
  55252. */
  55253. getClassName(): string;
  55254. /**
  55255. * Serializes this glow layer
  55256. * @returns a serialized glow layer object
  55257. */
  55258. serialize(): any;
  55259. /**
  55260. * Creates a Glow Layer from parsed glow layer data
  55261. * @param parsedGlowLayer defines glow layer data
  55262. * @param scene defines the current scene
  55263. * @param rootUrl defines the root URL containing the glow layer information
  55264. * @returns a parsed Glow Layer
  55265. */
  55266. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55267. }
  55268. }
  55269. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55270. /** @hidden */
  55271. export var glowBlurPostProcessPixelShader: {
  55272. name: string;
  55273. shader: string;
  55274. };
  55275. }
  55276. declare module "babylonjs/Layers/highlightLayer" {
  55277. import { Observable } from "babylonjs/Misc/observable";
  55278. import { Nullable } from "babylonjs/types";
  55279. import { Camera } from "babylonjs/Cameras/camera";
  55280. import { Scene } from "babylonjs/scene";
  55281. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55283. import { Mesh } from "babylonjs/Meshes/mesh";
  55284. import { Effect } from "babylonjs/Materials/effect";
  55285. import { Material } from "babylonjs/Materials/material";
  55286. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55287. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55288. import "babylonjs/Shaders/glowMapMerge.fragment";
  55289. import "babylonjs/Shaders/glowMapMerge.vertex";
  55290. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55291. module "babylonjs/abstractScene" {
  55292. interface AbstractScene {
  55293. /**
  55294. * Return a the first highlight layer of the scene with a given name.
  55295. * @param name The name of the highlight layer to look for.
  55296. * @return The highlight layer if found otherwise null.
  55297. */
  55298. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55299. }
  55300. }
  55301. /**
  55302. * Highlight layer options. This helps customizing the behaviour
  55303. * of the highlight layer.
  55304. */
  55305. export interface IHighlightLayerOptions {
  55306. /**
  55307. * Multiplication factor apply to the canvas size to compute the render target size
  55308. * used to generated the glowing objects (the smaller the faster).
  55309. */
  55310. mainTextureRatio: number;
  55311. /**
  55312. * Enforces a fixed size texture to ensure resize independant blur.
  55313. */
  55314. mainTextureFixedSize?: number;
  55315. /**
  55316. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55317. * of the picture to blur (the smaller the faster).
  55318. */
  55319. blurTextureSizeRatio: number;
  55320. /**
  55321. * How big in texel of the blur texture is the vertical blur.
  55322. */
  55323. blurVerticalSize: number;
  55324. /**
  55325. * How big in texel of the blur texture is the horizontal blur.
  55326. */
  55327. blurHorizontalSize: number;
  55328. /**
  55329. * Alpha blending mode used to apply the blur. Default is combine.
  55330. */
  55331. alphaBlendingMode: number;
  55332. /**
  55333. * The camera attached to the layer.
  55334. */
  55335. camera: Nullable<Camera>;
  55336. /**
  55337. * Should we display highlight as a solid stroke?
  55338. */
  55339. isStroke?: boolean;
  55340. /**
  55341. * The rendering group to draw the layer in.
  55342. */
  55343. renderingGroupId: number;
  55344. }
  55345. /**
  55346. * The highlight layer Helps adding a glow effect around a mesh.
  55347. *
  55348. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55349. * glowy meshes to your scene.
  55350. *
  55351. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55352. */
  55353. export class HighlightLayer extends EffectLayer {
  55354. name: string;
  55355. /**
  55356. * Effect Name of the highlight layer.
  55357. */
  55358. static readonly EffectName: string;
  55359. /**
  55360. * The neutral color used during the preparation of the glow effect.
  55361. * This is black by default as the blend operation is a blend operation.
  55362. */
  55363. static NeutralColor: Color4;
  55364. /**
  55365. * Stencil value used for glowing meshes.
  55366. */
  55367. static GlowingMeshStencilReference: number;
  55368. /**
  55369. * Stencil value used for the other meshes in the scene.
  55370. */
  55371. static NormalMeshStencilReference: number;
  55372. /**
  55373. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55374. */
  55375. innerGlow: boolean;
  55376. /**
  55377. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55378. */
  55379. outerGlow: boolean;
  55380. /**
  55381. * Specifies the horizontal size of the blur.
  55382. */
  55383. set blurHorizontalSize(value: number);
  55384. /**
  55385. * Specifies the vertical size of the blur.
  55386. */
  55387. set blurVerticalSize(value: number);
  55388. /**
  55389. * Gets the horizontal size of the blur.
  55390. */
  55391. get blurHorizontalSize(): number;
  55392. /**
  55393. * Gets the vertical size of the blur.
  55394. */
  55395. get blurVerticalSize(): number;
  55396. /**
  55397. * An event triggered when the highlight layer is being blurred.
  55398. */
  55399. onBeforeBlurObservable: Observable<HighlightLayer>;
  55400. /**
  55401. * An event triggered when the highlight layer has been blurred.
  55402. */
  55403. onAfterBlurObservable: Observable<HighlightLayer>;
  55404. private _instanceGlowingMeshStencilReference;
  55405. private _options;
  55406. private _downSamplePostprocess;
  55407. private _horizontalBlurPostprocess;
  55408. private _verticalBlurPostprocess;
  55409. private _blurTexture;
  55410. private _meshes;
  55411. private _excludedMeshes;
  55412. /**
  55413. * Instantiates a new highlight Layer and references it to the scene..
  55414. * @param name The name of the layer
  55415. * @param scene The scene to use the layer in
  55416. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55417. */
  55418. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55419. /**
  55420. * Get the effect name of the layer.
  55421. * @return The effect name
  55422. */
  55423. getEffectName(): string;
  55424. /**
  55425. * Create the merge effect. This is the shader use to blit the information back
  55426. * to the main canvas at the end of the scene rendering.
  55427. */
  55428. protected _createMergeEffect(): Effect;
  55429. /**
  55430. * Creates the render target textures and post processes used in the highlight layer.
  55431. */
  55432. protected _createTextureAndPostProcesses(): void;
  55433. /**
  55434. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55435. */
  55436. needStencil(): boolean;
  55437. /**
  55438. * Checks for the readiness of the element composing the layer.
  55439. * @param subMesh the mesh to check for
  55440. * @param useInstances specify wether or not to use instances to render the mesh
  55441. * @param emissiveTexture the associated emissive texture used to generate the glow
  55442. * @return true if ready otherwise, false
  55443. */
  55444. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55445. /**
  55446. * Implementation specific of rendering the generating effect on the main canvas.
  55447. * @param effect The effect used to render through
  55448. */
  55449. protected _internalRender(effect: Effect): void;
  55450. /**
  55451. * Returns true if the layer contains information to display, otherwise false.
  55452. */
  55453. shouldRender(): boolean;
  55454. /**
  55455. * Returns true if the mesh should render, otherwise false.
  55456. * @param mesh The mesh to render
  55457. * @returns true if it should render otherwise false
  55458. */
  55459. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55460. /**
  55461. * Sets the required values for both the emissive texture and and the main color.
  55462. */
  55463. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55464. /**
  55465. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55466. * @param mesh The mesh to exclude from the highlight layer
  55467. */
  55468. addExcludedMesh(mesh: Mesh): void;
  55469. /**
  55470. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55471. * @param mesh The mesh to highlight
  55472. */
  55473. removeExcludedMesh(mesh: Mesh): void;
  55474. /**
  55475. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55476. * @param mesh mesh to test
  55477. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55478. */
  55479. hasMesh(mesh: AbstractMesh): boolean;
  55480. /**
  55481. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55482. * @param mesh The mesh to highlight
  55483. * @param color The color of the highlight
  55484. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55485. */
  55486. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55487. /**
  55488. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55489. * @param mesh The mesh to highlight
  55490. */
  55491. removeMesh(mesh: Mesh): void;
  55492. /**
  55493. * Force the stencil to the normal expected value for none glowing parts
  55494. */
  55495. private _defaultStencilReference;
  55496. /**
  55497. * Free any resources and references associated to a mesh.
  55498. * Internal use
  55499. * @param mesh The mesh to free.
  55500. * @hidden
  55501. */
  55502. _disposeMesh(mesh: Mesh): void;
  55503. /**
  55504. * Dispose the highlight layer and free resources.
  55505. */
  55506. dispose(): void;
  55507. /**
  55508. * Gets the class name of the effect layer
  55509. * @returns the string with the class name of the effect layer
  55510. */
  55511. getClassName(): string;
  55512. /**
  55513. * Serializes this Highlight layer
  55514. * @returns a serialized Highlight layer object
  55515. */
  55516. serialize(): any;
  55517. /**
  55518. * Creates a Highlight layer from parsed Highlight layer data
  55519. * @param parsedHightlightLayer defines the Highlight layer data
  55520. * @param scene defines the current scene
  55521. * @param rootUrl defines the root URL containing the Highlight layer information
  55522. * @returns a parsed Highlight layer
  55523. */
  55524. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55525. }
  55526. }
  55527. declare module "babylonjs/Layers/layerSceneComponent" {
  55528. import { Scene } from "babylonjs/scene";
  55529. import { ISceneComponent } from "babylonjs/sceneComponent";
  55530. import { Layer } from "babylonjs/Layers/layer";
  55531. import { AbstractScene } from "babylonjs/abstractScene";
  55532. module "babylonjs/abstractScene" {
  55533. interface AbstractScene {
  55534. /**
  55535. * The list of layers (background and foreground) of the scene
  55536. */
  55537. layers: Array<Layer>;
  55538. }
  55539. }
  55540. /**
  55541. * Defines the layer scene component responsible to manage any layers
  55542. * in a given scene.
  55543. */
  55544. export class LayerSceneComponent implements ISceneComponent {
  55545. /**
  55546. * The component name helpfull to identify the component in the list of scene components.
  55547. */
  55548. readonly name: string;
  55549. /**
  55550. * The scene the component belongs to.
  55551. */
  55552. scene: Scene;
  55553. private _engine;
  55554. /**
  55555. * Creates a new instance of the component for the given scene
  55556. * @param scene Defines the scene to register the component in
  55557. */
  55558. constructor(scene: Scene);
  55559. /**
  55560. * Registers the component in a given scene
  55561. */
  55562. register(): void;
  55563. /**
  55564. * Rebuilds the elements related to this component in case of
  55565. * context lost for instance.
  55566. */
  55567. rebuild(): void;
  55568. /**
  55569. * Disposes the component and the associated ressources.
  55570. */
  55571. dispose(): void;
  55572. private _draw;
  55573. private _drawCameraPredicate;
  55574. private _drawCameraBackground;
  55575. private _drawCameraForeground;
  55576. private _drawRenderTargetPredicate;
  55577. private _drawRenderTargetBackground;
  55578. private _drawRenderTargetForeground;
  55579. /**
  55580. * Adds all the elements from the container to the scene
  55581. * @param container the container holding the elements
  55582. */
  55583. addFromContainer(container: AbstractScene): void;
  55584. /**
  55585. * Removes all the elements in the container from the scene
  55586. * @param container contains the elements to remove
  55587. * @param dispose if the removed element should be disposed (default: false)
  55588. */
  55589. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55590. }
  55591. }
  55592. declare module "babylonjs/Shaders/layer.fragment" {
  55593. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55594. /** @hidden */
  55595. export var layerPixelShader: {
  55596. name: string;
  55597. shader: string;
  55598. };
  55599. }
  55600. declare module "babylonjs/Shaders/layer.vertex" {
  55601. /** @hidden */
  55602. export var layerVertexShader: {
  55603. name: string;
  55604. shader: string;
  55605. };
  55606. }
  55607. declare module "babylonjs/Layers/layer" {
  55608. import { Observable } from "babylonjs/Misc/observable";
  55609. import { Nullable } from "babylonjs/types";
  55610. import { Scene } from "babylonjs/scene";
  55611. import { Vector2 } from "babylonjs/Maths/math.vector";
  55612. import { Color4 } from "babylonjs/Maths/math.color";
  55613. import { Texture } from "babylonjs/Materials/Textures/texture";
  55614. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55615. import "babylonjs/Shaders/layer.fragment";
  55616. import "babylonjs/Shaders/layer.vertex";
  55617. /**
  55618. * This represents a full screen 2d layer.
  55619. * This can be useful to display a picture in the background of your scene for instance.
  55620. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55621. */
  55622. export class Layer {
  55623. /**
  55624. * Define the name of the layer.
  55625. */
  55626. name: string;
  55627. /**
  55628. * Define the texture the layer should display.
  55629. */
  55630. texture: Nullable<Texture>;
  55631. /**
  55632. * Is the layer in background or foreground.
  55633. */
  55634. isBackground: boolean;
  55635. /**
  55636. * Define the color of the layer (instead of texture).
  55637. */
  55638. color: Color4;
  55639. /**
  55640. * Define the scale of the layer in order to zoom in out of the texture.
  55641. */
  55642. scale: Vector2;
  55643. /**
  55644. * Define an offset for the layer in order to shift the texture.
  55645. */
  55646. offset: Vector2;
  55647. /**
  55648. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55649. */
  55650. alphaBlendingMode: number;
  55651. /**
  55652. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55653. * Alpha test will not mix with the background color in case of transparency.
  55654. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55655. */
  55656. alphaTest: boolean;
  55657. /**
  55658. * Define a mask to restrict the layer to only some of the scene cameras.
  55659. */
  55660. layerMask: number;
  55661. /**
  55662. * Define the list of render target the layer is visible into.
  55663. */
  55664. renderTargetTextures: RenderTargetTexture[];
  55665. /**
  55666. * Define if the layer is only used in renderTarget or if it also
  55667. * renders in the main frame buffer of the canvas.
  55668. */
  55669. renderOnlyInRenderTargetTextures: boolean;
  55670. private _scene;
  55671. private _vertexBuffers;
  55672. private _indexBuffer;
  55673. private _effect;
  55674. private _previousDefines;
  55675. /**
  55676. * An event triggered when the layer is disposed.
  55677. */
  55678. onDisposeObservable: Observable<Layer>;
  55679. private _onDisposeObserver;
  55680. /**
  55681. * Back compatibility with callback before the onDisposeObservable existed.
  55682. * The set callback will be triggered when the layer has been disposed.
  55683. */
  55684. set onDispose(callback: () => void);
  55685. /**
  55686. * An event triggered before rendering the scene
  55687. */
  55688. onBeforeRenderObservable: Observable<Layer>;
  55689. private _onBeforeRenderObserver;
  55690. /**
  55691. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55692. * The set callback will be triggered just before rendering the layer.
  55693. */
  55694. set onBeforeRender(callback: () => void);
  55695. /**
  55696. * An event triggered after rendering the scene
  55697. */
  55698. onAfterRenderObservable: Observable<Layer>;
  55699. private _onAfterRenderObserver;
  55700. /**
  55701. * Back compatibility with callback before the onAfterRenderObservable existed.
  55702. * The set callback will be triggered just after rendering the layer.
  55703. */
  55704. set onAfterRender(callback: () => void);
  55705. /**
  55706. * Instantiates a new layer.
  55707. * This represents a full screen 2d layer.
  55708. * This can be useful to display a picture in the background of your scene for instance.
  55709. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55710. * @param name Define the name of the layer in the scene
  55711. * @param imgUrl Define the url of the texture to display in the layer
  55712. * @param scene Define the scene the layer belongs to
  55713. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55714. * @param color Defines a color for the layer
  55715. */
  55716. constructor(
  55717. /**
  55718. * Define the name of the layer.
  55719. */
  55720. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55721. private _createIndexBuffer;
  55722. /** @hidden */
  55723. _rebuild(): void;
  55724. /**
  55725. * Renders the layer in the scene.
  55726. */
  55727. render(): void;
  55728. /**
  55729. * Disposes and releases the associated ressources.
  55730. */
  55731. dispose(): void;
  55732. }
  55733. }
  55734. declare module "babylonjs/Layers/index" {
  55735. export * from "babylonjs/Layers/effectLayer";
  55736. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55737. export * from "babylonjs/Layers/glowLayer";
  55738. export * from "babylonjs/Layers/highlightLayer";
  55739. export * from "babylonjs/Layers/layer";
  55740. export * from "babylonjs/Layers/layerSceneComponent";
  55741. }
  55742. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55743. /** @hidden */
  55744. export var lensFlarePixelShader: {
  55745. name: string;
  55746. shader: string;
  55747. };
  55748. }
  55749. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55750. /** @hidden */
  55751. export var lensFlareVertexShader: {
  55752. name: string;
  55753. shader: string;
  55754. };
  55755. }
  55756. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55757. import { Scene } from "babylonjs/scene";
  55758. import { Vector3 } from "babylonjs/Maths/math.vector";
  55759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55760. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55761. import "babylonjs/Shaders/lensFlare.fragment";
  55762. import "babylonjs/Shaders/lensFlare.vertex";
  55763. import { Viewport } from "babylonjs/Maths/math.viewport";
  55764. /**
  55765. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55766. * It is usually composed of several `lensFlare`.
  55767. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55768. */
  55769. export class LensFlareSystem {
  55770. /**
  55771. * Define the name of the lens flare system
  55772. */
  55773. name: string;
  55774. /**
  55775. * List of lens flares used in this system.
  55776. */
  55777. lensFlares: LensFlare[];
  55778. /**
  55779. * Define a limit from the border the lens flare can be visible.
  55780. */
  55781. borderLimit: number;
  55782. /**
  55783. * Define a viewport border we do not want to see the lens flare in.
  55784. */
  55785. viewportBorder: number;
  55786. /**
  55787. * Define a predicate which could limit the list of meshes able to occlude the effect.
  55788. */
  55789. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55790. /**
  55791. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  55792. */
  55793. layerMask: number;
  55794. /**
  55795. * Define the id of the lens flare system in the scene.
  55796. * (equal to name by default)
  55797. */
  55798. id: string;
  55799. private _scene;
  55800. private _emitter;
  55801. private _vertexBuffers;
  55802. private _indexBuffer;
  55803. private _effect;
  55804. private _positionX;
  55805. private _positionY;
  55806. private _isEnabled;
  55807. /** @hidden */
  55808. static _SceneComponentInitialization: (scene: Scene) => void;
  55809. /**
  55810. * Instantiates a lens flare system.
  55811. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55812. * It is usually composed of several `lensFlare`.
  55813. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55814. * @param name Define the name of the lens flare system in the scene
  55815. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55816. * @param scene Define the scene the lens flare system belongs to
  55817. */
  55818. constructor(
  55819. /**
  55820. * Define the name of the lens flare system
  55821. */
  55822. name: string, emitter: any, scene: Scene);
  55823. /**
  55824. * Define if the lens flare system is enabled.
  55825. */
  55826. get isEnabled(): boolean;
  55827. set isEnabled(value: boolean);
  55828. /**
  55829. * Get the scene the effects belongs to.
  55830. * @returns the scene holding the lens flare system
  55831. */
  55832. getScene(): Scene;
  55833. /**
  55834. * Get the emitter of the lens flare system.
  55835. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55836. * @returns the emitter of the lens flare system
  55837. */
  55838. getEmitter(): any;
  55839. /**
  55840. * Set the emitter of the lens flare system.
  55841. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55842. * @param newEmitter Define the new emitter of the system
  55843. */
  55844. setEmitter(newEmitter: any): void;
  55845. /**
  55846. * Get the lens flare system emitter position.
  55847. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55848. * @returns the position
  55849. */
  55850. getEmitterPosition(): Vector3;
  55851. /**
  55852. * @hidden
  55853. */
  55854. computeEffectivePosition(globalViewport: Viewport): boolean;
  55855. /** @hidden */
  55856. _isVisible(): boolean;
  55857. /**
  55858. * @hidden
  55859. */
  55860. render(): boolean;
  55861. /**
  55862. * Dispose and release the lens flare with its associated resources.
  55863. */
  55864. dispose(): void;
  55865. /**
  55866. * Parse a lens flare system from a JSON repressentation
  55867. * @param parsedLensFlareSystem Define the JSON to parse
  55868. * @param scene Define the scene the parsed system should be instantiated in
  55869. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55870. * @returns the parsed system
  55871. */
  55872. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55873. /**
  55874. * Serialize the current Lens Flare System into a JSON representation.
  55875. * @returns the serialized JSON
  55876. */
  55877. serialize(): any;
  55878. }
  55879. }
  55880. declare module "babylonjs/LensFlares/lensFlare" {
  55881. import { Nullable } from "babylonjs/types";
  55882. import { Color3 } from "babylonjs/Maths/math.color";
  55883. import { Texture } from "babylonjs/Materials/Textures/texture";
  55884. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55885. /**
  55886. * This represents one of the lens effect in a `lensFlareSystem`.
  55887. * It controls one of the indiviual texture used in the effect.
  55888. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55889. */
  55890. export class LensFlare {
  55891. /**
  55892. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55893. */
  55894. size: number;
  55895. /**
  55896. * 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.
  55897. */
  55898. position: number;
  55899. /**
  55900. * Define the lens color.
  55901. */
  55902. color: Color3;
  55903. /**
  55904. * Define the lens texture.
  55905. */
  55906. texture: Nullable<Texture>;
  55907. /**
  55908. * Define the alpha mode to render this particular lens.
  55909. */
  55910. alphaMode: number;
  55911. private _system;
  55912. /**
  55913. * Creates a new Lens Flare.
  55914. * This represents one of the lens effect in a `lensFlareSystem`.
  55915. * It controls one of the indiviual texture used in the effect.
  55916. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55917. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55918. * @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.
  55919. * @param color Define the lens color
  55920. * @param imgUrl Define the lens texture url
  55921. * @param system Define the `lensFlareSystem` this flare is part of
  55922. * @returns The newly created Lens Flare
  55923. */
  55924. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55925. /**
  55926. * Instantiates a new Lens Flare.
  55927. * This represents one of the lens effect in a `lensFlareSystem`.
  55928. * It controls one of the indiviual texture used in the effect.
  55929. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55930. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55931. * @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.
  55932. * @param color Define the lens color
  55933. * @param imgUrl Define the lens texture url
  55934. * @param system Define the `lensFlareSystem` this flare is part of
  55935. */
  55936. constructor(
  55937. /**
  55938. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55939. */
  55940. size: number,
  55941. /**
  55942. * 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.
  55943. */
  55944. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55945. /**
  55946. * Dispose and release the lens flare with its associated resources.
  55947. */
  55948. dispose(): void;
  55949. }
  55950. }
  55951. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55952. import { Nullable } from "babylonjs/types";
  55953. import { Scene } from "babylonjs/scene";
  55954. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55955. import { AbstractScene } from "babylonjs/abstractScene";
  55956. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55957. module "babylonjs/abstractScene" {
  55958. interface AbstractScene {
  55959. /**
  55960. * The list of lens flare system added to the scene
  55961. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55962. */
  55963. lensFlareSystems: Array<LensFlareSystem>;
  55964. /**
  55965. * Removes the given lens flare system from this scene.
  55966. * @param toRemove The lens flare system to remove
  55967. * @returns The index of the removed lens flare system
  55968. */
  55969. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55970. /**
  55971. * Adds the given lens flare system to this scene
  55972. * @param newLensFlareSystem The lens flare system to add
  55973. */
  55974. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55975. /**
  55976. * Gets a lens flare system using its name
  55977. * @param name defines the name to look for
  55978. * @returns the lens flare system or null if not found
  55979. */
  55980. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55981. /**
  55982. * Gets a lens flare system using its id
  55983. * @param id defines the id to look for
  55984. * @returns the lens flare system or null if not found
  55985. */
  55986. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55987. }
  55988. }
  55989. /**
  55990. * Defines the lens flare scene component responsible to manage any lens flares
  55991. * in a given scene.
  55992. */
  55993. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  55994. /**
  55995. * The component name helpfull to identify the component in the list of scene components.
  55996. */
  55997. readonly name: string;
  55998. /**
  55999. * The scene the component belongs to.
  56000. */
  56001. scene: Scene;
  56002. /**
  56003. * Creates a new instance of the component for the given scene
  56004. * @param scene Defines the scene to register the component in
  56005. */
  56006. constructor(scene: Scene);
  56007. /**
  56008. * Registers the component in a given scene
  56009. */
  56010. register(): void;
  56011. /**
  56012. * Rebuilds the elements related to this component in case of
  56013. * context lost for instance.
  56014. */
  56015. rebuild(): void;
  56016. /**
  56017. * Adds all the elements from the container to the scene
  56018. * @param container the container holding the elements
  56019. */
  56020. addFromContainer(container: AbstractScene): void;
  56021. /**
  56022. * Removes all the elements in the container from the scene
  56023. * @param container contains the elements to remove
  56024. * @param dispose if the removed element should be disposed (default: false)
  56025. */
  56026. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56027. /**
  56028. * Serializes the component data to the specified json object
  56029. * @param serializationObject The object to serialize to
  56030. */
  56031. serialize(serializationObject: any): void;
  56032. /**
  56033. * Disposes the component and the associated ressources.
  56034. */
  56035. dispose(): void;
  56036. private _draw;
  56037. }
  56038. }
  56039. declare module "babylonjs/LensFlares/index" {
  56040. export * from "babylonjs/LensFlares/lensFlare";
  56041. export * from "babylonjs/LensFlares/lensFlareSystem";
  56042. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56043. }
  56044. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56045. import { Scene } from "babylonjs/scene";
  56046. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56047. import { AbstractScene } from "babylonjs/abstractScene";
  56048. /**
  56049. * Defines the shadow generator component responsible to manage any shadow generators
  56050. * in a given scene.
  56051. */
  56052. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56053. /**
  56054. * The component name helpfull to identify the component in the list of scene components.
  56055. */
  56056. readonly name: string;
  56057. /**
  56058. * The scene the component belongs to.
  56059. */
  56060. scene: Scene;
  56061. /**
  56062. * Creates a new instance of the component for the given scene
  56063. * @param scene Defines the scene to register the component in
  56064. */
  56065. constructor(scene: Scene);
  56066. /**
  56067. * Registers the component in a given scene
  56068. */
  56069. register(): void;
  56070. /**
  56071. * Rebuilds the elements related to this component in case of
  56072. * context lost for instance.
  56073. */
  56074. rebuild(): void;
  56075. /**
  56076. * Serializes the component data to the specified json object
  56077. * @param serializationObject The object to serialize to
  56078. */
  56079. serialize(serializationObject: any): void;
  56080. /**
  56081. * Adds all the elements from the container to the scene
  56082. * @param container the container holding the elements
  56083. */
  56084. addFromContainer(container: AbstractScene): void;
  56085. /**
  56086. * Removes all the elements in the container from the scene
  56087. * @param container contains the elements to remove
  56088. * @param dispose if the removed element should be disposed (default: false)
  56089. */
  56090. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56091. /**
  56092. * Rebuilds the elements related to this component in case of
  56093. * context lost for instance.
  56094. */
  56095. dispose(): void;
  56096. private _gatherRenderTargets;
  56097. }
  56098. }
  56099. declare module "babylonjs/Lights/Shadows/index" {
  56100. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56101. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56102. }
  56103. declare module "babylonjs/Lights/pointLight" {
  56104. import { Scene } from "babylonjs/scene";
  56105. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56107. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56108. import { Effect } from "babylonjs/Materials/effect";
  56109. /**
  56110. * A point light is a light defined by an unique point in world space.
  56111. * The light is emitted in every direction from this point.
  56112. * A good example of a point light is a standard light bulb.
  56113. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56114. */
  56115. export class PointLight extends ShadowLight {
  56116. private _shadowAngle;
  56117. /**
  56118. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56119. * This specifies what angle the shadow will use to be created.
  56120. *
  56121. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56122. */
  56123. get shadowAngle(): number;
  56124. /**
  56125. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56126. * This specifies what angle the shadow will use to be created.
  56127. *
  56128. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56129. */
  56130. set shadowAngle(value: number);
  56131. /**
  56132. * Gets the direction if it has been set.
  56133. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56134. */
  56135. get direction(): Vector3;
  56136. /**
  56137. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56138. */
  56139. set direction(value: Vector3);
  56140. /**
  56141. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56142. * A PointLight emits the light in every direction.
  56143. * It can cast shadows.
  56144. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56145. * ```javascript
  56146. * var pointLight = new PointLight("pl", camera.position, scene);
  56147. * ```
  56148. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56149. * @param name The light friendly name
  56150. * @param position The position of the point light in the scene
  56151. * @param scene The scene the lights belongs to
  56152. */
  56153. constructor(name: string, position: Vector3, scene: Scene);
  56154. /**
  56155. * Returns the string "PointLight"
  56156. * @returns the class name
  56157. */
  56158. getClassName(): string;
  56159. /**
  56160. * Returns the integer 0.
  56161. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56162. */
  56163. getTypeID(): number;
  56164. /**
  56165. * Specifies wether or not the shadowmap should be a cube texture.
  56166. * @returns true if the shadowmap needs to be a cube texture.
  56167. */
  56168. needCube(): boolean;
  56169. /**
  56170. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56171. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56172. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56173. */
  56174. getShadowDirection(faceIndex?: number): Vector3;
  56175. /**
  56176. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56177. * - fov = PI / 2
  56178. * - aspect ratio : 1.0
  56179. * - z-near and far equal to the active camera minZ and maxZ.
  56180. * Returns the PointLight.
  56181. */
  56182. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56183. protected _buildUniformLayout(): void;
  56184. /**
  56185. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56186. * @param effect The effect to update
  56187. * @param lightIndex The index of the light in the effect to update
  56188. * @returns The point light
  56189. */
  56190. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56191. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56192. /**
  56193. * Prepares the list of defines specific to the light type.
  56194. * @param defines the list of defines
  56195. * @param lightIndex defines the index of the light for the effect
  56196. */
  56197. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56198. }
  56199. }
  56200. declare module "babylonjs/Lights/index" {
  56201. export * from "babylonjs/Lights/light";
  56202. export * from "babylonjs/Lights/shadowLight";
  56203. export * from "babylonjs/Lights/Shadows/index";
  56204. export * from "babylonjs/Lights/directionalLight";
  56205. export * from "babylonjs/Lights/hemisphericLight";
  56206. export * from "babylonjs/Lights/pointLight";
  56207. export * from "babylonjs/Lights/spotLight";
  56208. }
  56209. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56210. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56211. /**
  56212. * Header information of HDR texture files.
  56213. */
  56214. export interface HDRInfo {
  56215. /**
  56216. * The height of the texture in pixels.
  56217. */
  56218. height: number;
  56219. /**
  56220. * The width of the texture in pixels.
  56221. */
  56222. width: number;
  56223. /**
  56224. * The index of the beginning of the data in the binary file.
  56225. */
  56226. dataPosition: number;
  56227. }
  56228. /**
  56229. * This groups tools to convert HDR texture to native colors array.
  56230. */
  56231. export class HDRTools {
  56232. private static Ldexp;
  56233. private static Rgbe2float;
  56234. private static readStringLine;
  56235. /**
  56236. * Reads header information from an RGBE texture stored in a native array.
  56237. * More information on this format are available here:
  56238. * https://en.wikipedia.org/wiki/RGBE_image_format
  56239. *
  56240. * @param uint8array The binary file stored in native array.
  56241. * @return The header information.
  56242. */
  56243. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56244. /**
  56245. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56246. * This RGBE texture needs to store the information as a panorama.
  56247. *
  56248. * More information on this format are available here:
  56249. * https://en.wikipedia.org/wiki/RGBE_image_format
  56250. *
  56251. * @param buffer The binary file stored in an array buffer.
  56252. * @param size The expected size of the extracted cubemap.
  56253. * @return The Cube Map information.
  56254. */
  56255. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  56256. /**
  56257. * Returns the pixels data extracted from an RGBE texture.
  56258. * This pixels will be stored left to right up to down in the R G B order in one array.
  56259. *
  56260. * More information on this format are available here:
  56261. * https://en.wikipedia.org/wiki/RGBE_image_format
  56262. *
  56263. * @param uint8array The binary file stored in an array buffer.
  56264. * @param hdrInfo The header information of the file.
  56265. * @return The pixels data in RGB right to left up to down order.
  56266. */
  56267. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  56268. private static RGBE_ReadPixels_RLE;
  56269. }
  56270. }
  56271. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  56272. import { Nullable } from "babylonjs/types";
  56273. import { Scene } from "babylonjs/scene";
  56274. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56276. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56277. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56278. /**
  56279. * This represents a texture coming from an HDR input.
  56280. *
  56281. * The only supported format is currently panorama picture stored in RGBE format.
  56282. * Example of such files can be found on HDRLib: http://hdrlib.com/
  56283. */
  56284. export class HDRCubeTexture extends BaseTexture {
  56285. private static _facesMapping;
  56286. private _generateHarmonics;
  56287. private _noMipmap;
  56288. private _textureMatrix;
  56289. private _size;
  56290. private _onLoad;
  56291. private _onError;
  56292. /**
  56293. * The texture URL.
  56294. */
  56295. url: string;
  56296. /**
  56297. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  56298. */
  56299. coordinatesMode: number;
  56300. protected _isBlocking: boolean;
  56301. /**
  56302. * Sets wether or not the texture is blocking during loading.
  56303. */
  56304. set isBlocking(value: boolean);
  56305. /**
  56306. * Gets wether or not the texture is blocking during loading.
  56307. */
  56308. get isBlocking(): boolean;
  56309. protected _rotationY: number;
  56310. /**
  56311. * Sets texture matrix rotation angle around Y axis in radians.
  56312. */
  56313. set rotationY(value: number);
  56314. /**
  56315. * Gets texture matrix rotation angle around Y axis radians.
  56316. */
  56317. get rotationY(): number;
  56318. /**
  56319. * Gets or sets the center of the bounding box associated with the cube texture
  56320. * It must define where the camera used to render the texture was set
  56321. */
  56322. boundingBoxPosition: Vector3;
  56323. private _boundingBoxSize;
  56324. /**
  56325. * Gets or sets the size of the bounding box associated with the cube texture
  56326. * When defined, the cubemap will switch to local mode
  56327. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56328. * @example https://www.babylonjs-playground.com/#RNASML
  56329. */
  56330. set boundingBoxSize(value: Vector3);
  56331. get boundingBoxSize(): Vector3;
  56332. /**
  56333. * Instantiates an HDRTexture from the following parameters.
  56334. *
  56335. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  56336. * @param scene The scene the texture will be used in
  56337. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56338. * @param noMipmap Forces to not generate the mipmap if true
  56339. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  56340. * @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)
  56341. * @param reserved Reserved flag for internal use.
  56342. */
  56343. 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>);
  56344. /**
  56345. * Get the current class name of the texture useful for serialization or dynamic coding.
  56346. * @returns "HDRCubeTexture"
  56347. */
  56348. getClassName(): string;
  56349. /**
  56350. * Occurs when the file is raw .hdr file.
  56351. */
  56352. private loadTexture;
  56353. clone(): HDRCubeTexture;
  56354. delayLoad(): void;
  56355. /**
  56356. * Get the texture reflection matrix used to rotate/transform the reflection.
  56357. * @returns the reflection matrix
  56358. */
  56359. getReflectionTextureMatrix(): Matrix;
  56360. /**
  56361. * Set the texture reflection matrix used to rotate/transform the reflection.
  56362. * @param value Define the reflection matrix to set
  56363. */
  56364. setReflectionTextureMatrix(value: Matrix): void;
  56365. /**
  56366. * Parses a JSON representation of an HDR Texture in order to create the texture
  56367. * @param parsedTexture Define the JSON representation
  56368. * @param scene Define the scene the texture should be created in
  56369. * @param rootUrl Define the root url in case we need to load relative dependencies
  56370. * @returns the newly created texture after parsing
  56371. */
  56372. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  56373. serialize(): any;
  56374. }
  56375. }
  56376. declare module "babylonjs/Physics/physicsEngine" {
  56377. import { Nullable } from "babylonjs/types";
  56378. import { Vector3 } from "babylonjs/Maths/math.vector";
  56379. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56380. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  56381. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  56382. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56383. /**
  56384. * Class used to control physics engine
  56385. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56386. */
  56387. export class PhysicsEngine implements IPhysicsEngine {
  56388. private _physicsPlugin;
  56389. /**
  56390. * Global value used to control the smallest number supported by the simulation
  56391. */
  56392. static Epsilon: number;
  56393. private _impostors;
  56394. private _joints;
  56395. private _subTimeStep;
  56396. /**
  56397. * Gets the gravity vector used by the simulation
  56398. */
  56399. gravity: Vector3;
  56400. /**
  56401. * Factory used to create the default physics plugin.
  56402. * @returns The default physics plugin
  56403. */
  56404. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  56405. /**
  56406. * Creates a new Physics Engine
  56407. * @param gravity defines the gravity vector used by the simulation
  56408. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  56409. */
  56410. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  56411. /**
  56412. * Sets the gravity vector used by the simulation
  56413. * @param gravity defines the gravity vector to use
  56414. */
  56415. setGravity(gravity: Vector3): void;
  56416. /**
  56417. * Set the time step of the physics engine.
  56418. * Default is 1/60.
  56419. * To slow it down, enter 1/600 for example.
  56420. * To speed it up, 1/30
  56421. * @param newTimeStep defines the new timestep to apply to this world.
  56422. */
  56423. setTimeStep(newTimeStep?: number): void;
  56424. /**
  56425. * Get the time step of the physics engine.
  56426. * @returns the current time step
  56427. */
  56428. getTimeStep(): number;
  56429. /**
  56430. * Set the sub time step of the physics engine.
  56431. * Default is 0 meaning there is no sub steps
  56432. * To increase physics resolution precision, set a small value (like 1 ms)
  56433. * @param subTimeStep defines the new sub timestep used for physics resolution.
  56434. */
  56435. setSubTimeStep(subTimeStep?: number): void;
  56436. /**
  56437. * Get the sub time step of the physics engine.
  56438. * @returns the current sub time step
  56439. */
  56440. getSubTimeStep(): number;
  56441. /**
  56442. * Release all resources
  56443. */
  56444. dispose(): void;
  56445. /**
  56446. * Gets the name of the current physics plugin
  56447. * @returns the name of the plugin
  56448. */
  56449. getPhysicsPluginName(): string;
  56450. /**
  56451. * Adding a new impostor for the impostor tracking.
  56452. * This will be done by the impostor itself.
  56453. * @param impostor the impostor to add
  56454. */
  56455. addImpostor(impostor: PhysicsImpostor): void;
  56456. /**
  56457. * Remove an impostor from the engine.
  56458. * This impostor and its mesh will not longer be updated by the physics engine.
  56459. * @param impostor the impostor to remove
  56460. */
  56461. removeImpostor(impostor: PhysicsImpostor): void;
  56462. /**
  56463. * Add a joint to the physics engine
  56464. * @param mainImpostor defines the main impostor to which the joint is added.
  56465. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  56466. * @param joint defines the joint that will connect both impostors.
  56467. */
  56468. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  56469. /**
  56470. * Removes a joint from the simulation
  56471. * @param mainImpostor defines the impostor used with the joint
  56472. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  56473. * @param joint defines the joint to remove
  56474. */
  56475. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  56476. /**
  56477. * Called by the scene. No need to call it.
  56478. * @param delta defines the timespam between frames
  56479. */
  56480. _step(delta: number): void;
  56481. /**
  56482. * Gets the current plugin used to run the simulation
  56483. * @returns current plugin
  56484. */
  56485. getPhysicsPlugin(): IPhysicsEnginePlugin;
  56486. /**
  56487. * Gets the list of physic impostors
  56488. * @returns an array of PhysicsImpostor
  56489. */
  56490. getImpostors(): Array<PhysicsImpostor>;
  56491. /**
  56492. * Gets the impostor for a physics enabled object
  56493. * @param object defines the object impersonated by the impostor
  56494. * @returns the PhysicsImpostor or null if not found
  56495. */
  56496. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  56497. /**
  56498. * Gets the impostor for a physics body object
  56499. * @param body defines physics body used by the impostor
  56500. * @returns the PhysicsImpostor or null if not found
  56501. */
  56502. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  56503. /**
  56504. * Does a raycast in the physics world
  56505. * @param from when should the ray start?
  56506. * @param to when should the ray end?
  56507. * @returns PhysicsRaycastResult
  56508. */
  56509. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56510. }
  56511. }
  56512. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  56513. import { Nullable } from "babylonjs/types";
  56514. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  56515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56516. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56517. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56518. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56519. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56520. /** @hidden */
  56521. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  56522. private _useDeltaForWorldStep;
  56523. world: any;
  56524. name: string;
  56525. private _physicsMaterials;
  56526. private _fixedTimeStep;
  56527. private _cannonRaycastResult;
  56528. private _raycastResult;
  56529. private _physicsBodysToRemoveAfterStep;
  56530. BJSCANNON: any;
  56531. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  56532. setGravity(gravity: Vector3): void;
  56533. setTimeStep(timeStep: number): void;
  56534. getTimeStep(): number;
  56535. executeStep(delta: number): void;
  56536. private _removeMarkedPhysicsBodiesFromWorld;
  56537. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56538. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56539. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56540. private _processChildMeshes;
  56541. removePhysicsBody(impostor: PhysicsImpostor): void;
  56542. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56543. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56544. private _addMaterial;
  56545. private _checkWithEpsilon;
  56546. private _createShape;
  56547. private _createHeightmap;
  56548. private _minus90X;
  56549. private _plus90X;
  56550. private _tmpPosition;
  56551. private _tmpDeltaPosition;
  56552. private _tmpUnityRotation;
  56553. private _updatePhysicsBodyTransformation;
  56554. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56555. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56556. isSupported(): boolean;
  56557. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56558. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56559. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56560. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56561. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56562. getBodyMass(impostor: PhysicsImpostor): number;
  56563. getBodyFriction(impostor: PhysicsImpostor): number;
  56564. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56565. getBodyRestitution(impostor: PhysicsImpostor): number;
  56566. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56567. sleepBody(impostor: PhysicsImpostor): void;
  56568. wakeUpBody(impostor: PhysicsImpostor): void;
  56569. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  56570. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56571. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56572. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56573. getRadius(impostor: PhysicsImpostor): number;
  56574. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56575. dispose(): void;
  56576. private _extendNamespace;
  56577. /**
  56578. * Does a raycast in the physics world
  56579. * @param from when should the ray start?
  56580. * @param to when should the ray end?
  56581. * @returns PhysicsRaycastResult
  56582. */
  56583. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56584. }
  56585. }
  56586. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  56587. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56588. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56589. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56591. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  56592. import { Nullable } from "babylonjs/types";
  56593. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56594. /** @hidden */
  56595. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  56596. world: any;
  56597. name: string;
  56598. BJSOIMO: any;
  56599. private _raycastResult;
  56600. constructor(iterations?: number, oimoInjection?: any);
  56601. setGravity(gravity: Vector3): void;
  56602. setTimeStep(timeStep: number): void;
  56603. getTimeStep(): number;
  56604. private _tmpImpostorsArray;
  56605. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56606. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56607. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56608. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56609. private _tmpPositionVector;
  56610. removePhysicsBody(impostor: PhysicsImpostor): void;
  56611. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56612. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56613. isSupported(): boolean;
  56614. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56615. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56616. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56617. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56618. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56619. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56620. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56621. getBodyMass(impostor: PhysicsImpostor): number;
  56622. getBodyFriction(impostor: PhysicsImpostor): number;
  56623. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56624. getBodyRestitution(impostor: PhysicsImpostor): number;
  56625. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56626. sleepBody(impostor: PhysicsImpostor): void;
  56627. wakeUpBody(impostor: PhysicsImpostor): void;
  56628. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56629. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  56630. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  56631. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56632. getRadius(impostor: PhysicsImpostor): number;
  56633. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56634. dispose(): void;
  56635. /**
  56636. * Does a raycast in the physics world
  56637. * @param from when should the ray start?
  56638. * @param to when should the ray end?
  56639. * @returns PhysicsRaycastResult
  56640. */
  56641. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56642. }
  56643. }
  56644. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56645. import { Nullable } from "babylonjs/types";
  56646. import { Scene } from "babylonjs/scene";
  56647. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56648. import { Color4 } from "babylonjs/Maths/math.color";
  56649. import { Mesh } from "babylonjs/Meshes/mesh";
  56650. /**
  56651. * Class containing static functions to help procedurally build meshes
  56652. */
  56653. export class RibbonBuilder {
  56654. /**
  56655. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56656. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56657. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56658. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56659. * * 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
  56660. * * 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
  56661. * * 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
  56662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56665. * * 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
  56666. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56667. * * 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
  56668. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56670. * @param name defines the name of the mesh
  56671. * @param options defines the options used to create the mesh
  56672. * @param scene defines the hosting scene
  56673. * @returns the ribbon mesh
  56674. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56675. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56676. */
  56677. static CreateRibbon(name: string, options: {
  56678. pathArray: Vector3[][];
  56679. closeArray?: boolean;
  56680. closePath?: boolean;
  56681. offset?: number;
  56682. updatable?: boolean;
  56683. sideOrientation?: number;
  56684. frontUVs?: Vector4;
  56685. backUVs?: Vector4;
  56686. instance?: Mesh;
  56687. invertUV?: boolean;
  56688. uvs?: Vector2[];
  56689. colors?: Color4[];
  56690. }, scene?: Nullable<Scene>): Mesh;
  56691. }
  56692. }
  56693. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56694. import { Nullable } from "babylonjs/types";
  56695. import { Scene } from "babylonjs/scene";
  56696. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56697. import { Mesh } from "babylonjs/Meshes/mesh";
  56698. /**
  56699. * Class containing static functions to help procedurally build meshes
  56700. */
  56701. export class ShapeBuilder {
  56702. /**
  56703. * 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.
  56704. * * 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.
  56705. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56706. * * 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.
  56707. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56708. * * 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
  56709. * * 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
  56710. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56715. * @param name defines the name of the mesh
  56716. * @param options defines the options used to create the mesh
  56717. * @param scene defines the hosting scene
  56718. * @returns the extruded shape mesh
  56719. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56720. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56721. */
  56722. static ExtrudeShape(name: string, options: {
  56723. shape: Vector3[];
  56724. path: Vector3[];
  56725. scale?: number;
  56726. rotation?: number;
  56727. cap?: number;
  56728. updatable?: boolean;
  56729. sideOrientation?: number;
  56730. frontUVs?: Vector4;
  56731. backUVs?: Vector4;
  56732. instance?: Mesh;
  56733. invertUV?: boolean;
  56734. }, scene?: Nullable<Scene>): Mesh;
  56735. /**
  56736. * Creates an custom extruded shape mesh.
  56737. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56738. * * 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.
  56739. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56740. * * 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
  56741. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56742. * * 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
  56743. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56744. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56745. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56746. * * 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
  56747. * * 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
  56748. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56753. * @param name defines the name of the mesh
  56754. * @param options defines the options used to create the mesh
  56755. * @param scene defines the hosting scene
  56756. * @returns the custom extruded shape mesh
  56757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56758. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56760. */
  56761. static ExtrudeShapeCustom(name: string, options: {
  56762. shape: Vector3[];
  56763. path: Vector3[];
  56764. scaleFunction?: any;
  56765. rotationFunction?: any;
  56766. ribbonCloseArray?: boolean;
  56767. ribbonClosePath?: boolean;
  56768. cap?: number;
  56769. updatable?: boolean;
  56770. sideOrientation?: number;
  56771. frontUVs?: Vector4;
  56772. backUVs?: Vector4;
  56773. instance?: Mesh;
  56774. invertUV?: boolean;
  56775. }, scene?: Nullable<Scene>): Mesh;
  56776. private static _ExtrudeShapeGeneric;
  56777. }
  56778. }
  56779. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  56780. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  56781. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56782. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56783. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56784. import { Nullable } from "babylonjs/types";
  56785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56786. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56787. /**
  56788. * AmmoJS Physics plugin
  56789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  56790. * @see https://github.com/kripken/ammo.js/
  56791. */
  56792. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  56793. private _useDeltaForWorldStep;
  56794. /**
  56795. * Reference to the Ammo library
  56796. */
  56797. bjsAMMO: any;
  56798. /**
  56799. * Created ammoJS world which physics bodies are added to
  56800. */
  56801. world: any;
  56802. /**
  56803. * Name of the plugin
  56804. */
  56805. name: string;
  56806. private _timeStep;
  56807. private _fixedTimeStep;
  56808. private _maxSteps;
  56809. private _tmpQuaternion;
  56810. private _tmpAmmoTransform;
  56811. private _tmpAmmoQuaternion;
  56812. private _tmpAmmoConcreteContactResultCallback;
  56813. private _collisionConfiguration;
  56814. private _dispatcher;
  56815. private _overlappingPairCache;
  56816. private _solver;
  56817. private _softBodySolver;
  56818. private _tmpAmmoVectorA;
  56819. private _tmpAmmoVectorB;
  56820. private _tmpAmmoVectorC;
  56821. private _tmpAmmoVectorD;
  56822. private _tmpContactCallbackResult;
  56823. private _tmpAmmoVectorRCA;
  56824. private _tmpAmmoVectorRCB;
  56825. private _raycastResult;
  56826. private static readonly DISABLE_COLLISION_FLAG;
  56827. private static readonly KINEMATIC_FLAG;
  56828. private static readonly DISABLE_DEACTIVATION_FLAG;
  56829. /**
  56830. * Initializes the ammoJS plugin
  56831. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56832. * @param ammoInjection can be used to inject your own ammo reference
  56833. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56834. */
  56835. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56836. /**
  56837. * Sets the gravity of the physics world (m/(s^2))
  56838. * @param gravity Gravity to set
  56839. */
  56840. setGravity(gravity: Vector3): void;
  56841. /**
  56842. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56843. * @param timeStep timestep to use in seconds
  56844. */
  56845. setTimeStep(timeStep: number): void;
  56846. /**
  56847. * 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)
  56848. * @param fixedTimeStep fixedTimeStep to use in seconds
  56849. */
  56850. setFixedTimeStep(fixedTimeStep: number): void;
  56851. /**
  56852. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56853. * @param maxSteps the maximum number of steps by the physics engine per frame
  56854. */
  56855. setMaxSteps(maxSteps: number): void;
  56856. /**
  56857. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56858. * @returns the current timestep in seconds
  56859. */
  56860. getTimeStep(): number;
  56861. /**
  56862. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56863. */
  56864. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56865. private _isImpostorInContact;
  56866. private _isImpostorPairInContact;
  56867. private _stepSimulation;
  56868. /**
  56869. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56870. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56871. * After the step the babylon meshes are set to the position of the physics imposters
  56872. * @param delta amount of time to step forward
  56873. * @param impostors array of imposters to update before/after the step
  56874. */
  56875. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56876. /**
  56877. * Update babylon mesh to match physics world object
  56878. * @param impostor imposter to match
  56879. */
  56880. private _afterSoftStep;
  56881. /**
  56882. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56883. * @param impostor imposter to match
  56884. */
  56885. private _ropeStep;
  56886. /**
  56887. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56888. * @param impostor imposter to match
  56889. */
  56890. private _softbodyOrClothStep;
  56891. private _tmpVector;
  56892. private _tmpMatrix;
  56893. /**
  56894. * Applies an impulse on the imposter
  56895. * @param impostor imposter to apply impulse to
  56896. * @param force amount of force to be applied to the imposter
  56897. * @param contactPoint the location to apply the impulse on the imposter
  56898. */
  56899. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56900. /**
  56901. * Applies a force on the imposter
  56902. * @param impostor imposter to apply force
  56903. * @param force amount of force to be applied to the imposter
  56904. * @param contactPoint the location to apply the force on the imposter
  56905. */
  56906. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56907. /**
  56908. * Creates a physics body using the plugin
  56909. * @param impostor the imposter to create the physics body on
  56910. */
  56911. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56912. /**
  56913. * Removes the physics body from the imposter and disposes of the body's memory
  56914. * @param impostor imposter to remove the physics body from
  56915. */
  56916. removePhysicsBody(impostor: PhysicsImpostor): void;
  56917. /**
  56918. * Generates a joint
  56919. * @param impostorJoint the imposter joint to create the joint with
  56920. */
  56921. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56922. /**
  56923. * Removes a joint
  56924. * @param impostorJoint the imposter joint to remove the joint from
  56925. */
  56926. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56927. private _addMeshVerts;
  56928. /**
  56929. * Initialise the soft body vertices to match its object's (mesh) vertices
  56930. * Softbody vertices (nodes) are in world space and to match this
  56931. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56932. * @param impostor to create the softbody for
  56933. */
  56934. private _softVertexData;
  56935. /**
  56936. * Create an impostor's soft body
  56937. * @param impostor to create the softbody for
  56938. */
  56939. private _createSoftbody;
  56940. /**
  56941. * Create cloth for an impostor
  56942. * @param impostor to create the softbody for
  56943. */
  56944. private _createCloth;
  56945. /**
  56946. * Create rope for an impostor
  56947. * @param impostor to create the softbody for
  56948. */
  56949. private _createRope;
  56950. /**
  56951. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56952. * @param impostor to create the custom physics shape for
  56953. */
  56954. private _createCustom;
  56955. private _addHullVerts;
  56956. private _createShape;
  56957. /**
  56958. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56959. * @param impostor imposter containing the physics body and babylon object
  56960. */
  56961. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56962. /**
  56963. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56964. * @param impostor imposter containing the physics body and babylon object
  56965. * @param newPosition new position
  56966. * @param newRotation new rotation
  56967. */
  56968. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56969. /**
  56970. * If this plugin is supported
  56971. * @returns true if its supported
  56972. */
  56973. isSupported(): boolean;
  56974. /**
  56975. * Sets the linear velocity of the physics body
  56976. * @param impostor imposter to set the velocity on
  56977. * @param velocity velocity to set
  56978. */
  56979. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56980. /**
  56981. * Sets the angular velocity of the physics body
  56982. * @param impostor imposter to set the velocity on
  56983. * @param velocity velocity to set
  56984. */
  56985. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56986. /**
  56987. * gets the linear velocity
  56988. * @param impostor imposter to get linear velocity from
  56989. * @returns linear velocity
  56990. */
  56991. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56992. /**
  56993. * gets the angular velocity
  56994. * @param impostor imposter to get angular velocity from
  56995. * @returns angular velocity
  56996. */
  56997. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56998. /**
  56999. * Sets the mass of physics body
  57000. * @param impostor imposter to set the mass on
  57001. * @param mass mass to set
  57002. */
  57003. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57004. /**
  57005. * Gets the mass of the physics body
  57006. * @param impostor imposter to get the mass from
  57007. * @returns mass
  57008. */
  57009. getBodyMass(impostor: PhysicsImpostor): number;
  57010. /**
  57011. * Gets friction of the impostor
  57012. * @param impostor impostor to get friction from
  57013. * @returns friction value
  57014. */
  57015. getBodyFriction(impostor: PhysicsImpostor): number;
  57016. /**
  57017. * Sets friction of the impostor
  57018. * @param impostor impostor to set friction on
  57019. * @param friction friction value
  57020. */
  57021. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57022. /**
  57023. * Gets restitution of the impostor
  57024. * @param impostor impostor to get restitution from
  57025. * @returns restitution value
  57026. */
  57027. getBodyRestitution(impostor: PhysicsImpostor): number;
  57028. /**
  57029. * Sets resitution of the impostor
  57030. * @param impostor impostor to set resitution on
  57031. * @param restitution resitution value
  57032. */
  57033. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57034. /**
  57035. * Gets pressure inside the impostor
  57036. * @param impostor impostor to get pressure from
  57037. * @returns pressure value
  57038. */
  57039. getBodyPressure(impostor: PhysicsImpostor): number;
  57040. /**
  57041. * Sets pressure inside a soft body impostor
  57042. * Cloth and rope must remain 0 pressure
  57043. * @param impostor impostor to set pressure on
  57044. * @param pressure pressure value
  57045. */
  57046. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57047. /**
  57048. * Gets stiffness of the impostor
  57049. * @param impostor impostor to get stiffness from
  57050. * @returns pressure value
  57051. */
  57052. getBodyStiffness(impostor: PhysicsImpostor): number;
  57053. /**
  57054. * Sets stiffness of the impostor
  57055. * @param impostor impostor to set stiffness on
  57056. * @param stiffness stiffness value from 0 to 1
  57057. */
  57058. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57059. /**
  57060. * Gets velocityIterations of the impostor
  57061. * @param impostor impostor to get velocity iterations from
  57062. * @returns velocityIterations value
  57063. */
  57064. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57065. /**
  57066. * Sets velocityIterations of the impostor
  57067. * @param impostor impostor to set velocity iterations on
  57068. * @param velocityIterations velocityIterations value
  57069. */
  57070. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57071. /**
  57072. * Gets positionIterations of the impostor
  57073. * @param impostor impostor to get position iterations from
  57074. * @returns positionIterations value
  57075. */
  57076. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57077. /**
  57078. * Sets positionIterations of the impostor
  57079. * @param impostor impostor to set position on
  57080. * @param positionIterations positionIterations value
  57081. */
  57082. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57083. /**
  57084. * Append an anchor to a cloth object
  57085. * @param impostor is the cloth impostor to add anchor to
  57086. * @param otherImpostor is the rigid impostor to anchor to
  57087. * @param width ratio across width from 0 to 1
  57088. * @param height ratio up height from 0 to 1
  57089. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57090. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57091. */
  57092. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57093. /**
  57094. * Append an hook to a rope object
  57095. * @param impostor is the rope impostor to add hook to
  57096. * @param otherImpostor is the rigid impostor to hook to
  57097. * @param length ratio along the rope from 0 to 1
  57098. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57099. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57100. */
  57101. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57102. /**
  57103. * Sleeps the physics body and stops it from being active
  57104. * @param impostor impostor to sleep
  57105. */
  57106. sleepBody(impostor: PhysicsImpostor): void;
  57107. /**
  57108. * Activates the physics body
  57109. * @param impostor impostor to activate
  57110. */
  57111. wakeUpBody(impostor: PhysicsImpostor): void;
  57112. /**
  57113. * Updates the distance parameters of the joint
  57114. * @param joint joint to update
  57115. * @param maxDistance maximum distance of the joint
  57116. * @param minDistance minimum distance of the joint
  57117. */
  57118. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57119. /**
  57120. * Sets a motor on the joint
  57121. * @param joint joint to set motor on
  57122. * @param speed speed of the motor
  57123. * @param maxForce maximum force of the motor
  57124. * @param motorIndex index of the motor
  57125. */
  57126. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57127. /**
  57128. * Sets the motors limit
  57129. * @param joint joint to set limit on
  57130. * @param upperLimit upper limit
  57131. * @param lowerLimit lower limit
  57132. */
  57133. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57134. /**
  57135. * Syncs the position and rotation of a mesh with the impostor
  57136. * @param mesh mesh to sync
  57137. * @param impostor impostor to update the mesh with
  57138. */
  57139. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57140. /**
  57141. * Gets the radius of the impostor
  57142. * @param impostor impostor to get radius from
  57143. * @returns the radius
  57144. */
  57145. getRadius(impostor: PhysicsImpostor): number;
  57146. /**
  57147. * Gets the box size of the impostor
  57148. * @param impostor impostor to get box size from
  57149. * @param result the resulting box size
  57150. */
  57151. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57152. /**
  57153. * Disposes of the impostor
  57154. */
  57155. dispose(): void;
  57156. /**
  57157. * Does a raycast in the physics world
  57158. * @param from when should the ray start?
  57159. * @param to when should the ray end?
  57160. * @returns PhysicsRaycastResult
  57161. */
  57162. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57163. }
  57164. }
  57165. declare module "babylonjs/Probes/reflectionProbe" {
  57166. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57167. import { Vector3 } from "babylonjs/Maths/math.vector";
  57168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57169. import { Nullable } from "babylonjs/types";
  57170. import { Scene } from "babylonjs/scene";
  57171. module "babylonjs/abstractScene" {
  57172. interface AbstractScene {
  57173. /**
  57174. * The list of reflection probes added to the scene
  57175. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57176. */
  57177. reflectionProbes: Array<ReflectionProbe>;
  57178. /**
  57179. * Removes the given reflection probe from this scene.
  57180. * @param toRemove The reflection probe to remove
  57181. * @returns The index of the removed reflection probe
  57182. */
  57183. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57184. /**
  57185. * Adds the given reflection probe to this scene.
  57186. * @param newReflectionProbe The reflection probe to add
  57187. */
  57188. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57189. }
  57190. }
  57191. /**
  57192. * Class used to generate realtime reflection / refraction cube textures
  57193. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57194. */
  57195. export class ReflectionProbe {
  57196. /** defines the name of the probe */
  57197. name: string;
  57198. private _scene;
  57199. private _renderTargetTexture;
  57200. private _projectionMatrix;
  57201. private _viewMatrix;
  57202. private _target;
  57203. private _add;
  57204. private _attachedMesh;
  57205. private _invertYAxis;
  57206. /** Gets or sets probe position (center of the cube map) */
  57207. position: Vector3;
  57208. /**
  57209. * Creates a new reflection probe
  57210. * @param name defines the name of the probe
  57211. * @param size defines the texture resolution (for each face)
  57212. * @param scene defines the hosting scene
  57213. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57214. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57215. */
  57216. constructor(
  57217. /** defines the name of the probe */
  57218. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57219. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57220. get samples(): number;
  57221. set samples(value: number);
  57222. /** Gets or sets the refresh rate to use (on every frame by default) */
  57223. get refreshRate(): number;
  57224. set refreshRate(value: number);
  57225. /**
  57226. * Gets the hosting scene
  57227. * @returns a Scene
  57228. */
  57229. getScene(): Scene;
  57230. /** Gets the internal CubeTexture used to render to */
  57231. get cubeTexture(): RenderTargetTexture;
  57232. /** Gets the list of meshes to render */
  57233. get renderList(): Nullable<AbstractMesh[]>;
  57234. /**
  57235. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57236. * @param mesh defines the mesh to attach to
  57237. */
  57238. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57239. /**
  57240. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57241. * @param renderingGroupId The rendering group id corresponding to its index
  57242. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57243. */
  57244. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57245. /**
  57246. * Clean all associated resources
  57247. */
  57248. dispose(): void;
  57249. /**
  57250. * Converts the reflection probe information to a readable string for debug purpose.
  57251. * @param fullDetails Supports for multiple levels of logging within scene loading
  57252. * @returns the human readable reflection probe info
  57253. */
  57254. toString(fullDetails?: boolean): string;
  57255. /**
  57256. * Get the class name of the relfection probe.
  57257. * @returns "ReflectionProbe"
  57258. */
  57259. getClassName(): string;
  57260. /**
  57261. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  57262. * @returns The JSON representation of the texture
  57263. */
  57264. serialize(): any;
  57265. /**
  57266. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  57267. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  57268. * @param scene Define the scene the parsed reflection probe should be instantiated in
  57269. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  57270. * @returns The parsed reflection probe if successful
  57271. */
  57272. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  57273. }
  57274. }
  57275. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  57276. /** @hidden */
  57277. export var _BabylonLoaderRegistered: boolean;
  57278. /**
  57279. * Helps setting up some configuration for the babylon file loader.
  57280. */
  57281. export class BabylonFileLoaderConfiguration {
  57282. /**
  57283. * The loader does not allow injecting custom physix engine into the plugins.
  57284. * Unfortunately in ES6, we need to manually inject them into the plugin.
  57285. * So you could set this variable to your engine import to make it work.
  57286. */
  57287. static LoaderInjectedPhysicsEngine: any;
  57288. }
  57289. }
  57290. declare module "babylonjs/Loading/Plugins/index" {
  57291. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  57292. }
  57293. declare module "babylonjs/Loading/index" {
  57294. export * from "babylonjs/Loading/loadingScreen";
  57295. export * from "babylonjs/Loading/Plugins/index";
  57296. export * from "babylonjs/Loading/sceneLoader";
  57297. export * from "babylonjs/Loading/sceneLoaderFlags";
  57298. }
  57299. declare module "babylonjs/Materials/Background/index" {
  57300. export * from "babylonjs/Materials/Background/backgroundMaterial";
  57301. }
  57302. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  57303. import { Scene } from "babylonjs/scene";
  57304. import { Color3 } from "babylonjs/Maths/math.color";
  57305. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57306. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57307. /**
  57308. * The Physically based simple base material of BJS.
  57309. *
  57310. * This enables better naming and convention enforcements on top of the pbrMaterial.
  57311. * It is used as the base class for both the specGloss and metalRough conventions.
  57312. */
  57313. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  57314. /**
  57315. * Number of Simultaneous lights allowed on the material.
  57316. */
  57317. maxSimultaneousLights: number;
  57318. /**
  57319. * If sets to true, disables all the lights affecting the material.
  57320. */
  57321. disableLighting: boolean;
  57322. /**
  57323. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  57324. */
  57325. environmentTexture: BaseTexture;
  57326. /**
  57327. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57328. */
  57329. invertNormalMapX: boolean;
  57330. /**
  57331. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57332. */
  57333. invertNormalMapY: boolean;
  57334. /**
  57335. * Normal map used in the model.
  57336. */
  57337. normalTexture: BaseTexture;
  57338. /**
  57339. * Emissivie color used to self-illuminate the model.
  57340. */
  57341. emissiveColor: Color3;
  57342. /**
  57343. * Emissivie texture used to self-illuminate the model.
  57344. */
  57345. emissiveTexture: BaseTexture;
  57346. /**
  57347. * Occlusion Channel Strenght.
  57348. */
  57349. occlusionStrength: number;
  57350. /**
  57351. * Occlusion Texture of the material (adding extra occlusion effects).
  57352. */
  57353. occlusionTexture: BaseTexture;
  57354. /**
  57355. * Defines the alpha limits in alpha test mode.
  57356. */
  57357. alphaCutOff: number;
  57358. /**
  57359. * Gets the current double sided mode.
  57360. */
  57361. get doubleSided(): boolean;
  57362. /**
  57363. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57364. */
  57365. set doubleSided(value: boolean);
  57366. /**
  57367. * Stores the pre-calculated light information of a mesh in a texture.
  57368. */
  57369. lightmapTexture: BaseTexture;
  57370. /**
  57371. * If true, the light map contains occlusion information instead of lighting info.
  57372. */
  57373. useLightmapAsShadowmap: boolean;
  57374. /**
  57375. * Instantiates a new PBRMaterial instance.
  57376. *
  57377. * @param name The material name
  57378. * @param scene The scene the material will be use in.
  57379. */
  57380. constructor(name: string, scene: Scene);
  57381. getClassName(): string;
  57382. }
  57383. }
  57384. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  57385. import { Scene } from "babylonjs/scene";
  57386. import { Color3 } from "babylonjs/Maths/math.color";
  57387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57388. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  57389. /**
  57390. * The PBR material of BJS following the metal roughness convention.
  57391. *
  57392. * This fits to the PBR convention in the GLTF definition:
  57393. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  57394. */
  57395. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  57396. /**
  57397. * The base color has two different interpretations depending on the value of metalness.
  57398. * When the material is a metal, the base color is the specific measured reflectance value
  57399. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  57400. * of the material.
  57401. */
  57402. baseColor: Color3;
  57403. /**
  57404. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  57405. * well as opacity information in the alpha channel.
  57406. */
  57407. baseTexture: BaseTexture;
  57408. /**
  57409. * Specifies the metallic scalar value of the material.
  57410. * Can also be used to scale the metalness values of the metallic texture.
  57411. */
  57412. metallic: number;
  57413. /**
  57414. * Specifies the roughness scalar value of the material.
  57415. * Can also be used to scale the roughness values of the metallic texture.
  57416. */
  57417. roughness: number;
  57418. /**
  57419. * Texture containing both the metallic value in the B channel and the
  57420. * roughness value in the G channel to keep better precision.
  57421. */
  57422. metallicRoughnessTexture: BaseTexture;
  57423. /**
  57424. * Instantiates a new PBRMetalRoughnessMaterial instance.
  57425. *
  57426. * @param name The material name
  57427. * @param scene The scene the material will be use in.
  57428. */
  57429. constructor(name: string, scene: Scene);
  57430. /**
  57431. * Return the currrent class name of the material.
  57432. */
  57433. getClassName(): string;
  57434. /**
  57435. * Makes a duplicate of the current material.
  57436. * @param name - name to use for the new material.
  57437. */
  57438. clone(name: string): PBRMetallicRoughnessMaterial;
  57439. /**
  57440. * Serialize the material to a parsable JSON object.
  57441. */
  57442. serialize(): any;
  57443. /**
  57444. * Parses a JSON object correponding to the serialize function.
  57445. */
  57446. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  57447. }
  57448. }
  57449. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  57450. import { Scene } from "babylonjs/scene";
  57451. import { Color3 } from "babylonjs/Maths/math.color";
  57452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57453. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  57454. /**
  57455. * The PBR material of BJS following the specular glossiness convention.
  57456. *
  57457. * This fits to the PBR convention in the GLTF definition:
  57458. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  57459. */
  57460. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  57461. /**
  57462. * Specifies the diffuse color of the material.
  57463. */
  57464. diffuseColor: Color3;
  57465. /**
  57466. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  57467. * channel.
  57468. */
  57469. diffuseTexture: BaseTexture;
  57470. /**
  57471. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  57472. */
  57473. specularColor: Color3;
  57474. /**
  57475. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  57476. */
  57477. glossiness: number;
  57478. /**
  57479. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  57480. */
  57481. specularGlossinessTexture: BaseTexture;
  57482. /**
  57483. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  57484. *
  57485. * @param name The material name
  57486. * @param scene The scene the material will be use in.
  57487. */
  57488. constructor(name: string, scene: Scene);
  57489. /**
  57490. * Return the currrent class name of the material.
  57491. */
  57492. getClassName(): string;
  57493. /**
  57494. * Makes a duplicate of the current material.
  57495. * @param name - name to use for the new material.
  57496. */
  57497. clone(name: string): PBRSpecularGlossinessMaterial;
  57498. /**
  57499. * Serialize the material to a parsable JSON object.
  57500. */
  57501. serialize(): any;
  57502. /**
  57503. * Parses a JSON object correponding to the serialize function.
  57504. */
  57505. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  57506. }
  57507. }
  57508. declare module "babylonjs/Materials/PBR/index" {
  57509. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57510. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  57511. export * from "babylonjs/Materials/PBR/pbrMaterial";
  57512. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  57513. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  57514. }
  57515. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  57516. import { Nullable } from "babylonjs/types";
  57517. import { Scene } from "babylonjs/scene";
  57518. import { Matrix } from "babylonjs/Maths/math.vector";
  57519. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57520. /**
  57521. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  57522. * It can help converting any input color in a desired output one. This can then be used to create effects
  57523. * from sepia, black and white to sixties or futuristic rendering...
  57524. *
  57525. * The only supported format is currently 3dl.
  57526. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  57527. */
  57528. export class ColorGradingTexture extends BaseTexture {
  57529. /**
  57530. * The current texture matrix. (will always be identity in color grading texture)
  57531. */
  57532. private _textureMatrix;
  57533. /**
  57534. * The texture URL.
  57535. */
  57536. url: string;
  57537. /**
  57538. * Empty line regex stored for GC.
  57539. */
  57540. private static _noneEmptyLineRegex;
  57541. private _engine;
  57542. /**
  57543. * Instantiates a ColorGradingTexture from the following parameters.
  57544. *
  57545. * @param url The location of the color gradind data (currently only supporting 3dl)
  57546. * @param scene The scene the texture will be used in
  57547. */
  57548. constructor(url: string, scene: Scene);
  57549. /**
  57550. * Returns the texture matrix used in most of the material.
  57551. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  57552. */
  57553. getTextureMatrix(): Matrix;
  57554. /**
  57555. * Occurs when the file being loaded is a .3dl LUT file.
  57556. */
  57557. private load3dlTexture;
  57558. /**
  57559. * Starts the loading process of the texture.
  57560. */
  57561. private loadTexture;
  57562. /**
  57563. * Clones the color gradind texture.
  57564. */
  57565. clone(): ColorGradingTexture;
  57566. /**
  57567. * Called during delayed load for textures.
  57568. */
  57569. delayLoad(): void;
  57570. /**
  57571. * Parses a color grading texture serialized by Babylon.
  57572. * @param parsedTexture The texture information being parsedTexture
  57573. * @param scene The scene to load the texture in
  57574. * @param rootUrl The root url of the data assets to load
  57575. * @return A color gradind texture
  57576. */
  57577. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  57578. /**
  57579. * Serializes the LUT texture to json format.
  57580. */
  57581. serialize(): any;
  57582. }
  57583. }
  57584. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  57585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57586. import { Scene } from "babylonjs/scene";
  57587. import { Nullable } from "babylonjs/types";
  57588. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57589. /**
  57590. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  57591. */
  57592. export class EquiRectangularCubeTexture extends BaseTexture {
  57593. /** The six faces of the cube. */
  57594. private static _FacesMapping;
  57595. private _noMipmap;
  57596. private _onLoad;
  57597. private _onError;
  57598. /** The size of the cubemap. */
  57599. private _size;
  57600. /** The buffer of the image. */
  57601. private _buffer;
  57602. /** The width of the input image. */
  57603. private _width;
  57604. /** The height of the input image. */
  57605. private _height;
  57606. /** The URL to the image. */
  57607. url: string;
  57608. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  57609. coordinatesMode: number;
  57610. /**
  57611. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  57612. * @param url The location of the image
  57613. * @param scene The scene the texture will be used in
  57614. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57615. * @param noMipmap Forces to not generate the mipmap if true
  57616. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57617. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57618. * @param onLoad — defines a callback called when texture is loaded
  57619. * @param onError — defines a callback called if there is an error
  57620. */
  57621. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  57622. /**
  57623. * Load the image data, by putting the image on a canvas and extracting its buffer.
  57624. */
  57625. private loadImage;
  57626. /**
  57627. * Convert the image buffer into a cubemap and create a CubeTexture.
  57628. */
  57629. private loadTexture;
  57630. /**
  57631. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  57632. * @param buffer The ArrayBuffer that should be converted.
  57633. * @returns The buffer as Float32Array.
  57634. */
  57635. private getFloat32ArrayFromArrayBuffer;
  57636. /**
  57637. * Get the current class name of the texture useful for serialization or dynamic coding.
  57638. * @returns "EquiRectangularCubeTexture"
  57639. */
  57640. getClassName(): string;
  57641. /**
  57642. * Create a clone of the current EquiRectangularCubeTexture and return it.
  57643. * @returns A clone of the current EquiRectangularCubeTexture.
  57644. */
  57645. clone(): EquiRectangularCubeTexture;
  57646. }
  57647. }
  57648. declare module "babylonjs/Misc/tga" {
  57649. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57650. /**
  57651. * Based on jsTGALoader - Javascript loader for TGA file
  57652. * By Vincent Thibault
  57653. * @see http://blog.robrowser.com/javascript-tga-loader.html
  57654. */
  57655. export class TGATools {
  57656. private static _TYPE_INDEXED;
  57657. private static _TYPE_RGB;
  57658. private static _TYPE_GREY;
  57659. private static _TYPE_RLE_INDEXED;
  57660. private static _TYPE_RLE_RGB;
  57661. private static _TYPE_RLE_GREY;
  57662. private static _ORIGIN_MASK;
  57663. private static _ORIGIN_SHIFT;
  57664. private static _ORIGIN_BL;
  57665. private static _ORIGIN_BR;
  57666. private static _ORIGIN_UL;
  57667. private static _ORIGIN_UR;
  57668. /**
  57669. * Gets the header of a TGA file
  57670. * @param data defines the TGA data
  57671. * @returns the header
  57672. */
  57673. static GetTGAHeader(data: Uint8Array): any;
  57674. /**
  57675. * Uploads TGA content to a Babylon Texture
  57676. * @hidden
  57677. */
  57678. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  57679. /** @hidden */
  57680. 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;
  57681. /** @hidden */
  57682. 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;
  57683. /** @hidden */
  57684. 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;
  57685. /** @hidden */
  57686. 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;
  57687. /** @hidden */
  57688. 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;
  57689. /** @hidden */
  57690. 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;
  57691. }
  57692. }
  57693. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  57694. import { Nullable } from "babylonjs/types";
  57695. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57696. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57697. /**
  57698. * Implementation of the TGA Texture Loader.
  57699. * @hidden
  57700. */
  57701. export class _TGATextureLoader implements IInternalTextureLoader {
  57702. /**
  57703. * Defines wether the loader supports cascade loading the different faces.
  57704. */
  57705. readonly supportCascades: boolean;
  57706. /**
  57707. * This returns if the loader support the current file information.
  57708. * @param extension defines the file extension of the file being loaded
  57709. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57710. * @param fallback defines the fallback internal texture if any
  57711. * @param isBase64 defines whether the texture is encoded as a base64
  57712. * @param isBuffer defines whether the texture data are stored as a buffer
  57713. * @returns true if the loader can load the specified file
  57714. */
  57715. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57716. /**
  57717. * Transform the url before loading if required.
  57718. * @param rootUrl the url of the texture
  57719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57720. * @returns the transformed texture
  57721. */
  57722. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57723. /**
  57724. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57725. * @param rootUrl the url of the texture
  57726. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57727. * @returns the fallback texture
  57728. */
  57729. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57730. /**
  57731. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  57732. * @param data contains the texture data
  57733. * @param texture defines the BabylonJS internal texture
  57734. * @param createPolynomials will be true if polynomials have been requested
  57735. * @param onLoad defines the callback to trigger once the texture is ready
  57736. * @param onError defines the callback to trigger in case of error
  57737. */
  57738. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57739. /**
  57740. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57741. * @param data contains the texture data
  57742. * @param texture defines the BabylonJS internal texture
  57743. * @param callback defines the method to call once ready to upload
  57744. */
  57745. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57746. }
  57747. }
  57748. declare module "babylonjs/Misc/basis" {
  57749. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57750. /**
  57751. * Info about the .basis files
  57752. */
  57753. class BasisFileInfo {
  57754. /**
  57755. * If the file has alpha
  57756. */
  57757. hasAlpha: boolean;
  57758. /**
  57759. * Info about each image of the basis file
  57760. */
  57761. images: Array<{
  57762. levels: Array<{
  57763. width: number;
  57764. height: number;
  57765. transcodedPixels: ArrayBufferView;
  57766. }>;
  57767. }>;
  57768. }
  57769. /**
  57770. * Result of transcoding a basis file
  57771. */
  57772. class TranscodeResult {
  57773. /**
  57774. * Info about the .basis file
  57775. */
  57776. fileInfo: BasisFileInfo;
  57777. /**
  57778. * Format to use when loading the file
  57779. */
  57780. format: number;
  57781. }
  57782. /**
  57783. * Configuration options for the Basis transcoder
  57784. */
  57785. export class BasisTranscodeConfiguration {
  57786. /**
  57787. * Supported compression formats used to determine the supported output format of the transcoder
  57788. */
  57789. supportedCompressionFormats?: {
  57790. /**
  57791. * etc1 compression format
  57792. */
  57793. etc1?: boolean;
  57794. /**
  57795. * s3tc compression format
  57796. */
  57797. s3tc?: boolean;
  57798. /**
  57799. * pvrtc compression format
  57800. */
  57801. pvrtc?: boolean;
  57802. /**
  57803. * etc2 compression format
  57804. */
  57805. etc2?: boolean;
  57806. };
  57807. /**
  57808. * If mipmap levels should be loaded for transcoded images (Default: true)
  57809. */
  57810. loadMipmapLevels?: boolean;
  57811. /**
  57812. * Index of a single image to load (Default: all images)
  57813. */
  57814. loadSingleImage?: number;
  57815. }
  57816. /**
  57817. * Used to load .Basis files
  57818. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57819. */
  57820. export class BasisTools {
  57821. private static _IgnoreSupportedFormats;
  57822. /**
  57823. * URL to use when loading the basis transcoder
  57824. */
  57825. static JSModuleURL: string;
  57826. /**
  57827. * URL to use when loading the wasm module for the transcoder
  57828. */
  57829. static WasmModuleURL: string;
  57830. /**
  57831. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57832. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57833. * @returns internal format corresponding to the Basis format
  57834. */
  57835. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57836. private static _WorkerPromise;
  57837. private static _Worker;
  57838. private static _actionId;
  57839. private static _CreateWorkerAsync;
  57840. /**
  57841. * Transcodes a loaded image file to compressed pixel data
  57842. * @param imageData image data to transcode
  57843. * @param config configuration options for the transcoding
  57844. * @returns a promise resulting in the transcoded image
  57845. */
  57846. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57847. /**
  57848. * Loads a texture from the transcode result
  57849. * @param texture texture load to
  57850. * @param transcodeResult the result of transcoding the basis file to load from
  57851. */
  57852. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57853. }
  57854. }
  57855. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57856. import { Nullable } from "babylonjs/types";
  57857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57858. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57859. /**
  57860. * Loader for .basis file format
  57861. */
  57862. export class _BasisTextureLoader implements IInternalTextureLoader {
  57863. /**
  57864. * Defines whether the loader supports cascade loading the different faces.
  57865. */
  57866. readonly supportCascades: boolean;
  57867. /**
  57868. * This returns if the loader support the current file information.
  57869. * @param extension defines the file extension of the file being loaded
  57870. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57871. * @param fallback defines the fallback internal texture if any
  57872. * @param isBase64 defines whether the texture is encoded as a base64
  57873. * @param isBuffer defines whether the texture data are stored as a buffer
  57874. * @returns true if the loader can load the specified file
  57875. */
  57876. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57877. /**
  57878. * Transform the url before loading if required.
  57879. * @param rootUrl the url of the texture
  57880. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57881. * @returns the transformed texture
  57882. */
  57883. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57884. /**
  57885. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57886. * @param rootUrl the url of the texture
  57887. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57888. * @returns the fallback texture
  57889. */
  57890. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57891. /**
  57892. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57893. * @param data contains the texture data
  57894. * @param texture defines the BabylonJS internal texture
  57895. * @param createPolynomials will be true if polynomials have been requested
  57896. * @param onLoad defines the callback to trigger once the texture is ready
  57897. * @param onError defines the callback to trigger in case of error
  57898. */
  57899. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57900. /**
  57901. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57902. * @param data contains the texture data
  57903. * @param texture defines the BabylonJS internal texture
  57904. * @param callback defines the method to call once ready to upload
  57905. */
  57906. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57907. }
  57908. }
  57909. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57910. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57911. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57912. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57913. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57914. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57915. }
  57916. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57917. import { Scene } from "babylonjs/scene";
  57918. import { Texture } from "babylonjs/Materials/Textures/texture";
  57919. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57920. /**
  57921. * 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.
  57922. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57923. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57924. */
  57925. export class CustomProceduralTexture extends ProceduralTexture {
  57926. private _animate;
  57927. private _time;
  57928. private _config;
  57929. private _texturePath;
  57930. /**
  57931. * Instantiates a new Custom Procedural Texture.
  57932. * 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.
  57933. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57934. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57935. * @param name Define the name of the texture
  57936. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57937. * @param size Define the size of the texture to create
  57938. * @param scene Define the scene the texture belongs to
  57939. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57940. * @param generateMipMaps Define if the texture should creates mip maps or not
  57941. */
  57942. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57943. private _loadJson;
  57944. /**
  57945. * Is the texture ready to be used ? (rendered at least once)
  57946. * @returns true if ready, otherwise, false.
  57947. */
  57948. isReady(): boolean;
  57949. /**
  57950. * Render the texture to its associated render target.
  57951. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57952. */
  57953. render(useCameraPostProcess?: boolean): void;
  57954. /**
  57955. * Update the list of dependant textures samplers in the shader.
  57956. */
  57957. updateTextures(): void;
  57958. /**
  57959. * Update the uniform values of the procedural texture in the shader.
  57960. */
  57961. updateShaderUniforms(): void;
  57962. /**
  57963. * Define if the texture animates or not.
  57964. */
  57965. get animate(): boolean;
  57966. set animate(value: boolean);
  57967. }
  57968. }
  57969. declare module "babylonjs/Shaders/noise.fragment" {
  57970. /** @hidden */
  57971. export var noisePixelShader: {
  57972. name: string;
  57973. shader: string;
  57974. };
  57975. }
  57976. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57977. import { Nullable } from "babylonjs/types";
  57978. import { Scene } from "babylonjs/scene";
  57979. import { Texture } from "babylonjs/Materials/Textures/texture";
  57980. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57981. import "babylonjs/Shaders/noise.fragment";
  57982. /**
  57983. * Class used to generate noise procedural textures
  57984. */
  57985. export class NoiseProceduralTexture extends ProceduralTexture {
  57986. private _time;
  57987. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57988. brightness: number;
  57989. /** Defines the number of octaves to process */
  57990. octaves: number;
  57991. /** Defines the level of persistence (0.8 by default) */
  57992. persistence: number;
  57993. /** Gets or sets animation speed factor (default is 1) */
  57994. animationSpeedFactor: number;
  57995. /**
  57996. * Creates a new NoiseProceduralTexture
  57997. * @param name defines the name fo the texture
  57998. * @param size defines the size of the texture (default is 256)
  57999. * @param scene defines the hosting scene
  58000. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58001. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58002. */
  58003. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58004. private _updateShaderUniforms;
  58005. protected _getDefines(): string;
  58006. /** Generate the current state of the procedural texture */
  58007. render(useCameraPostProcess?: boolean): void;
  58008. /**
  58009. * Serializes this noise procedural texture
  58010. * @returns a serialized noise procedural texture object
  58011. */
  58012. serialize(): any;
  58013. /**
  58014. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58015. * @param parsedTexture defines parsed texture data
  58016. * @param scene defines the current scene
  58017. * @param rootUrl defines the root URL containing noise procedural texture information
  58018. * @returns a parsed NoiseProceduralTexture
  58019. */
  58020. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58021. }
  58022. }
  58023. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58024. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58025. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58026. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58027. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58028. }
  58029. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58030. import { Nullable } from "babylonjs/types";
  58031. import { Scene } from "babylonjs/scene";
  58032. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58033. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58034. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58035. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58036. /**
  58037. * Raw cube texture where the raw buffers are passed in
  58038. */
  58039. export class RawCubeTexture extends CubeTexture {
  58040. /**
  58041. * Creates a cube texture where the raw buffers are passed in.
  58042. * @param scene defines the scene the texture is attached to
  58043. * @param data defines the array of data to use to create each face
  58044. * @param size defines the size of the textures
  58045. * @param format defines the format of the data
  58046. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58047. * @param generateMipMaps defines if the engine should generate the mip levels
  58048. * @param invertY defines if data must be stored with Y axis inverted
  58049. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58050. * @param compression defines the compression used (null by default)
  58051. */
  58052. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58053. /**
  58054. * Updates the raw cube texture.
  58055. * @param data defines the data to store
  58056. * @param format defines the data format
  58057. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58058. * @param invertY defines if data must be stored with Y axis inverted
  58059. * @param compression defines the compression used (null by default)
  58060. * @param level defines which level of the texture to update
  58061. */
  58062. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58063. /**
  58064. * Updates a raw cube texture with RGBD encoded data.
  58065. * @param data defines the array of data [mipmap][face] to use to create each face
  58066. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58067. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58068. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58069. * @returns a promsie that resolves when the operation is complete
  58070. */
  58071. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58072. /**
  58073. * Clones the raw cube texture.
  58074. * @return a new cube texture
  58075. */
  58076. clone(): CubeTexture;
  58077. /** @hidden */
  58078. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58079. }
  58080. }
  58081. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58082. import { Scene } from "babylonjs/scene";
  58083. import { Texture } from "babylonjs/Materials/Textures/texture";
  58084. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58085. /**
  58086. * Class used to store 3D textures containing user data
  58087. */
  58088. export class RawTexture3D extends Texture {
  58089. /** Gets or sets the texture format to use */
  58090. format: number;
  58091. private _engine;
  58092. /**
  58093. * Create a new RawTexture3D
  58094. * @param data defines the data of the texture
  58095. * @param width defines the width of the texture
  58096. * @param height defines the height of the texture
  58097. * @param depth defines the depth of the texture
  58098. * @param format defines the texture format to use
  58099. * @param scene defines the hosting scene
  58100. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58101. * @param invertY defines if texture must be stored with Y axis inverted
  58102. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58103. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58104. */
  58105. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58106. /** Gets or sets the texture format to use */
  58107. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58108. /**
  58109. * Update the texture with new data
  58110. * @param data defines the data to store in the texture
  58111. */
  58112. update(data: ArrayBufferView): void;
  58113. }
  58114. }
  58115. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58116. import { Scene } from "babylonjs/scene";
  58117. import { Texture } from "babylonjs/Materials/Textures/texture";
  58118. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58119. /**
  58120. * Class used to store 2D array textures containing user data
  58121. */
  58122. export class RawTexture2DArray extends Texture {
  58123. /** Gets or sets the texture format to use */
  58124. format: number;
  58125. private _engine;
  58126. /**
  58127. * Create a new RawTexture2DArray
  58128. * @param data defines the data of the texture
  58129. * @param width defines the width of the texture
  58130. * @param height defines the height of the texture
  58131. * @param depth defines the number of layers of the texture
  58132. * @param format defines the texture format to use
  58133. * @param scene defines the hosting scene
  58134. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58135. * @param invertY defines if texture must be stored with Y axis inverted
  58136. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58137. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58138. */
  58139. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58140. /** Gets or sets the texture format to use */
  58141. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58142. /**
  58143. * Update the texture with new data
  58144. * @param data defines the data to store in the texture
  58145. */
  58146. update(data: ArrayBufferView): void;
  58147. }
  58148. }
  58149. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58150. import { Scene } from "babylonjs/scene";
  58151. import { Plane } from "babylonjs/Maths/math.plane";
  58152. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58153. /**
  58154. * Creates a refraction texture used by refraction channel of the standard material.
  58155. * It is like a mirror but to see through a material.
  58156. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58157. */
  58158. export class RefractionTexture extends RenderTargetTexture {
  58159. /**
  58160. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58161. * 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.
  58162. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58163. */
  58164. refractionPlane: Plane;
  58165. /**
  58166. * Define how deep under the surface we should see.
  58167. */
  58168. depth: number;
  58169. /**
  58170. * Creates a refraction texture used by refraction channel of the standard material.
  58171. * It is like a mirror but to see through a material.
  58172. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58173. * @param name Define the texture name
  58174. * @param size Define the size of the underlying texture
  58175. * @param scene Define the scene the refraction belongs to
  58176. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58177. */
  58178. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58179. /**
  58180. * Clone the refraction texture.
  58181. * @returns the cloned texture
  58182. */
  58183. clone(): RefractionTexture;
  58184. /**
  58185. * Serialize the texture to a JSON representation you could use in Parse later on
  58186. * @returns the serialized JSON representation
  58187. */
  58188. serialize(): any;
  58189. }
  58190. }
  58191. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58192. import { Nullable } from "babylonjs/types";
  58193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58194. import { Matrix } from "babylonjs/Maths/math.vector";
  58195. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58196. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58197. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58198. import { Scene } from "babylonjs/scene";
  58199. /**
  58200. * Defines the options related to the creation of an HtmlElementTexture
  58201. */
  58202. export interface IHtmlElementTextureOptions {
  58203. /**
  58204. * Defines wether mip maps should be created or not.
  58205. */
  58206. generateMipMaps?: boolean;
  58207. /**
  58208. * Defines the sampling mode of the texture.
  58209. */
  58210. samplingMode?: number;
  58211. /**
  58212. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58213. */
  58214. engine: Nullable<ThinEngine>;
  58215. /**
  58216. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58217. */
  58218. scene: Nullable<Scene>;
  58219. }
  58220. /**
  58221. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58222. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58223. * is automatically managed.
  58224. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58225. * in your application.
  58226. *
  58227. * As the update is not automatic, you need to call them manually.
  58228. */
  58229. export class HtmlElementTexture extends BaseTexture {
  58230. /**
  58231. * The texture URL.
  58232. */
  58233. element: HTMLVideoElement | HTMLCanvasElement;
  58234. private static readonly DefaultOptions;
  58235. private _textureMatrix;
  58236. private _engine;
  58237. private _isVideo;
  58238. private _generateMipMaps;
  58239. private _samplingMode;
  58240. /**
  58241. * Instantiates a HtmlElementTexture from the following parameters.
  58242. *
  58243. * @param name Defines the name of the texture
  58244. * @param element Defines the video or canvas the texture is filled with
  58245. * @param options Defines the other none mandatory texture creation options
  58246. */
  58247. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58248. private _createInternalTexture;
  58249. /**
  58250. * Returns the texture matrix used in most of the material.
  58251. */
  58252. getTextureMatrix(): Matrix;
  58253. /**
  58254. * Updates the content of the texture.
  58255. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58256. */
  58257. update(invertY?: Nullable<boolean>): void;
  58258. }
  58259. }
  58260. declare module "babylonjs/Materials/Textures/index" {
  58261. export * from "babylonjs/Materials/Textures/baseTexture";
  58262. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  58263. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  58264. export * from "babylonjs/Materials/Textures/cubeTexture";
  58265. export * from "babylonjs/Materials/Textures/dynamicTexture";
  58266. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  58267. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  58268. export * from "babylonjs/Materials/Textures/internalTexture";
  58269. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  58270. export * from "babylonjs/Materials/Textures/Loaders/index";
  58271. export * from "babylonjs/Materials/Textures/mirrorTexture";
  58272. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  58273. export * from "babylonjs/Materials/Textures/Procedurals/index";
  58274. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  58275. export * from "babylonjs/Materials/Textures/rawTexture";
  58276. export * from "babylonjs/Materials/Textures/rawTexture3D";
  58277. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  58278. export * from "babylonjs/Materials/Textures/refractionTexture";
  58279. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  58280. export * from "babylonjs/Materials/Textures/texture";
  58281. export * from "babylonjs/Materials/Textures/videoTexture";
  58282. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  58283. }
  58284. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  58285. /**
  58286. * Enum used to define the target of a block
  58287. */
  58288. export enum NodeMaterialBlockTargets {
  58289. /** Vertex shader */
  58290. Vertex = 1,
  58291. /** Fragment shader */
  58292. Fragment = 2,
  58293. /** Neutral */
  58294. Neutral = 4,
  58295. /** Vertex and Fragment */
  58296. VertexAndFragment = 3
  58297. }
  58298. }
  58299. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  58300. /**
  58301. * Defines the kind of connection point for node based material
  58302. */
  58303. export enum NodeMaterialBlockConnectionPointTypes {
  58304. /** Float */
  58305. Float = 1,
  58306. /** Int */
  58307. Int = 2,
  58308. /** Vector2 */
  58309. Vector2 = 4,
  58310. /** Vector3 */
  58311. Vector3 = 8,
  58312. /** Vector4 */
  58313. Vector4 = 16,
  58314. /** Color3 */
  58315. Color3 = 32,
  58316. /** Color4 */
  58317. Color4 = 64,
  58318. /** Matrix */
  58319. Matrix = 128,
  58320. /** Detect type based on connection */
  58321. AutoDetect = 1024,
  58322. /** Output type that will be defined by input type */
  58323. BasedOnInput = 2048
  58324. }
  58325. }
  58326. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  58327. /**
  58328. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  58329. */
  58330. export enum NodeMaterialBlockConnectionPointMode {
  58331. /** Value is an uniform */
  58332. Uniform = 0,
  58333. /** Value is a mesh attribute */
  58334. Attribute = 1,
  58335. /** Value is a varying between vertex and fragment shaders */
  58336. Varying = 2,
  58337. /** Mode is undefined */
  58338. Undefined = 3
  58339. }
  58340. }
  58341. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  58342. /**
  58343. * Enum used to define system values e.g. values automatically provided by the system
  58344. */
  58345. export enum NodeMaterialSystemValues {
  58346. /** World */
  58347. World = 1,
  58348. /** View */
  58349. View = 2,
  58350. /** Projection */
  58351. Projection = 3,
  58352. /** ViewProjection */
  58353. ViewProjection = 4,
  58354. /** WorldView */
  58355. WorldView = 5,
  58356. /** WorldViewProjection */
  58357. WorldViewProjection = 6,
  58358. /** CameraPosition */
  58359. CameraPosition = 7,
  58360. /** Fog Color */
  58361. FogColor = 8,
  58362. /** Delta time */
  58363. DeltaTime = 9
  58364. }
  58365. }
  58366. declare module "babylonjs/Materials/Node/Enums/index" {
  58367. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58368. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58369. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  58370. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58371. }
  58372. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  58373. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58374. /**
  58375. * Root class for all node material optimizers
  58376. */
  58377. export class NodeMaterialOptimizer {
  58378. /**
  58379. * Function used to optimize a NodeMaterial graph
  58380. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  58381. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  58382. */
  58383. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  58384. }
  58385. }
  58386. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  58387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58390. import { Scene } from "babylonjs/scene";
  58391. /**
  58392. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  58393. */
  58394. export class TransformBlock extends NodeMaterialBlock {
  58395. /**
  58396. * Defines the value to use to complement W value to transform it to a Vector4
  58397. */
  58398. complementW: number;
  58399. /**
  58400. * Defines the value to use to complement z value to transform it to a Vector4
  58401. */
  58402. complementZ: number;
  58403. /**
  58404. * Creates a new TransformBlock
  58405. * @param name defines the block name
  58406. */
  58407. constructor(name: string);
  58408. /**
  58409. * Gets the current class name
  58410. * @returns the class name
  58411. */
  58412. getClassName(): string;
  58413. /**
  58414. * Gets the vector input
  58415. */
  58416. get vector(): NodeMaterialConnectionPoint;
  58417. /**
  58418. * Gets the output component
  58419. */
  58420. get output(): NodeMaterialConnectionPoint;
  58421. /**
  58422. * Gets the matrix transform input
  58423. */
  58424. get transform(): NodeMaterialConnectionPoint;
  58425. protected _buildBlock(state: NodeMaterialBuildState): this;
  58426. serialize(): any;
  58427. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58428. protected _dumpPropertiesCode(): string;
  58429. }
  58430. }
  58431. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  58432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58435. /**
  58436. * Block used to output the vertex position
  58437. */
  58438. export class VertexOutputBlock extends NodeMaterialBlock {
  58439. /**
  58440. * Creates a new VertexOutputBlock
  58441. * @param name defines the block name
  58442. */
  58443. constructor(name: string);
  58444. /**
  58445. * Gets the current class name
  58446. * @returns the class name
  58447. */
  58448. getClassName(): string;
  58449. /**
  58450. * Gets the vector input component
  58451. */
  58452. get vector(): NodeMaterialConnectionPoint;
  58453. protected _buildBlock(state: NodeMaterialBuildState): this;
  58454. }
  58455. }
  58456. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  58457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58460. /**
  58461. * Block used to output the final color
  58462. */
  58463. export class FragmentOutputBlock extends NodeMaterialBlock {
  58464. /**
  58465. * Create a new FragmentOutputBlock
  58466. * @param name defines the block name
  58467. */
  58468. constructor(name: string);
  58469. /**
  58470. * Gets the current class name
  58471. * @returns the class name
  58472. */
  58473. getClassName(): string;
  58474. /**
  58475. * Gets the rgba input component
  58476. */
  58477. get rgba(): NodeMaterialConnectionPoint;
  58478. /**
  58479. * Gets the rgb input component
  58480. */
  58481. get rgb(): NodeMaterialConnectionPoint;
  58482. /**
  58483. * Gets the a input component
  58484. */
  58485. get a(): NodeMaterialConnectionPoint;
  58486. protected _buildBlock(state: NodeMaterialBuildState): this;
  58487. }
  58488. }
  58489. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  58490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58493. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58495. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58496. import { Effect } from "babylonjs/Materials/effect";
  58497. import { Mesh } from "babylonjs/Meshes/mesh";
  58498. import { Nullable } from "babylonjs/types";
  58499. import { Scene } from "babylonjs/scene";
  58500. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58501. /**
  58502. * Block used to read a reflection texture from a sampler
  58503. */
  58504. export class ReflectionTextureBlock extends NodeMaterialBlock {
  58505. private _define3DName;
  58506. private _defineCubicName;
  58507. private _defineExplicitName;
  58508. private _defineProjectionName;
  58509. private _defineLocalCubicName;
  58510. private _defineSphericalName;
  58511. private _definePlanarName;
  58512. private _defineEquirectangularName;
  58513. private _defineMirroredEquirectangularFixedName;
  58514. private _defineEquirectangularFixedName;
  58515. private _defineSkyboxName;
  58516. private _cubeSamplerName;
  58517. private _2DSamplerName;
  58518. private _positionUVWName;
  58519. private _directionWName;
  58520. private _reflectionCoordsName;
  58521. private _reflection2DCoordsName;
  58522. private _reflectionColorName;
  58523. private _reflectionMatrixName;
  58524. /**
  58525. * Gets or sets the texture associated with the node
  58526. */
  58527. texture: Nullable<BaseTexture>;
  58528. /**
  58529. * Create a new TextureBlock
  58530. * @param name defines the block name
  58531. */
  58532. constructor(name: string);
  58533. /**
  58534. * Gets the current class name
  58535. * @returns the class name
  58536. */
  58537. getClassName(): string;
  58538. /**
  58539. * Gets the world position input component
  58540. */
  58541. get position(): NodeMaterialConnectionPoint;
  58542. /**
  58543. * Gets the world position input component
  58544. */
  58545. get worldPosition(): NodeMaterialConnectionPoint;
  58546. /**
  58547. * Gets the world normal input component
  58548. */
  58549. get worldNormal(): NodeMaterialConnectionPoint;
  58550. /**
  58551. * Gets the world input component
  58552. */
  58553. get world(): NodeMaterialConnectionPoint;
  58554. /**
  58555. * Gets the camera (or eye) position component
  58556. */
  58557. get cameraPosition(): NodeMaterialConnectionPoint;
  58558. /**
  58559. * Gets the view input component
  58560. */
  58561. get view(): NodeMaterialConnectionPoint;
  58562. /**
  58563. * Gets the rgb output component
  58564. */
  58565. get rgb(): NodeMaterialConnectionPoint;
  58566. /**
  58567. * Gets the r output component
  58568. */
  58569. get r(): NodeMaterialConnectionPoint;
  58570. /**
  58571. * Gets the g output component
  58572. */
  58573. get g(): NodeMaterialConnectionPoint;
  58574. /**
  58575. * Gets the b output component
  58576. */
  58577. get b(): NodeMaterialConnectionPoint;
  58578. autoConfigure(material: NodeMaterial): void;
  58579. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58580. isReady(): boolean;
  58581. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58582. private _injectVertexCode;
  58583. private _writeOutput;
  58584. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58585. protected _dumpPropertiesCode(): string;
  58586. serialize(): any;
  58587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58588. }
  58589. }
  58590. declare module "babylonjs/Materials/Node/nodeMaterial" {
  58591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58592. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58593. import { Scene } from "babylonjs/scene";
  58594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58595. import { Matrix } from "babylonjs/Maths/math.vector";
  58596. import { Mesh } from "babylonjs/Meshes/mesh";
  58597. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58598. import { Observable } from "babylonjs/Misc/observable";
  58599. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58600. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58601. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58602. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58603. import { Nullable } from "babylonjs/types";
  58604. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58605. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58606. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58607. /**
  58608. * Interface used to configure the node material editor
  58609. */
  58610. export interface INodeMaterialEditorOptions {
  58611. /** Define the URl to load node editor script */
  58612. editorURL?: string;
  58613. }
  58614. /** @hidden */
  58615. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  58616. /** BONES */
  58617. NUM_BONE_INFLUENCERS: number;
  58618. BonesPerMesh: number;
  58619. BONETEXTURE: boolean;
  58620. /** MORPH TARGETS */
  58621. MORPHTARGETS: boolean;
  58622. MORPHTARGETS_NORMAL: boolean;
  58623. MORPHTARGETS_TANGENT: boolean;
  58624. MORPHTARGETS_UV: boolean;
  58625. NUM_MORPH_INFLUENCERS: number;
  58626. /** IMAGE PROCESSING */
  58627. IMAGEPROCESSING: boolean;
  58628. VIGNETTE: boolean;
  58629. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58630. VIGNETTEBLENDMODEOPAQUE: boolean;
  58631. TONEMAPPING: boolean;
  58632. TONEMAPPING_ACES: boolean;
  58633. CONTRAST: boolean;
  58634. EXPOSURE: boolean;
  58635. COLORCURVES: boolean;
  58636. COLORGRADING: boolean;
  58637. COLORGRADING3D: boolean;
  58638. SAMPLER3DGREENDEPTH: boolean;
  58639. SAMPLER3DBGRMAP: boolean;
  58640. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58641. /** MISC. */
  58642. BUMPDIRECTUV: number;
  58643. constructor();
  58644. setValue(name: string, value: boolean): void;
  58645. }
  58646. /**
  58647. * Class used to configure NodeMaterial
  58648. */
  58649. export interface INodeMaterialOptions {
  58650. /**
  58651. * Defines if blocks should emit comments
  58652. */
  58653. emitComments: boolean;
  58654. }
  58655. /**
  58656. * Class used to create a node based material built by assembling shader blocks
  58657. */
  58658. export class NodeMaterial extends PushMaterial {
  58659. private static _BuildIdGenerator;
  58660. private _options;
  58661. private _vertexCompilationState;
  58662. private _fragmentCompilationState;
  58663. private _sharedData;
  58664. private _buildId;
  58665. private _buildWasSuccessful;
  58666. private _cachedWorldViewMatrix;
  58667. private _cachedWorldViewProjectionMatrix;
  58668. private _optimizers;
  58669. private _animationFrame;
  58670. /** Define the URl to load node editor script */
  58671. static EditorURL: string;
  58672. private BJSNODEMATERIALEDITOR;
  58673. /** Get the inspector from bundle or global */
  58674. private _getGlobalNodeMaterialEditor;
  58675. /**
  58676. * Gets or sets data used by visual editor
  58677. * @see https://nme.babylonjs.com
  58678. */
  58679. editorData: any;
  58680. /**
  58681. * 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)
  58682. */
  58683. ignoreAlpha: boolean;
  58684. /**
  58685. * Defines the maximum number of lights that can be used in the material
  58686. */
  58687. maxSimultaneousLights: number;
  58688. /**
  58689. * Observable raised when the material is built
  58690. */
  58691. onBuildObservable: Observable<NodeMaterial>;
  58692. /**
  58693. * Gets or sets the root nodes of the material vertex shader
  58694. */
  58695. _vertexOutputNodes: NodeMaterialBlock[];
  58696. /**
  58697. * Gets or sets the root nodes of the material fragment (pixel) shader
  58698. */
  58699. _fragmentOutputNodes: NodeMaterialBlock[];
  58700. /** Gets or sets options to control the node material overall behavior */
  58701. get options(): INodeMaterialOptions;
  58702. set options(options: INodeMaterialOptions);
  58703. /**
  58704. * Default configuration related to image processing available in the standard Material.
  58705. */
  58706. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58707. /**
  58708. * Gets the image processing configuration used either in this material.
  58709. */
  58710. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58711. /**
  58712. * Sets the Default image processing configuration used either in the this material.
  58713. *
  58714. * If sets to null, the scene one is in use.
  58715. */
  58716. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58717. /**
  58718. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58719. */
  58720. attachedBlocks: NodeMaterialBlock[];
  58721. /**
  58722. * Create a new node based material
  58723. * @param name defines the material name
  58724. * @param scene defines the hosting scene
  58725. * @param options defines creation option
  58726. */
  58727. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58728. /**
  58729. * Gets the current class name of the material e.g. "NodeMaterial"
  58730. * @returns the class name
  58731. */
  58732. getClassName(): string;
  58733. /**
  58734. * Keep track of the image processing observer to allow dispose and replace.
  58735. */
  58736. private _imageProcessingObserver;
  58737. /**
  58738. * Attaches a new image processing configuration to the Standard Material.
  58739. * @param configuration
  58740. */
  58741. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58742. /**
  58743. * Get a block by its name
  58744. * @param name defines the name of the block to retrieve
  58745. * @returns the required block or null if not found
  58746. */
  58747. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58748. /**
  58749. * Get a block by its name
  58750. * @param predicate defines the predicate used to find the good candidate
  58751. * @returns the required block or null if not found
  58752. */
  58753. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58754. /**
  58755. * Get an input block by its name
  58756. * @param predicate defines the predicate used to find the good candidate
  58757. * @returns the required input block or null if not found
  58758. */
  58759. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58760. /**
  58761. * Gets the list of input blocks attached to this material
  58762. * @returns an array of InputBlocks
  58763. */
  58764. getInputBlocks(): InputBlock[];
  58765. /**
  58766. * Adds a new optimizer to the list of optimizers
  58767. * @param optimizer defines the optimizers to add
  58768. * @returns the current material
  58769. */
  58770. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58771. /**
  58772. * Remove an optimizer from the list of optimizers
  58773. * @param optimizer defines the optimizers to remove
  58774. * @returns the current material
  58775. */
  58776. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58777. /**
  58778. * Add a new block to the list of output nodes
  58779. * @param node defines the node to add
  58780. * @returns the current material
  58781. */
  58782. addOutputNode(node: NodeMaterialBlock): this;
  58783. /**
  58784. * Remove a block from the list of root nodes
  58785. * @param node defines the node to remove
  58786. * @returns the current material
  58787. */
  58788. removeOutputNode(node: NodeMaterialBlock): this;
  58789. private _addVertexOutputNode;
  58790. private _removeVertexOutputNode;
  58791. private _addFragmentOutputNode;
  58792. private _removeFragmentOutputNode;
  58793. /**
  58794. * Specifies if the material will require alpha blending
  58795. * @returns a boolean specifying if alpha blending is needed
  58796. */
  58797. needAlphaBlending(): boolean;
  58798. /**
  58799. * Specifies if this material should be rendered in alpha test mode
  58800. * @returns a boolean specifying if an alpha test is needed.
  58801. */
  58802. needAlphaTesting(): boolean;
  58803. private _initializeBlock;
  58804. private _resetDualBlocks;
  58805. /**
  58806. * Remove a block from the current node material
  58807. * @param block defines the block to remove
  58808. */
  58809. removeBlock(block: NodeMaterialBlock): void;
  58810. /**
  58811. * Build the material and generates the inner effect
  58812. * @param verbose defines if the build should log activity
  58813. */
  58814. build(verbose?: boolean): void;
  58815. /**
  58816. * Runs an otpimization phase to try to improve the shader code
  58817. */
  58818. optimize(): void;
  58819. private _prepareDefinesForAttributes;
  58820. /**
  58821. * Get if the submesh is ready to be used and all its information available.
  58822. * Child classes can use it to update shaders
  58823. * @param mesh defines the mesh to check
  58824. * @param subMesh defines which submesh to check
  58825. * @param useInstances specifies that instances should be used
  58826. * @returns a boolean indicating that the submesh is ready or not
  58827. */
  58828. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58829. /**
  58830. * Get a string representing the shaders built by the current node graph
  58831. */
  58832. get compiledShaders(): string;
  58833. /**
  58834. * Binds the world matrix to the material
  58835. * @param world defines the world transformation matrix
  58836. */
  58837. bindOnlyWorldMatrix(world: Matrix): void;
  58838. /**
  58839. * Binds the submesh to this material by preparing the effect and shader to draw
  58840. * @param world defines the world transformation matrix
  58841. * @param mesh defines the mesh containing the submesh
  58842. * @param subMesh defines the submesh to bind the material to
  58843. */
  58844. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58845. /**
  58846. * Gets the active textures from the material
  58847. * @returns an array of textures
  58848. */
  58849. getActiveTextures(): BaseTexture[];
  58850. /**
  58851. * Gets the list of texture blocks
  58852. * @returns an array of texture blocks
  58853. */
  58854. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58855. /**
  58856. * Specifies if the material uses a texture
  58857. * @param texture defines the texture to check against the material
  58858. * @returns a boolean specifying if the material uses the texture
  58859. */
  58860. hasTexture(texture: BaseTexture): boolean;
  58861. /**
  58862. * Disposes the material
  58863. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58864. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58865. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58866. */
  58867. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58868. /** Creates the node editor window. */
  58869. private _createNodeEditor;
  58870. /**
  58871. * Launch the node material editor
  58872. * @param config Define the configuration of the editor
  58873. * @return a promise fulfilled when the node editor is visible
  58874. */
  58875. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58876. /**
  58877. * Clear the current material
  58878. */
  58879. clear(): void;
  58880. /**
  58881. * Clear the current material and set it to a default state
  58882. */
  58883. setToDefault(): void;
  58884. /**
  58885. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58886. * @param url defines the url to load from
  58887. * @returns a promise that will fullfil when the material is fully loaded
  58888. */
  58889. loadAsync(url: string): Promise<void>;
  58890. private _gatherBlocks;
  58891. /**
  58892. * Generate a string containing the code declaration required to create an equivalent of this material
  58893. * @returns a string
  58894. */
  58895. generateCode(): string;
  58896. /**
  58897. * Serializes this material in a JSON representation
  58898. * @returns the serialized material object
  58899. */
  58900. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58901. private _restoreConnections;
  58902. /**
  58903. * Clear the current graph and load a new one from a serialization object
  58904. * @param source defines the JSON representation of the material
  58905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58906. */
  58907. loadFromSerialization(source: any, rootUrl?: string): void;
  58908. /**
  58909. * Creates a node material from parsed material data
  58910. * @param source defines the JSON representation of the material
  58911. * @param scene defines the hosting scene
  58912. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58913. * @returns a new node material
  58914. */
  58915. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58916. /**
  58917. * Creates a new node material set to default basic configuration
  58918. * @param name defines the name of the material
  58919. * @param scene defines the hosting scene
  58920. * @returns a new NodeMaterial
  58921. */
  58922. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58923. }
  58924. }
  58925. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58928. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58931. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58932. import { Effect } from "babylonjs/Materials/effect";
  58933. import { Mesh } from "babylonjs/Meshes/mesh";
  58934. import { Nullable } from "babylonjs/types";
  58935. import { Texture } from "babylonjs/Materials/Textures/texture";
  58936. import { Scene } from "babylonjs/scene";
  58937. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58938. /**
  58939. * Block used to read a texture from a sampler
  58940. */
  58941. export class TextureBlock extends NodeMaterialBlock {
  58942. private _defineName;
  58943. private _linearDefineName;
  58944. private _tempTextureRead;
  58945. private _samplerName;
  58946. private _transformedUVName;
  58947. private _textureTransformName;
  58948. private _textureInfoName;
  58949. private _mainUVName;
  58950. private _mainUVDefineName;
  58951. /**
  58952. * Gets or sets the texture associated with the node
  58953. */
  58954. texture: Nullable<Texture>;
  58955. /**
  58956. * Create a new TextureBlock
  58957. * @param name defines the block name
  58958. */
  58959. constructor(name: string);
  58960. /**
  58961. * Gets the current class name
  58962. * @returns the class name
  58963. */
  58964. getClassName(): string;
  58965. /**
  58966. * Gets the uv input component
  58967. */
  58968. get uv(): NodeMaterialConnectionPoint;
  58969. /**
  58970. * Gets the rgba output component
  58971. */
  58972. get rgba(): NodeMaterialConnectionPoint;
  58973. /**
  58974. * Gets the rgb output component
  58975. */
  58976. get rgb(): NodeMaterialConnectionPoint;
  58977. /**
  58978. * Gets the r output component
  58979. */
  58980. get r(): NodeMaterialConnectionPoint;
  58981. /**
  58982. * Gets the g output component
  58983. */
  58984. get g(): NodeMaterialConnectionPoint;
  58985. /**
  58986. * Gets the b output component
  58987. */
  58988. get b(): NodeMaterialConnectionPoint;
  58989. /**
  58990. * Gets the a output component
  58991. */
  58992. get a(): NodeMaterialConnectionPoint;
  58993. get target(): NodeMaterialBlockTargets;
  58994. autoConfigure(material: NodeMaterial): void;
  58995. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58997. private _getTextureBase;
  58998. isReady(): boolean;
  58999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59000. private get _isMixed();
  59001. private _injectVertexCode;
  59002. private _writeTextureRead;
  59003. private _writeOutput;
  59004. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59005. protected _dumpPropertiesCode(): string;
  59006. serialize(): any;
  59007. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59008. }
  59009. }
  59010. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  59011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59013. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59014. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59015. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59016. import { Scene } from "babylonjs/scene";
  59017. /**
  59018. * Class used to store shared data between 2 NodeMaterialBuildState
  59019. */
  59020. export class NodeMaterialBuildStateSharedData {
  59021. /**
  59022. * Gets the list of emitted varyings
  59023. */
  59024. temps: string[];
  59025. /**
  59026. * Gets the list of emitted varyings
  59027. */
  59028. varyings: string[];
  59029. /**
  59030. * Gets the varying declaration string
  59031. */
  59032. varyingDeclaration: string;
  59033. /**
  59034. * Input blocks
  59035. */
  59036. inputBlocks: InputBlock[];
  59037. /**
  59038. * Input blocks
  59039. */
  59040. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  59041. /**
  59042. * Bindable blocks (Blocks that need to set data to the effect)
  59043. */
  59044. bindableBlocks: NodeMaterialBlock[];
  59045. /**
  59046. * List of blocks that can provide a compilation fallback
  59047. */
  59048. blocksWithFallbacks: NodeMaterialBlock[];
  59049. /**
  59050. * List of blocks that can provide a define update
  59051. */
  59052. blocksWithDefines: NodeMaterialBlock[];
  59053. /**
  59054. * List of blocks that can provide a repeatable content
  59055. */
  59056. repeatableContentBlocks: NodeMaterialBlock[];
  59057. /**
  59058. * List of blocks that can provide a dynamic list of uniforms
  59059. */
  59060. dynamicUniformBlocks: NodeMaterialBlock[];
  59061. /**
  59062. * List of blocks that can block the isReady function for the material
  59063. */
  59064. blockingBlocks: NodeMaterialBlock[];
  59065. /**
  59066. * Gets the list of animated inputs
  59067. */
  59068. animatedInputs: InputBlock[];
  59069. /**
  59070. * Build Id used to avoid multiple recompilations
  59071. */
  59072. buildId: number;
  59073. /** List of emitted variables */
  59074. variableNames: {
  59075. [key: string]: number;
  59076. };
  59077. /** List of emitted defines */
  59078. defineNames: {
  59079. [key: string]: number;
  59080. };
  59081. /** Should emit comments? */
  59082. emitComments: boolean;
  59083. /** Emit build activity */
  59084. verbose: boolean;
  59085. /** Gets or sets the hosting scene */
  59086. scene: Scene;
  59087. /**
  59088. * Gets the compilation hints emitted at compilation time
  59089. */
  59090. hints: {
  59091. needWorldViewMatrix: boolean;
  59092. needWorldViewProjectionMatrix: boolean;
  59093. needAlphaBlending: boolean;
  59094. needAlphaTesting: boolean;
  59095. };
  59096. /**
  59097. * List of compilation checks
  59098. */
  59099. checks: {
  59100. emitVertex: boolean;
  59101. emitFragment: boolean;
  59102. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  59103. };
  59104. /** Creates a new shared data */
  59105. constructor();
  59106. /**
  59107. * Emits console errors and exceptions if there is a failing check
  59108. */
  59109. emitErrors(): void;
  59110. }
  59111. }
  59112. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  59113. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59114. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59115. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  59116. /**
  59117. * Class used to store node based material build state
  59118. */
  59119. export class NodeMaterialBuildState {
  59120. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  59121. supportUniformBuffers: boolean;
  59122. /**
  59123. * Gets the list of emitted attributes
  59124. */
  59125. attributes: string[];
  59126. /**
  59127. * Gets the list of emitted uniforms
  59128. */
  59129. uniforms: string[];
  59130. /**
  59131. * Gets the list of emitted constants
  59132. */
  59133. constants: string[];
  59134. /**
  59135. * Gets the list of emitted samplers
  59136. */
  59137. samplers: string[];
  59138. /**
  59139. * Gets the list of emitted functions
  59140. */
  59141. functions: {
  59142. [key: string]: string;
  59143. };
  59144. /**
  59145. * Gets the list of emitted extensions
  59146. */
  59147. extensions: {
  59148. [key: string]: string;
  59149. };
  59150. /**
  59151. * Gets the target of the compilation state
  59152. */
  59153. target: NodeMaterialBlockTargets;
  59154. /**
  59155. * Gets the list of emitted counters
  59156. */
  59157. counters: {
  59158. [key: string]: number;
  59159. };
  59160. /**
  59161. * Shared data between multiple NodeMaterialBuildState instances
  59162. */
  59163. sharedData: NodeMaterialBuildStateSharedData;
  59164. /** @hidden */
  59165. _vertexState: NodeMaterialBuildState;
  59166. /** @hidden */
  59167. _attributeDeclaration: string;
  59168. /** @hidden */
  59169. _uniformDeclaration: string;
  59170. /** @hidden */
  59171. _constantDeclaration: string;
  59172. /** @hidden */
  59173. _samplerDeclaration: string;
  59174. /** @hidden */
  59175. _varyingTransfer: string;
  59176. private _repeatableContentAnchorIndex;
  59177. /** @hidden */
  59178. _builtCompilationString: string;
  59179. /**
  59180. * Gets the emitted compilation strings
  59181. */
  59182. compilationString: string;
  59183. /**
  59184. * Finalize the compilation strings
  59185. * @param state defines the current compilation state
  59186. */
  59187. finalize(state: NodeMaterialBuildState): void;
  59188. /** @hidden */
  59189. get _repeatableContentAnchor(): string;
  59190. /** @hidden */
  59191. _getFreeVariableName(prefix: string): string;
  59192. /** @hidden */
  59193. _getFreeDefineName(prefix: string): string;
  59194. /** @hidden */
  59195. _excludeVariableName(name: string): void;
  59196. /** @hidden */
  59197. _emit2DSampler(name: string): void;
  59198. /** @hidden */
  59199. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  59200. /** @hidden */
  59201. _emitExtension(name: string, extension: string): void;
  59202. /** @hidden */
  59203. _emitFunction(name: string, code: string, comments: string): void;
  59204. /** @hidden */
  59205. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  59206. replaceStrings?: {
  59207. search: RegExp;
  59208. replace: string;
  59209. }[];
  59210. repeatKey?: string;
  59211. }): string;
  59212. /** @hidden */
  59213. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  59214. repeatKey?: string;
  59215. removeAttributes?: boolean;
  59216. removeUniforms?: boolean;
  59217. removeVaryings?: boolean;
  59218. removeIfDef?: boolean;
  59219. replaceStrings?: {
  59220. search: RegExp;
  59221. replace: string;
  59222. }[];
  59223. }, storeKey?: string): void;
  59224. /** @hidden */
  59225. _registerTempVariable(name: string): boolean;
  59226. /** @hidden */
  59227. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  59228. /** @hidden */
  59229. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  59230. /** @hidden */
  59231. _emitFloat(value: number): string;
  59232. }
  59233. }
  59234. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  59235. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59237. import { Nullable } from "babylonjs/types";
  59238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59239. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59240. import { Effect } from "babylonjs/Materials/effect";
  59241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59242. import { Mesh } from "babylonjs/Meshes/mesh";
  59243. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59244. import { Scene } from "babylonjs/scene";
  59245. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59246. /**
  59247. * Defines a block that can be used inside a node based material
  59248. */
  59249. export class NodeMaterialBlock {
  59250. private _buildId;
  59251. private _buildTarget;
  59252. private _target;
  59253. private _isFinalMerger;
  59254. private _isInput;
  59255. protected _isUnique: boolean;
  59256. /** @hidden */
  59257. _codeVariableName: string;
  59258. /** @hidden */
  59259. _inputs: NodeMaterialConnectionPoint[];
  59260. /** @hidden */
  59261. _outputs: NodeMaterialConnectionPoint[];
  59262. /** @hidden */
  59263. _preparationId: number;
  59264. /**
  59265. * Gets or sets the name of the block
  59266. */
  59267. name: string;
  59268. /**
  59269. * Gets or sets the unique id of the node
  59270. */
  59271. uniqueId: number;
  59272. /**
  59273. * Gets or sets the comments associated with this block
  59274. */
  59275. comments: string;
  59276. /**
  59277. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  59278. */
  59279. get isUnique(): boolean;
  59280. /**
  59281. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  59282. */
  59283. get isFinalMerger(): boolean;
  59284. /**
  59285. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  59286. */
  59287. get isInput(): boolean;
  59288. /**
  59289. * Gets or sets the build Id
  59290. */
  59291. get buildId(): number;
  59292. set buildId(value: number);
  59293. /**
  59294. * Gets or sets the target of the block
  59295. */
  59296. get target(): NodeMaterialBlockTargets;
  59297. set target(value: NodeMaterialBlockTargets);
  59298. /**
  59299. * Gets the list of input points
  59300. */
  59301. get inputs(): NodeMaterialConnectionPoint[];
  59302. /** Gets the list of output points */
  59303. get outputs(): NodeMaterialConnectionPoint[];
  59304. /**
  59305. * Find an input by its name
  59306. * @param name defines the name of the input to look for
  59307. * @returns the input or null if not found
  59308. */
  59309. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59310. /**
  59311. * Find an output by its name
  59312. * @param name defines the name of the outputto look for
  59313. * @returns the output or null if not found
  59314. */
  59315. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59316. /**
  59317. * Creates a new NodeMaterialBlock
  59318. * @param name defines the block name
  59319. * @param target defines the target of that block (Vertex by default)
  59320. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  59321. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  59322. */
  59323. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  59324. /**
  59325. * Initialize the block and prepare the context for build
  59326. * @param state defines the state that will be used for the build
  59327. */
  59328. initialize(state: NodeMaterialBuildState): void;
  59329. /**
  59330. * Bind data to effect. Will only be called for blocks with isBindable === true
  59331. * @param effect defines the effect to bind data to
  59332. * @param nodeMaterial defines the hosting NodeMaterial
  59333. * @param mesh defines the mesh that will be rendered
  59334. */
  59335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59336. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  59337. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  59338. protected _writeFloat(value: number): string;
  59339. /**
  59340. * Gets the current class name e.g. "NodeMaterialBlock"
  59341. * @returns the class name
  59342. */
  59343. getClassName(): string;
  59344. /**
  59345. * Register a new input. Must be called inside a block constructor
  59346. * @param name defines the connection point name
  59347. * @param type defines the connection point type
  59348. * @param isOptional defines a boolean indicating that this input can be omitted
  59349. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59350. * @returns the current block
  59351. */
  59352. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  59353. /**
  59354. * Register a new output. Must be called inside a block constructor
  59355. * @param name defines the connection point name
  59356. * @param type defines the connection point type
  59357. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59358. * @returns the current block
  59359. */
  59360. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  59361. /**
  59362. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  59363. * @param forOutput defines an optional connection point to check compatibility with
  59364. * @returns the first available input or null
  59365. */
  59366. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  59367. /**
  59368. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  59369. * @param forBlock defines an optional block to check compatibility with
  59370. * @returns the first available input or null
  59371. */
  59372. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  59373. /**
  59374. * Gets the sibling of the given output
  59375. * @param current defines the current output
  59376. * @returns the next output in the list or null
  59377. */
  59378. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  59379. /**
  59380. * Connect current block with another block
  59381. * @param other defines the block to connect with
  59382. * @param options define the various options to help pick the right connections
  59383. * @returns the current block
  59384. */
  59385. connectTo(other: NodeMaterialBlock, options?: {
  59386. input?: string;
  59387. output?: string;
  59388. outputSwizzle?: string;
  59389. }): this | undefined;
  59390. protected _buildBlock(state: NodeMaterialBuildState): void;
  59391. /**
  59392. * Add uniforms, samplers and uniform buffers at compilation time
  59393. * @param state defines the state to update
  59394. * @param nodeMaterial defines the node material requesting the update
  59395. * @param defines defines the material defines to update
  59396. * @param uniformBuffers defines the list of uniform buffer names
  59397. */
  59398. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59399. /**
  59400. * Add potential fallbacks if shader compilation fails
  59401. * @param mesh defines the mesh to be rendered
  59402. * @param fallbacks defines the current prioritized list of fallbacks
  59403. */
  59404. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59405. /**
  59406. * Initialize defines for shader compilation
  59407. * @param mesh defines the mesh to be rendered
  59408. * @param nodeMaterial defines the node material requesting the update
  59409. * @param defines defines the material defines to update
  59410. * @param useInstances specifies that instances should be used
  59411. */
  59412. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59413. /**
  59414. * Update defines for shader compilation
  59415. * @param mesh defines the mesh to be rendered
  59416. * @param nodeMaterial defines the node material requesting the update
  59417. * @param defines defines the material defines to update
  59418. * @param useInstances specifies that instances should be used
  59419. */
  59420. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59421. /**
  59422. * Lets the block try to connect some inputs automatically
  59423. * @param material defines the hosting NodeMaterial
  59424. */
  59425. autoConfigure(material: NodeMaterial): void;
  59426. /**
  59427. * Function called when a block is declared as repeatable content generator
  59428. * @param vertexShaderState defines the current compilation state for the vertex shader
  59429. * @param fragmentShaderState defines the current compilation state for the fragment shader
  59430. * @param mesh defines the mesh to be rendered
  59431. * @param defines defines the material defines to update
  59432. */
  59433. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59434. /**
  59435. * Checks if the block is ready
  59436. * @param mesh defines the mesh to be rendered
  59437. * @param nodeMaterial defines the node material requesting the update
  59438. * @param defines defines the material defines to update
  59439. * @param useInstances specifies that instances should be used
  59440. * @returns true if the block is ready
  59441. */
  59442. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  59443. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  59444. private _processBuild;
  59445. /**
  59446. * Compile the current node and generate the shader code
  59447. * @param state defines the current compilation state (uniforms, samplers, current string)
  59448. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  59449. * @returns true if already built
  59450. */
  59451. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  59452. protected _inputRename(name: string): string;
  59453. protected _outputRename(name: string): string;
  59454. protected _dumpPropertiesCode(): string;
  59455. /** @hidden */
  59456. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  59457. /** @hidden */
  59458. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  59459. /**
  59460. * Clone the current block to a new identical block
  59461. * @param scene defines the hosting scene
  59462. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59463. * @returns a copy of the current block
  59464. */
  59465. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  59466. /**
  59467. * Serializes this block in a JSON representation
  59468. * @returns the serialized block object
  59469. */
  59470. serialize(): any;
  59471. /** @hidden */
  59472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59473. /**
  59474. * Release resources
  59475. */
  59476. dispose(): void;
  59477. }
  59478. }
  59479. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  59480. /**
  59481. * Enum defining the type of animations supported by InputBlock
  59482. */
  59483. export enum AnimatedInputBlockTypes {
  59484. /** No animation */
  59485. None = 0,
  59486. /** Time based animation. Will only work for floats */
  59487. Time = 1
  59488. }
  59489. }
  59490. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  59491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59492. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59493. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59494. import { Nullable } from "babylonjs/types";
  59495. import { Effect } from "babylonjs/Materials/effect";
  59496. import { Matrix } from "babylonjs/Maths/math.vector";
  59497. import { Scene } from "babylonjs/scene";
  59498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59500. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59501. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59502. /**
  59503. * Block used to expose an input value
  59504. */
  59505. export class InputBlock extends NodeMaterialBlock {
  59506. private _mode;
  59507. private _associatedVariableName;
  59508. private _storedValue;
  59509. private _valueCallback;
  59510. private _type;
  59511. private _animationType;
  59512. /** Gets or set a value used to limit the range of float values */
  59513. min: number;
  59514. /** Gets or set a value used to limit the range of float values */
  59515. max: number;
  59516. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  59517. matrixMode: number;
  59518. /** @hidden */
  59519. _systemValue: Nullable<NodeMaterialSystemValues>;
  59520. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  59521. visibleInInspector: boolean;
  59522. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  59523. isConstant: boolean;
  59524. /** Gets or sets the group to use to display this block in the Inspector */
  59525. groupInInspector: string;
  59526. /**
  59527. * Gets or sets the connection point type (default is float)
  59528. */
  59529. get type(): NodeMaterialBlockConnectionPointTypes;
  59530. /**
  59531. * Creates a new InputBlock
  59532. * @param name defines the block name
  59533. * @param target defines the target of that block (Vertex by default)
  59534. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  59535. */
  59536. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  59537. /**
  59538. * Gets the output component
  59539. */
  59540. get output(): NodeMaterialConnectionPoint;
  59541. /**
  59542. * Set the source of this connection point to a vertex attribute
  59543. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  59544. * @returns the current connection point
  59545. */
  59546. setAsAttribute(attributeName?: string): InputBlock;
  59547. /**
  59548. * Set the source of this connection point to a system value
  59549. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  59550. * @returns the current connection point
  59551. */
  59552. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  59553. /**
  59554. * Gets or sets the value of that point.
  59555. * Please note that this value will be ignored if valueCallback is defined
  59556. */
  59557. get value(): any;
  59558. set value(value: any);
  59559. /**
  59560. * Gets or sets a callback used to get the value of that point.
  59561. * Please note that setting this value will force the connection point to ignore the value property
  59562. */
  59563. get valueCallback(): () => any;
  59564. set valueCallback(value: () => any);
  59565. /**
  59566. * Gets or sets the associated variable name in the shader
  59567. */
  59568. get associatedVariableName(): string;
  59569. set associatedVariableName(value: string);
  59570. /** Gets or sets the type of animation applied to the input */
  59571. get animationType(): AnimatedInputBlockTypes;
  59572. set animationType(value: AnimatedInputBlockTypes);
  59573. /**
  59574. * Gets a boolean indicating that this connection point not defined yet
  59575. */
  59576. get isUndefined(): boolean;
  59577. /**
  59578. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  59579. * In this case the connection point name must be the name of the uniform to use.
  59580. * Can only be set on inputs
  59581. */
  59582. get isUniform(): boolean;
  59583. set isUniform(value: boolean);
  59584. /**
  59585. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  59586. * In this case the connection point name must be the name of the attribute to use
  59587. * Can only be set on inputs
  59588. */
  59589. get isAttribute(): boolean;
  59590. set isAttribute(value: boolean);
  59591. /**
  59592. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  59593. * Can only be set on exit points
  59594. */
  59595. get isVarying(): boolean;
  59596. set isVarying(value: boolean);
  59597. /**
  59598. * Gets a boolean indicating that the current connection point is a system value
  59599. */
  59600. get isSystemValue(): boolean;
  59601. /**
  59602. * Gets or sets the current well known value or null if not defined as a system value
  59603. */
  59604. get systemValue(): Nullable<NodeMaterialSystemValues>;
  59605. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  59606. /**
  59607. * Gets the current class name
  59608. * @returns the class name
  59609. */
  59610. getClassName(): string;
  59611. /**
  59612. * Animate the input if animationType !== None
  59613. * @param scene defines the rendering scene
  59614. */
  59615. animate(scene: Scene): void;
  59616. private _emitDefine;
  59617. initialize(state: NodeMaterialBuildState): void;
  59618. /**
  59619. * Set the input block to its default value (based on its type)
  59620. */
  59621. setDefaultValue(): void;
  59622. private _emitConstant;
  59623. private _emit;
  59624. /** @hidden */
  59625. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  59626. /** @hidden */
  59627. _transmit(effect: Effect, scene: Scene): void;
  59628. protected _buildBlock(state: NodeMaterialBuildState): void;
  59629. protected _dumpPropertiesCode(): string;
  59630. serialize(): any;
  59631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59632. }
  59633. }
  59634. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  59635. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59636. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59637. import { Nullable } from "babylonjs/types";
  59638. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59639. import { Observable } from "babylonjs/Misc/observable";
  59640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59641. /**
  59642. * Enum used to define the compatibility state between two connection points
  59643. */
  59644. export enum NodeMaterialConnectionPointCompatibilityStates {
  59645. /** Points are compatibles */
  59646. Compatible = 0,
  59647. /** Points are incompatible because of their types */
  59648. TypeIncompatible = 1,
  59649. /** Points are incompatible because of their targets (vertex vs fragment) */
  59650. TargetIncompatible = 2
  59651. }
  59652. /**
  59653. * Defines the direction of a connection point
  59654. */
  59655. export enum NodeMaterialConnectionPointDirection {
  59656. /** Input */
  59657. Input = 0,
  59658. /** Output */
  59659. Output = 1
  59660. }
  59661. /**
  59662. * Defines a connection point for a block
  59663. */
  59664. export class NodeMaterialConnectionPoint {
  59665. /** @hidden */
  59666. _ownerBlock: NodeMaterialBlock;
  59667. /** @hidden */
  59668. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  59669. private _endpoints;
  59670. private _associatedVariableName;
  59671. private _direction;
  59672. /** @hidden */
  59673. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59674. /** @hidden */
  59675. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59676. private _type;
  59677. /** @hidden */
  59678. _enforceAssociatedVariableName: boolean;
  59679. /** Gets the direction of the point */
  59680. get direction(): NodeMaterialConnectionPointDirection;
  59681. /**
  59682. * Gets or sets the additional types supported by this connection point
  59683. */
  59684. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59685. /**
  59686. * Gets or sets the additional types excluded by this connection point
  59687. */
  59688. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59689. /**
  59690. * Observable triggered when this point is connected
  59691. */
  59692. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  59693. /**
  59694. * Gets or sets the associated variable name in the shader
  59695. */
  59696. get associatedVariableName(): string;
  59697. set associatedVariableName(value: string);
  59698. /**
  59699. * Gets or sets the connection point type (default is float)
  59700. */
  59701. get type(): NodeMaterialBlockConnectionPointTypes;
  59702. set type(value: NodeMaterialBlockConnectionPointTypes);
  59703. /**
  59704. * Gets or sets the connection point name
  59705. */
  59706. name: string;
  59707. /**
  59708. * Gets or sets a boolean indicating that this connection point can be omitted
  59709. */
  59710. isOptional: boolean;
  59711. /**
  59712. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59713. */
  59714. define: string;
  59715. /** @hidden */
  59716. _prioritizeVertex: boolean;
  59717. private _target;
  59718. /** Gets or sets the target of that connection point */
  59719. get target(): NodeMaterialBlockTargets;
  59720. set target(value: NodeMaterialBlockTargets);
  59721. /**
  59722. * Gets a boolean indicating that the current point is connected
  59723. */
  59724. get isConnected(): boolean;
  59725. /**
  59726. * Gets a boolean indicating that the current point is connected to an input block
  59727. */
  59728. get isConnectedToInputBlock(): boolean;
  59729. /**
  59730. * Gets a the connected input block (if any)
  59731. */
  59732. get connectInputBlock(): Nullable<InputBlock>;
  59733. /** Get the other side of the connection (if any) */
  59734. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59735. /** Get the block that owns this connection point */
  59736. get ownerBlock(): NodeMaterialBlock;
  59737. /** Get the block connected on the other side of this connection (if any) */
  59738. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59739. /** Get the block connected on the endpoints of this connection (if any) */
  59740. get connectedBlocks(): Array<NodeMaterialBlock>;
  59741. /** Gets the list of connected endpoints */
  59742. get endpoints(): NodeMaterialConnectionPoint[];
  59743. /** Gets a boolean indicating if that output point is connected to at least one input */
  59744. get hasEndpoints(): boolean;
  59745. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59746. get isConnectedInVertexShader(): boolean;
  59747. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59748. get isConnectedInFragmentShader(): boolean;
  59749. /**
  59750. * Creates a new connection point
  59751. * @param name defines the connection point name
  59752. * @param ownerBlock defines the block hosting this connection point
  59753. * @param direction defines the direction of the connection point
  59754. */
  59755. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59756. /**
  59757. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59758. * @returns the class name
  59759. */
  59760. getClassName(): string;
  59761. /**
  59762. * Gets a boolean indicating if the current point can be connected to another point
  59763. * @param connectionPoint defines the other connection point
  59764. * @returns a boolean
  59765. */
  59766. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59767. /**
  59768. * Gets a number indicating if the current point can be connected to another point
  59769. * @param connectionPoint defines the other connection point
  59770. * @returns a number defining the compatibility state
  59771. */
  59772. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59773. /**
  59774. * Connect this point to another connection point
  59775. * @param connectionPoint defines the other connection point
  59776. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59777. * @returns the current connection point
  59778. */
  59779. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59780. /**
  59781. * Disconnect this point from one of his endpoint
  59782. * @param endpoint defines the other connection point
  59783. * @returns the current connection point
  59784. */
  59785. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59786. /**
  59787. * Serializes this point in a JSON representation
  59788. * @returns the serialized point object
  59789. */
  59790. serialize(): any;
  59791. /**
  59792. * Release resources
  59793. */
  59794. dispose(): void;
  59795. }
  59796. }
  59797. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  59798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59801. import { Mesh } from "babylonjs/Meshes/mesh";
  59802. import { Effect } from "babylonjs/Materials/effect";
  59803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59804. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59805. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59806. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59807. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59808. /**
  59809. * Block used to add support for vertex skinning (bones)
  59810. */
  59811. export class BonesBlock extends NodeMaterialBlock {
  59812. /**
  59813. * Creates a new BonesBlock
  59814. * @param name defines the block name
  59815. */
  59816. constructor(name: string);
  59817. /**
  59818. * Initialize the block and prepare the context for build
  59819. * @param state defines the state that will be used for the build
  59820. */
  59821. initialize(state: NodeMaterialBuildState): void;
  59822. /**
  59823. * Gets the current class name
  59824. * @returns the class name
  59825. */
  59826. getClassName(): string;
  59827. /**
  59828. * Gets the matrix indices input component
  59829. */
  59830. get matricesIndices(): NodeMaterialConnectionPoint;
  59831. /**
  59832. * Gets the matrix weights input component
  59833. */
  59834. get matricesWeights(): NodeMaterialConnectionPoint;
  59835. /**
  59836. * Gets the extra matrix indices input component
  59837. */
  59838. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59839. /**
  59840. * Gets the extra matrix weights input component
  59841. */
  59842. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59843. /**
  59844. * Gets the world input component
  59845. */
  59846. get world(): NodeMaterialConnectionPoint;
  59847. /**
  59848. * Gets the output component
  59849. */
  59850. get output(): NodeMaterialConnectionPoint;
  59851. autoConfigure(material: NodeMaterial): void;
  59852. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59853. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59855. protected _buildBlock(state: NodeMaterialBuildState): this;
  59856. }
  59857. }
  59858. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59863. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59864. /**
  59865. * Block used to add support for instances
  59866. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59867. */
  59868. export class InstancesBlock extends NodeMaterialBlock {
  59869. /**
  59870. * Creates a new InstancesBlock
  59871. * @param name defines the block name
  59872. */
  59873. constructor(name: string);
  59874. /**
  59875. * Gets the current class name
  59876. * @returns the class name
  59877. */
  59878. getClassName(): string;
  59879. /**
  59880. * Gets the first world row input component
  59881. */
  59882. get world0(): NodeMaterialConnectionPoint;
  59883. /**
  59884. * Gets the second world row input component
  59885. */
  59886. get world1(): NodeMaterialConnectionPoint;
  59887. /**
  59888. * Gets the third world row input component
  59889. */
  59890. get world2(): NodeMaterialConnectionPoint;
  59891. /**
  59892. * Gets the forth world row input component
  59893. */
  59894. get world3(): NodeMaterialConnectionPoint;
  59895. /**
  59896. * Gets the world input component
  59897. */
  59898. get world(): NodeMaterialConnectionPoint;
  59899. /**
  59900. * Gets the output component
  59901. */
  59902. get output(): NodeMaterialConnectionPoint;
  59903. autoConfigure(material: NodeMaterial): void;
  59904. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59905. protected _buildBlock(state: NodeMaterialBuildState): this;
  59906. }
  59907. }
  59908. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59913. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59914. import { Effect } from "babylonjs/Materials/effect";
  59915. import { Mesh } from "babylonjs/Meshes/mesh";
  59916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59918. /**
  59919. * Block used to add morph targets support to vertex shader
  59920. */
  59921. export class MorphTargetsBlock extends NodeMaterialBlock {
  59922. private _repeatableContentAnchor;
  59923. private _repeatebleContentGenerated;
  59924. /**
  59925. * Create a new MorphTargetsBlock
  59926. * @param name defines the block name
  59927. */
  59928. constructor(name: string);
  59929. /**
  59930. * Gets the current class name
  59931. * @returns the class name
  59932. */
  59933. getClassName(): string;
  59934. /**
  59935. * Gets the position input component
  59936. */
  59937. get position(): NodeMaterialConnectionPoint;
  59938. /**
  59939. * Gets the normal input component
  59940. */
  59941. get normal(): NodeMaterialConnectionPoint;
  59942. /**
  59943. * Gets the tangent input component
  59944. */
  59945. get tangent(): NodeMaterialConnectionPoint;
  59946. /**
  59947. * Gets the tangent input component
  59948. */
  59949. get uv(): NodeMaterialConnectionPoint;
  59950. /**
  59951. * Gets the position output component
  59952. */
  59953. get positionOutput(): NodeMaterialConnectionPoint;
  59954. /**
  59955. * Gets the normal output component
  59956. */
  59957. get normalOutput(): NodeMaterialConnectionPoint;
  59958. /**
  59959. * Gets the tangent output component
  59960. */
  59961. get tangentOutput(): NodeMaterialConnectionPoint;
  59962. /**
  59963. * Gets the tangent output component
  59964. */
  59965. get uvOutput(): NodeMaterialConnectionPoint;
  59966. initialize(state: NodeMaterialBuildState): void;
  59967. autoConfigure(material: NodeMaterial): void;
  59968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59969. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59970. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59971. protected _buildBlock(state: NodeMaterialBuildState): this;
  59972. }
  59973. }
  59974. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59978. import { Nullable } from "babylonjs/types";
  59979. import { Scene } from "babylonjs/scene";
  59980. import { Effect } from "babylonjs/Materials/effect";
  59981. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59982. import { Mesh } from "babylonjs/Meshes/mesh";
  59983. import { Light } from "babylonjs/Lights/light";
  59984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59985. /**
  59986. * Block used to get data information from a light
  59987. */
  59988. export class LightInformationBlock extends NodeMaterialBlock {
  59989. private _lightDataUniformName;
  59990. private _lightColorUniformName;
  59991. private _lightTypeDefineName;
  59992. /**
  59993. * Gets or sets the light associated with this block
  59994. */
  59995. light: Nullable<Light>;
  59996. /**
  59997. * Creates a new LightInformationBlock
  59998. * @param name defines the block name
  59999. */
  60000. constructor(name: string);
  60001. /**
  60002. * Gets the current class name
  60003. * @returns the class name
  60004. */
  60005. getClassName(): string;
  60006. /**
  60007. * Gets the world position input component
  60008. */
  60009. get worldPosition(): NodeMaterialConnectionPoint;
  60010. /**
  60011. * Gets the direction output component
  60012. */
  60013. get direction(): NodeMaterialConnectionPoint;
  60014. /**
  60015. * Gets the direction output component
  60016. */
  60017. get color(): NodeMaterialConnectionPoint;
  60018. /**
  60019. * Gets the direction output component
  60020. */
  60021. get intensity(): NodeMaterialConnectionPoint;
  60022. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60024. protected _buildBlock(state: NodeMaterialBuildState): this;
  60025. serialize(): any;
  60026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60027. }
  60028. }
  60029. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  60030. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  60031. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  60032. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  60033. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  60034. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  60035. }
  60036. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  60037. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60038. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60039. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60041. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60042. import { Effect } from "babylonjs/Materials/effect";
  60043. import { Mesh } from "babylonjs/Meshes/mesh";
  60044. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60045. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60046. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60047. /**
  60048. * Block used to add image processing support to fragment shader
  60049. */
  60050. export class ImageProcessingBlock extends NodeMaterialBlock {
  60051. /**
  60052. * Create a new ImageProcessingBlock
  60053. * @param name defines the block name
  60054. */
  60055. constructor(name: string);
  60056. /**
  60057. * Gets the current class name
  60058. * @returns the class name
  60059. */
  60060. getClassName(): string;
  60061. /**
  60062. * Gets the color input component
  60063. */
  60064. get color(): NodeMaterialConnectionPoint;
  60065. /**
  60066. * Gets the output component
  60067. */
  60068. get output(): NodeMaterialConnectionPoint;
  60069. /**
  60070. * Initialize the block and prepare the context for build
  60071. * @param state defines the state that will be used for the build
  60072. */
  60073. initialize(state: NodeMaterialBuildState): void;
  60074. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60075. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60076. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60077. protected _buildBlock(state: NodeMaterialBuildState): this;
  60078. }
  60079. }
  60080. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  60081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60084. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60086. import { Effect } from "babylonjs/Materials/effect";
  60087. import { Mesh } from "babylonjs/Meshes/mesh";
  60088. import { Scene } from "babylonjs/scene";
  60089. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  60090. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  60091. /**
  60092. * Block used to pertub normals based on a normal map
  60093. */
  60094. export class PerturbNormalBlock extends NodeMaterialBlock {
  60095. private _tangentSpaceParameterName;
  60096. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60097. invertX: boolean;
  60098. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60099. invertY: boolean;
  60100. /**
  60101. * Create a new PerturbNormalBlock
  60102. * @param name defines the block name
  60103. */
  60104. constructor(name: string);
  60105. /**
  60106. * Gets the current class name
  60107. * @returns the class name
  60108. */
  60109. getClassName(): string;
  60110. /**
  60111. * Gets the world position input component
  60112. */
  60113. get worldPosition(): NodeMaterialConnectionPoint;
  60114. /**
  60115. * Gets the world normal input component
  60116. */
  60117. get worldNormal(): NodeMaterialConnectionPoint;
  60118. /**
  60119. * Gets the uv input component
  60120. */
  60121. get uv(): NodeMaterialConnectionPoint;
  60122. /**
  60123. * Gets the normal map color input component
  60124. */
  60125. get normalMapColor(): NodeMaterialConnectionPoint;
  60126. /**
  60127. * Gets the strength input component
  60128. */
  60129. get strength(): NodeMaterialConnectionPoint;
  60130. /**
  60131. * Gets the output component
  60132. */
  60133. get output(): NodeMaterialConnectionPoint;
  60134. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60135. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60136. autoConfigure(material: NodeMaterial): void;
  60137. protected _buildBlock(state: NodeMaterialBuildState): this;
  60138. protected _dumpPropertiesCode(): string;
  60139. serialize(): any;
  60140. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60141. }
  60142. }
  60143. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  60144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60147. /**
  60148. * Block used to discard a pixel if a value is smaller than a cutoff
  60149. */
  60150. export class DiscardBlock extends NodeMaterialBlock {
  60151. /**
  60152. * Create a new DiscardBlock
  60153. * @param name defines the block name
  60154. */
  60155. constructor(name: string);
  60156. /**
  60157. * Gets the current class name
  60158. * @returns the class name
  60159. */
  60160. getClassName(): string;
  60161. /**
  60162. * Gets the color input component
  60163. */
  60164. get value(): NodeMaterialConnectionPoint;
  60165. /**
  60166. * Gets the cutoff input component
  60167. */
  60168. get cutoff(): NodeMaterialConnectionPoint;
  60169. protected _buildBlock(state: NodeMaterialBuildState): this;
  60170. }
  60171. }
  60172. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  60173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60176. /**
  60177. * Block used to test if the fragment shader is front facing
  60178. */
  60179. export class FrontFacingBlock extends NodeMaterialBlock {
  60180. /**
  60181. * Creates a new FrontFacingBlock
  60182. * @param name defines the block name
  60183. */
  60184. constructor(name: string);
  60185. /**
  60186. * Gets the current class name
  60187. * @returns the class name
  60188. */
  60189. getClassName(): string;
  60190. /**
  60191. * Gets the output component
  60192. */
  60193. get output(): NodeMaterialConnectionPoint;
  60194. protected _buildBlock(state: NodeMaterialBuildState): this;
  60195. }
  60196. }
  60197. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  60198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60201. /**
  60202. * Block used to get the derivative value on x and y of a given input
  60203. */
  60204. export class DerivativeBlock extends NodeMaterialBlock {
  60205. /**
  60206. * Create a new DerivativeBlock
  60207. * @param name defines the block name
  60208. */
  60209. constructor(name: string);
  60210. /**
  60211. * Gets the current class name
  60212. * @returns the class name
  60213. */
  60214. getClassName(): string;
  60215. /**
  60216. * Gets the input component
  60217. */
  60218. get input(): NodeMaterialConnectionPoint;
  60219. /**
  60220. * Gets the derivative output on x
  60221. */
  60222. get dx(): NodeMaterialConnectionPoint;
  60223. /**
  60224. * Gets the derivative output on y
  60225. */
  60226. get dy(): NodeMaterialConnectionPoint;
  60227. protected _buildBlock(state: NodeMaterialBuildState): this;
  60228. }
  60229. }
  60230. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  60231. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  60232. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  60233. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  60234. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  60235. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  60236. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  60237. }
  60238. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  60239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60241. import { Mesh } from "babylonjs/Meshes/mesh";
  60242. import { Effect } from "babylonjs/Materials/effect";
  60243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60245. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60246. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60247. /**
  60248. * Block used to add support for scene fog
  60249. */
  60250. export class FogBlock extends NodeMaterialBlock {
  60251. private _fogDistanceName;
  60252. private _fogParameters;
  60253. /**
  60254. * Create a new FogBlock
  60255. * @param name defines the block name
  60256. */
  60257. constructor(name: string);
  60258. /**
  60259. * Gets the current class name
  60260. * @returns the class name
  60261. */
  60262. getClassName(): string;
  60263. /**
  60264. * Gets the world position input component
  60265. */
  60266. get worldPosition(): NodeMaterialConnectionPoint;
  60267. /**
  60268. * Gets the view input component
  60269. */
  60270. get view(): NodeMaterialConnectionPoint;
  60271. /**
  60272. * Gets the color input component
  60273. */
  60274. get input(): NodeMaterialConnectionPoint;
  60275. /**
  60276. * Gets the fog color input component
  60277. */
  60278. get fogColor(): NodeMaterialConnectionPoint;
  60279. /**
  60280. * Gets the output component
  60281. */
  60282. get output(): NodeMaterialConnectionPoint;
  60283. autoConfigure(material: NodeMaterial): void;
  60284. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60285. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60286. protected _buildBlock(state: NodeMaterialBuildState): this;
  60287. }
  60288. }
  60289. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  60290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60294. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60295. import { Effect } from "babylonjs/Materials/effect";
  60296. import { Mesh } from "babylonjs/Meshes/mesh";
  60297. import { Light } from "babylonjs/Lights/light";
  60298. import { Nullable } from "babylonjs/types";
  60299. import { Scene } from "babylonjs/scene";
  60300. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60301. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60302. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60303. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60304. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60305. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60306. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60307. /**
  60308. * Block used to add light in the fragment shader
  60309. */
  60310. export class LightBlock extends NodeMaterialBlock {
  60311. private _lightId;
  60312. /**
  60313. * Gets or sets the light associated with this block
  60314. */
  60315. light: Nullable<Light>;
  60316. /**
  60317. * Create a new LightBlock
  60318. * @param name defines the block name
  60319. */
  60320. constructor(name: string);
  60321. /**
  60322. * Gets the current class name
  60323. * @returns the class name
  60324. */
  60325. getClassName(): string;
  60326. /**
  60327. * Gets the world position input component
  60328. */
  60329. get worldPosition(): NodeMaterialConnectionPoint;
  60330. /**
  60331. * Gets the world normal input component
  60332. */
  60333. get worldNormal(): NodeMaterialConnectionPoint;
  60334. /**
  60335. * Gets the camera (or eye) position component
  60336. */
  60337. get cameraPosition(): NodeMaterialConnectionPoint;
  60338. /**
  60339. * Gets the glossiness component
  60340. */
  60341. get glossiness(): NodeMaterialConnectionPoint;
  60342. /**
  60343. * Gets the glossinness power component
  60344. */
  60345. get glossPower(): NodeMaterialConnectionPoint;
  60346. /**
  60347. * Gets the diffuse color component
  60348. */
  60349. get diffuseColor(): NodeMaterialConnectionPoint;
  60350. /**
  60351. * Gets the specular color component
  60352. */
  60353. get specularColor(): NodeMaterialConnectionPoint;
  60354. /**
  60355. * Gets the diffuse output component
  60356. */
  60357. get diffuseOutput(): NodeMaterialConnectionPoint;
  60358. /**
  60359. * Gets the specular output component
  60360. */
  60361. get specularOutput(): NodeMaterialConnectionPoint;
  60362. /**
  60363. * Gets the shadow output component
  60364. */
  60365. get shadow(): NodeMaterialConnectionPoint;
  60366. autoConfigure(material: NodeMaterial): void;
  60367. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60368. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60369. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60370. private _injectVertexCode;
  60371. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60372. serialize(): any;
  60373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60374. }
  60375. }
  60376. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  60377. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  60378. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  60379. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60380. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60381. }
  60382. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  60383. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60384. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60385. }
  60386. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  60387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60390. /**
  60391. * Block used to multiply 2 values
  60392. */
  60393. export class MultiplyBlock extends NodeMaterialBlock {
  60394. /**
  60395. * Creates a new MultiplyBlock
  60396. * @param name defines the block name
  60397. */
  60398. constructor(name: string);
  60399. /**
  60400. * Gets the current class name
  60401. * @returns the class name
  60402. */
  60403. getClassName(): string;
  60404. /**
  60405. * Gets the left operand input component
  60406. */
  60407. get left(): NodeMaterialConnectionPoint;
  60408. /**
  60409. * Gets the right operand input component
  60410. */
  60411. get right(): NodeMaterialConnectionPoint;
  60412. /**
  60413. * Gets the output component
  60414. */
  60415. get output(): NodeMaterialConnectionPoint;
  60416. protected _buildBlock(state: NodeMaterialBuildState): this;
  60417. }
  60418. }
  60419. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  60420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60423. /**
  60424. * Block used to add 2 vectors
  60425. */
  60426. export class AddBlock extends NodeMaterialBlock {
  60427. /**
  60428. * Creates a new AddBlock
  60429. * @param name defines the block name
  60430. */
  60431. constructor(name: string);
  60432. /**
  60433. * Gets the current class name
  60434. * @returns the class name
  60435. */
  60436. getClassName(): string;
  60437. /**
  60438. * Gets the left operand input component
  60439. */
  60440. get left(): NodeMaterialConnectionPoint;
  60441. /**
  60442. * Gets the right operand input component
  60443. */
  60444. get right(): NodeMaterialConnectionPoint;
  60445. /**
  60446. * Gets the output component
  60447. */
  60448. get output(): NodeMaterialConnectionPoint;
  60449. protected _buildBlock(state: NodeMaterialBuildState): this;
  60450. }
  60451. }
  60452. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  60453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60456. /**
  60457. * Block used to scale a vector by a float
  60458. */
  60459. export class ScaleBlock extends NodeMaterialBlock {
  60460. /**
  60461. * Creates a new ScaleBlock
  60462. * @param name defines the block name
  60463. */
  60464. constructor(name: string);
  60465. /**
  60466. * Gets the current class name
  60467. * @returns the class name
  60468. */
  60469. getClassName(): string;
  60470. /**
  60471. * Gets the input component
  60472. */
  60473. get input(): NodeMaterialConnectionPoint;
  60474. /**
  60475. * Gets the factor input component
  60476. */
  60477. get factor(): NodeMaterialConnectionPoint;
  60478. /**
  60479. * Gets the output component
  60480. */
  60481. get output(): NodeMaterialConnectionPoint;
  60482. protected _buildBlock(state: NodeMaterialBuildState): this;
  60483. }
  60484. }
  60485. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  60486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60489. import { Scene } from "babylonjs/scene";
  60490. /**
  60491. * Block used to clamp a float
  60492. */
  60493. export class ClampBlock extends NodeMaterialBlock {
  60494. /** Gets or sets the minimum range */
  60495. minimum: number;
  60496. /** Gets or sets the maximum range */
  60497. maximum: number;
  60498. /**
  60499. * Creates a new ClampBlock
  60500. * @param name defines the block name
  60501. */
  60502. constructor(name: string);
  60503. /**
  60504. * Gets the current class name
  60505. * @returns the class name
  60506. */
  60507. getClassName(): string;
  60508. /**
  60509. * Gets the value input component
  60510. */
  60511. get value(): NodeMaterialConnectionPoint;
  60512. /**
  60513. * Gets the output component
  60514. */
  60515. get output(): NodeMaterialConnectionPoint;
  60516. protected _buildBlock(state: NodeMaterialBuildState): this;
  60517. protected _dumpPropertiesCode(): string;
  60518. serialize(): any;
  60519. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60520. }
  60521. }
  60522. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  60523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60526. /**
  60527. * Block used to apply a cross product between 2 vectors
  60528. */
  60529. export class CrossBlock extends NodeMaterialBlock {
  60530. /**
  60531. * Creates a new CrossBlock
  60532. * @param name defines the block name
  60533. */
  60534. constructor(name: string);
  60535. /**
  60536. * Gets the current class name
  60537. * @returns the class name
  60538. */
  60539. getClassName(): string;
  60540. /**
  60541. * Gets the left operand input component
  60542. */
  60543. get left(): NodeMaterialConnectionPoint;
  60544. /**
  60545. * Gets the right operand input component
  60546. */
  60547. get right(): NodeMaterialConnectionPoint;
  60548. /**
  60549. * Gets the output component
  60550. */
  60551. get output(): NodeMaterialConnectionPoint;
  60552. protected _buildBlock(state: NodeMaterialBuildState): this;
  60553. }
  60554. }
  60555. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  60556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60559. /**
  60560. * Block used to apply a dot product between 2 vectors
  60561. */
  60562. export class DotBlock extends NodeMaterialBlock {
  60563. /**
  60564. * Creates a new DotBlock
  60565. * @param name defines the block name
  60566. */
  60567. constructor(name: string);
  60568. /**
  60569. * Gets the current class name
  60570. * @returns the class name
  60571. */
  60572. getClassName(): string;
  60573. /**
  60574. * Gets the left operand input component
  60575. */
  60576. get left(): NodeMaterialConnectionPoint;
  60577. /**
  60578. * Gets the right operand input component
  60579. */
  60580. get right(): NodeMaterialConnectionPoint;
  60581. /**
  60582. * Gets the output component
  60583. */
  60584. get output(): NodeMaterialConnectionPoint;
  60585. protected _buildBlock(state: NodeMaterialBuildState): this;
  60586. }
  60587. }
  60588. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  60589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60592. import { Vector2 } from "babylonjs/Maths/math.vector";
  60593. import { Scene } from "babylonjs/scene";
  60594. /**
  60595. * Block used to remap a float from a range to a new one
  60596. */
  60597. export class RemapBlock extends NodeMaterialBlock {
  60598. /**
  60599. * Gets or sets the source range
  60600. */
  60601. sourceRange: Vector2;
  60602. /**
  60603. * Gets or sets the target range
  60604. */
  60605. targetRange: Vector2;
  60606. /**
  60607. * Creates a new RemapBlock
  60608. * @param name defines the block name
  60609. */
  60610. constructor(name: string);
  60611. /**
  60612. * Gets the current class name
  60613. * @returns the class name
  60614. */
  60615. getClassName(): string;
  60616. /**
  60617. * Gets the input component
  60618. */
  60619. get input(): NodeMaterialConnectionPoint;
  60620. /**
  60621. * Gets the source min input component
  60622. */
  60623. get sourceMin(): NodeMaterialConnectionPoint;
  60624. /**
  60625. * Gets the source max input component
  60626. */
  60627. get sourceMax(): NodeMaterialConnectionPoint;
  60628. /**
  60629. * Gets the target min input component
  60630. */
  60631. get targetMin(): NodeMaterialConnectionPoint;
  60632. /**
  60633. * Gets the target max input component
  60634. */
  60635. get targetMax(): NodeMaterialConnectionPoint;
  60636. /**
  60637. * Gets the output component
  60638. */
  60639. get output(): NodeMaterialConnectionPoint;
  60640. protected _buildBlock(state: NodeMaterialBuildState): this;
  60641. protected _dumpPropertiesCode(): string;
  60642. serialize(): any;
  60643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60644. }
  60645. }
  60646. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  60647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60650. /**
  60651. * Block used to normalize a vector
  60652. */
  60653. export class NormalizeBlock extends NodeMaterialBlock {
  60654. /**
  60655. * Creates a new NormalizeBlock
  60656. * @param name defines the block name
  60657. */
  60658. constructor(name: string);
  60659. /**
  60660. * Gets the current class name
  60661. * @returns the class name
  60662. */
  60663. getClassName(): string;
  60664. /**
  60665. * Gets the input component
  60666. */
  60667. get input(): NodeMaterialConnectionPoint;
  60668. /**
  60669. * Gets the output component
  60670. */
  60671. get output(): NodeMaterialConnectionPoint;
  60672. protected _buildBlock(state: NodeMaterialBuildState): this;
  60673. }
  60674. }
  60675. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  60676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60679. import { Scene } from "babylonjs/scene";
  60680. /**
  60681. * Operations supported by the Trigonometry block
  60682. */
  60683. export enum TrigonometryBlockOperations {
  60684. /** Cos */
  60685. Cos = 0,
  60686. /** Sin */
  60687. Sin = 1,
  60688. /** Abs */
  60689. Abs = 2,
  60690. /** Exp */
  60691. Exp = 3,
  60692. /** Exp2 */
  60693. Exp2 = 4,
  60694. /** Round */
  60695. Round = 5,
  60696. /** Floor */
  60697. Floor = 6,
  60698. /** Ceiling */
  60699. Ceiling = 7,
  60700. /** Square root */
  60701. Sqrt = 8,
  60702. /** Log */
  60703. Log = 9,
  60704. /** Tangent */
  60705. Tan = 10,
  60706. /** Arc tangent */
  60707. ArcTan = 11,
  60708. /** Arc cosinus */
  60709. ArcCos = 12,
  60710. /** Arc sinus */
  60711. ArcSin = 13,
  60712. /** Fraction */
  60713. Fract = 14,
  60714. /** Sign */
  60715. Sign = 15,
  60716. /** To radians (from degrees) */
  60717. Radians = 16,
  60718. /** To degrees (from radians) */
  60719. Degrees = 17
  60720. }
  60721. /**
  60722. * Block used to apply trigonometry operation to floats
  60723. */
  60724. export class TrigonometryBlock extends NodeMaterialBlock {
  60725. /**
  60726. * Gets or sets the operation applied by the block
  60727. */
  60728. operation: TrigonometryBlockOperations;
  60729. /**
  60730. * Creates a new TrigonometryBlock
  60731. * @param name defines the block name
  60732. */
  60733. constructor(name: string);
  60734. /**
  60735. * Gets the current class name
  60736. * @returns the class name
  60737. */
  60738. getClassName(): string;
  60739. /**
  60740. * Gets the input component
  60741. */
  60742. get input(): NodeMaterialConnectionPoint;
  60743. /**
  60744. * Gets the output component
  60745. */
  60746. get output(): NodeMaterialConnectionPoint;
  60747. protected _buildBlock(state: NodeMaterialBuildState): this;
  60748. serialize(): any;
  60749. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60750. protected _dumpPropertiesCode(): string;
  60751. }
  60752. }
  60753. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  60754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60757. /**
  60758. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60759. */
  60760. export class ColorMergerBlock extends NodeMaterialBlock {
  60761. /**
  60762. * Create a new ColorMergerBlock
  60763. * @param name defines the block name
  60764. */
  60765. constructor(name: string);
  60766. /**
  60767. * Gets the current class name
  60768. * @returns the class name
  60769. */
  60770. getClassName(): string;
  60771. /**
  60772. * Gets the rgb component (input)
  60773. */
  60774. get rgbIn(): NodeMaterialConnectionPoint;
  60775. /**
  60776. * Gets the r component (input)
  60777. */
  60778. get r(): NodeMaterialConnectionPoint;
  60779. /**
  60780. * Gets the g component (input)
  60781. */
  60782. get g(): NodeMaterialConnectionPoint;
  60783. /**
  60784. * Gets the b component (input)
  60785. */
  60786. get b(): NodeMaterialConnectionPoint;
  60787. /**
  60788. * Gets the a component (input)
  60789. */
  60790. get a(): NodeMaterialConnectionPoint;
  60791. /**
  60792. * Gets the rgba component (output)
  60793. */
  60794. get rgba(): NodeMaterialConnectionPoint;
  60795. /**
  60796. * Gets the rgb component (output)
  60797. */
  60798. get rgbOut(): NodeMaterialConnectionPoint;
  60799. /**
  60800. * Gets the rgb component (output)
  60801. * @deprecated Please use rgbOut instead.
  60802. */
  60803. get rgb(): NodeMaterialConnectionPoint;
  60804. protected _buildBlock(state: NodeMaterialBuildState): this;
  60805. }
  60806. }
  60807. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60811. /**
  60812. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60813. */
  60814. export class VectorMergerBlock extends NodeMaterialBlock {
  60815. /**
  60816. * Create a new VectorMergerBlock
  60817. * @param name defines the block name
  60818. */
  60819. constructor(name: string);
  60820. /**
  60821. * Gets the current class name
  60822. * @returns the class name
  60823. */
  60824. getClassName(): string;
  60825. /**
  60826. * Gets the xyz component (input)
  60827. */
  60828. get xyzIn(): NodeMaterialConnectionPoint;
  60829. /**
  60830. * Gets the xy component (input)
  60831. */
  60832. get xyIn(): NodeMaterialConnectionPoint;
  60833. /**
  60834. * Gets the x component (input)
  60835. */
  60836. get x(): NodeMaterialConnectionPoint;
  60837. /**
  60838. * Gets the y component (input)
  60839. */
  60840. get y(): NodeMaterialConnectionPoint;
  60841. /**
  60842. * Gets the z component (input)
  60843. */
  60844. get z(): NodeMaterialConnectionPoint;
  60845. /**
  60846. * Gets the w component (input)
  60847. */
  60848. get w(): NodeMaterialConnectionPoint;
  60849. /**
  60850. * Gets the xyzw component (output)
  60851. */
  60852. get xyzw(): NodeMaterialConnectionPoint;
  60853. /**
  60854. * Gets the xyz component (output)
  60855. */
  60856. get xyzOut(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the xy component (output)
  60859. */
  60860. get xyOut(): NodeMaterialConnectionPoint;
  60861. /**
  60862. * Gets the xy component (output)
  60863. * @deprecated Please use xyOut instead.
  60864. */
  60865. get xy(): NodeMaterialConnectionPoint;
  60866. /**
  60867. * Gets the xyz component (output)
  60868. * @deprecated Please use xyzOut instead.
  60869. */
  60870. get xyz(): NodeMaterialConnectionPoint;
  60871. protected _buildBlock(state: NodeMaterialBuildState): this;
  60872. }
  60873. }
  60874. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60878. /**
  60879. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60880. */
  60881. export class ColorSplitterBlock extends NodeMaterialBlock {
  60882. /**
  60883. * Create a new ColorSplitterBlock
  60884. * @param name defines the block name
  60885. */
  60886. constructor(name: string);
  60887. /**
  60888. * Gets the current class name
  60889. * @returns the class name
  60890. */
  60891. getClassName(): string;
  60892. /**
  60893. * Gets the rgba component (input)
  60894. */
  60895. get rgba(): NodeMaterialConnectionPoint;
  60896. /**
  60897. * Gets the rgb component (input)
  60898. */
  60899. get rgbIn(): NodeMaterialConnectionPoint;
  60900. /**
  60901. * Gets the rgb component (output)
  60902. */
  60903. get rgbOut(): NodeMaterialConnectionPoint;
  60904. /**
  60905. * Gets the r component (output)
  60906. */
  60907. get r(): NodeMaterialConnectionPoint;
  60908. /**
  60909. * Gets the g component (output)
  60910. */
  60911. get g(): NodeMaterialConnectionPoint;
  60912. /**
  60913. * Gets the b component (output)
  60914. */
  60915. get b(): NodeMaterialConnectionPoint;
  60916. /**
  60917. * Gets the a component (output)
  60918. */
  60919. get a(): NodeMaterialConnectionPoint;
  60920. protected _inputRename(name: string): string;
  60921. protected _outputRename(name: string): string;
  60922. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60923. }
  60924. }
  60925. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60928. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60929. /**
  60930. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60931. */
  60932. export class VectorSplitterBlock extends NodeMaterialBlock {
  60933. /**
  60934. * Create a new VectorSplitterBlock
  60935. * @param name defines the block name
  60936. */
  60937. constructor(name: string);
  60938. /**
  60939. * Gets the current class name
  60940. * @returns the class name
  60941. */
  60942. getClassName(): string;
  60943. /**
  60944. * Gets the xyzw component (input)
  60945. */
  60946. get xyzw(): NodeMaterialConnectionPoint;
  60947. /**
  60948. * Gets the xyz component (input)
  60949. */
  60950. get xyzIn(): NodeMaterialConnectionPoint;
  60951. /**
  60952. * Gets the xy component (input)
  60953. */
  60954. get xyIn(): NodeMaterialConnectionPoint;
  60955. /**
  60956. * Gets the xyz component (output)
  60957. */
  60958. get xyzOut(): NodeMaterialConnectionPoint;
  60959. /**
  60960. * Gets the xy component (output)
  60961. */
  60962. get xyOut(): NodeMaterialConnectionPoint;
  60963. /**
  60964. * Gets the x component (output)
  60965. */
  60966. get x(): NodeMaterialConnectionPoint;
  60967. /**
  60968. * Gets the y component (output)
  60969. */
  60970. get y(): NodeMaterialConnectionPoint;
  60971. /**
  60972. * Gets the z component (output)
  60973. */
  60974. get z(): NodeMaterialConnectionPoint;
  60975. /**
  60976. * Gets the w component (output)
  60977. */
  60978. get w(): NodeMaterialConnectionPoint;
  60979. protected _inputRename(name: string): string;
  60980. protected _outputRename(name: string): string;
  60981. protected _buildBlock(state: NodeMaterialBuildState): this;
  60982. }
  60983. }
  60984. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60985. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60986. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60988. /**
  60989. * Block used to lerp between 2 values
  60990. */
  60991. export class LerpBlock extends NodeMaterialBlock {
  60992. /**
  60993. * Creates a new LerpBlock
  60994. * @param name defines the block name
  60995. */
  60996. constructor(name: string);
  60997. /**
  60998. * Gets the current class name
  60999. * @returns the class name
  61000. */
  61001. getClassName(): string;
  61002. /**
  61003. * Gets the left operand input component
  61004. */
  61005. get left(): NodeMaterialConnectionPoint;
  61006. /**
  61007. * Gets the right operand input component
  61008. */
  61009. get right(): NodeMaterialConnectionPoint;
  61010. /**
  61011. * Gets the gradient operand input component
  61012. */
  61013. get gradient(): NodeMaterialConnectionPoint;
  61014. /**
  61015. * Gets the output component
  61016. */
  61017. get output(): NodeMaterialConnectionPoint;
  61018. protected _buildBlock(state: NodeMaterialBuildState): this;
  61019. }
  61020. }
  61021. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  61022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61025. /**
  61026. * Block used to divide 2 vectors
  61027. */
  61028. export class DivideBlock extends NodeMaterialBlock {
  61029. /**
  61030. * Creates a new DivideBlock
  61031. * @param name defines the block name
  61032. */
  61033. constructor(name: string);
  61034. /**
  61035. * Gets the current class name
  61036. * @returns the class name
  61037. */
  61038. getClassName(): string;
  61039. /**
  61040. * Gets the left operand input component
  61041. */
  61042. get left(): NodeMaterialConnectionPoint;
  61043. /**
  61044. * Gets the right operand input component
  61045. */
  61046. get right(): NodeMaterialConnectionPoint;
  61047. /**
  61048. * Gets the output component
  61049. */
  61050. get output(): NodeMaterialConnectionPoint;
  61051. protected _buildBlock(state: NodeMaterialBuildState): this;
  61052. }
  61053. }
  61054. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  61055. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61058. /**
  61059. * Block used to subtract 2 vectors
  61060. */
  61061. export class SubtractBlock extends NodeMaterialBlock {
  61062. /**
  61063. * Creates a new SubtractBlock
  61064. * @param name defines the block name
  61065. */
  61066. constructor(name: string);
  61067. /**
  61068. * Gets the current class name
  61069. * @returns the class name
  61070. */
  61071. getClassName(): string;
  61072. /**
  61073. * Gets the left operand input component
  61074. */
  61075. get left(): NodeMaterialConnectionPoint;
  61076. /**
  61077. * Gets the right operand input component
  61078. */
  61079. get right(): NodeMaterialConnectionPoint;
  61080. /**
  61081. * Gets the output component
  61082. */
  61083. get output(): NodeMaterialConnectionPoint;
  61084. protected _buildBlock(state: NodeMaterialBuildState): this;
  61085. }
  61086. }
  61087. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  61088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61091. /**
  61092. * Block used to step a value
  61093. */
  61094. export class StepBlock extends NodeMaterialBlock {
  61095. /**
  61096. * Creates a new StepBlock
  61097. * @param name defines the block name
  61098. */
  61099. constructor(name: string);
  61100. /**
  61101. * Gets the current class name
  61102. * @returns the class name
  61103. */
  61104. getClassName(): string;
  61105. /**
  61106. * Gets the value operand input component
  61107. */
  61108. get value(): NodeMaterialConnectionPoint;
  61109. /**
  61110. * Gets the edge operand input component
  61111. */
  61112. get edge(): NodeMaterialConnectionPoint;
  61113. /**
  61114. * Gets the output component
  61115. */
  61116. get output(): NodeMaterialConnectionPoint;
  61117. protected _buildBlock(state: NodeMaterialBuildState): this;
  61118. }
  61119. }
  61120. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  61121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61124. /**
  61125. * Block used to get the opposite (1 - x) of a value
  61126. */
  61127. export class OneMinusBlock extends NodeMaterialBlock {
  61128. /**
  61129. * Creates a new OneMinusBlock
  61130. * @param name defines the block name
  61131. */
  61132. constructor(name: string);
  61133. /**
  61134. * Gets the current class name
  61135. * @returns the class name
  61136. */
  61137. getClassName(): string;
  61138. /**
  61139. * Gets the input component
  61140. */
  61141. get input(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the output component
  61144. */
  61145. get output(): NodeMaterialConnectionPoint;
  61146. protected _buildBlock(state: NodeMaterialBuildState): this;
  61147. }
  61148. }
  61149. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  61150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61153. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61154. /**
  61155. * Block used to get the view direction
  61156. */
  61157. export class ViewDirectionBlock extends NodeMaterialBlock {
  61158. /**
  61159. * Creates a new ViewDirectionBlock
  61160. * @param name defines the block name
  61161. */
  61162. constructor(name: string);
  61163. /**
  61164. * Gets the current class name
  61165. * @returns the class name
  61166. */
  61167. getClassName(): string;
  61168. /**
  61169. * Gets the world position component
  61170. */
  61171. get worldPosition(): NodeMaterialConnectionPoint;
  61172. /**
  61173. * Gets the camera position component
  61174. */
  61175. get cameraPosition(): NodeMaterialConnectionPoint;
  61176. /**
  61177. * Gets the output component
  61178. */
  61179. get output(): NodeMaterialConnectionPoint;
  61180. autoConfigure(material: NodeMaterial): void;
  61181. protected _buildBlock(state: NodeMaterialBuildState): this;
  61182. }
  61183. }
  61184. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  61185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61188. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61189. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  61190. /**
  61191. * Block used to compute fresnel value
  61192. */
  61193. export class FresnelBlock extends NodeMaterialBlock {
  61194. /**
  61195. * Create a new FresnelBlock
  61196. * @param name defines the block name
  61197. */
  61198. constructor(name: string);
  61199. /**
  61200. * Gets the current class name
  61201. * @returns the class name
  61202. */
  61203. getClassName(): string;
  61204. /**
  61205. * Gets the world normal input component
  61206. */
  61207. get worldNormal(): NodeMaterialConnectionPoint;
  61208. /**
  61209. * Gets the view direction input component
  61210. */
  61211. get viewDirection(): NodeMaterialConnectionPoint;
  61212. /**
  61213. * Gets the bias input component
  61214. */
  61215. get bias(): NodeMaterialConnectionPoint;
  61216. /**
  61217. * Gets the camera (or eye) position component
  61218. */
  61219. get power(): NodeMaterialConnectionPoint;
  61220. /**
  61221. * Gets the fresnel output component
  61222. */
  61223. get fresnel(): NodeMaterialConnectionPoint;
  61224. autoConfigure(material: NodeMaterial): void;
  61225. protected _buildBlock(state: NodeMaterialBuildState): this;
  61226. }
  61227. }
  61228. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  61229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61232. /**
  61233. * Block used to get the max of 2 values
  61234. */
  61235. export class MaxBlock extends NodeMaterialBlock {
  61236. /**
  61237. * Creates a new MaxBlock
  61238. * @param name defines the block name
  61239. */
  61240. constructor(name: string);
  61241. /**
  61242. * Gets the current class name
  61243. * @returns the class name
  61244. */
  61245. getClassName(): string;
  61246. /**
  61247. * Gets the left operand input component
  61248. */
  61249. get left(): NodeMaterialConnectionPoint;
  61250. /**
  61251. * Gets the right operand input component
  61252. */
  61253. get right(): NodeMaterialConnectionPoint;
  61254. /**
  61255. * Gets the output component
  61256. */
  61257. get output(): NodeMaterialConnectionPoint;
  61258. protected _buildBlock(state: NodeMaterialBuildState): this;
  61259. }
  61260. }
  61261. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  61262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61265. /**
  61266. * Block used to get the min of 2 values
  61267. */
  61268. export class MinBlock extends NodeMaterialBlock {
  61269. /**
  61270. * Creates a new MinBlock
  61271. * @param name defines the block name
  61272. */
  61273. constructor(name: string);
  61274. /**
  61275. * Gets the current class name
  61276. * @returns the class name
  61277. */
  61278. getClassName(): string;
  61279. /**
  61280. * Gets the left operand input component
  61281. */
  61282. get left(): NodeMaterialConnectionPoint;
  61283. /**
  61284. * Gets the right operand input component
  61285. */
  61286. get right(): NodeMaterialConnectionPoint;
  61287. /**
  61288. * Gets the output component
  61289. */
  61290. get output(): NodeMaterialConnectionPoint;
  61291. protected _buildBlock(state: NodeMaterialBuildState): this;
  61292. }
  61293. }
  61294. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  61295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61298. /**
  61299. * Block used to get the distance between 2 values
  61300. */
  61301. export class DistanceBlock extends NodeMaterialBlock {
  61302. /**
  61303. * Creates a new DistanceBlock
  61304. * @param name defines the block name
  61305. */
  61306. constructor(name: string);
  61307. /**
  61308. * Gets the current class name
  61309. * @returns the class name
  61310. */
  61311. getClassName(): string;
  61312. /**
  61313. * Gets the left operand input component
  61314. */
  61315. get left(): NodeMaterialConnectionPoint;
  61316. /**
  61317. * Gets the right operand input component
  61318. */
  61319. get right(): NodeMaterialConnectionPoint;
  61320. /**
  61321. * Gets the output component
  61322. */
  61323. get output(): NodeMaterialConnectionPoint;
  61324. protected _buildBlock(state: NodeMaterialBuildState): this;
  61325. }
  61326. }
  61327. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  61328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61331. /**
  61332. * Block used to get the length of a vector
  61333. */
  61334. export class LengthBlock extends NodeMaterialBlock {
  61335. /**
  61336. * Creates a new LengthBlock
  61337. * @param name defines the block name
  61338. */
  61339. constructor(name: string);
  61340. /**
  61341. * Gets the current class name
  61342. * @returns the class name
  61343. */
  61344. getClassName(): string;
  61345. /**
  61346. * Gets the value input component
  61347. */
  61348. get value(): NodeMaterialConnectionPoint;
  61349. /**
  61350. * Gets the output component
  61351. */
  61352. get output(): NodeMaterialConnectionPoint;
  61353. protected _buildBlock(state: NodeMaterialBuildState): this;
  61354. }
  61355. }
  61356. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  61357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61360. /**
  61361. * Block used to get negative version of a value (i.e. x * -1)
  61362. */
  61363. export class NegateBlock extends NodeMaterialBlock {
  61364. /**
  61365. * Creates a new NegateBlock
  61366. * @param name defines the block name
  61367. */
  61368. constructor(name: string);
  61369. /**
  61370. * Gets the current class name
  61371. * @returns the class name
  61372. */
  61373. getClassName(): string;
  61374. /**
  61375. * Gets the value input component
  61376. */
  61377. get value(): NodeMaterialConnectionPoint;
  61378. /**
  61379. * Gets the output component
  61380. */
  61381. get output(): NodeMaterialConnectionPoint;
  61382. protected _buildBlock(state: NodeMaterialBuildState): this;
  61383. }
  61384. }
  61385. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  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 get the value of the first parameter raised to the power of the second
  61391. */
  61392. export class PowBlock extends NodeMaterialBlock {
  61393. /**
  61394. * Creates a new PowBlock
  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 value operand input component
  61405. */
  61406. get value(): NodeMaterialConnectionPoint;
  61407. /**
  61408. * Gets the power operand input component
  61409. */
  61410. get power(): NodeMaterialConnectionPoint;
  61411. /**
  61412. * Gets the output component
  61413. */
  61414. get output(): NodeMaterialConnectionPoint;
  61415. protected _buildBlock(state: NodeMaterialBuildState): this;
  61416. }
  61417. }
  61418. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  61419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61422. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61423. /**
  61424. * Block used to get a random number
  61425. */
  61426. export class RandomNumberBlock extends NodeMaterialBlock {
  61427. /**
  61428. * Creates a new RandomNumberBlock
  61429. * @param name defines the block name
  61430. */
  61431. constructor(name: string);
  61432. /**
  61433. * Gets the current class name
  61434. * @returns the class name
  61435. */
  61436. getClassName(): string;
  61437. /**
  61438. * Gets the seed input component
  61439. */
  61440. get seed(): NodeMaterialConnectionPoint;
  61441. /**
  61442. * Gets the output component
  61443. */
  61444. get output(): NodeMaterialConnectionPoint;
  61445. protected _buildBlock(state: NodeMaterialBuildState): this;
  61446. }
  61447. }
  61448. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  61449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61452. /**
  61453. * Block used to compute arc tangent of 2 values
  61454. */
  61455. export class ArcTan2Block extends NodeMaterialBlock {
  61456. /**
  61457. * Creates a new ArcTan2Block
  61458. * @param name defines the block name
  61459. */
  61460. constructor(name: string);
  61461. /**
  61462. * Gets the current class name
  61463. * @returns the class name
  61464. */
  61465. getClassName(): string;
  61466. /**
  61467. * Gets the x operand input component
  61468. */
  61469. get x(): NodeMaterialConnectionPoint;
  61470. /**
  61471. * Gets the y operand input component
  61472. */
  61473. get y(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the output component
  61476. */
  61477. get output(): NodeMaterialConnectionPoint;
  61478. protected _buildBlock(state: NodeMaterialBuildState): this;
  61479. }
  61480. }
  61481. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  61482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61485. /**
  61486. * Block used to smooth step a value
  61487. */
  61488. export class SmoothStepBlock extends NodeMaterialBlock {
  61489. /**
  61490. * Creates a new SmoothStepBlock
  61491. * @param name defines the block name
  61492. */
  61493. constructor(name: string);
  61494. /**
  61495. * Gets the current class name
  61496. * @returns the class name
  61497. */
  61498. getClassName(): string;
  61499. /**
  61500. * Gets the value operand input component
  61501. */
  61502. get value(): NodeMaterialConnectionPoint;
  61503. /**
  61504. * Gets the first edge operand input component
  61505. */
  61506. get edge0(): NodeMaterialConnectionPoint;
  61507. /**
  61508. * Gets the second edge operand input component
  61509. */
  61510. get edge1(): NodeMaterialConnectionPoint;
  61511. /**
  61512. * Gets the output component
  61513. */
  61514. get output(): NodeMaterialConnectionPoint;
  61515. protected _buildBlock(state: NodeMaterialBuildState): this;
  61516. }
  61517. }
  61518. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  61519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61522. /**
  61523. * Block used to get the reciprocal (1 / x) of a value
  61524. */
  61525. export class ReciprocalBlock extends NodeMaterialBlock {
  61526. /**
  61527. * Creates a new ReciprocalBlock
  61528. * @param name defines the block name
  61529. */
  61530. constructor(name: string);
  61531. /**
  61532. * Gets the current class name
  61533. * @returns the class name
  61534. */
  61535. getClassName(): string;
  61536. /**
  61537. * Gets the input component
  61538. */
  61539. get input(): NodeMaterialConnectionPoint;
  61540. /**
  61541. * Gets the output component
  61542. */
  61543. get output(): NodeMaterialConnectionPoint;
  61544. protected _buildBlock(state: NodeMaterialBuildState): this;
  61545. }
  61546. }
  61547. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  61548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61551. /**
  61552. * Block used to replace a color by another one
  61553. */
  61554. export class ReplaceColorBlock extends NodeMaterialBlock {
  61555. /**
  61556. * Creates a new ReplaceColorBlock
  61557. * @param name defines the block name
  61558. */
  61559. constructor(name: string);
  61560. /**
  61561. * Gets the current class name
  61562. * @returns the class name
  61563. */
  61564. getClassName(): string;
  61565. /**
  61566. * Gets the value input component
  61567. */
  61568. get value(): NodeMaterialConnectionPoint;
  61569. /**
  61570. * Gets the reference input component
  61571. */
  61572. get reference(): NodeMaterialConnectionPoint;
  61573. /**
  61574. * Gets the distance input component
  61575. */
  61576. get distance(): NodeMaterialConnectionPoint;
  61577. /**
  61578. * Gets the replacement input component
  61579. */
  61580. get replacement(): NodeMaterialConnectionPoint;
  61581. /**
  61582. * Gets the output component
  61583. */
  61584. get output(): NodeMaterialConnectionPoint;
  61585. protected _buildBlock(state: NodeMaterialBuildState): this;
  61586. }
  61587. }
  61588. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  61589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61592. /**
  61593. * Block used to posterize a value
  61594. * @see https://en.wikipedia.org/wiki/Posterization
  61595. */
  61596. export class PosterizeBlock extends NodeMaterialBlock {
  61597. /**
  61598. * Creates a new PosterizeBlock
  61599. * @param name defines the block name
  61600. */
  61601. constructor(name: string);
  61602. /**
  61603. * Gets the current class name
  61604. * @returns the class name
  61605. */
  61606. getClassName(): string;
  61607. /**
  61608. * Gets the value input component
  61609. */
  61610. get value(): NodeMaterialConnectionPoint;
  61611. /**
  61612. * Gets the steps input component
  61613. */
  61614. get steps(): NodeMaterialConnectionPoint;
  61615. /**
  61616. * Gets the output component
  61617. */
  61618. get output(): NodeMaterialConnectionPoint;
  61619. protected _buildBlock(state: NodeMaterialBuildState): this;
  61620. }
  61621. }
  61622. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  61623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61626. import { Scene } from "babylonjs/scene";
  61627. /**
  61628. * Operations supported by the Wave block
  61629. */
  61630. export enum WaveBlockKind {
  61631. /** SawTooth */
  61632. SawTooth = 0,
  61633. /** Square */
  61634. Square = 1,
  61635. /** Triangle */
  61636. Triangle = 2
  61637. }
  61638. /**
  61639. * Block used to apply wave operation to floats
  61640. */
  61641. export class WaveBlock extends NodeMaterialBlock {
  61642. /**
  61643. * Gets or sets the kibnd of wave to be applied by the block
  61644. */
  61645. kind: WaveBlockKind;
  61646. /**
  61647. * Creates a new WaveBlock
  61648. * @param name defines the block name
  61649. */
  61650. constructor(name: string);
  61651. /**
  61652. * Gets the current class name
  61653. * @returns the class name
  61654. */
  61655. getClassName(): string;
  61656. /**
  61657. * Gets the input component
  61658. */
  61659. get input(): NodeMaterialConnectionPoint;
  61660. /**
  61661. * Gets the output component
  61662. */
  61663. get output(): NodeMaterialConnectionPoint;
  61664. protected _buildBlock(state: NodeMaterialBuildState): this;
  61665. serialize(): any;
  61666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61667. }
  61668. }
  61669. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  61670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61673. import { Color3 } from "babylonjs/Maths/math.color";
  61674. import { Scene } from "babylonjs/scene";
  61675. /**
  61676. * Class used to store a color step for the GradientBlock
  61677. */
  61678. export class GradientBlockColorStep {
  61679. /**
  61680. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61681. */
  61682. step: number;
  61683. /**
  61684. * Gets or sets the color associated with this step
  61685. */
  61686. color: Color3;
  61687. /**
  61688. * Creates a new GradientBlockColorStep
  61689. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  61690. * @param color defines the color associated with this step
  61691. */
  61692. constructor(
  61693. /**
  61694. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61695. */
  61696. step: number,
  61697. /**
  61698. * Gets or sets the color associated with this step
  61699. */
  61700. color: Color3);
  61701. }
  61702. /**
  61703. * Block used to return a color from a gradient based on an input value between 0 and 1
  61704. */
  61705. export class GradientBlock extends NodeMaterialBlock {
  61706. /**
  61707. * Gets or sets the list of color steps
  61708. */
  61709. colorSteps: GradientBlockColorStep[];
  61710. /**
  61711. * Creates a new GradientBlock
  61712. * @param name defines the block name
  61713. */
  61714. constructor(name: string);
  61715. /**
  61716. * Gets the current class name
  61717. * @returns the class name
  61718. */
  61719. getClassName(): string;
  61720. /**
  61721. * Gets the gradient input component
  61722. */
  61723. get gradient(): NodeMaterialConnectionPoint;
  61724. /**
  61725. * Gets the output component
  61726. */
  61727. get output(): NodeMaterialConnectionPoint;
  61728. private _writeColorConstant;
  61729. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61730. serialize(): any;
  61731. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61732. protected _dumpPropertiesCode(): string;
  61733. }
  61734. }
  61735. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  61736. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61737. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61739. /**
  61740. * Block used to normalize lerp between 2 values
  61741. */
  61742. export class NLerpBlock extends NodeMaterialBlock {
  61743. /**
  61744. * Creates a new NLerpBlock
  61745. * @param name defines the block name
  61746. */
  61747. constructor(name: string);
  61748. /**
  61749. * Gets the current class name
  61750. * @returns the class name
  61751. */
  61752. getClassName(): string;
  61753. /**
  61754. * Gets the left operand input component
  61755. */
  61756. get left(): NodeMaterialConnectionPoint;
  61757. /**
  61758. * Gets the right operand input component
  61759. */
  61760. get right(): NodeMaterialConnectionPoint;
  61761. /**
  61762. * Gets the gradient operand input component
  61763. */
  61764. get gradient(): NodeMaterialConnectionPoint;
  61765. /**
  61766. * Gets the output component
  61767. */
  61768. get output(): NodeMaterialConnectionPoint;
  61769. protected _buildBlock(state: NodeMaterialBuildState): this;
  61770. }
  61771. }
  61772. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  61773. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61776. import { Scene } from "babylonjs/scene";
  61777. /**
  61778. * block used to Generate a Worley Noise 3D Noise Pattern
  61779. */
  61780. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61781. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61782. manhattanDistance: boolean;
  61783. /**
  61784. * Creates a new WorleyNoise3DBlock
  61785. * @param name defines the block name
  61786. */
  61787. constructor(name: string);
  61788. /**
  61789. * Gets the current class name
  61790. * @returns the class name
  61791. */
  61792. getClassName(): string;
  61793. /**
  61794. * Gets the seed input component
  61795. */
  61796. get seed(): NodeMaterialConnectionPoint;
  61797. /**
  61798. * Gets the jitter input component
  61799. */
  61800. get jitter(): NodeMaterialConnectionPoint;
  61801. /**
  61802. * Gets the output component
  61803. */
  61804. get output(): NodeMaterialConnectionPoint;
  61805. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61806. /**
  61807. * Exposes the properties to the UI?
  61808. */
  61809. protected _dumpPropertiesCode(): string;
  61810. /**
  61811. * Exposes the properties to the Seralize?
  61812. */
  61813. serialize(): any;
  61814. /**
  61815. * Exposes the properties to the deseralize?
  61816. */
  61817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61818. }
  61819. }
  61820. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61824. /**
  61825. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61826. */
  61827. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61828. /**
  61829. * Creates a new SimplexPerlin3DBlock
  61830. * @param name defines the block name
  61831. */
  61832. constructor(name: string);
  61833. /**
  61834. * Gets the current class name
  61835. * @returns the class name
  61836. */
  61837. getClassName(): string;
  61838. /**
  61839. * Gets the seed operand input component
  61840. */
  61841. get seed(): NodeMaterialConnectionPoint;
  61842. /**
  61843. * Gets the output component
  61844. */
  61845. get output(): NodeMaterialConnectionPoint;
  61846. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61847. }
  61848. }
  61849. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61853. /**
  61854. * Block used to blend normals
  61855. */
  61856. export class NormalBlendBlock extends NodeMaterialBlock {
  61857. /**
  61858. * Creates a new NormalBlendBlock
  61859. * @param name defines the block name
  61860. */
  61861. constructor(name: string);
  61862. /**
  61863. * Gets the current class name
  61864. * @returns the class name
  61865. */
  61866. getClassName(): string;
  61867. /**
  61868. * Gets the first input component
  61869. */
  61870. get normalMap0(): NodeMaterialConnectionPoint;
  61871. /**
  61872. * Gets the second input component
  61873. */
  61874. get normalMap1(): NodeMaterialConnectionPoint;
  61875. /**
  61876. * Gets the output component
  61877. */
  61878. get output(): NodeMaterialConnectionPoint;
  61879. protected _buildBlock(state: NodeMaterialBuildState): this;
  61880. }
  61881. }
  61882. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61886. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61887. /**
  61888. * Block used to rotate a 2d vector by a given angle
  61889. */
  61890. export class Rotate2dBlock extends NodeMaterialBlock {
  61891. /**
  61892. * Creates a new Rotate2dBlock
  61893. * @param name defines the block name
  61894. */
  61895. constructor(name: string);
  61896. /**
  61897. * Gets the current class name
  61898. * @returns the class name
  61899. */
  61900. getClassName(): string;
  61901. /**
  61902. * Gets the input vector
  61903. */
  61904. get input(): NodeMaterialConnectionPoint;
  61905. /**
  61906. * Gets the input angle
  61907. */
  61908. get angle(): NodeMaterialConnectionPoint;
  61909. /**
  61910. * Gets the output component
  61911. */
  61912. get output(): NodeMaterialConnectionPoint;
  61913. autoConfigure(material: NodeMaterial): void;
  61914. protected _buildBlock(state: NodeMaterialBuildState): this;
  61915. }
  61916. }
  61917. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  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. /**
  61922. * Block used to get the reflected vector from a direction and a normal
  61923. */
  61924. export class ReflectBlock extends NodeMaterialBlock {
  61925. /**
  61926. * Creates a new ReflectBlock
  61927. * @param name defines the block name
  61928. */
  61929. constructor(name: string);
  61930. /**
  61931. * Gets the current class name
  61932. * @returns the class name
  61933. */
  61934. getClassName(): string;
  61935. /**
  61936. * Gets the incident component
  61937. */
  61938. get incident(): NodeMaterialConnectionPoint;
  61939. /**
  61940. * Gets the normal component
  61941. */
  61942. get normal(): NodeMaterialConnectionPoint;
  61943. /**
  61944. * Gets the output component
  61945. */
  61946. get output(): NodeMaterialConnectionPoint;
  61947. protected _buildBlock(state: NodeMaterialBuildState): this;
  61948. }
  61949. }
  61950. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61954. /**
  61955. * Block used to get the refracted vector from a direction and a normal
  61956. */
  61957. export class RefractBlock extends NodeMaterialBlock {
  61958. /**
  61959. * Creates a new RefractBlock
  61960. * @param name defines the block name
  61961. */
  61962. constructor(name: string);
  61963. /**
  61964. * Gets the current class name
  61965. * @returns the class name
  61966. */
  61967. getClassName(): string;
  61968. /**
  61969. * Gets the incident component
  61970. */
  61971. get incident(): NodeMaterialConnectionPoint;
  61972. /**
  61973. * Gets the normal component
  61974. */
  61975. get normal(): NodeMaterialConnectionPoint;
  61976. /**
  61977. * Gets the index of refraction component
  61978. */
  61979. get ior(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the output component
  61982. */
  61983. get output(): NodeMaterialConnectionPoint;
  61984. protected _buildBlock(state: NodeMaterialBuildState): this;
  61985. }
  61986. }
  61987. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61991. /**
  61992. * Block used to desaturate a color
  61993. */
  61994. export class DesaturateBlock extends NodeMaterialBlock {
  61995. /**
  61996. * Creates a new DesaturateBlock
  61997. * @param name defines the block name
  61998. */
  61999. constructor(name: string);
  62000. /**
  62001. * Gets the current class name
  62002. * @returns the class name
  62003. */
  62004. getClassName(): string;
  62005. /**
  62006. * Gets the color operand input component
  62007. */
  62008. get color(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the level operand input component
  62011. */
  62012. get level(): NodeMaterialConnectionPoint;
  62013. /**
  62014. * Gets the output component
  62015. */
  62016. get output(): NodeMaterialConnectionPoint;
  62017. protected _buildBlock(state: NodeMaterialBuildState): this;
  62018. }
  62019. }
  62020. declare module "babylonjs/Materials/Node/Blocks/index" {
  62021. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  62022. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  62023. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  62024. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  62025. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  62026. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  62027. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  62028. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  62029. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  62030. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  62031. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  62032. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  62033. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  62034. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  62035. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  62036. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  62037. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  62038. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  62039. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  62040. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  62041. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  62042. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  62043. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  62044. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  62045. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  62046. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  62047. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  62048. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  62049. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  62050. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  62051. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  62052. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  62053. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  62054. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  62055. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  62056. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  62057. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  62058. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  62059. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  62060. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  62061. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  62062. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  62063. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  62064. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  62065. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  62066. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  62067. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  62068. }
  62069. declare module "babylonjs/Materials/Node/Optimizers/index" {
  62070. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  62071. }
  62072. declare module "babylonjs/Materials/Node/index" {
  62073. export * from "babylonjs/Materials/Node/Enums/index";
  62074. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62075. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  62076. export * from "babylonjs/Materials/Node/nodeMaterial";
  62077. export * from "babylonjs/Materials/Node/Blocks/index";
  62078. export * from "babylonjs/Materials/Node/Optimizers/index";
  62079. }
  62080. declare module "babylonjs/Materials/effectRenderer" {
  62081. import { Nullable } from "babylonjs/types";
  62082. import { Texture } from "babylonjs/Materials/Textures/texture";
  62083. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62084. import { Viewport } from "babylonjs/Maths/math.viewport";
  62085. import { Observable } from "babylonjs/Misc/observable";
  62086. import { Effect } from "babylonjs/Materials/effect";
  62087. import "babylonjs/Engines/Extensions/engine.renderTarget";
  62088. import "babylonjs/Shaders/postprocess.vertex";
  62089. /**
  62090. * Effect Render Options
  62091. */
  62092. export interface IEffectRendererOptions {
  62093. /**
  62094. * Defines the vertices positions.
  62095. */
  62096. positions?: number[];
  62097. /**
  62098. * Defines the indices.
  62099. */
  62100. indices?: number[];
  62101. }
  62102. /**
  62103. * Helper class to render one or more effects
  62104. */
  62105. export class EffectRenderer {
  62106. private engine;
  62107. private static _DefaultOptions;
  62108. private _vertexBuffers;
  62109. private _indexBuffer;
  62110. private _ringBufferIndex;
  62111. private _ringScreenBuffer;
  62112. private _fullscreenViewport;
  62113. private _getNextFrameBuffer;
  62114. /**
  62115. * Creates an effect renderer
  62116. * @param engine the engine to use for rendering
  62117. * @param options defines the options of the effect renderer
  62118. */
  62119. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62120. /**
  62121. * Sets the current viewport in normalized coordinates 0-1
  62122. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62123. */
  62124. setViewport(viewport?: Viewport): void;
  62125. /**
  62126. * Binds the embedded attributes buffer to the effect.
  62127. * @param effect Defines the effect to bind the attributes for
  62128. */
  62129. bindBuffers(effect: Effect): void;
  62130. /**
  62131. * Sets the current effect wrapper to use during draw.
  62132. * The effect needs to be ready before calling this api.
  62133. * This also sets the default full screen position attribute.
  62134. * @param effectWrapper Defines the effect to draw with
  62135. */
  62136. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62137. /**
  62138. * Draws a full screen quad.
  62139. */
  62140. draw(): void;
  62141. /**
  62142. * renders one or more effects to a specified texture
  62143. * @param effectWrappers list of effects to renderer
  62144. * @param outputTexture texture to draw to, if null it will render to the screen
  62145. */
  62146. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  62147. /**
  62148. * Disposes of the effect renderer
  62149. */
  62150. dispose(): void;
  62151. }
  62152. /**
  62153. * Options to create an EffectWrapper
  62154. */
  62155. interface EffectWrapperCreationOptions {
  62156. /**
  62157. * Engine to use to create the effect
  62158. */
  62159. engine: ThinEngine;
  62160. /**
  62161. * Fragment shader for the effect
  62162. */
  62163. fragmentShader: string;
  62164. /**
  62165. * Vertex shader for the effect
  62166. */
  62167. vertexShader?: string;
  62168. /**
  62169. * Attributes to use in the shader
  62170. */
  62171. attributeNames?: Array<string>;
  62172. /**
  62173. * Uniforms to use in the shader
  62174. */
  62175. uniformNames?: Array<string>;
  62176. /**
  62177. * Texture sampler names to use in the shader
  62178. */
  62179. samplerNames?: Array<string>;
  62180. /**
  62181. * The friendly name of the effect displayed in Spector.
  62182. */
  62183. name?: string;
  62184. }
  62185. /**
  62186. * Wraps an effect to be used for rendering
  62187. */
  62188. export class EffectWrapper {
  62189. /**
  62190. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62191. */
  62192. onApplyObservable: Observable<{}>;
  62193. /**
  62194. * The underlying effect
  62195. */
  62196. effect: Effect;
  62197. /**
  62198. * Creates an effect to be renderer
  62199. * @param creationOptions options to create the effect
  62200. */
  62201. constructor(creationOptions: EffectWrapperCreationOptions);
  62202. /**
  62203. * Disposes of the effect wrapper
  62204. */
  62205. dispose(): void;
  62206. }
  62207. }
  62208. declare module "babylonjs/Materials/index" {
  62209. export * from "babylonjs/Materials/Background/index";
  62210. export * from "babylonjs/Materials/colorCurves";
  62211. export * from "babylonjs/Materials/iEffectFallbacks";
  62212. export * from "babylonjs/Materials/effectFallbacks";
  62213. export * from "babylonjs/Materials/effect";
  62214. export * from "babylonjs/Materials/fresnelParameters";
  62215. export * from "babylonjs/Materials/imageProcessingConfiguration";
  62216. export * from "babylonjs/Materials/material";
  62217. export * from "babylonjs/Materials/materialDefines";
  62218. export * from "babylonjs/Materials/materialHelper";
  62219. export * from "babylonjs/Materials/multiMaterial";
  62220. export * from "babylonjs/Materials/PBR/index";
  62221. export * from "babylonjs/Materials/pushMaterial";
  62222. export * from "babylonjs/Materials/shaderMaterial";
  62223. export * from "babylonjs/Materials/standardMaterial";
  62224. export * from "babylonjs/Materials/Textures/index";
  62225. export * from "babylonjs/Materials/uniformBuffer";
  62226. export * from "babylonjs/Materials/materialFlags";
  62227. export * from "babylonjs/Materials/Node/index";
  62228. export * from "babylonjs/Materials/effectRenderer";
  62229. }
  62230. declare module "babylonjs/Maths/index" {
  62231. export * from "babylonjs/Maths/math.scalar";
  62232. export * from "babylonjs/Maths/math";
  62233. export * from "babylonjs/Maths/sphericalPolynomial";
  62234. }
  62235. declare module "babylonjs/Misc/workerPool" {
  62236. import { IDisposable } from "babylonjs/scene";
  62237. /**
  62238. * Helper class to push actions to a pool of workers.
  62239. */
  62240. export class WorkerPool implements IDisposable {
  62241. private _workerInfos;
  62242. private _pendingActions;
  62243. /**
  62244. * Constructor
  62245. * @param workers Array of workers to use for actions
  62246. */
  62247. constructor(workers: Array<Worker>);
  62248. /**
  62249. * Terminates all workers and clears any pending actions.
  62250. */
  62251. dispose(): void;
  62252. /**
  62253. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62254. * pended until a worker has completed its action.
  62255. * @param action The action to perform. Call onComplete when the action is complete.
  62256. */
  62257. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62258. private _execute;
  62259. }
  62260. }
  62261. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  62262. import { IDisposable } from "babylonjs/scene";
  62263. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  62264. /**
  62265. * Configuration for Draco compression
  62266. */
  62267. export interface IDracoCompressionConfiguration {
  62268. /**
  62269. * Configuration for the decoder.
  62270. */
  62271. decoder: {
  62272. /**
  62273. * The url to the WebAssembly module.
  62274. */
  62275. wasmUrl?: string;
  62276. /**
  62277. * The url to the WebAssembly binary.
  62278. */
  62279. wasmBinaryUrl?: string;
  62280. /**
  62281. * The url to the fallback JavaScript module.
  62282. */
  62283. fallbackUrl?: string;
  62284. };
  62285. }
  62286. /**
  62287. * Draco compression (https://google.github.io/draco/)
  62288. *
  62289. * This class wraps the Draco module.
  62290. *
  62291. * **Encoder**
  62292. *
  62293. * The encoder is not currently implemented.
  62294. *
  62295. * **Decoder**
  62296. *
  62297. * 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.
  62298. *
  62299. * To update the configuration, use the following code:
  62300. * ```javascript
  62301. * DracoCompression.Configuration = {
  62302. * decoder: {
  62303. * wasmUrl: "<url to the WebAssembly library>",
  62304. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62305. * fallbackUrl: "<url to the fallback JavaScript library>",
  62306. * }
  62307. * };
  62308. * ```
  62309. *
  62310. * 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.
  62311. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62312. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62313. *
  62314. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62315. * ```javascript
  62316. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62317. * ```
  62318. *
  62319. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62320. */
  62321. export class DracoCompression implements IDisposable {
  62322. private _workerPoolPromise?;
  62323. private _decoderModulePromise?;
  62324. /**
  62325. * The configuration. Defaults to the following urls:
  62326. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62327. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62328. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62329. */
  62330. static Configuration: IDracoCompressionConfiguration;
  62331. /**
  62332. * Returns true if the decoder configuration is available.
  62333. */
  62334. static get DecoderAvailable(): boolean;
  62335. /**
  62336. * Default number of workers to create when creating the draco compression object.
  62337. */
  62338. static DefaultNumWorkers: number;
  62339. private static GetDefaultNumWorkers;
  62340. private static _Default;
  62341. /**
  62342. * Default instance for the draco compression object.
  62343. */
  62344. static get Default(): DracoCompression;
  62345. /**
  62346. * Constructor
  62347. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62348. */
  62349. constructor(numWorkers?: number);
  62350. /**
  62351. * Stop all async operations and release resources.
  62352. */
  62353. dispose(): void;
  62354. /**
  62355. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  62356. * @returns a promise that resolves when ready
  62357. */
  62358. whenReadyAsync(): Promise<void>;
  62359. /**
  62360. * Decode Draco compressed mesh data to vertex data.
  62361. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  62362. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  62363. * @returns A promise that resolves with the decoded vertex data
  62364. */
  62365. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  62366. [kind: string]: number;
  62367. }): Promise<VertexData>;
  62368. }
  62369. }
  62370. declare module "babylonjs/Meshes/Compression/index" {
  62371. export * from "babylonjs/Meshes/Compression/dracoCompression";
  62372. }
  62373. declare module "babylonjs/Meshes/csg" {
  62374. import { Nullable } from "babylonjs/types";
  62375. import { Scene } from "babylonjs/scene";
  62376. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62377. import { Mesh } from "babylonjs/Meshes/mesh";
  62378. import { Material } from "babylonjs/Materials/material";
  62379. /**
  62380. * Class for building Constructive Solid Geometry
  62381. */
  62382. export class CSG {
  62383. private polygons;
  62384. /**
  62385. * The world matrix
  62386. */
  62387. matrix: Matrix;
  62388. /**
  62389. * Stores the position
  62390. */
  62391. position: Vector3;
  62392. /**
  62393. * Stores the rotation
  62394. */
  62395. rotation: Vector3;
  62396. /**
  62397. * Stores the rotation quaternion
  62398. */
  62399. rotationQuaternion: Nullable<Quaternion>;
  62400. /**
  62401. * Stores the scaling vector
  62402. */
  62403. scaling: Vector3;
  62404. /**
  62405. * Convert the Mesh to CSG
  62406. * @param mesh The Mesh to convert to CSG
  62407. * @returns A new CSG from the Mesh
  62408. */
  62409. static FromMesh(mesh: Mesh): CSG;
  62410. /**
  62411. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  62412. * @param polygons Polygons used to construct a CSG solid
  62413. */
  62414. private static FromPolygons;
  62415. /**
  62416. * Clones, or makes a deep copy, of the CSG
  62417. * @returns A new CSG
  62418. */
  62419. clone(): CSG;
  62420. /**
  62421. * Unions this CSG with another CSG
  62422. * @param csg The CSG to union against this CSG
  62423. * @returns The unioned CSG
  62424. */
  62425. union(csg: CSG): CSG;
  62426. /**
  62427. * Unions this CSG with another CSG in place
  62428. * @param csg The CSG to union against this CSG
  62429. */
  62430. unionInPlace(csg: CSG): void;
  62431. /**
  62432. * Subtracts this CSG with another CSG
  62433. * @param csg The CSG to subtract against this CSG
  62434. * @returns A new CSG
  62435. */
  62436. subtract(csg: CSG): CSG;
  62437. /**
  62438. * Subtracts this CSG with another CSG in place
  62439. * @param csg The CSG to subtact against this CSG
  62440. */
  62441. subtractInPlace(csg: CSG): void;
  62442. /**
  62443. * Intersect this CSG with another CSG
  62444. * @param csg The CSG to intersect against this CSG
  62445. * @returns A new CSG
  62446. */
  62447. intersect(csg: CSG): CSG;
  62448. /**
  62449. * Intersects this CSG with another CSG in place
  62450. * @param csg The CSG to intersect against this CSG
  62451. */
  62452. intersectInPlace(csg: CSG): void;
  62453. /**
  62454. * Return a new CSG solid with solid and empty space switched. This solid is
  62455. * not modified.
  62456. * @returns A new CSG solid with solid and empty space switched
  62457. */
  62458. inverse(): CSG;
  62459. /**
  62460. * Inverses the CSG in place
  62461. */
  62462. inverseInPlace(): void;
  62463. /**
  62464. * This is used to keep meshes transformations so they can be restored
  62465. * when we build back a Babylon Mesh
  62466. * NB : All CSG operations are performed in world coordinates
  62467. * @param csg The CSG to copy the transform attributes from
  62468. * @returns This CSG
  62469. */
  62470. copyTransformAttributes(csg: CSG): CSG;
  62471. /**
  62472. * Build Raw mesh from CSG
  62473. * Coordinates here are in world space
  62474. * @param name The name of the mesh geometry
  62475. * @param scene The Scene
  62476. * @param keepSubMeshes Specifies if the submeshes should be kept
  62477. * @returns A new Mesh
  62478. */
  62479. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62480. /**
  62481. * Build Mesh from CSG taking material and transforms into account
  62482. * @param name The name of the Mesh
  62483. * @param material The material of the Mesh
  62484. * @param scene The Scene
  62485. * @param keepSubMeshes Specifies if submeshes should be kept
  62486. * @returns The new Mesh
  62487. */
  62488. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62489. }
  62490. }
  62491. declare module "babylonjs/Meshes/trailMesh" {
  62492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62493. import { Mesh } from "babylonjs/Meshes/mesh";
  62494. import { Scene } from "babylonjs/scene";
  62495. /**
  62496. * Class used to create a trail following a mesh
  62497. */
  62498. export class TrailMesh extends Mesh {
  62499. private _generator;
  62500. private _autoStart;
  62501. private _running;
  62502. private _diameter;
  62503. private _length;
  62504. private _sectionPolygonPointsCount;
  62505. private _sectionVectors;
  62506. private _sectionNormalVectors;
  62507. private _beforeRenderObserver;
  62508. /**
  62509. * @constructor
  62510. * @param name The value used by scene.getMeshByName() to do a lookup.
  62511. * @param generator The mesh to generate a trail.
  62512. * @param scene The scene to add this mesh to.
  62513. * @param diameter Diameter of trailing mesh. Default is 1.
  62514. * @param length Length of trailing mesh. Default is 60.
  62515. * @param autoStart Automatically start trailing mesh. Default true.
  62516. */
  62517. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  62518. /**
  62519. * "TrailMesh"
  62520. * @returns "TrailMesh"
  62521. */
  62522. getClassName(): string;
  62523. private _createMesh;
  62524. /**
  62525. * Start trailing mesh.
  62526. */
  62527. start(): void;
  62528. /**
  62529. * Stop trailing mesh.
  62530. */
  62531. stop(): void;
  62532. /**
  62533. * Update trailing mesh geometry.
  62534. */
  62535. update(): void;
  62536. /**
  62537. * Returns a new TrailMesh object.
  62538. * @param name is a string, the name given to the new mesh
  62539. * @param newGenerator use new generator object for cloned trail mesh
  62540. * @returns a new mesh
  62541. */
  62542. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  62543. /**
  62544. * Serializes this trail mesh
  62545. * @param serializationObject object to write serialization to
  62546. */
  62547. serialize(serializationObject: any): void;
  62548. /**
  62549. * Parses a serialized trail mesh
  62550. * @param parsedMesh the serialized mesh
  62551. * @param scene the scene to create the trail mesh in
  62552. * @returns the created trail mesh
  62553. */
  62554. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  62555. }
  62556. }
  62557. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  62558. import { Nullable } from "babylonjs/types";
  62559. import { Scene } from "babylonjs/scene";
  62560. import { Vector4 } from "babylonjs/Maths/math.vector";
  62561. import { Color4 } from "babylonjs/Maths/math.color";
  62562. import { Mesh } from "babylonjs/Meshes/mesh";
  62563. /**
  62564. * Class containing static functions to help procedurally build meshes
  62565. */
  62566. export class TiledBoxBuilder {
  62567. /**
  62568. * Creates a box mesh
  62569. * 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)
  62570. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62574. * @param name defines the name of the mesh
  62575. * @param options defines the options used to create the mesh
  62576. * @param scene defines the hosting scene
  62577. * @returns the box mesh
  62578. */
  62579. static CreateTiledBox(name: string, options: {
  62580. pattern?: number;
  62581. width?: number;
  62582. height?: number;
  62583. depth?: number;
  62584. tileSize?: number;
  62585. tileWidth?: number;
  62586. tileHeight?: number;
  62587. alignHorizontal?: number;
  62588. alignVertical?: number;
  62589. faceUV?: Vector4[];
  62590. faceColors?: Color4[];
  62591. sideOrientation?: number;
  62592. updatable?: boolean;
  62593. }, scene?: Nullable<Scene>): Mesh;
  62594. }
  62595. }
  62596. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  62597. import { Vector4 } from "babylonjs/Maths/math.vector";
  62598. import { Mesh } from "babylonjs/Meshes/mesh";
  62599. /**
  62600. * Class containing static functions to help procedurally build meshes
  62601. */
  62602. export class TorusKnotBuilder {
  62603. /**
  62604. * Creates a torus knot mesh
  62605. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62606. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62607. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62608. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62612. * @param name defines the name of the mesh
  62613. * @param options defines the options used to create the mesh
  62614. * @param scene defines the hosting scene
  62615. * @returns the torus knot mesh
  62616. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62617. */
  62618. static CreateTorusKnot(name: string, options: {
  62619. radius?: number;
  62620. tube?: number;
  62621. radialSegments?: number;
  62622. tubularSegments?: number;
  62623. p?: number;
  62624. q?: number;
  62625. updatable?: boolean;
  62626. sideOrientation?: number;
  62627. frontUVs?: Vector4;
  62628. backUVs?: Vector4;
  62629. }, scene: any): Mesh;
  62630. }
  62631. }
  62632. declare module "babylonjs/Meshes/polygonMesh" {
  62633. import { Scene } from "babylonjs/scene";
  62634. import { Vector2 } from "babylonjs/Maths/math.vector";
  62635. import { Mesh } from "babylonjs/Meshes/mesh";
  62636. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  62637. import { Path2 } from "babylonjs/Maths/math.path";
  62638. /**
  62639. * Polygon
  62640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  62641. */
  62642. export class Polygon {
  62643. /**
  62644. * Creates a rectangle
  62645. * @param xmin bottom X coord
  62646. * @param ymin bottom Y coord
  62647. * @param xmax top X coord
  62648. * @param ymax top Y coord
  62649. * @returns points that make the resulting rectation
  62650. */
  62651. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  62652. /**
  62653. * Creates a circle
  62654. * @param radius radius of circle
  62655. * @param cx scale in x
  62656. * @param cy scale in y
  62657. * @param numberOfSides number of sides that make up the circle
  62658. * @returns points that make the resulting circle
  62659. */
  62660. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  62661. /**
  62662. * Creates a polygon from input string
  62663. * @param input Input polygon data
  62664. * @returns the parsed points
  62665. */
  62666. static Parse(input: string): Vector2[];
  62667. /**
  62668. * Starts building a polygon from x and y coordinates
  62669. * @param x x coordinate
  62670. * @param y y coordinate
  62671. * @returns the started path2
  62672. */
  62673. static StartingAt(x: number, y: number): Path2;
  62674. }
  62675. /**
  62676. * Builds a polygon
  62677. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  62678. */
  62679. export class PolygonMeshBuilder {
  62680. private _points;
  62681. private _outlinepoints;
  62682. private _holes;
  62683. private _name;
  62684. private _scene;
  62685. private _epoints;
  62686. private _eholes;
  62687. private _addToepoint;
  62688. /**
  62689. * Babylon reference to the earcut plugin.
  62690. */
  62691. bjsEarcut: any;
  62692. /**
  62693. * Creates a PolygonMeshBuilder
  62694. * @param name name of the builder
  62695. * @param contours Path of the polygon
  62696. * @param scene scene to add to when creating the mesh
  62697. * @param earcutInjection can be used to inject your own earcut reference
  62698. */
  62699. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  62700. /**
  62701. * Adds a whole within the polygon
  62702. * @param hole Array of points defining the hole
  62703. * @returns this
  62704. */
  62705. addHole(hole: Vector2[]): PolygonMeshBuilder;
  62706. /**
  62707. * Creates the polygon
  62708. * @param updatable If the mesh should be updatable
  62709. * @param depth The depth of the mesh created
  62710. * @returns the created mesh
  62711. */
  62712. build(updatable?: boolean, depth?: number): Mesh;
  62713. /**
  62714. * Creates the polygon
  62715. * @param depth The depth of the mesh created
  62716. * @returns the created VertexData
  62717. */
  62718. buildVertexData(depth?: number): VertexData;
  62719. /**
  62720. * Adds a side to the polygon
  62721. * @param positions points that make the polygon
  62722. * @param normals normals of the polygon
  62723. * @param uvs uvs of the polygon
  62724. * @param indices indices of the polygon
  62725. * @param bounds bounds of the polygon
  62726. * @param points points of the polygon
  62727. * @param depth depth of the polygon
  62728. * @param flip flip of the polygon
  62729. */
  62730. private addSide;
  62731. }
  62732. }
  62733. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  62734. import { Scene } from "babylonjs/scene";
  62735. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62736. import { Color4 } from "babylonjs/Maths/math.color";
  62737. import { Mesh } from "babylonjs/Meshes/mesh";
  62738. import { Nullable } from "babylonjs/types";
  62739. /**
  62740. * Class containing static functions to help procedurally build meshes
  62741. */
  62742. export class PolygonBuilder {
  62743. /**
  62744. * Creates a polygon mesh
  62745. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62746. * * 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
  62747. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62750. * * Remember you can only change the shape positions, not their number when updating a polygon
  62751. * @param name defines the name of the mesh
  62752. * @param options defines the options used to create the mesh
  62753. * @param scene defines the hosting scene
  62754. * @param earcutInjection can be used to inject your own earcut reference
  62755. * @returns the polygon mesh
  62756. */
  62757. static CreatePolygon(name: string, options: {
  62758. shape: Vector3[];
  62759. holes?: Vector3[][];
  62760. depth?: number;
  62761. faceUV?: Vector4[];
  62762. faceColors?: Color4[];
  62763. updatable?: boolean;
  62764. sideOrientation?: number;
  62765. frontUVs?: Vector4;
  62766. backUVs?: Vector4;
  62767. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62768. /**
  62769. * Creates an extruded polygon mesh, with depth in the Y direction.
  62770. * * 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)
  62771. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62772. * @param name defines the name of the mesh
  62773. * @param options defines the options used to create the mesh
  62774. * @param scene defines the hosting scene
  62775. * @param earcutInjection can be used to inject your own earcut reference
  62776. * @returns the polygon mesh
  62777. */
  62778. static ExtrudePolygon(name: string, options: {
  62779. shape: Vector3[];
  62780. holes?: Vector3[][];
  62781. depth?: number;
  62782. faceUV?: Vector4[];
  62783. faceColors?: Color4[];
  62784. updatable?: boolean;
  62785. sideOrientation?: number;
  62786. frontUVs?: Vector4;
  62787. backUVs?: Vector4;
  62788. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62789. }
  62790. }
  62791. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  62792. import { Scene } from "babylonjs/scene";
  62793. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62794. import { Mesh } from "babylonjs/Meshes/mesh";
  62795. import { Nullable } from "babylonjs/types";
  62796. /**
  62797. * Class containing static functions to help procedurally build meshes
  62798. */
  62799. export class LatheBuilder {
  62800. /**
  62801. * Creates lathe mesh.
  62802. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62803. * * 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
  62804. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62805. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62806. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62807. * * 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
  62808. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62809. * * 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
  62810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62814. * @param name defines the name of the mesh
  62815. * @param options defines the options used to create the mesh
  62816. * @param scene defines the hosting scene
  62817. * @returns the lathe mesh
  62818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62819. */
  62820. static CreateLathe(name: string, options: {
  62821. shape: Vector3[];
  62822. radius?: number;
  62823. tessellation?: number;
  62824. clip?: number;
  62825. arc?: number;
  62826. closed?: boolean;
  62827. updatable?: boolean;
  62828. sideOrientation?: number;
  62829. frontUVs?: Vector4;
  62830. backUVs?: Vector4;
  62831. cap?: number;
  62832. invertUV?: boolean;
  62833. }, scene?: Nullable<Scene>): Mesh;
  62834. }
  62835. }
  62836. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62837. import { Nullable } from "babylonjs/types";
  62838. import { Scene } from "babylonjs/scene";
  62839. import { Vector4 } from "babylonjs/Maths/math.vector";
  62840. import { Mesh } from "babylonjs/Meshes/mesh";
  62841. /**
  62842. * Class containing static functions to help procedurally build meshes
  62843. */
  62844. export class TiledPlaneBuilder {
  62845. /**
  62846. * Creates a tiled plane mesh
  62847. * * The parameter `pattern` will, depending on value, do nothing or
  62848. * * * flip (reflect about central vertical) alternate tiles across and up
  62849. * * * flip every tile on alternate rows
  62850. * * * rotate (180 degs) alternate tiles across and up
  62851. * * * rotate every tile on alternate rows
  62852. * * * flip and rotate alternate tiles across and up
  62853. * * * flip and rotate every tile on alternate rows
  62854. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62855. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62858. * * 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)
  62859. * * 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)
  62860. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62861. * @param name defines the name of the mesh
  62862. * @param options defines the options used to create the mesh
  62863. * @param scene defines the hosting scene
  62864. * @returns the box mesh
  62865. */
  62866. static CreateTiledPlane(name: string, options: {
  62867. pattern?: number;
  62868. tileSize?: number;
  62869. tileWidth?: number;
  62870. tileHeight?: number;
  62871. size?: number;
  62872. width?: number;
  62873. height?: number;
  62874. alignHorizontal?: number;
  62875. alignVertical?: number;
  62876. sideOrientation?: number;
  62877. frontUVs?: Vector4;
  62878. backUVs?: Vector4;
  62879. updatable?: boolean;
  62880. }, scene?: Nullable<Scene>): Mesh;
  62881. }
  62882. }
  62883. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62884. import { Nullable } from "babylonjs/types";
  62885. import { Scene } from "babylonjs/scene";
  62886. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62887. import { Mesh } from "babylonjs/Meshes/mesh";
  62888. /**
  62889. * Class containing static functions to help procedurally build meshes
  62890. */
  62891. export class TubeBuilder {
  62892. /**
  62893. * Creates a tube mesh.
  62894. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62895. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62896. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62897. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62898. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62899. * * 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)
  62900. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62901. * * 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
  62902. * * 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
  62903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62905. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62907. * @param name defines the name of the mesh
  62908. * @param options defines the options used to create the mesh
  62909. * @param scene defines the hosting scene
  62910. * @returns the tube mesh
  62911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62912. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62913. */
  62914. static CreateTube(name: string, options: {
  62915. path: Vector3[];
  62916. radius?: number;
  62917. tessellation?: number;
  62918. radiusFunction?: {
  62919. (i: number, distance: number): number;
  62920. };
  62921. cap?: number;
  62922. arc?: number;
  62923. updatable?: boolean;
  62924. sideOrientation?: number;
  62925. frontUVs?: Vector4;
  62926. backUVs?: Vector4;
  62927. instance?: Mesh;
  62928. invertUV?: boolean;
  62929. }, scene?: Nullable<Scene>): Mesh;
  62930. }
  62931. }
  62932. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62933. import { Scene } from "babylonjs/scene";
  62934. import { Vector4 } from "babylonjs/Maths/math.vector";
  62935. import { Mesh } from "babylonjs/Meshes/mesh";
  62936. import { Nullable } from "babylonjs/types";
  62937. /**
  62938. * Class containing static functions to help procedurally build meshes
  62939. */
  62940. export class IcoSphereBuilder {
  62941. /**
  62942. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62943. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62944. * * 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`)
  62945. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62946. * * 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
  62947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62948. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62950. * @param name defines the name of the mesh
  62951. * @param options defines the options used to create the mesh
  62952. * @param scene defines the hosting scene
  62953. * @returns the icosahedron mesh
  62954. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62955. */
  62956. static CreateIcoSphere(name: string, options: {
  62957. radius?: number;
  62958. radiusX?: number;
  62959. radiusY?: number;
  62960. radiusZ?: number;
  62961. flat?: boolean;
  62962. subdivisions?: number;
  62963. sideOrientation?: number;
  62964. frontUVs?: Vector4;
  62965. backUVs?: Vector4;
  62966. updatable?: boolean;
  62967. }, scene?: Nullable<Scene>): Mesh;
  62968. }
  62969. }
  62970. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62971. import { Vector3 } from "babylonjs/Maths/math.vector";
  62972. import { Mesh } from "babylonjs/Meshes/mesh";
  62973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62974. /**
  62975. * Class containing static functions to help procedurally build meshes
  62976. */
  62977. export class DecalBuilder {
  62978. /**
  62979. * Creates a decal mesh.
  62980. * 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
  62981. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62982. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62983. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62984. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62985. * @param name defines the name of the mesh
  62986. * @param sourceMesh defines the mesh where the decal must be applied
  62987. * @param options defines the options used to create the mesh
  62988. * @param scene defines the hosting scene
  62989. * @returns the decal mesh
  62990. * @see https://doc.babylonjs.com/how_to/decals
  62991. */
  62992. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62993. position?: Vector3;
  62994. normal?: Vector3;
  62995. size?: Vector3;
  62996. angle?: number;
  62997. }): Mesh;
  62998. }
  62999. }
  63000. declare module "babylonjs/Meshes/meshBuilder" {
  63001. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  63002. import { Nullable } from "babylonjs/types";
  63003. import { Scene } from "babylonjs/scene";
  63004. import { Mesh } from "babylonjs/Meshes/mesh";
  63005. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  63006. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  63007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63008. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63009. import { Plane } from "babylonjs/Maths/math.plane";
  63010. /**
  63011. * Class containing static functions to help procedurally build meshes
  63012. */
  63013. export class MeshBuilder {
  63014. /**
  63015. * Creates a box mesh
  63016. * * The parameter `size` sets the size (float) of each box side (default 1)
  63017. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63018. * * 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)
  63019. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63023. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63024. * @param name defines the name of the mesh
  63025. * @param options defines the options used to create the mesh
  63026. * @param scene defines the hosting scene
  63027. * @returns the box mesh
  63028. */
  63029. static CreateBox(name: string, options: {
  63030. size?: number;
  63031. width?: number;
  63032. height?: number;
  63033. depth?: number;
  63034. faceUV?: Vector4[];
  63035. faceColors?: Color4[];
  63036. sideOrientation?: number;
  63037. frontUVs?: Vector4;
  63038. backUVs?: Vector4;
  63039. updatable?: boolean;
  63040. }, scene?: Nullable<Scene>): Mesh;
  63041. /**
  63042. * Creates a tiled box mesh
  63043. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63045. * @param name defines the name of the mesh
  63046. * @param options defines the options used to create the mesh
  63047. * @param scene defines the hosting scene
  63048. * @returns the tiled box mesh
  63049. */
  63050. static CreateTiledBox(name: string, options: {
  63051. pattern?: number;
  63052. size?: number;
  63053. width?: number;
  63054. height?: number;
  63055. depth: number;
  63056. tileSize?: number;
  63057. tileWidth?: number;
  63058. tileHeight?: number;
  63059. faceUV?: Vector4[];
  63060. faceColors?: Color4[];
  63061. alignHorizontal?: number;
  63062. alignVertical?: number;
  63063. sideOrientation?: number;
  63064. updatable?: boolean;
  63065. }, scene?: Nullable<Scene>): Mesh;
  63066. /**
  63067. * Creates a sphere mesh
  63068. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63069. * * 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`)
  63070. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63071. * * 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
  63072. * * 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)
  63073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63076. * @param name defines the name of the mesh
  63077. * @param options defines the options used to create the mesh
  63078. * @param scene defines the hosting scene
  63079. * @returns the sphere mesh
  63080. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63081. */
  63082. static CreateSphere(name: string, options: {
  63083. segments?: number;
  63084. diameter?: number;
  63085. diameterX?: number;
  63086. diameterY?: number;
  63087. diameterZ?: number;
  63088. arc?: number;
  63089. slice?: number;
  63090. sideOrientation?: number;
  63091. frontUVs?: Vector4;
  63092. backUVs?: Vector4;
  63093. updatable?: boolean;
  63094. }, scene?: Nullable<Scene>): Mesh;
  63095. /**
  63096. * Creates a plane polygonal mesh. By default, this is a disc
  63097. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63098. * * 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
  63099. * * 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
  63100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63103. * @param name defines the name of the mesh
  63104. * @param options defines the options used to create the mesh
  63105. * @param scene defines the hosting scene
  63106. * @returns the plane polygonal mesh
  63107. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63108. */
  63109. static CreateDisc(name: string, options: {
  63110. radius?: number;
  63111. tessellation?: number;
  63112. arc?: number;
  63113. updatable?: boolean;
  63114. sideOrientation?: number;
  63115. frontUVs?: Vector4;
  63116. backUVs?: Vector4;
  63117. }, scene?: Nullable<Scene>): Mesh;
  63118. /**
  63119. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63120. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63121. * * 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`)
  63122. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63123. * * 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
  63124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63127. * @param name defines the name of the mesh
  63128. * @param options defines the options used to create the mesh
  63129. * @param scene defines the hosting scene
  63130. * @returns the icosahedron mesh
  63131. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63132. */
  63133. static CreateIcoSphere(name: string, options: {
  63134. radius?: number;
  63135. radiusX?: number;
  63136. radiusY?: number;
  63137. radiusZ?: number;
  63138. flat?: boolean;
  63139. subdivisions?: number;
  63140. sideOrientation?: number;
  63141. frontUVs?: Vector4;
  63142. backUVs?: Vector4;
  63143. updatable?: boolean;
  63144. }, scene?: Nullable<Scene>): Mesh;
  63145. /**
  63146. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63147. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63148. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63149. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63150. * * 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
  63151. * * 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
  63152. * * 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
  63153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63156. * * 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
  63157. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63158. * * 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
  63159. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63161. * @param name defines the name of the mesh
  63162. * @param options defines the options used to create the mesh
  63163. * @param scene defines the hosting scene
  63164. * @returns the ribbon mesh
  63165. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63166. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63167. */
  63168. static CreateRibbon(name: string, options: {
  63169. pathArray: Vector3[][];
  63170. closeArray?: boolean;
  63171. closePath?: boolean;
  63172. offset?: number;
  63173. updatable?: boolean;
  63174. sideOrientation?: number;
  63175. frontUVs?: Vector4;
  63176. backUVs?: Vector4;
  63177. instance?: Mesh;
  63178. invertUV?: boolean;
  63179. uvs?: Vector2[];
  63180. colors?: Color4[];
  63181. }, scene?: Nullable<Scene>): Mesh;
  63182. /**
  63183. * Creates a cylinder or a cone mesh
  63184. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63185. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63186. * * 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.
  63187. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63188. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63189. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63190. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63191. * * 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).
  63192. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63193. * * 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).
  63194. * * 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
  63195. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63196. * * 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
  63197. * * 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.
  63198. * * If `enclose` is false, a ring surface is one element.
  63199. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63200. * * 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
  63201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63204. * @param name defines the name of the mesh
  63205. * @param options defines the options used to create the mesh
  63206. * @param scene defines the hosting scene
  63207. * @returns the cylinder mesh
  63208. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63209. */
  63210. static CreateCylinder(name: string, options: {
  63211. height?: number;
  63212. diameterTop?: number;
  63213. diameterBottom?: number;
  63214. diameter?: number;
  63215. tessellation?: number;
  63216. subdivisions?: number;
  63217. arc?: number;
  63218. faceColors?: Color4[];
  63219. faceUV?: Vector4[];
  63220. updatable?: boolean;
  63221. hasRings?: boolean;
  63222. enclose?: boolean;
  63223. cap?: number;
  63224. sideOrientation?: number;
  63225. frontUVs?: Vector4;
  63226. backUVs?: Vector4;
  63227. }, scene?: Nullable<Scene>): Mesh;
  63228. /**
  63229. * Creates a torus mesh
  63230. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63231. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63232. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63236. * @param name defines the name of the mesh
  63237. * @param options defines the options used to create the mesh
  63238. * @param scene defines the hosting scene
  63239. * @returns the torus mesh
  63240. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63241. */
  63242. static CreateTorus(name: string, options: {
  63243. diameter?: number;
  63244. thickness?: number;
  63245. tessellation?: number;
  63246. updatable?: boolean;
  63247. sideOrientation?: number;
  63248. frontUVs?: Vector4;
  63249. backUVs?: Vector4;
  63250. }, scene?: Nullable<Scene>): Mesh;
  63251. /**
  63252. * Creates a torus knot mesh
  63253. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63254. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63255. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63256. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63260. * @param name defines the name of the mesh
  63261. * @param options defines the options used to create the mesh
  63262. * @param scene defines the hosting scene
  63263. * @returns the torus knot mesh
  63264. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63265. */
  63266. static CreateTorusKnot(name: string, options: {
  63267. radius?: number;
  63268. tube?: number;
  63269. radialSegments?: number;
  63270. tubularSegments?: number;
  63271. p?: number;
  63272. q?: number;
  63273. updatable?: boolean;
  63274. sideOrientation?: number;
  63275. frontUVs?: Vector4;
  63276. backUVs?: Vector4;
  63277. }, scene?: Nullable<Scene>): Mesh;
  63278. /**
  63279. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63280. * * 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
  63281. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63282. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63283. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63284. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63285. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63286. * * 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
  63287. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63290. * @param name defines the name of the new line system
  63291. * @param options defines the options used to create the line system
  63292. * @param scene defines the hosting scene
  63293. * @returns a new line system mesh
  63294. */
  63295. static CreateLineSystem(name: string, options: {
  63296. lines: Vector3[][];
  63297. updatable?: boolean;
  63298. instance?: Nullable<LinesMesh>;
  63299. colors?: Nullable<Color4[][]>;
  63300. useVertexAlpha?: boolean;
  63301. }, scene: Nullable<Scene>): LinesMesh;
  63302. /**
  63303. * Creates a line mesh
  63304. * 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
  63305. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63306. * * The parameter `points` is an array successive Vector3
  63307. * * 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
  63308. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63309. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63310. * * When updating an instance, remember that only point positions can change, not the number of points
  63311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63313. * @param name defines the name of the new line system
  63314. * @param options defines the options used to create the line system
  63315. * @param scene defines the hosting scene
  63316. * @returns a new line mesh
  63317. */
  63318. static CreateLines(name: string, options: {
  63319. points: Vector3[];
  63320. updatable?: boolean;
  63321. instance?: Nullable<LinesMesh>;
  63322. colors?: Color4[];
  63323. useVertexAlpha?: boolean;
  63324. }, scene?: Nullable<Scene>): LinesMesh;
  63325. /**
  63326. * Creates a dashed line mesh
  63327. * * 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
  63328. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63329. * * The parameter `points` is an array successive Vector3
  63330. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63331. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63332. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63333. * * 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
  63334. * * When updating an instance, remember that only point positions can change, not the number of points
  63335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63336. * @param name defines the name of the mesh
  63337. * @param options defines the options used to create the mesh
  63338. * @param scene defines the hosting scene
  63339. * @returns the dashed line mesh
  63340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63341. */
  63342. static CreateDashedLines(name: string, options: {
  63343. points: Vector3[];
  63344. dashSize?: number;
  63345. gapSize?: number;
  63346. dashNb?: number;
  63347. updatable?: boolean;
  63348. instance?: LinesMesh;
  63349. }, scene?: Nullable<Scene>): LinesMesh;
  63350. /**
  63351. * 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.
  63352. * * 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.
  63353. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63354. * * 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.
  63355. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  63356. * * 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
  63357. * * 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
  63358. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  63359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  63362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63363. * @param name defines the name of the mesh
  63364. * @param options defines the options used to create the mesh
  63365. * @param scene defines the hosting scene
  63366. * @returns the extruded shape mesh
  63367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63369. */
  63370. static ExtrudeShape(name: string, options: {
  63371. shape: Vector3[];
  63372. path: Vector3[];
  63373. scale?: number;
  63374. rotation?: number;
  63375. cap?: number;
  63376. updatable?: boolean;
  63377. sideOrientation?: number;
  63378. frontUVs?: Vector4;
  63379. backUVs?: Vector4;
  63380. instance?: Mesh;
  63381. invertUV?: boolean;
  63382. }, scene?: Nullable<Scene>): Mesh;
  63383. /**
  63384. * Creates an custom extruded shape mesh.
  63385. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  63386. * * 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.
  63387. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63388. * * 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
  63389. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  63390. * * 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
  63391. * * It must returns a float value that will be the scale value applied to the shape on each path point
  63392. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  63393. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  63394. * * 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
  63395. * * 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
  63396. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63401. * @param name defines the name of the mesh
  63402. * @param options defines the options used to create the mesh
  63403. * @param scene defines the hosting scene
  63404. * @returns the custom extruded shape mesh
  63405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  63406. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63408. */
  63409. static ExtrudeShapeCustom(name: string, options: {
  63410. shape: Vector3[];
  63411. path: Vector3[];
  63412. scaleFunction?: any;
  63413. rotationFunction?: any;
  63414. ribbonCloseArray?: boolean;
  63415. ribbonClosePath?: boolean;
  63416. cap?: number;
  63417. updatable?: boolean;
  63418. sideOrientation?: number;
  63419. frontUVs?: Vector4;
  63420. backUVs?: Vector4;
  63421. instance?: Mesh;
  63422. invertUV?: boolean;
  63423. }, scene?: Nullable<Scene>): Mesh;
  63424. /**
  63425. * Creates lathe mesh.
  63426. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63427. * * 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
  63428. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63429. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63430. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63431. * * 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
  63432. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63433. * * 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
  63434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63436. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63438. * @param name defines the name of the mesh
  63439. * @param options defines the options used to create the mesh
  63440. * @param scene defines the hosting scene
  63441. * @returns the lathe mesh
  63442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63443. */
  63444. static CreateLathe(name: string, options: {
  63445. shape: Vector3[];
  63446. radius?: number;
  63447. tessellation?: number;
  63448. clip?: number;
  63449. arc?: number;
  63450. closed?: boolean;
  63451. updatable?: boolean;
  63452. sideOrientation?: number;
  63453. frontUVs?: Vector4;
  63454. backUVs?: Vector4;
  63455. cap?: number;
  63456. invertUV?: boolean;
  63457. }, scene?: Nullable<Scene>): Mesh;
  63458. /**
  63459. * Creates a tiled plane mesh
  63460. * * You can set a limited pattern arrangement with the tiles
  63461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63464. * @param name defines the name of the mesh
  63465. * @param options defines the options used to create the mesh
  63466. * @param scene defines the hosting scene
  63467. * @returns the plane mesh
  63468. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63469. */
  63470. static CreateTiledPlane(name: string, options: {
  63471. pattern?: number;
  63472. tileSize?: number;
  63473. tileWidth?: number;
  63474. tileHeight?: number;
  63475. size?: number;
  63476. width?: number;
  63477. height?: number;
  63478. alignHorizontal?: number;
  63479. alignVertical?: number;
  63480. sideOrientation?: number;
  63481. frontUVs?: Vector4;
  63482. backUVs?: Vector4;
  63483. updatable?: boolean;
  63484. }, scene?: Nullable<Scene>): Mesh;
  63485. /**
  63486. * Creates a plane mesh
  63487. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  63488. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  63489. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  63490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63493. * @param name defines the name of the mesh
  63494. * @param options defines the options used to create the mesh
  63495. * @param scene defines the hosting scene
  63496. * @returns the plane mesh
  63497. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63498. */
  63499. static CreatePlane(name: string, options: {
  63500. size?: number;
  63501. width?: number;
  63502. height?: number;
  63503. sideOrientation?: number;
  63504. frontUVs?: Vector4;
  63505. backUVs?: Vector4;
  63506. updatable?: boolean;
  63507. sourcePlane?: Plane;
  63508. }, scene?: Nullable<Scene>): Mesh;
  63509. /**
  63510. * Creates a ground mesh
  63511. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  63512. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  63513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63514. * @param name defines the name of the mesh
  63515. * @param options defines the options used to create the mesh
  63516. * @param scene defines the hosting scene
  63517. * @returns the ground mesh
  63518. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  63519. */
  63520. static CreateGround(name: string, options: {
  63521. width?: number;
  63522. height?: number;
  63523. subdivisions?: number;
  63524. subdivisionsX?: number;
  63525. subdivisionsY?: number;
  63526. updatable?: boolean;
  63527. }, scene?: Nullable<Scene>): Mesh;
  63528. /**
  63529. * Creates a tiled ground mesh
  63530. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  63531. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  63532. * * 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
  63533. * * 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
  63534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63535. * @param name defines the name of the mesh
  63536. * @param options defines the options used to create the mesh
  63537. * @param scene defines the hosting scene
  63538. * @returns the tiled ground mesh
  63539. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  63540. */
  63541. static CreateTiledGround(name: string, options: {
  63542. xmin: number;
  63543. zmin: number;
  63544. xmax: number;
  63545. zmax: number;
  63546. subdivisions?: {
  63547. w: number;
  63548. h: number;
  63549. };
  63550. precision?: {
  63551. w: number;
  63552. h: number;
  63553. };
  63554. updatable?: boolean;
  63555. }, scene?: Nullable<Scene>): Mesh;
  63556. /**
  63557. * Creates a ground mesh from a height map
  63558. * * The parameter `url` sets the URL of the height map image resource.
  63559. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  63560. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  63561. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  63562. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  63563. * * 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.
  63564. * * 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).
  63565. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  63566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63567. * @param name defines the name of the mesh
  63568. * @param url defines the url to the height map
  63569. * @param options defines the options used to create the mesh
  63570. * @param scene defines the hosting scene
  63571. * @returns the ground mesh
  63572. * @see https://doc.babylonjs.com/babylon101/height_map
  63573. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  63574. */
  63575. static CreateGroundFromHeightMap(name: string, url: string, options: {
  63576. width?: number;
  63577. height?: number;
  63578. subdivisions?: number;
  63579. minHeight?: number;
  63580. maxHeight?: number;
  63581. colorFilter?: Color3;
  63582. alphaFilter?: number;
  63583. updatable?: boolean;
  63584. onReady?: (mesh: GroundMesh) => void;
  63585. }, scene?: Nullable<Scene>): GroundMesh;
  63586. /**
  63587. * Creates a polygon mesh
  63588. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63589. * * 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
  63590. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63593. * * Remember you can only change the shape positions, not their number when updating a polygon
  63594. * @param name defines the name of the mesh
  63595. * @param options defines the options used to create the mesh
  63596. * @param scene defines the hosting scene
  63597. * @param earcutInjection can be used to inject your own earcut reference
  63598. * @returns the polygon mesh
  63599. */
  63600. static CreatePolygon(name: string, options: {
  63601. shape: Vector3[];
  63602. holes?: Vector3[][];
  63603. depth?: number;
  63604. faceUV?: Vector4[];
  63605. faceColors?: Color4[];
  63606. updatable?: boolean;
  63607. sideOrientation?: number;
  63608. frontUVs?: Vector4;
  63609. backUVs?: Vector4;
  63610. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63611. /**
  63612. * Creates an extruded polygon mesh, with depth in the Y direction.
  63613. * * 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)
  63614. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63615. * @param name defines the name of the mesh
  63616. * @param options defines the options used to create the mesh
  63617. * @param scene defines the hosting scene
  63618. * @param earcutInjection can be used to inject your own earcut reference
  63619. * @returns the polygon mesh
  63620. */
  63621. static ExtrudePolygon(name: string, options: {
  63622. shape: Vector3[];
  63623. holes?: Vector3[][];
  63624. depth?: number;
  63625. faceUV?: Vector4[];
  63626. faceColors?: Color4[];
  63627. updatable?: boolean;
  63628. sideOrientation?: number;
  63629. frontUVs?: Vector4;
  63630. backUVs?: Vector4;
  63631. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63632. /**
  63633. * Creates a tube mesh.
  63634. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63635. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63636. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63637. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63638. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63639. * * 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)
  63640. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63641. * * 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
  63642. * * 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
  63643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63645. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63647. * @param name defines the name of the mesh
  63648. * @param options defines the options used to create the mesh
  63649. * @param scene defines the hosting scene
  63650. * @returns the tube mesh
  63651. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63652. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63653. */
  63654. static CreateTube(name: string, options: {
  63655. path: Vector3[];
  63656. radius?: number;
  63657. tessellation?: number;
  63658. radiusFunction?: {
  63659. (i: number, distance: number): number;
  63660. };
  63661. cap?: number;
  63662. arc?: number;
  63663. updatable?: boolean;
  63664. sideOrientation?: number;
  63665. frontUVs?: Vector4;
  63666. backUVs?: Vector4;
  63667. instance?: Mesh;
  63668. invertUV?: boolean;
  63669. }, scene?: Nullable<Scene>): Mesh;
  63670. /**
  63671. * Creates a polyhedron mesh
  63672. * * 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
  63673. * * The parameter `size` (positive float, default 1) sets the polygon size
  63674. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  63675. * * 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`
  63676. * * 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
  63677. * * 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)`)
  63678. * * 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
  63679. * * 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
  63680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63683. * @param name defines the name of the mesh
  63684. * @param options defines the options used to create the mesh
  63685. * @param scene defines the hosting scene
  63686. * @returns the polyhedron mesh
  63687. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  63688. */
  63689. static CreatePolyhedron(name: string, options: {
  63690. type?: number;
  63691. size?: number;
  63692. sizeX?: number;
  63693. sizeY?: number;
  63694. sizeZ?: number;
  63695. custom?: any;
  63696. faceUV?: Vector4[];
  63697. faceColors?: Color4[];
  63698. flat?: boolean;
  63699. updatable?: boolean;
  63700. sideOrientation?: number;
  63701. frontUVs?: Vector4;
  63702. backUVs?: Vector4;
  63703. }, scene?: Nullable<Scene>): Mesh;
  63704. /**
  63705. * Creates a decal mesh.
  63706. * 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
  63707. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63708. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63709. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63710. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63711. * @param name defines the name of the mesh
  63712. * @param sourceMesh defines the mesh where the decal must be applied
  63713. * @param options defines the options used to create the mesh
  63714. * @param scene defines the hosting scene
  63715. * @returns the decal mesh
  63716. * @see https://doc.babylonjs.com/how_to/decals
  63717. */
  63718. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63719. position?: Vector3;
  63720. normal?: Vector3;
  63721. size?: Vector3;
  63722. angle?: number;
  63723. }): Mesh;
  63724. }
  63725. }
  63726. declare module "babylonjs/Meshes/meshSimplification" {
  63727. import { Mesh } from "babylonjs/Meshes/mesh";
  63728. /**
  63729. * A simplifier interface for future simplification implementations
  63730. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63731. */
  63732. export interface ISimplifier {
  63733. /**
  63734. * Simplification of a given mesh according to the given settings.
  63735. * Since this requires computation, it is assumed that the function runs async.
  63736. * @param settings The settings of the simplification, including quality and distance
  63737. * @param successCallback A callback that will be called after the mesh was simplified.
  63738. * @param errorCallback in case of an error, this callback will be called. optional.
  63739. */
  63740. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63741. }
  63742. /**
  63743. * Expected simplification settings.
  63744. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63745. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63746. */
  63747. export interface ISimplificationSettings {
  63748. /**
  63749. * Gets or sets the expected quality
  63750. */
  63751. quality: number;
  63752. /**
  63753. * Gets or sets the distance when this optimized version should be used
  63754. */
  63755. distance: number;
  63756. /**
  63757. * Gets an already optimized mesh
  63758. */
  63759. optimizeMesh?: boolean;
  63760. }
  63761. /**
  63762. * Class used to specify simplification options
  63763. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63764. */
  63765. export class SimplificationSettings implements ISimplificationSettings {
  63766. /** expected quality */
  63767. quality: number;
  63768. /** distance when this optimized version should be used */
  63769. distance: number;
  63770. /** already optimized mesh */
  63771. optimizeMesh?: boolean | undefined;
  63772. /**
  63773. * Creates a SimplificationSettings
  63774. * @param quality expected quality
  63775. * @param distance distance when this optimized version should be used
  63776. * @param optimizeMesh already optimized mesh
  63777. */
  63778. constructor(
  63779. /** expected quality */
  63780. quality: number,
  63781. /** distance when this optimized version should be used */
  63782. distance: number,
  63783. /** already optimized mesh */
  63784. optimizeMesh?: boolean | undefined);
  63785. }
  63786. /**
  63787. * Interface used to define a simplification task
  63788. */
  63789. export interface ISimplificationTask {
  63790. /**
  63791. * Array of settings
  63792. */
  63793. settings: Array<ISimplificationSettings>;
  63794. /**
  63795. * Simplification type
  63796. */
  63797. simplificationType: SimplificationType;
  63798. /**
  63799. * Mesh to simplify
  63800. */
  63801. mesh: Mesh;
  63802. /**
  63803. * Callback called on success
  63804. */
  63805. successCallback?: () => void;
  63806. /**
  63807. * Defines if parallel processing can be used
  63808. */
  63809. parallelProcessing: boolean;
  63810. }
  63811. /**
  63812. * Queue used to order the simplification tasks
  63813. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63814. */
  63815. export class SimplificationQueue {
  63816. private _simplificationArray;
  63817. /**
  63818. * Gets a boolean indicating that the process is still running
  63819. */
  63820. running: boolean;
  63821. /**
  63822. * Creates a new queue
  63823. */
  63824. constructor();
  63825. /**
  63826. * Adds a new simplification task
  63827. * @param task defines a task to add
  63828. */
  63829. addTask(task: ISimplificationTask): void;
  63830. /**
  63831. * Execute next task
  63832. */
  63833. executeNext(): void;
  63834. /**
  63835. * Execute a simplification task
  63836. * @param task defines the task to run
  63837. */
  63838. runSimplification(task: ISimplificationTask): void;
  63839. private getSimplifier;
  63840. }
  63841. /**
  63842. * The implemented types of simplification
  63843. * At the moment only Quadratic Error Decimation is implemented
  63844. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63845. */
  63846. export enum SimplificationType {
  63847. /** Quadratic error decimation */
  63848. QUADRATIC = 0
  63849. }
  63850. }
  63851. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63852. import { Scene } from "babylonjs/scene";
  63853. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63854. import { ISceneComponent } from "babylonjs/sceneComponent";
  63855. module "babylonjs/scene" {
  63856. interface Scene {
  63857. /** @hidden (Backing field) */
  63858. _simplificationQueue: SimplificationQueue;
  63859. /**
  63860. * Gets or sets the simplification queue attached to the scene
  63861. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63862. */
  63863. simplificationQueue: SimplificationQueue;
  63864. }
  63865. }
  63866. module "babylonjs/Meshes/mesh" {
  63867. interface Mesh {
  63868. /**
  63869. * Simplify the mesh according to the given array of settings.
  63870. * Function will return immediately and will simplify async
  63871. * @param settings a collection of simplification settings
  63872. * @param parallelProcessing should all levels calculate parallel or one after the other
  63873. * @param simplificationType the type of simplification to run
  63874. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63875. * @returns the current mesh
  63876. */
  63877. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63878. }
  63879. }
  63880. /**
  63881. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63882. * created in a scene
  63883. */
  63884. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63885. /**
  63886. * The component name helpfull to identify the component in the list of scene components.
  63887. */
  63888. readonly name: string;
  63889. /**
  63890. * The scene the component belongs to.
  63891. */
  63892. scene: Scene;
  63893. /**
  63894. * Creates a new instance of the component for the given scene
  63895. * @param scene Defines the scene to register the component in
  63896. */
  63897. constructor(scene: Scene);
  63898. /**
  63899. * Registers the component in a given scene
  63900. */
  63901. register(): void;
  63902. /**
  63903. * Rebuilds the elements related to this component in case of
  63904. * context lost for instance.
  63905. */
  63906. rebuild(): void;
  63907. /**
  63908. * Disposes the component and the associated ressources
  63909. */
  63910. dispose(): void;
  63911. private _beforeCameraUpdate;
  63912. }
  63913. }
  63914. declare module "babylonjs/Meshes/Builders/index" {
  63915. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63916. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63917. export * from "babylonjs/Meshes/Builders/discBuilder";
  63918. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63919. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63920. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63921. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63922. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63923. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63924. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63925. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63926. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63927. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63928. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63929. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63930. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63931. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63932. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63933. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63934. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63935. }
  63936. declare module "babylonjs/Meshes/index" {
  63937. export * from "babylonjs/Meshes/abstractMesh";
  63938. export * from "babylonjs/Meshes/buffer";
  63939. export * from "babylonjs/Meshes/Compression/index";
  63940. export * from "babylonjs/Meshes/csg";
  63941. export * from "babylonjs/Meshes/geometry";
  63942. export * from "babylonjs/Meshes/groundMesh";
  63943. export * from "babylonjs/Meshes/trailMesh";
  63944. export * from "babylonjs/Meshes/instancedMesh";
  63945. export * from "babylonjs/Meshes/linesMesh";
  63946. export * from "babylonjs/Meshes/mesh";
  63947. export * from "babylonjs/Meshes/mesh.vertexData";
  63948. export * from "babylonjs/Meshes/meshBuilder";
  63949. export * from "babylonjs/Meshes/meshSimplification";
  63950. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63951. export * from "babylonjs/Meshes/polygonMesh";
  63952. export * from "babylonjs/Meshes/subMesh";
  63953. export * from "babylonjs/Meshes/meshLODLevel";
  63954. export * from "babylonjs/Meshes/transformNode";
  63955. export * from "babylonjs/Meshes/Builders/index";
  63956. export * from "babylonjs/Meshes/dataBuffer";
  63957. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63958. }
  63959. declare module "babylonjs/Morph/index" {
  63960. export * from "babylonjs/Morph/morphTarget";
  63961. export * from "babylonjs/Morph/morphTargetManager";
  63962. }
  63963. declare module "babylonjs/Navigation/INavigationEngine" {
  63964. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63965. import { Vector3 } from "babylonjs/Maths/math";
  63966. import { Mesh } from "babylonjs/Meshes/mesh";
  63967. import { Scene } from "babylonjs/scene";
  63968. /**
  63969. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63970. */
  63971. export interface INavigationEnginePlugin {
  63972. /**
  63973. * plugin name
  63974. */
  63975. name: string;
  63976. /**
  63977. * Creates a navigation mesh
  63978. * @param meshes array of all the geometry used to compute the navigatio mesh
  63979. * @param parameters bunch of parameters used to filter geometry
  63980. */
  63981. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63982. /**
  63983. * Create a navigation mesh debug mesh
  63984. * @param scene is where the mesh will be added
  63985. * @returns debug display mesh
  63986. */
  63987. createDebugNavMesh(scene: Scene): Mesh;
  63988. /**
  63989. * Get a navigation mesh constrained position, closest to the parameter position
  63990. * @param position world position
  63991. * @returns the closest point to position constrained by the navigation mesh
  63992. */
  63993. getClosestPoint(position: Vector3): Vector3;
  63994. /**
  63995. * Get a navigation mesh constrained position, within a particular radius
  63996. * @param position world position
  63997. * @param maxRadius the maximum distance to the constrained world position
  63998. * @returns the closest point to position constrained by the navigation mesh
  63999. */
  64000. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64001. /**
  64002. * Compute the final position from a segment made of destination-position
  64003. * @param position world position
  64004. * @param destination world position
  64005. * @returns the resulting point along the navmesh
  64006. */
  64007. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64008. /**
  64009. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64010. * @param start world position
  64011. * @param end world position
  64012. * @returns array containing world position composing the path
  64013. */
  64014. computePath(start: Vector3, end: Vector3): Vector3[];
  64015. /**
  64016. * If this plugin is supported
  64017. * @returns true if plugin is supported
  64018. */
  64019. isSupported(): boolean;
  64020. /**
  64021. * Create a new Crowd so you can add agents
  64022. * @param maxAgents the maximum agent count in the crowd
  64023. * @param maxAgentRadius the maximum radius an agent can have
  64024. * @param scene to attach the crowd to
  64025. * @returns the crowd you can add agents to
  64026. */
  64027. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64028. /**
  64029. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64030. * The queries will try to find a solution within those bounds
  64031. * default is (1,1,1)
  64032. * @param extent x,y,z value that define the extent around the queries point of reference
  64033. */
  64034. setDefaultQueryExtent(extent: Vector3): void;
  64035. /**
  64036. * Get the Bounding box extent specified by setDefaultQueryExtent
  64037. * @returns the box extent values
  64038. */
  64039. getDefaultQueryExtent(): Vector3;
  64040. /**
  64041. * Release all resources
  64042. */
  64043. dispose(): void;
  64044. }
  64045. /**
  64046. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64047. */
  64048. export interface ICrowd {
  64049. /**
  64050. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64051. * You can attach anything to that node. The node position is updated in the scene update tick.
  64052. * @param pos world position that will be constrained by the navigation mesh
  64053. * @param parameters agent parameters
  64054. * @param transform hooked to the agent that will be update by the scene
  64055. * @returns agent index
  64056. */
  64057. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64058. /**
  64059. * Returns the agent position in world space
  64060. * @param index agent index returned by addAgent
  64061. * @returns world space position
  64062. */
  64063. getAgentPosition(index: number): Vector3;
  64064. /**
  64065. * Gets the agent velocity in world space
  64066. * @param index agent index returned by addAgent
  64067. * @returns world space velocity
  64068. */
  64069. getAgentVelocity(index: number): Vector3;
  64070. /**
  64071. * remove a particular agent previously created
  64072. * @param index agent index returned by addAgent
  64073. */
  64074. removeAgent(index: number): void;
  64075. /**
  64076. * get the list of all agents attached to this crowd
  64077. * @returns list of agent indices
  64078. */
  64079. getAgents(): number[];
  64080. /**
  64081. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64082. * @param deltaTime in seconds
  64083. */
  64084. update(deltaTime: number): void;
  64085. /**
  64086. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64087. * @param index agent index returned by addAgent
  64088. * @param destination targeted world position
  64089. */
  64090. agentGoto(index: number, destination: Vector3): void;
  64091. /**
  64092. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64093. * The queries will try to find a solution within those bounds
  64094. * default is (1,1,1)
  64095. * @param extent x,y,z value that define the extent around the queries point of reference
  64096. */
  64097. setDefaultQueryExtent(extent: Vector3): void;
  64098. /**
  64099. * Get the Bounding box extent specified by setDefaultQueryExtent
  64100. * @returns the box extent values
  64101. */
  64102. getDefaultQueryExtent(): Vector3;
  64103. /**
  64104. * Release all resources
  64105. */
  64106. dispose(): void;
  64107. }
  64108. /**
  64109. * Configures an agent
  64110. */
  64111. export interface IAgentParameters {
  64112. /**
  64113. * Agent radius. [Limit: >= 0]
  64114. */
  64115. radius: number;
  64116. /**
  64117. * Agent height. [Limit: > 0]
  64118. */
  64119. height: number;
  64120. /**
  64121. * Maximum allowed acceleration. [Limit: >= 0]
  64122. */
  64123. maxAcceleration: number;
  64124. /**
  64125. * Maximum allowed speed. [Limit: >= 0]
  64126. */
  64127. maxSpeed: number;
  64128. /**
  64129. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64130. */
  64131. collisionQueryRange: number;
  64132. /**
  64133. * The path visibility optimization range. [Limit: > 0]
  64134. */
  64135. pathOptimizationRange: number;
  64136. /**
  64137. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64138. */
  64139. separationWeight: number;
  64140. }
  64141. /**
  64142. * Configures the navigation mesh creation
  64143. */
  64144. export interface INavMeshParameters {
  64145. /**
  64146. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64147. */
  64148. cs: number;
  64149. /**
  64150. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64151. */
  64152. ch: number;
  64153. /**
  64154. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64155. */
  64156. walkableSlopeAngle: number;
  64157. /**
  64158. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64159. * be considered walkable. [Limit: >= 3] [Units: vx]
  64160. */
  64161. walkableHeight: number;
  64162. /**
  64163. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64164. */
  64165. walkableClimb: number;
  64166. /**
  64167. * The distance to erode/shrink the walkable area of the heightfield away from
  64168. * obstructions. [Limit: >=0] [Units: vx]
  64169. */
  64170. walkableRadius: number;
  64171. /**
  64172. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64173. */
  64174. maxEdgeLen: number;
  64175. /**
  64176. * The maximum distance a simplfied contour's border edges should deviate
  64177. * the original raw contour. [Limit: >=0] [Units: vx]
  64178. */
  64179. maxSimplificationError: number;
  64180. /**
  64181. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64182. */
  64183. minRegionArea: number;
  64184. /**
  64185. * Any regions with a span count smaller than this value will, if possible,
  64186. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64187. */
  64188. mergeRegionArea: number;
  64189. /**
  64190. * The maximum number of vertices allowed for polygons generated during the
  64191. * contour to polygon conversion process. [Limit: >= 3]
  64192. */
  64193. maxVertsPerPoly: number;
  64194. /**
  64195. * Sets the sampling distance to use when generating the detail mesh.
  64196. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64197. */
  64198. detailSampleDist: number;
  64199. /**
  64200. * The maximum distance the detail mesh surface should deviate from heightfield
  64201. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64202. */
  64203. detailSampleMaxError: number;
  64204. }
  64205. }
  64206. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  64207. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  64208. import { Mesh } from "babylonjs/Meshes/mesh";
  64209. import { Scene } from "babylonjs/scene";
  64210. import { Vector3 } from "babylonjs/Maths/math";
  64211. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64212. /**
  64213. * RecastJS navigation plugin
  64214. */
  64215. export class RecastJSPlugin implements INavigationEnginePlugin {
  64216. /**
  64217. * Reference to the Recast library
  64218. */
  64219. bjsRECAST: any;
  64220. /**
  64221. * plugin name
  64222. */
  64223. name: string;
  64224. /**
  64225. * the first navmesh created. We might extend this to support multiple navmeshes
  64226. */
  64227. navMesh: any;
  64228. /**
  64229. * Initializes the recastJS plugin
  64230. * @param recastInjection can be used to inject your own recast reference
  64231. */
  64232. constructor(recastInjection?: any);
  64233. /**
  64234. * Creates a navigation mesh
  64235. * @param meshes array of all the geometry used to compute the navigatio mesh
  64236. * @param parameters bunch of parameters used to filter geometry
  64237. */
  64238. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64239. /**
  64240. * Create a navigation mesh debug mesh
  64241. * @param scene is where the mesh will be added
  64242. * @returns debug display mesh
  64243. */
  64244. createDebugNavMesh(scene: Scene): Mesh;
  64245. /**
  64246. * Get a navigation mesh constrained position, closest to the parameter position
  64247. * @param position world position
  64248. * @returns the closest point to position constrained by the navigation mesh
  64249. */
  64250. getClosestPoint(position: Vector3): Vector3;
  64251. /**
  64252. * Get a navigation mesh constrained position, within a particular radius
  64253. * @param position world position
  64254. * @param maxRadius the maximum distance to the constrained world position
  64255. * @returns the closest point to position constrained by the navigation mesh
  64256. */
  64257. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64258. /**
  64259. * Compute the final position from a segment made of destination-position
  64260. * @param position world position
  64261. * @param destination world position
  64262. * @returns the resulting point along the navmesh
  64263. */
  64264. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64265. /**
  64266. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64267. * @param start world position
  64268. * @param end world position
  64269. * @returns array containing world position composing the path
  64270. */
  64271. computePath(start: Vector3, end: Vector3): Vector3[];
  64272. /**
  64273. * Create a new Crowd so you can add agents
  64274. * @param maxAgents the maximum agent count in the crowd
  64275. * @param maxAgentRadius the maximum radius an agent can have
  64276. * @param scene to attach the crowd to
  64277. * @returns the crowd you can add agents to
  64278. */
  64279. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64280. /**
  64281. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64282. * The queries will try to find a solution within those bounds
  64283. * default is (1,1,1)
  64284. * @param extent x,y,z value that define the extent around the queries point of reference
  64285. */
  64286. setDefaultQueryExtent(extent: Vector3): void;
  64287. /**
  64288. * Get the Bounding box extent specified by setDefaultQueryExtent
  64289. * @returns the box extent values
  64290. */
  64291. getDefaultQueryExtent(): Vector3;
  64292. /**
  64293. * Disposes
  64294. */
  64295. dispose(): void;
  64296. /**
  64297. * If this plugin is supported
  64298. * @returns true if plugin is supported
  64299. */
  64300. isSupported(): boolean;
  64301. }
  64302. /**
  64303. * Recast detour crowd implementation
  64304. */
  64305. export class RecastJSCrowd implements ICrowd {
  64306. /**
  64307. * Recast/detour plugin
  64308. */
  64309. bjsRECASTPlugin: RecastJSPlugin;
  64310. /**
  64311. * Link to the detour crowd
  64312. */
  64313. recastCrowd: any;
  64314. /**
  64315. * One transform per agent
  64316. */
  64317. transforms: TransformNode[];
  64318. /**
  64319. * All agents created
  64320. */
  64321. agents: number[];
  64322. /**
  64323. * Link to the scene is kept to unregister the crowd from the scene
  64324. */
  64325. private _scene;
  64326. /**
  64327. * Observer for crowd updates
  64328. */
  64329. private _onBeforeAnimationsObserver;
  64330. /**
  64331. * Constructor
  64332. * @param plugin recastJS plugin
  64333. * @param maxAgents the maximum agent count in the crowd
  64334. * @param maxAgentRadius the maximum radius an agent can have
  64335. * @param scene to attach the crowd to
  64336. * @returns the crowd you can add agents to
  64337. */
  64338. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  64339. /**
  64340. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64341. * You can attach anything to that node. The node position is updated in the scene update tick.
  64342. * @param pos world position that will be constrained by the navigation mesh
  64343. * @param parameters agent parameters
  64344. * @param transform hooked to the agent that will be update by the scene
  64345. * @returns agent index
  64346. */
  64347. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64348. /**
  64349. * Returns the agent position in world space
  64350. * @param index agent index returned by addAgent
  64351. * @returns world space position
  64352. */
  64353. getAgentPosition(index: number): Vector3;
  64354. /**
  64355. * Returns the agent velocity in world space
  64356. * @param index agent index returned by addAgent
  64357. * @returns world space velocity
  64358. */
  64359. getAgentVelocity(index: number): Vector3;
  64360. /**
  64361. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64362. * @param index agent index returned by addAgent
  64363. * @param destination targeted world position
  64364. */
  64365. agentGoto(index: number, destination: Vector3): void;
  64366. /**
  64367. * remove a particular agent previously created
  64368. * @param index agent index returned by addAgent
  64369. */
  64370. removeAgent(index: number): void;
  64371. /**
  64372. * get the list of all agents attached to this crowd
  64373. * @returns list of agent indices
  64374. */
  64375. getAgents(): number[];
  64376. /**
  64377. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64378. * @param deltaTime in seconds
  64379. */
  64380. update(deltaTime: number): void;
  64381. /**
  64382. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64383. * The queries will try to find a solution within those bounds
  64384. * default is (1,1,1)
  64385. * @param extent x,y,z value that define the extent around the queries point of reference
  64386. */
  64387. setDefaultQueryExtent(extent: Vector3): void;
  64388. /**
  64389. * Get the Bounding box extent specified by setDefaultQueryExtent
  64390. * @returns the box extent values
  64391. */
  64392. getDefaultQueryExtent(): Vector3;
  64393. /**
  64394. * Release all resources
  64395. */
  64396. dispose(): void;
  64397. }
  64398. }
  64399. declare module "babylonjs/Navigation/Plugins/index" {
  64400. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  64401. }
  64402. declare module "babylonjs/Navigation/index" {
  64403. export * from "babylonjs/Navigation/INavigationEngine";
  64404. export * from "babylonjs/Navigation/Plugins/index";
  64405. }
  64406. declare module "babylonjs/Offline/database" {
  64407. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  64408. /**
  64409. * Class used to enable access to IndexedDB
  64410. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64411. */
  64412. export class Database implements IOfflineProvider {
  64413. private _callbackManifestChecked;
  64414. private _currentSceneUrl;
  64415. private _db;
  64416. private _enableSceneOffline;
  64417. private _enableTexturesOffline;
  64418. private _manifestVersionFound;
  64419. private _mustUpdateRessources;
  64420. private _hasReachedQuota;
  64421. private _isSupported;
  64422. private _idbFactory;
  64423. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  64424. private static IsUASupportingBlobStorage;
  64425. /**
  64426. * Gets a boolean indicating if Database storate is enabled (off by default)
  64427. */
  64428. static IDBStorageEnabled: boolean;
  64429. /**
  64430. * Gets a boolean indicating if scene must be saved in the database
  64431. */
  64432. get enableSceneOffline(): boolean;
  64433. /**
  64434. * Gets a boolean indicating if textures must be saved in the database
  64435. */
  64436. get enableTexturesOffline(): boolean;
  64437. /**
  64438. * Creates a new Database
  64439. * @param urlToScene defines the url to load the scene
  64440. * @param callbackManifestChecked defines the callback to use when manifest is checked
  64441. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  64442. */
  64443. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  64444. private static _ParseURL;
  64445. private static _ReturnFullUrlLocation;
  64446. private _checkManifestFile;
  64447. /**
  64448. * Open the database and make it available
  64449. * @param successCallback defines the callback to call on success
  64450. * @param errorCallback defines the callback to call on error
  64451. */
  64452. open(successCallback: () => void, errorCallback: () => void): void;
  64453. /**
  64454. * Loads an image from the database
  64455. * @param url defines the url to load from
  64456. * @param image defines the target DOM image
  64457. */
  64458. loadImage(url: string, image: HTMLImageElement): void;
  64459. private _loadImageFromDBAsync;
  64460. private _saveImageIntoDBAsync;
  64461. private _checkVersionFromDB;
  64462. private _loadVersionFromDBAsync;
  64463. private _saveVersionIntoDBAsync;
  64464. /**
  64465. * Loads a file from database
  64466. * @param url defines the URL to load from
  64467. * @param sceneLoaded defines a callback to call on success
  64468. * @param progressCallBack defines a callback to call when progress changed
  64469. * @param errorCallback defines a callback to call on error
  64470. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64471. */
  64472. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64473. private _loadFileAsync;
  64474. private _saveFileAsync;
  64475. /**
  64476. * Validates if xhr data is correct
  64477. * @param xhr defines the request to validate
  64478. * @param dataType defines the expected data type
  64479. * @returns true if data is correct
  64480. */
  64481. private static _ValidateXHRData;
  64482. }
  64483. }
  64484. declare module "babylonjs/Offline/index" {
  64485. export * from "babylonjs/Offline/database";
  64486. export * from "babylonjs/Offline/IOfflineProvider";
  64487. }
  64488. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  64489. /** @hidden */
  64490. export var gpuUpdateParticlesPixelShader: {
  64491. name: string;
  64492. shader: string;
  64493. };
  64494. }
  64495. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  64496. /** @hidden */
  64497. export var gpuUpdateParticlesVertexShader: {
  64498. name: string;
  64499. shader: string;
  64500. };
  64501. }
  64502. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  64503. /** @hidden */
  64504. export var clipPlaneFragmentDeclaration2: {
  64505. name: string;
  64506. shader: string;
  64507. };
  64508. }
  64509. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  64510. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  64511. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64512. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64513. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64514. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  64515. /** @hidden */
  64516. export var gpuRenderParticlesPixelShader: {
  64517. name: string;
  64518. shader: string;
  64519. };
  64520. }
  64521. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  64522. /** @hidden */
  64523. export var clipPlaneVertexDeclaration2: {
  64524. name: string;
  64525. shader: string;
  64526. };
  64527. }
  64528. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  64529. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  64530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  64531. /** @hidden */
  64532. export var gpuRenderParticlesVertexShader: {
  64533. name: string;
  64534. shader: string;
  64535. };
  64536. }
  64537. declare module "babylonjs/Particles/gpuParticleSystem" {
  64538. import { Nullable } from "babylonjs/types";
  64539. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  64540. import { Observable } from "babylonjs/Misc/observable";
  64541. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64542. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64543. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  64544. import { Scene, IDisposable } from "babylonjs/scene";
  64545. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  64546. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64547. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  64548. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  64549. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  64550. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  64551. /**
  64552. * This represents a GPU particle system in Babylon
  64553. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  64554. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  64555. */
  64556. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  64557. /**
  64558. * The layer mask we are rendering the particles through.
  64559. */
  64560. layerMask: number;
  64561. private _capacity;
  64562. private _activeCount;
  64563. private _currentActiveCount;
  64564. private _accumulatedCount;
  64565. private _renderEffect;
  64566. private _updateEffect;
  64567. private _buffer0;
  64568. private _buffer1;
  64569. private _spriteBuffer;
  64570. private _updateVAO;
  64571. private _renderVAO;
  64572. private _targetIndex;
  64573. private _sourceBuffer;
  64574. private _targetBuffer;
  64575. private _engine;
  64576. private _currentRenderId;
  64577. private _started;
  64578. private _stopped;
  64579. private _timeDelta;
  64580. private _randomTexture;
  64581. private _randomTexture2;
  64582. private _attributesStrideSize;
  64583. private _updateEffectOptions;
  64584. private _randomTextureSize;
  64585. private _actualFrame;
  64586. private readonly _rawTextureWidth;
  64587. /**
  64588. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  64589. */
  64590. static get IsSupported(): boolean;
  64591. /**
  64592. * An event triggered when the system is disposed.
  64593. */
  64594. onDisposeObservable: Observable<GPUParticleSystem>;
  64595. /**
  64596. * Gets the maximum number of particles active at the same time.
  64597. * @returns The max number of active particles.
  64598. */
  64599. getCapacity(): number;
  64600. /**
  64601. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  64602. * to override the particles.
  64603. */
  64604. forceDepthWrite: boolean;
  64605. /**
  64606. * Gets or set the number of active particles
  64607. */
  64608. get activeParticleCount(): number;
  64609. set activeParticleCount(value: number);
  64610. private _preWarmDone;
  64611. /**
  64612. * Is this system ready to be used/rendered
  64613. * @return true if the system is ready
  64614. */
  64615. isReady(): boolean;
  64616. /**
  64617. * Gets if the system has been started. (Note: this will still be true after stop is called)
  64618. * @returns True if it has been started, otherwise false.
  64619. */
  64620. isStarted(): boolean;
  64621. /**
  64622. * Starts the particle system and begins to emit
  64623. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  64624. */
  64625. start(delay?: number): void;
  64626. /**
  64627. * Stops the particle system.
  64628. */
  64629. stop(): void;
  64630. /**
  64631. * Remove all active particles
  64632. */
  64633. reset(): void;
  64634. /**
  64635. * Returns the string "GPUParticleSystem"
  64636. * @returns a string containing the class name
  64637. */
  64638. getClassName(): string;
  64639. private _colorGradientsTexture;
  64640. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  64641. /**
  64642. * Adds a new color gradient
  64643. * @param gradient defines the gradient to use (between 0 and 1)
  64644. * @param color1 defines the color to affect to the specified gradient
  64645. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  64646. * @returns the current particle system
  64647. */
  64648. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  64649. /**
  64650. * Remove a specific color gradient
  64651. * @param gradient defines the gradient to remove
  64652. * @returns the current particle system
  64653. */
  64654. removeColorGradient(gradient: number): GPUParticleSystem;
  64655. private _angularSpeedGradientsTexture;
  64656. private _sizeGradientsTexture;
  64657. private _velocityGradientsTexture;
  64658. private _limitVelocityGradientsTexture;
  64659. private _dragGradientsTexture;
  64660. private _addFactorGradient;
  64661. /**
  64662. * Adds a new size gradient
  64663. * @param gradient defines the gradient to use (between 0 and 1)
  64664. * @param factor defines the size factor to affect to the specified gradient
  64665. * @returns the current particle system
  64666. */
  64667. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  64668. /**
  64669. * Remove a specific size gradient
  64670. * @param gradient defines the gradient to remove
  64671. * @returns the current particle system
  64672. */
  64673. removeSizeGradient(gradient: number): GPUParticleSystem;
  64674. /**
  64675. * Adds a new angular speed gradient
  64676. * @param gradient defines the gradient to use (between 0 and 1)
  64677. * @param factor defines the angular speed to affect to the specified gradient
  64678. * @returns the current particle system
  64679. */
  64680. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  64681. /**
  64682. * Remove a specific angular speed gradient
  64683. * @param gradient defines the gradient to remove
  64684. * @returns the current particle system
  64685. */
  64686. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  64687. /**
  64688. * Adds a new velocity gradient
  64689. * @param gradient defines the gradient to use (between 0 and 1)
  64690. * @param factor defines the velocity to affect to the specified gradient
  64691. * @returns the current particle system
  64692. */
  64693. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64694. /**
  64695. * Remove a specific velocity gradient
  64696. * @param gradient defines the gradient to remove
  64697. * @returns the current particle system
  64698. */
  64699. removeVelocityGradient(gradient: number): GPUParticleSystem;
  64700. /**
  64701. * Adds a new limit velocity gradient
  64702. * @param gradient defines the gradient to use (between 0 and 1)
  64703. * @param factor defines the limit velocity value to affect to the specified gradient
  64704. * @returns the current particle system
  64705. */
  64706. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64707. /**
  64708. * Remove a specific limit velocity gradient
  64709. * @param gradient defines the gradient to remove
  64710. * @returns the current particle system
  64711. */
  64712. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64713. /**
  64714. * Adds a new drag gradient
  64715. * @param gradient defines the gradient to use (between 0 and 1)
  64716. * @param factor defines the drag value to affect to the specified gradient
  64717. * @returns the current particle system
  64718. */
  64719. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64720. /**
  64721. * Remove a specific drag gradient
  64722. * @param gradient defines the gradient to remove
  64723. * @returns the current particle system
  64724. */
  64725. removeDragGradient(gradient: number): GPUParticleSystem;
  64726. /**
  64727. * Not supported by GPUParticleSystem
  64728. * @param gradient defines the gradient to use (between 0 and 1)
  64729. * @param factor defines the emit rate value to affect to the specified gradient
  64730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64731. * @returns the current particle system
  64732. */
  64733. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64734. /**
  64735. * Not supported by GPUParticleSystem
  64736. * @param gradient defines the gradient to remove
  64737. * @returns the current particle system
  64738. */
  64739. removeEmitRateGradient(gradient: number): IParticleSystem;
  64740. /**
  64741. * Not supported by GPUParticleSystem
  64742. * @param gradient defines the gradient to use (between 0 and 1)
  64743. * @param factor defines the start size value to affect to the specified gradient
  64744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64745. * @returns the current particle system
  64746. */
  64747. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64748. /**
  64749. * Not supported by GPUParticleSystem
  64750. * @param gradient defines the gradient to remove
  64751. * @returns the current particle system
  64752. */
  64753. removeStartSizeGradient(gradient: number): IParticleSystem;
  64754. /**
  64755. * Not supported by GPUParticleSystem
  64756. * @param gradient defines the gradient to use (between 0 and 1)
  64757. * @param min defines the color remap minimal range
  64758. * @param max defines the color remap maximal range
  64759. * @returns the current particle system
  64760. */
  64761. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64762. /**
  64763. * Not supported by GPUParticleSystem
  64764. * @param gradient defines the gradient to remove
  64765. * @returns the current particle system
  64766. */
  64767. removeColorRemapGradient(): IParticleSystem;
  64768. /**
  64769. * Not supported by GPUParticleSystem
  64770. * @param gradient defines the gradient to use (between 0 and 1)
  64771. * @param min defines the alpha remap minimal range
  64772. * @param max defines the alpha remap maximal range
  64773. * @returns the current particle system
  64774. */
  64775. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64776. /**
  64777. * Not supported by GPUParticleSystem
  64778. * @param gradient defines the gradient to remove
  64779. * @returns the current particle system
  64780. */
  64781. removeAlphaRemapGradient(): IParticleSystem;
  64782. /**
  64783. * Not supported by GPUParticleSystem
  64784. * @param gradient defines the gradient to use (between 0 and 1)
  64785. * @param color defines the color to affect to the specified gradient
  64786. * @returns the current particle system
  64787. */
  64788. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64789. /**
  64790. * Not supported by GPUParticleSystem
  64791. * @param gradient defines the gradient to remove
  64792. * @returns the current particle system
  64793. */
  64794. removeRampGradient(): IParticleSystem;
  64795. /**
  64796. * Not supported by GPUParticleSystem
  64797. * @returns the list of ramp gradients
  64798. */
  64799. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64800. /**
  64801. * Not supported by GPUParticleSystem
  64802. * Gets or sets a boolean indicating that ramp gradients must be used
  64803. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64804. */
  64805. get useRampGradients(): boolean;
  64806. set useRampGradients(value: boolean);
  64807. /**
  64808. * Not supported by GPUParticleSystem
  64809. * @param gradient defines the gradient to use (between 0 and 1)
  64810. * @param factor defines the life time factor to affect to the specified gradient
  64811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64812. * @returns the current particle system
  64813. */
  64814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64815. /**
  64816. * Not supported by GPUParticleSystem
  64817. * @param gradient defines the gradient to remove
  64818. * @returns the current particle system
  64819. */
  64820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64821. /**
  64822. * Instantiates a GPU particle system.
  64823. * 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.
  64824. * @param name The name of the particle system
  64825. * @param options The options used to create the system
  64826. * @param scene The scene the particle system belongs to
  64827. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64828. */
  64829. constructor(name: string, options: Partial<{
  64830. capacity: number;
  64831. randomTextureSize: number;
  64832. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64833. protected _reset(): void;
  64834. private _createUpdateVAO;
  64835. private _createRenderVAO;
  64836. private _initialize;
  64837. /** @hidden */
  64838. _recreateUpdateEffect(): void;
  64839. /** @hidden */
  64840. _recreateRenderEffect(): void;
  64841. /**
  64842. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64843. * @param preWarm defines if we are in the pre-warmimg phase
  64844. */
  64845. animate(preWarm?: boolean): void;
  64846. private _createFactorGradientTexture;
  64847. private _createSizeGradientTexture;
  64848. private _createAngularSpeedGradientTexture;
  64849. private _createVelocityGradientTexture;
  64850. private _createLimitVelocityGradientTexture;
  64851. private _createDragGradientTexture;
  64852. private _createColorGradientTexture;
  64853. /**
  64854. * Renders the particle system in its current state
  64855. * @param preWarm defines if the system should only update the particles but not render them
  64856. * @returns the current number of particles
  64857. */
  64858. render(preWarm?: boolean): number;
  64859. /**
  64860. * Rebuilds the particle system
  64861. */
  64862. rebuild(): void;
  64863. private _releaseBuffers;
  64864. private _releaseVAOs;
  64865. /**
  64866. * Disposes the particle system and free the associated resources
  64867. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64868. */
  64869. dispose(disposeTexture?: boolean): void;
  64870. /**
  64871. * Clones the particle system.
  64872. * @param name The name of the cloned object
  64873. * @param newEmitter The new emitter to use
  64874. * @returns the cloned particle system
  64875. */
  64876. clone(name: string, newEmitter: any): GPUParticleSystem;
  64877. /**
  64878. * Serializes the particle system to a JSON object.
  64879. * @returns the JSON object
  64880. */
  64881. serialize(): any;
  64882. /**
  64883. * Parses a JSON object to create a GPU particle system.
  64884. * @param parsedParticleSystem The JSON object to parse
  64885. * @param scene The scene to create the particle system in
  64886. * @param rootUrl The root url to use to load external dependencies like texture
  64887. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64888. * @returns the parsed GPU particle system
  64889. */
  64890. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64891. }
  64892. }
  64893. declare module "babylonjs/Particles/particleSystemSet" {
  64894. import { Nullable } from "babylonjs/types";
  64895. import { Color3 } from "babylonjs/Maths/math.color";
  64896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64898. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64899. import { Scene, IDisposable } from "babylonjs/scene";
  64900. /**
  64901. * Represents a set of particle systems working together to create a specific effect
  64902. */
  64903. export class ParticleSystemSet implements IDisposable {
  64904. /**
  64905. * Gets or sets base Assets URL
  64906. */
  64907. static BaseAssetsUrl: string;
  64908. private _emitterCreationOptions;
  64909. private _emitterNode;
  64910. /**
  64911. * Gets the particle system list
  64912. */
  64913. systems: IParticleSystem[];
  64914. /**
  64915. * Gets the emitter node used with this set
  64916. */
  64917. get emitterNode(): Nullable<TransformNode>;
  64918. /**
  64919. * Creates a new emitter mesh as a sphere
  64920. * @param options defines the options used to create the sphere
  64921. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64922. * @param scene defines the hosting scene
  64923. */
  64924. setEmitterAsSphere(options: {
  64925. diameter: number;
  64926. segments: number;
  64927. color: Color3;
  64928. }, renderingGroupId: number, scene: Scene): void;
  64929. /**
  64930. * Starts all particle systems of the set
  64931. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64932. */
  64933. start(emitter?: AbstractMesh): void;
  64934. /**
  64935. * Release all associated resources
  64936. */
  64937. dispose(): void;
  64938. /**
  64939. * Serialize the set into a JSON compatible object
  64940. * @returns a JSON compatible representation of the set
  64941. */
  64942. serialize(): any;
  64943. /**
  64944. * Parse a new ParticleSystemSet from a serialized source
  64945. * @param data defines a JSON compatible representation of the set
  64946. * @param scene defines the hosting scene
  64947. * @param gpu defines if we want GPU particles or CPU particles
  64948. * @returns a new ParticleSystemSet
  64949. */
  64950. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64951. }
  64952. }
  64953. declare module "babylonjs/Particles/particleHelper" {
  64954. import { Nullable } from "babylonjs/types";
  64955. import { Scene } from "babylonjs/scene";
  64956. import { Vector3 } from "babylonjs/Maths/math.vector";
  64957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64958. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64959. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64960. /**
  64961. * This class is made for on one-liner static method to help creating particle system set.
  64962. */
  64963. export class ParticleHelper {
  64964. /**
  64965. * Gets or sets base Assets URL
  64966. */
  64967. static BaseAssetsUrl: string;
  64968. /**
  64969. * Create a default particle system that you can tweak
  64970. * @param emitter defines the emitter to use
  64971. * @param capacity defines the system capacity (default is 500 particles)
  64972. * @param scene defines the hosting scene
  64973. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64974. * @returns the new Particle system
  64975. */
  64976. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64977. /**
  64978. * This is the main static method (one-liner) of this helper to create different particle systems
  64979. * @param type This string represents the type to the particle system to create
  64980. * @param scene The scene where the particle system should live
  64981. * @param gpu If the system will use gpu
  64982. * @returns the ParticleSystemSet created
  64983. */
  64984. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64985. /**
  64986. * Static function used to export a particle system to a ParticleSystemSet variable.
  64987. * Please note that the emitter shape is not exported
  64988. * @param systems defines the particle systems to export
  64989. * @returns the created particle system set
  64990. */
  64991. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64992. }
  64993. }
  64994. declare module "babylonjs/Particles/particleSystemComponent" {
  64995. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64996. import { Effect } from "babylonjs/Materials/effect";
  64997. import "babylonjs/Shaders/particles.vertex";
  64998. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64999. module "babylonjs/Engines/engine" {
  65000. interface Engine {
  65001. /**
  65002. * Create an effect to use with particle systems.
  65003. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  65004. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65005. * @param uniformsNames defines a list of attribute names
  65006. * @param samplers defines an array of string used to represent textures
  65007. * @param defines defines the string containing the defines to use to compile the shaders
  65008. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65009. * @param onCompiled defines a function to call when the effect creation is successful
  65010. * @param onError defines a function to call when the effect creation has failed
  65011. * @returns the new Effect
  65012. */
  65013. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  65014. }
  65015. }
  65016. module "babylonjs/Meshes/mesh" {
  65017. interface Mesh {
  65018. /**
  65019. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65020. * @returns an array of IParticleSystem
  65021. */
  65022. getEmittedParticleSystems(): IParticleSystem[];
  65023. /**
  65024. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65025. * @returns an array of IParticleSystem
  65026. */
  65027. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65028. }
  65029. }
  65030. /**
  65031. * @hidden
  65032. */
  65033. export var _IDoNeedToBeInTheBuild: number;
  65034. }
  65035. declare module "babylonjs/Particles/pointsCloudSystem" {
  65036. import { Color4 } from "babylonjs/Maths/math";
  65037. import { Mesh } from "babylonjs/Meshes/mesh";
  65038. import { Scene, IDisposable } from "babylonjs/scene";
  65039. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  65040. /** Defines the 4 color options */
  65041. export enum PointColor {
  65042. /** color value */
  65043. Color = 2,
  65044. /** uv value */
  65045. UV = 1,
  65046. /** random value */
  65047. Random = 0,
  65048. /** stated value */
  65049. Stated = 3
  65050. }
  65051. /**
  65052. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65053. * 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.
  65054. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65055. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65056. *
  65057. * Full documentation here : TO BE ENTERED
  65058. */
  65059. export class PointsCloudSystem implements IDisposable {
  65060. /**
  65061. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65062. * Example : var p = SPS.particles[i];
  65063. */
  65064. particles: CloudPoint[];
  65065. /**
  65066. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65067. */
  65068. nbParticles: number;
  65069. /**
  65070. * This a counter for your own usage. It's not set by any SPS functions.
  65071. */
  65072. counter: number;
  65073. /**
  65074. * The PCS name. This name is also given to the underlying mesh.
  65075. */
  65076. name: string;
  65077. /**
  65078. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65079. */
  65080. mesh: Mesh;
  65081. /**
  65082. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65083. * Please read :
  65084. */
  65085. vars: any;
  65086. /**
  65087. * @hidden
  65088. */
  65089. _size: number;
  65090. private _scene;
  65091. private _promises;
  65092. private _positions;
  65093. private _indices;
  65094. private _normals;
  65095. private _colors;
  65096. private _uvs;
  65097. private _indices32;
  65098. private _positions32;
  65099. private _colors32;
  65100. private _uvs32;
  65101. private _updatable;
  65102. private _isVisibilityBoxLocked;
  65103. private _alwaysVisible;
  65104. private _groups;
  65105. private _groupCounter;
  65106. private _computeParticleColor;
  65107. private _computeParticleTexture;
  65108. private _computeParticleRotation;
  65109. private _computeBoundingBox;
  65110. private _isReady;
  65111. /**
  65112. * Creates a PCS (Points Cloud System) object
  65113. * @param name (String) is the PCS name, this will be the underlying mesh name
  65114. * @param pointSize (number) is the size for each point
  65115. * @param scene (Scene) is the scene in which the PCS is added
  65116. * @param options defines the options of the PCS e.g.
  65117. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65118. */
  65119. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65120. updatable?: boolean;
  65121. });
  65122. /**
  65123. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65124. * If no points were added to the PCS, the returned mesh is just a single point.
  65125. * @returns a promise for the created mesh
  65126. */
  65127. buildMeshAsync(): Promise<Mesh>;
  65128. /**
  65129. * @hidden
  65130. */
  65131. private _buildMesh;
  65132. private _addParticle;
  65133. private _randomUnitVector;
  65134. private _getColorIndicesForCoord;
  65135. private _setPointsColorOrUV;
  65136. private _colorFromTexture;
  65137. private _calculateDensity;
  65138. /**
  65139. * Adds points to the PCS in random positions within a unit sphere
  65140. * @param nb (positive integer) the number of particles to be created from this model
  65141. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65142. * @returns the number of groups in the system
  65143. */
  65144. addPoints(nb: number, pointFunction?: any): number;
  65145. /**
  65146. * Adds points to the PCS from the surface of the model shape
  65147. * @param mesh is any Mesh object that will be used as a surface model for the points
  65148. * @param nb (positive integer) the number of particles to be created from this model
  65149. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65150. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65151. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65152. * @returns the number of groups in the system
  65153. */
  65154. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65155. /**
  65156. * Adds points to the PCS inside the model shape
  65157. * @param mesh is any Mesh object that will be used as a surface model for the points
  65158. * @param nb (positive integer) the number of particles to be created from this model
  65159. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65160. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65161. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65162. * @returns the number of groups in the system
  65163. */
  65164. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65165. /**
  65166. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65167. * This method calls `updateParticle()` for each particle of the SPS.
  65168. * For an animated SPS, it is usually called within the render loop.
  65169. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65170. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65171. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65172. * @returns the PCS.
  65173. */
  65174. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65175. /**
  65176. * Disposes the PCS.
  65177. */
  65178. dispose(): void;
  65179. /**
  65180. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65181. * doc :
  65182. * @returns the PCS.
  65183. */
  65184. refreshVisibleSize(): PointsCloudSystem;
  65185. /**
  65186. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65187. * @param size the size (float) of the visibility box
  65188. * note : this doesn't lock the PCS mesh bounding box.
  65189. * doc :
  65190. */
  65191. setVisibilityBox(size: number): void;
  65192. /**
  65193. * Gets whether the PCS is always visible or not
  65194. * doc :
  65195. */
  65196. get isAlwaysVisible(): boolean;
  65197. /**
  65198. * Sets the PCS as always visible or not
  65199. * doc :
  65200. */
  65201. set isAlwaysVisible(val: boolean);
  65202. /**
  65203. * Tells to `setParticles()` to compute the particle rotations or not
  65204. * Default value : false. The PCS is faster when it's set to false
  65205. * Note : particle rotations are only applied to parent particles
  65206. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65207. */
  65208. set computeParticleRotation(val: boolean);
  65209. /**
  65210. * Tells to `setParticles()` to compute the particle colors or not.
  65211. * Default value : true. The PCS is faster when it's set to false.
  65212. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65213. */
  65214. set computeParticleColor(val: boolean);
  65215. set computeParticleTexture(val: boolean);
  65216. /**
  65217. * Gets if `setParticles()` computes the particle colors or not.
  65218. * Default value : false. The PCS is faster when it's set to false.
  65219. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65220. */
  65221. get computeParticleColor(): boolean;
  65222. /**
  65223. * Gets if `setParticles()` computes the particle textures or not.
  65224. * Default value : false. The PCS is faster when it's set to false.
  65225. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65226. */
  65227. get computeParticleTexture(): boolean;
  65228. /**
  65229. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65230. */
  65231. set computeBoundingBox(val: boolean);
  65232. /**
  65233. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65234. */
  65235. get computeBoundingBox(): boolean;
  65236. /**
  65237. * This function does nothing. It may be overwritten to set all the particle first values.
  65238. * The PCS doesn't call this function, you may have to call it by your own.
  65239. * doc :
  65240. */
  65241. initParticles(): void;
  65242. /**
  65243. * This function does nothing. It may be overwritten to recycle a particle
  65244. * The PCS doesn't call this function, you can to call it
  65245. * doc :
  65246. * @param particle The particle to recycle
  65247. * @returns the recycled particle
  65248. */
  65249. recycleParticle(particle: CloudPoint): CloudPoint;
  65250. /**
  65251. * Updates a particle : this function should be overwritten by the user.
  65252. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65253. * doc :
  65254. * @example : just set a particle position or velocity and recycle conditions
  65255. * @param particle The particle to update
  65256. * @returns the updated particle
  65257. */
  65258. updateParticle(particle: CloudPoint): CloudPoint;
  65259. /**
  65260. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65261. * This does nothing and may be overwritten by the user.
  65262. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65263. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65264. * @param update the boolean update value actually passed to setParticles()
  65265. */
  65266. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65267. /**
  65268. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65269. * This will be passed three parameters.
  65270. * This does nothing and may be overwritten by the user.
  65271. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65272. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65273. * @param update the boolean update value actually passed to setParticles()
  65274. */
  65275. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65276. }
  65277. }
  65278. declare module "babylonjs/Particles/cloudPoint" {
  65279. import { Nullable } from "babylonjs/types";
  65280. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  65281. import { Mesh } from "babylonjs/Meshes/mesh";
  65282. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  65283. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  65284. /**
  65285. * Represents one particle of a points cloud system.
  65286. */
  65287. export class CloudPoint {
  65288. /**
  65289. * particle global index
  65290. */
  65291. idx: number;
  65292. /**
  65293. * The color of the particle
  65294. */
  65295. color: Nullable<Color4>;
  65296. /**
  65297. * The world space position of the particle.
  65298. */
  65299. position: Vector3;
  65300. /**
  65301. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65302. */
  65303. rotation: Vector3;
  65304. /**
  65305. * The world space rotation quaternion of the particle.
  65306. */
  65307. rotationQuaternion: Nullable<Quaternion>;
  65308. /**
  65309. * The uv of the particle.
  65310. */
  65311. uv: Nullable<Vector2>;
  65312. /**
  65313. * The current speed of the particle.
  65314. */
  65315. velocity: Vector3;
  65316. /**
  65317. * The pivot point in the particle local space.
  65318. */
  65319. pivot: Vector3;
  65320. /**
  65321. * Must the particle be translated from its pivot point in its local space ?
  65322. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65323. * Default : false
  65324. */
  65325. translateFromPivot: boolean;
  65326. /**
  65327. * Index of this particle in the global "positions" array (Internal use)
  65328. * @hidden
  65329. */
  65330. _pos: number;
  65331. /**
  65332. * @hidden Index of this particle in the global "indices" array (Internal use)
  65333. */
  65334. _ind: number;
  65335. /**
  65336. * Group this particle belongs to
  65337. */
  65338. _group: PointsGroup;
  65339. /**
  65340. * Group id of this particle
  65341. */
  65342. groupId: number;
  65343. /**
  65344. * Index of the particle in its group id (Internal use)
  65345. */
  65346. idxInGroup: number;
  65347. /**
  65348. * @hidden Particle BoundingInfo object (Internal use)
  65349. */
  65350. _boundingInfo: BoundingInfo;
  65351. /**
  65352. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  65353. */
  65354. _pcs: PointsCloudSystem;
  65355. /**
  65356. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  65357. */
  65358. _stillInvisible: boolean;
  65359. /**
  65360. * @hidden Last computed particle rotation matrix
  65361. */
  65362. _rotationMatrix: number[];
  65363. /**
  65364. * Parent particle Id, if any.
  65365. * Default null.
  65366. */
  65367. parentId: Nullable<number>;
  65368. /**
  65369. * @hidden Internal global position in the PCS.
  65370. */
  65371. _globalPosition: Vector3;
  65372. /**
  65373. * Creates a Point Cloud object.
  65374. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  65375. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  65376. * @param group (PointsGroup) is the group the particle belongs to
  65377. * @param groupId (integer) is the group identifier in the PCS.
  65378. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  65379. * @param pcs defines the PCS it is associated to
  65380. */
  65381. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  65382. /**
  65383. * get point size
  65384. */
  65385. get size(): Vector3;
  65386. /**
  65387. * Set point size
  65388. */
  65389. set size(scale: Vector3);
  65390. /**
  65391. * Legacy support, changed quaternion to rotationQuaternion
  65392. */
  65393. get quaternion(): Nullable<Quaternion>;
  65394. /**
  65395. * Legacy support, changed quaternion to rotationQuaternion
  65396. */
  65397. set quaternion(q: Nullable<Quaternion>);
  65398. /**
  65399. * Returns a boolean. True if the particle intersects a mesh, else false
  65400. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  65401. * @param target is the object (point or mesh) what the intersection is computed against
  65402. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  65403. * @returns true if it intersects
  65404. */
  65405. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  65406. /**
  65407. * get the rotation matrix of the particle
  65408. * @hidden
  65409. */
  65410. getRotationMatrix(m: Matrix): void;
  65411. }
  65412. /**
  65413. * Represents a group of points in a points cloud system
  65414. * * PCS internal tool, don't use it manually.
  65415. */
  65416. export class PointsGroup {
  65417. /**
  65418. * The group id
  65419. * @hidden
  65420. */
  65421. groupID: number;
  65422. /**
  65423. * image data for group (internal use)
  65424. * @hidden
  65425. */
  65426. _groupImageData: Nullable<ArrayBufferView>;
  65427. /**
  65428. * Image Width (internal use)
  65429. * @hidden
  65430. */
  65431. _groupImgWidth: number;
  65432. /**
  65433. * Image Height (internal use)
  65434. * @hidden
  65435. */
  65436. _groupImgHeight: number;
  65437. /**
  65438. * Custom position function (internal use)
  65439. * @hidden
  65440. */
  65441. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  65442. /**
  65443. * density per facet for surface points
  65444. * @hidden
  65445. */
  65446. _groupDensity: number[];
  65447. /**
  65448. * Only when points are colored by texture carries pointer to texture list array
  65449. * @hidden
  65450. */
  65451. _textureNb: number;
  65452. /**
  65453. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  65454. * PCS internal tool, don't use it manually.
  65455. * @hidden
  65456. */
  65457. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  65458. }
  65459. }
  65460. declare module "babylonjs/Particles/index" {
  65461. export * from "babylonjs/Particles/baseParticleSystem";
  65462. export * from "babylonjs/Particles/EmitterTypes/index";
  65463. export * from "babylonjs/Particles/gpuParticleSystem";
  65464. export * from "babylonjs/Particles/IParticleSystem";
  65465. export * from "babylonjs/Particles/particle";
  65466. export * from "babylonjs/Particles/particleHelper";
  65467. export * from "babylonjs/Particles/particleSystem";
  65468. export * from "babylonjs/Particles/particleSystemComponent";
  65469. export * from "babylonjs/Particles/particleSystemSet";
  65470. export * from "babylonjs/Particles/solidParticle";
  65471. export * from "babylonjs/Particles/solidParticleSystem";
  65472. export * from "babylonjs/Particles/cloudPoint";
  65473. export * from "babylonjs/Particles/pointsCloudSystem";
  65474. export * from "babylonjs/Particles/subEmitter";
  65475. }
  65476. declare module "babylonjs/Physics/physicsEngineComponent" {
  65477. import { Nullable } from "babylonjs/types";
  65478. import { Observable, Observer } from "babylonjs/Misc/observable";
  65479. import { Vector3 } from "babylonjs/Maths/math.vector";
  65480. import { Mesh } from "babylonjs/Meshes/mesh";
  65481. import { ISceneComponent } from "babylonjs/sceneComponent";
  65482. import { Scene } from "babylonjs/scene";
  65483. import { Node } from "babylonjs/node";
  65484. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  65485. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65486. module "babylonjs/scene" {
  65487. interface Scene {
  65488. /** @hidden (Backing field) */
  65489. _physicsEngine: Nullable<IPhysicsEngine>;
  65490. /** @hidden */
  65491. _physicsTimeAccumulator: number;
  65492. /**
  65493. * Gets the current physics engine
  65494. * @returns a IPhysicsEngine or null if none attached
  65495. */
  65496. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  65497. /**
  65498. * Enables physics to the current scene
  65499. * @param gravity defines the scene's gravity for the physics engine
  65500. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  65501. * @return a boolean indicating if the physics engine was initialized
  65502. */
  65503. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  65504. /**
  65505. * Disables and disposes the physics engine associated with the scene
  65506. */
  65507. disablePhysicsEngine(): void;
  65508. /**
  65509. * Gets a boolean indicating if there is an active physics engine
  65510. * @returns a boolean indicating if there is an active physics engine
  65511. */
  65512. isPhysicsEnabled(): boolean;
  65513. /**
  65514. * Deletes a physics compound impostor
  65515. * @param compound defines the compound to delete
  65516. */
  65517. deleteCompoundImpostor(compound: any): void;
  65518. /**
  65519. * An event triggered when physic simulation is about to be run
  65520. */
  65521. onBeforePhysicsObservable: Observable<Scene>;
  65522. /**
  65523. * An event triggered when physic simulation has been done
  65524. */
  65525. onAfterPhysicsObservable: Observable<Scene>;
  65526. }
  65527. }
  65528. module "babylonjs/Meshes/abstractMesh" {
  65529. interface AbstractMesh {
  65530. /** @hidden */
  65531. _physicsImpostor: Nullable<PhysicsImpostor>;
  65532. /**
  65533. * Gets or sets impostor used for physic simulation
  65534. * @see http://doc.babylonjs.com/features/physics_engine
  65535. */
  65536. physicsImpostor: Nullable<PhysicsImpostor>;
  65537. /**
  65538. * Gets the current physics impostor
  65539. * @see http://doc.babylonjs.com/features/physics_engine
  65540. * @returns a physics impostor or null
  65541. */
  65542. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  65543. /** Apply a physic impulse to the mesh
  65544. * @param force defines the force to apply
  65545. * @param contactPoint defines where to apply the force
  65546. * @returns the current mesh
  65547. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  65548. */
  65549. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  65550. /**
  65551. * Creates a physic joint between two meshes
  65552. * @param otherMesh defines the other mesh to use
  65553. * @param pivot1 defines the pivot to use on this mesh
  65554. * @param pivot2 defines the pivot to use on the other mesh
  65555. * @param options defines additional options (can be plugin dependent)
  65556. * @returns the current mesh
  65557. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  65558. */
  65559. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  65560. /** @hidden */
  65561. _disposePhysicsObserver: Nullable<Observer<Node>>;
  65562. }
  65563. }
  65564. /**
  65565. * Defines the physics engine scene component responsible to manage a physics engine
  65566. */
  65567. export class PhysicsEngineSceneComponent implements ISceneComponent {
  65568. /**
  65569. * The component name helpful to identify the component in the list of scene components.
  65570. */
  65571. readonly name: string;
  65572. /**
  65573. * The scene the component belongs to.
  65574. */
  65575. scene: Scene;
  65576. /**
  65577. * Creates a new instance of the component for the given scene
  65578. * @param scene Defines the scene to register the component in
  65579. */
  65580. constructor(scene: Scene);
  65581. /**
  65582. * Registers the component in a given scene
  65583. */
  65584. register(): void;
  65585. /**
  65586. * Rebuilds the elements related to this component in case of
  65587. * context lost for instance.
  65588. */
  65589. rebuild(): void;
  65590. /**
  65591. * Disposes the component and the associated ressources
  65592. */
  65593. dispose(): void;
  65594. }
  65595. }
  65596. declare module "babylonjs/Physics/physicsHelper" {
  65597. import { Nullable } from "babylonjs/types";
  65598. import { Vector3 } from "babylonjs/Maths/math.vector";
  65599. import { Mesh } from "babylonjs/Meshes/mesh";
  65600. import { Scene } from "babylonjs/scene";
  65601. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65602. /**
  65603. * A helper for physics simulations
  65604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65605. */
  65606. export class PhysicsHelper {
  65607. private _scene;
  65608. private _physicsEngine;
  65609. /**
  65610. * Initializes the Physics helper
  65611. * @param scene Babylon.js scene
  65612. */
  65613. constructor(scene: Scene);
  65614. /**
  65615. * Applies a radial explosion impulse
  65616. * @param origin the origin of the explosion
  65617. * @param radiusOrEventOptions the radius or the options of radial explosion
  65618. * @param strength the explosion strength
  65619. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65620. * @returns A physics radial explosion event, or null
  65621. */
  65622. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65623. /**
  65624. * Applies a radial explosion force
  65625. * @param origin the origin of the explosion
  65626. * @param radiusOrEventOptions the radius or the options of radial explosion
  65627. * @param strength the explosion strength
  65628. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65629. * @returns A physics radial explosion event, or null
  65630. */
  65631. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65632. /**
  65633. * Creates a gravitational field
  65634. * @param origin the origin of the explosion
  65635. * @param radiusOrEventOptions the radius or the options of radial explosion
  65636. * @param strength the explosion strength
  65637. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65638. * @returns A physics gravitational field event, or null
  65639. */
  65640. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  65641. /**
  65642. * Creates a physics updraft event
  65643. * @param origin the origin of the updraft
  65644. * @param radiusOrEventOptions the radius or the options of the updraft
  65645. * @param strength the strength of the updraft
  65646. * @param height the height of the updraft
  65647. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  65648. * @returns A physics updraft event, or null
  65649. */
  65650. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  65651. /**
  65652. * Creates a physics vortex event
  65653. * @param origin the of the vortex
  65654. * @param radiusOrEventOptions the radius or the options of the vortex
  65655. * @param strength the strength of the vortex
  65656. * @param height the height of the vortex
  65657. * @returns a Physics vortex event, or null
  65658. * A physics vortex event or null
  65659. */
  65660. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  65661. }
  65662. /**
  65663. * Represents a physics radial explosion event
  65664. */
  65665. class PhysicsRadialExplosionEvent {
  65666. private _scene;
  65667. private _options;
  65668. private _sphere;
  65669. private _dataFetched;
  65670. /**
  65671. * Initializes a radial explosioin event
  65672. * @param _scene BabylonJS scene
  65673. * @param _options The options for the vortex event
  65674. */
  65675. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  65676. /**
  65677. * Returns the data related to the radial explosion event (sphere).
  65678. * @returns The radial explosion event data
  65679. */
  65680. getData(): PhysicsRadialExplosionEventData;
  65681. /**
  65682. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  65683. * @param impostor A physics imposter
  65684. * @param origin the origin of the explosion
  65685. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  65686. */
  65687. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  65688. /**
  65689. * Triggers affecterd impostors callbacks
  65690. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  65691. */
  65692. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  65693. /**
  65694. * Disposes the sphere.
  65695. * @param force Specifies if the sphere should be disposed by force
  65696. */
  65697. dispose(force?: boolean): void;
  65698. /*** Helpers ***/
  65699. private _prepareSphere;
  65700. private _intersectsWithSphere;
  65701. }
  65702. /**
  65703. * Represents a gravitational field event
  65704. */
  65705. class PhysicsGravitationalFieldEvent {
  65706. private _physicsHelper;
  65707. private _scene;
  65708. private _origin;
  65709. private _options;
  65710. private _tickCallback;
  65711. private _sphere;
  65712. private _dataFetched;
  65713. /**
  65714. * Initializes the physics gravitational field event
  65715. * @param _physicsHelper A physics helper
  65716. * @param _scene BabylonJS scene
  65717. * @param _origin The origin position of the gravitational field event
  65718. * @param _options The options for the vortex event
  65719. */
  65720. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65721. /**
  65722. * Returns the data related to the gravitational field event (sphere).
  65723. * @returns A gravitational field event
  65724. */
  65725. getData(): PhysicsGravitationalFieldEventData;
  65726. /**
  65727. * Enables the gravitational field.
  65728. */
  65729. enable(): void;
  65730. /**
  65731. * Disables the gravitational field.
  65732. */
  65733. disable(): void;
  65734. /**
  65735. * Disposes the sphere.
  65736. * @param force The force to dispose from the gravitational field event
  65737. */
  65738. dispose(force?: boolean): void;
  65739. private _tick;
  65740. }
  65741. /**
  65742. * Represents a physics updraft event
  65743. */
  65744. class PhysicsUpdraftEvent {
  65745. private _scene;
  65746. private _origin;
  65747. private _options;
  65748. private _physicsEngine;
  65749. private _originTop;
  65750. private _originDirection;
  65751. private _tickCallback;
  65752. private _cylinder;
  65753. private _cylinderPosition;
  65754. private _dataFetched;
  65755. /**
  65756. * Initializes the physics updraft event
  65757. * @param _scene BabylonJS scene
  65758. * @param _origin The origin position of the updraft
  65759. * @param _options The options for the updraft event
  65760. */
  65761. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65762. /**
  65763. * Returns the data related to the updraft event (cylinder).
  65764. * @returns A physics updraft event
  65765. */
  65766. getData(): PhysicsUpdraftEventData;
  65767. /**
  65768. * Enables the updraft.
  65769. */
  65770. enable(): void;
  65771. /**
  65772. * Disables the updraft.
  65773. */
  65774. disable(): void;
  65775. /**
  65776. * Disposes the cylinder.
  65777. * @param force Specifies if the updraft should be disposed by force
  65778. */
  65779. dispose(force?: boolean): void;
  65780. private getImpostorHitData;
  65781. private _tick;
  65782. /*** Helpers ***/
  65783. private _prepareCylinder;
  65784. private _intersectsWithCylinder;
  65785. }
  65786. /**
  65787. * Represents a physics vortex event
  65788. */
  65789. class PhysicsVortexEvent {
  65790. private _scene;
  65791. private _origin;
  65792. private _options;
  65793. private _physicsEngine;
  65794. private _originTop;
  65795. private _tickCallback;
  65796. private _cylinder;
  65797. private _cylinderPosition;
  65798. private _dataFetched;
  65799. /**
  65800. * Initializes the physics vortex event
  65801. * @param _scene The BabylonJS scene
  65802. * @param _origin The origin position of the vortex
  65803. * @param _options The options for the vortex event
  65804. */
  65805. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65806. /**
  65807. * Returns the data related to the vortex event (cylinder).
  65808. * @returns The physics vortex event data
  65809. */
  65810. getData(): PhysicsVortexEventData;
  65811. /**
  65812. * Enables the vortex.
  65813. */
  65814. enable(): void;
  65815. /**
  65816. * Disables the cortex.
  65817. */
  65818. disable(): void;
  65819. /**
  65820. * Disposes the sphere.
  65821. * @param force
  65822. */
  65823. dispose(force?: boolean): void;
  65824. private getImpostorHitData;
  65825. private _tick;
  65826. /*** Helpers ***/
  65827. private _prepareCylinder;
  65828. private _intersectsWithCylinder;
  65829. }
  65830. /**
  65831. * Options fot the radial explosion event
  65832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65833. */
  65834. export class PhysicsRadialExplosionEventOptions {
  65835. /**
  65836. * The radius of the sphere for the radial explosion.
  65837. */
  65838. radius: number;
  65839. /**
  65840. * The strenth of the explosion.
  65841. */
  65842. strength: number;
  65843. /**
  65844. * The strenght of the force in correspondence to the distance of the affected object
  65845. */
  65846. falloff: PhysicsRadialImpulseFalloff;
  65847. /**
  65848. * Sphere options for the radial explosion.
  65849. */
  65850. sphere: {
  65851. segments: number;
  65852. diameter: number;
  65853. };
  65854. /**
  65855. * Sphere options for the radial explosion.
  65856. */
  65857. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65858. }
  65859. /**
  65860. * Options fot the updraft event
  65861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65862. */
  65863. export class PhysicsUpdraftEventOptions {
  65864. /**
  65865. * The radius of the cylinder for the vortex
  65866. */
  65867. radius: number;
  65868. /**
  65869. * The strenth of the updraft.
  65870. */
  65871. strength: number;
  65872. /**
  65873. * The height of the cylinder for the updraft.
  65874. */
  65875. height: number;
  65876. /**
  65877. * The mode for the the updraft.
  65878. */
  65879. updraftMode: PhysicsUpdraftMode;
  65880. }
  65881. /**
  65882. * Options fot the vortex event
  65883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65884. */
  65885. export class PhysicsVortexEventOptions {
  65886. /**
  65887. * The radius of the cylinder for the vortex
  65888. */
  65889. radius: number;
  65890. /**
  65891. * The strenth of the vortex.
  65892. */
  65893. strength: number;
  65894. /**
  65895. * The height of the cylinder for the vortex.
  65896. */
  65897. height: number;
  65898. /**
  65899. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65900. */
  65901. centripetalForceThreshold: number;
  65902. /**
  65903. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65904. */
  65905. centripetalForceMultiplier: number;
  65906. /**
  65907. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65908. */
  65909. centrifugalForceMultiplier: number;
  65910. /**
  65911. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65912. */
  65913. updraftForceMultiplier: number;
  65914. }
  65915. /**
  65916. * The strenght of the force in correspondence to the distance of the affected object
  65917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65918. */
  65919. export enum PhysicsRadialImpulseFalloff {
  65920. /** Defines that impulse is constant in strength across it's whole radius */
  65921. Constant = 0,
  65922. /** Defines that impulse gets weaker if it's further from the origin */
  65923. Linear = 1
  65924. }
  65925. /**
  65926. * The strength of the force in correspondence to the distance of the affected object
  65927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65928. */
  65929. export enum PhysicsUpdraftMode {
  65930. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65931. Center = 0,
  65932. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65933. Perpendicular = 1
  65934. }
  65935. /**
  65936. * Interface for a physics hit data
  65937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65938. */
  65939. export interface PhysicsHitData {
  65940. /**
  65941. * The force applied at the contact point
  65942. */
  65943. force: Vector3;
  65944. /**
  65945. * The contact point
  65946. */
  65947. contactPoint: Vector3;
  65948. /**
  65949. * The distance from the origin to the contact point
  65950. */
  65951. distanceFromOrigin: number;
  65952. }
  65953. /**
  65954. * Interface for radial explosion event data
  65955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65956. */
  65957. export interface PhysicsRadialExplosionEventData {
  65958. /**
  65959. * A sphere used for the radial explosion event
  65960. */
  65961. sphere: Mesh;
  65962. }
  65963. /**
  65964. * Interface for gravitational field event data
  65965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65966. */
  65967. export interface PhysicsGravitationalFieldEventData {
  65968. /**
  65969. * A sphere mesh used for the gravitational field event
  65970. */
  65971. sphere: Mesh;
  65972. }
  65973. /**
  65974. * Interface for updraft event data
  65975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65976. */
  65977. export interface PhysicsUpdraftEventData {
  65978. /**
  65979. * A cylinder used for the updraft event
  65980. */
  65981. cylinder: Mesh;
  65982. }
  65983. /**
  65984. * Interface for vortex event data
  65985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65986. */
  65987. export interface PhysicsVortexEventData {
  65988. /**
  65989. * A cylinder used for the vortex event
  65990. */
  65991. cylinder: Mesh;
  65992. }
  65993. /**
  65994. * Interface for an affected physics impostor
  65995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65996. */
  65997. export interface PhysicsAffectedImpostorWithData {
  65998. /**
  65999. * The impostor affected by the effect
  66000. */
  66001. impostor: PhysicsImpostor;
  66002. /**
  66003. * The data about the hit/horce from the explosion
  66004. */
  66005. hitData: PhysicsHitData;
  66006. }
  66007. }
  66008. declare module "babylonjs/Physics/Plugins/index" {
  66009. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  66010. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  66011. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  66012. }
  66013. declare module "babylonjs/Physics/index" {
  66014. export * from "babylonjs/Physics/IPhysicsEngine";
  66015. export * from "babylonjs/Physics/physicsEngine";
  66016. export * from "babylonjs/Physics/physicsEngineComponent";
  66017. export * from "babylonjs/Physics/physicsHelper";
  66018. export * from "babylonjs/Physics/physicsImpostor";
  66019. export * from "babylonjs/Physics/physicsJoint";
  66020. export * from "babylonjs/Physics/Plugins/index";
  66021. }
  66022. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  66023. /** @hidden */
  66024. export var blackAndWhitePixelShader: {
  66025. name: string;
  66026. shader: string;
  66027. };
  66028. }
  66029. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  66030. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66031. import { Camera } from "babylonjs/Cameras/camera";
  66032. import { Engine } from "babylonjs/Engines/engine";
  66033. import "babylonjs/Shaders/blackAndWhite.fragment";
  66034. /**
  66035. * Post process used to render in black and white
  66036. */
  66037. export class BlackAndWhitePostProcess extends PostProcess {
  66038. /**
  66039. * Linear about to convert he result to black and white (default: 1)
  66040. */
  66041. degree: number;
  66042. /**
  66043. * Creates a black and white post process
  66044. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66045. * @param name The name of the effect.
  66046. * @param options The required width/height ratio to downsize to before computing the render pass.
  66047. * @param camera The camera to apply the render pass to.
  66048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66049. * @param engine The engine which the post process will be applied. (default: current engine)
  66050. * @param reusable If the post process can be reused on the same frame. (default: false)
  66051. */
  66052. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66053. }
  66054. }
  66055. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  66056. import { Nullable } from "babylonjs/types";
  66057. import { Camera } from "babylonjs/Cameras/camera";
  66058. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66059. import { Engine } from "babylonjs/Engines/engine";
  66060. /**
  66061. * This represents a set of one or more post processes in Babylon.
  66062. * A post process can be used to apply a shader to a texture after it is rendered.
  66063. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66064. */
  66065. export class PostProcessRenderEffect {
  66066. private _postProcesses;
  66067. private _getPostProcesses;
  66068. private _singleInstance;
  66069. private _cameras;
  66070. private _indicesForCamera;
  66071. /**
  66072. * Name of the effect
  66073. * @hidden
  66074. */
  66075. _name: string;
  66076. /**
  66077. * Instantiates a post process render effect.
  66078. * A post process can be used to apply a shader to a texture after it is rendered.
  66079. * @param engine The engine the effect is tied to
  66080. * @param name The name of the effect
  66081. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66082. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66083. */
  66084. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66085. /**
  66086. * Checks if all the post processes in the effect are supported.
  66087. */
  66088. get isSupported(): boolean;
  66089. /**
  66090. * Updates the current state of the effect
  66091. * @hidden
  66092. */
  66093. _update(): void;
  66094. /**
  66095. * Attaches the effect on cameras
  66096. * @param cameras The camera to attach to.
  66097. * @hidden
  66098. */
  66099. _attachCameras(cameras: Camera): void;
  66100. /**
  66101. * Attaches the effect on cameras
  66102. * @param cameras The camera to attach to.
  66103. * @hidden
  66104. */
  66105. _attachCameras(cameras: Camera[]): void;
  66106. /**
  66107. * Detaches the effect on cameras
  66108. * @param cameras The camera to detatch from.
  66109. * @hidden
  66110. */
  66111. _detachCameras(cameras: Camera): void;
  66112. /**
  66113. * Detatches the effect on cameras
  66114. * @param cameras The camera to detatch from.
  66115. * @hidden
  66116. */
  66117. _detachCameras(cameras: Camera[]): void;
  66118. /**
  66119. * Enables the effect on given cameras
  66120. * @param cameras The camera to enable.
  66121. * @hidden
  66122. */
  66123. _enable(cameras: Camera): void;
  66124. /**
  66125. * Enables the effect on given cameras
  66126. * @param cameras The camera to enable.
  66127. * @hidden
  66128. */
  66129. _enable(cameras: Nullable<Camera[]>): void;
  66130. /**
  66131. * Disables the effect on the given cameras
  66132. * @param cameras The camera to disable.
  66133. * @hidden
  66134. */
  66135. _disable(cameras: Camera): void;
  66136. /**
  66137. * Disables the effect on the given cameras
  66138. * @param cameras The camera to disable.
  66139. * @hidden
  66140. */
  66141. _disable(cameras: Nullable<Camera[]>): void;
  66142. /**
  66143. * Gets a list of the post processes contained in the effect.
  66144. * @param camera The camera to get the post processes on.
  66145. * @returns The list of the post processes in the effect.
  66146. */
  66147. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66148. }
  66149. }
  66150. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  66151. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66152. /** @hidden */
  66153. export var extractHighlightsPixelShader: {
  66154. name: string;
  66155. shader: string;
  66156. };
  66157. }
  66158. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  66159. import { Nullable } from "babylonjs/types";
  66160. import { Camera } from "babylonjs/Cameras/camera";
  66161. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66162. import { Engine } from "babylonjs/Engines/engine";
  66163. import "babylonjs/Shaders/extractHighlights.fragment";
  66164. /**
  66165. * 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.
  66166. */
  66167. export class ExtractHighlightsPostProcess extends PostProcess {
  66168. /**
  66169. * The luminance threshold, pixels below this value will be set to black.
  66170. */
  66171. threshold: number;
  66172. /** @hidden */
  66173. _exposure: number;
  66174. /**
  66175. * Post process which has the input texture to be used when performing highlight extraction
  66176. * @hidden
  66177. */
  66178. _inputPostProcess: Nullable<PostProcess>;
  66179. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66180. }
  66181. }
  66182. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  66183. /** @hidden */
  66184. export var bloomMergePixelShader: {
  66185. name: string;
  66186. shader: string;
  66187. };
  66188. }
  66189. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  66190. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66191. import { Nullable } from "babylonjs/types";
  66192. import { Engine } from "babylonjs/Engines/engine";
  66193. import { Camera } from "babylonjs/Cameras/camera";
  66194. import "babylonjs/Shaders/bloomMerge.fragment";
  66195. /**
  66196. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66197. */
  66198. export class BloomMergePostProcess extends PostProcess {
  66199. /** Weight of the bloom to be added to the original input. */
  66200. weight: number;
  66201. /**
  66202. * Creates a new instance of @see BloomMergePostProcess
  66203. * @param name The name of the effect.
  66204. * @param originalFromInput Post process which's input will be used for the merge.
  66205. * @param blurred Blurred highlights post process which's output will be used.
  66206. * @param weight Weight of the bloom to be added to the original input.
  66207. * @param options The required width/height ratio to downsize to before computing the render pass.
  66208. * @param camera The camera to apply the render pass to.
  66209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66210. * @param engine The engine which the post process will be applied. (default: current engine)
  66211. * @param reusable If the post process can be reused on the same frame. (default: false)
  66212. * @param textureType Type of textures used when performing the post process. (default: 0)
  66213. * @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)
  66214. */
  66215. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66216. /** Weight of the bloom to be added to the original input. */
  66217. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66218. }
  66219. }
  66220. declare module "babylonjs/PostProcesses/bloomEffect" {
  66221. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66222. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66223. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66224. import { Camera } from "babylonjs/Cameras/camera";
  66225. import { Scene } from "babylonjs/scene";
  66226. /**
  66227. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66228. */
  66229. export class BloomEffect extends PostProcessRenderEffect {
  66230. private bloomScale;
  66231. /**
  66232. * @hidden Internal
  66233. */
  66234. _effects: Array<PostProcess>;
  66235. /**
  66236. * @hidden Internal
  66237. */
  66238. _downscale: ExtractHighlightsPostProcess;
  66239. private _blurX;
  66240. private _blurY;
  66241. private _merge;
  66242. /**
  66243. * The luminance threshold to find bright areas of the image to bloom.
  66244. */
  66245. get threshold(): number;
  66246. set threshold(value: number);
  66247. /**
  66248. * The strength of the bloom.
  66249. */
  66250. get weight(): number;
  66251. set weight(value: number);
  66252. /**
  66253. * Specifies the size of the bloom blur kernel, relative to the final output size
  66254. */
  66255. get kernel(): number;
  66256. set kernel(value: number);
  66257. /**
  66258. * Creates a new instance of @see BloomEffect
  66259. * @param scene The scene the effect belongs to.
  66260. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66261. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66262. * @param bloomWeight The the strength of bloom.
  66263. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66264. * @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)
  66265. */
  66266. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66267. /**
  66268. * Disposes each of the internal effects for a given camera.
  66269. * @param camera The camera to dispose the effect on.
  66270. */
  66271. disposeEffects(camera: Camera): void;
  66272. /**
  66273. * @hidden Internal
  66274. */
  66275. _updateEffects(): void;
  66276. /**
  66277. * Internal
  66278. * @returns if all the contained post processes are ready.
  66279. * @hidden
  66280. */
  66281. _isReady(): boolean;
  66282. }
  66283. }
  66284. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  66285. /** @hidden */
  66286. export var chromaticAberrationPixelShader: {
  66287. name: string;
  66288. shader: string;
  66289. };
  66290. }
  66291. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  66292. import { Vector2 } from "babylonjs/Maths/math.vector";
  66293. import { Nullable } from "babylonjs/types";
  66294. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66295. import { Camera } from "babylonjs/Cameras/camera";
  66296. import { Engine } from "babylonjs/Engines/engine";
  66297. import "babylonjs/Shaders/chromaticAberration.fragment";
  66298. /**
  66299. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66300. */
  66301. export class ChromaticAberrationPostProcess extends PostProcess {
  66302. /**
  66303. * The amount of seperation of rgb channels (default: 30)
  66304. */
  66305. aberrationAmount: number;
  66306. /**
  66307. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66308. */
  66309. radialIntensity: number;
  66310. /**
  66311. * 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))
  66312. */
  66313. direction: Vector2;
  66314. /**
  66315. * 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))
  66316. */
  66317. centerPosition: Vector2;
  66318. /**
  66319. * Creates a new instance ChromaticAberrationPostProcess
  66320. * @param name The name of the effect.
  66321. * @param screenWidth The width of the screen to apply the effect on.
  66322. * @param screenHeight The height of the screen to apply the effect on.
  66323. * @param options The required width/height ratio to downsize to before computing the render pass.
  66324. * @param camera The camera to apply the render pass to.
  66325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66326. * @param engine The engine which the post process will be applied. (default: current engine)
  66327. * @param reusable If the post process can be reused on the same frame. (default: false)
  66328. * @param textureType Type of textures used when performing the post process. (default: 0)
  66329. * @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)
  66330. */
  66331. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66332. }
  66333. }
  66334. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  66335. /** @hidden */
  66336. export var circleOfConfusionPixelShader: {
  66337. name: string;
  66338. shader: string;
  66339. };
  66340. }
  66341. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  66342. import { Nullable } from "babylonjs/types";
  66343. import { Engine } from "babylonjs/Engines/engine";
  66344. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66345. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66346. import { Camera } from "babylonjs/Cameras/camera";
  66347. import "babylonjs/Shaders/circleOfConfusion.fragment";
  66348. /**
  66349. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  66350. */
  66351. export class CircleOfConfusionPostProcess extends PostProcess {
  66352. /**
  66353. * 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.
  66354. */
  66355. lensSize: number;
  66356. /**
  66357. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66358. */
  66359. fStop: number;
  66360. /**
  66361. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66362. */
  66363. focusDistance: number;
  66364. /**
  66365. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  66366. */
  66367. focalLength: number;
  66368. private _depthTexture;
  66369. /**
  66370. * Creates a new instance CircleOfConfusionPostProcess
  66371. * @param name The name of the effect.
  66372. * @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.
  66373. * @param options The required width/height ratio to downsize to before computing the render pass.
  66374. * @param camera The camera to apply the render pass to.
  66375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66376. * @param engine The engine which the post process will be applied. (default: current engine)
  66377. * @param reusable If the post process can be reused on the same frame. (default: false)
  66378. * @param textureType Type of textures used when performing the post process. (default: 0)
  66379. * @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)
  66380. */
  66381. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66382. /**
  66383. * 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.
  66384. */
  66385. set depthTexture(value: RenderTargetTexture);
  66386. }
  66387. }
  66388. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  66389. /** @hidden */
  66390. export var colorCorrectionPixelShader: {
  66391. name: string;
  66392. shader: string;
  66393. };
  66394. }
  66395. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  66396. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66397. import { Engine } from "babylonjs/Engines/engine";
  66398. import { Camera } from "babylonjs/Cameras/camera";
  66399. import "babylonjs/Shaders/colorCorrection.fragment";
  66400. /**
  66401. *
  66402. * This post-process allows the modification of rendered colors by using
  66403. * a 'look-up table' (LUT). This effect is also called Color Grading.
  66404. *
  66405. * The object needs to be provided an url to a texture containing the color
  66406. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  66407. * Use an image editing software to tweak the LUT to match your needs.
  66408. *
  66409. * For an example of a color LUT, see here:
  66410. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  66411. * For explanations on color grading, see here:
  66412. * @see http://udn.epicgames.com/Three/ColorGrading.html
  66413. *
  66414. */
  66415. export class ColorCorrectionPostProcess extends PostProcess {
  66416. private _colorTableTexture;
  66417. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66418. }
  66419. }
  66420. declare module "babylonjs/Shaders/convolution.fragment" {
  66421. /** @hidden */
  66422. export var convolutionPixelShader: {
  66423. name: string;
  66424. shader: string;
  66425. };
  66426. }
  66427. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  66428. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66429. import { Nullable } from "babylonjs/types";
  66430. import { Camera } from "babylonjs/Cameras/camera";
  66431. import { Engine } from "babylonjs/Engines/engine";
  66432. import "babylonjs/Shaders/convolution.fragment";
  66433. /**
  66434. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  66435. * input texture to perform effects such as edge detection or sharpening
  66436. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66437. */
  66438. export class ConvolutionPostProcess extends PostProcess {
  66439. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66440. kernel: number[];
  66441. /**
  66442. * Creates a new instance ConvolutionPostProcess
  66443. * @param name The name of the effect.
  66444. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  66445. * @param options The required width/height ratio to downsize to before computing the render pass.
  66446. * @param camera The camera to apply the render pass to.
  66447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66448. * @param engine The engine which the post process will be applied. (default: current engine)
  66449. * @param reusable If the post process can be reused on the same frame. (default: false)
  66450. * @param textureType Type of textures used when performing the post process. (default: 0)
  66451. */
  66452. constructor(name: string,
  66453. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66454. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66455. /**
  66456. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66457. */
  66458. static EdgeDetect0Kernel: number[];
  66459. /**
  66460. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66461. */
  66462. static EdgeDetect1Kernel: number[];
  66463. /**
  66464. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66465. */
  66466. static EdgeDetect2Kernel: number[];
  66467. /**
  66468. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66469. */
  66470. static SharpenKernel: number[];
  66471. /**
  66472. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66473. */
  66474. static EmbossKernel: number[];
  66475. /**
  66476. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66477. */
  66478. static GaussianKernel: number[];
  66479. }
  66480. }
  66481. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  66482. import { Nullable } from "babylonjs/types";
  66483. import { Vector2 } from "babylonjs/Maths/math.vector";
  66484. import { Camera } from "babylonjs/Cameras/camera";
  66485. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66486. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66487. import { Engine } from "babylonjs/Engines/engine";
  66488. import { Scene } from "babylonjs/scene";
  66489. /**
  66490. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  66491. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  66492. * based on samples that have a large difference in distance than the center pixel.
  66493. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  66494. */
  66495. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  66496. direction: Vector2;
  66497. /**
  66498. * Creates a new instance CircleOfConfusionPostProcess
  66499. * @param name The name of the effect.
  66500. * @param scene The scene the effect belongs to.
  66501. * @param direction The direction the blur should be applied.
  66502. * @param kernel The size of the kernel used to blur.
  66503. * @param options The required width/height ratio to downsize to before computing the render pass.
  66504. * @param camera The camera to apply the render pass to.
  66505. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  66506. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  66507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66508. * @param engine The engine which the post process will be applied. (default: current engine)
  66509. * @param reusable If the post process can be reused on the same frame. (default: false)
  66510. * @param textureType Type of textures used when performing the post process. (default: 0)
  66511. * @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)
  66512. */
  66513. 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);
  66514. }
  66515. }
  66516. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  66517. /** @hidden */
  66518. export var depthOfFieldMergePixelShader: {
  66519. name: string;
  66520. shader: string;
  66521. };
  66522. }
  66523. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  66524. import { Nullable } from "babylonjs/types";
  66525. import { Camera } from "babylonjs/Cameras/camera";
  66526. import { Effect } from "babylonjs/Materials/effect";
  66527. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66528. import { Engine } from "babylonjs/Engines/engine";
  66529. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  66530. /**
  66531. * Options to be set when merging outputs from the default pipeline.
  66532. */
  66533. export class DepthOfFieldMergePostProcessOptions {
  66534. /**
  66535. * The original image to merge on top of
  66536. */
  66537. originalFromInput: PostProcess;
  66538. /**
  66539. * Parameters to perform the merge of the depth of field effect
  66540. */
  66541. depthOfField?: {
  66542. circleOfConfusion: PostProcess;
  66543. blurSteps: Array<PostProcess>;
  66544. };
  66545. /**
  66546. * Parameters to perform the merge of bloom effect
  66547. */
  66548. bloom?: {
  66549. blurred: PostProcess;
  66550. weight: number;
  66551. };
  66552. }
  66553. /**
  66554. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66555. */
  66556. export class DepthOfFieldMergePostProcess extends PostProcess {
  66557. private blurSteps;
  66558. /**
  66559. * Creates a new instance of DepthOfFieldMergePostProcess
  66560. * @param name The name of the effect.
  66561. * @param originalFromInput Post process which's input will be used for the merge.
  66562. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  66563. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  66564. * @param options The required width/height ratio to downsize to before computing the render pass.
  66565. * @param camera The camera to apply the render pass to.
  66566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66567. * @param engine The engine which the post process will be applied. (default: current engine)
  66568. * @param reusable If the post process can be reused on the same frame. (default: false)
  66569. * @param textureType Type of textures used when performing the post process. (default: 0)
  66570. * @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)
  66571. */
  66572. 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);
  66573. /**
  66574. * Updates the effect with the current post process compile time values and recompiles the shader.
  66575. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66576. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66577. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66578. * @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
  66579. * @param onCompiled Called when the shader has been compiled.
  66580. * @param onError Called if there is an error when compiling a shader.
  66581. */
  66582. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66583. }
  66584. }
  66585. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  66586. import { Nullable } from "babylonjs/types";
  66587. import { Camera } from "babylonjs/Cameras/camera";
  66588. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66589. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66590. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66591. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66592. import { Scene } from "babylonjs/scene";
  66593. /**
  66594. * Specifies the level of max blur that should be applied when using the depth of field effect
  66595. */
  66596. export enum DepthOfFieldEffectBlurLevel {
  66597. /**
  66598. * Subtle blur
  66599. */
  66600. Low = 0,
  66601. /**
  66602. * Medium blur
  66603. */
  66604. Medium = 1,
  66605. /**
  66606. * Large blur
  66607. */
  66608. High = 2
  66609. }
  66610. /**
  66611. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  66612. */
  66613. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  66614. private _circleOfConfusion;
  66615. /**
  66616. * @hidden Internal, blurs from high to low
  66617. */
  66618. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  66619. private _depthOfFieldBlurY;
  66620. private _dofMerge;
  66621. /**
  66622. * @hidden Internal post processes in depth of field effect
  66623. */
  66624. _effects: Array<PostProcess>;
  66625. /**
  66626. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  66627. */
  66628. set focalLength(value: number);
  66629. get focalLength(): number;
  66630. /**
  66631. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66632. */
  66633. set fStop(value: number);
  66634. get fStop(): number;
  66635. /**
  66636. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66637. */
  66638. set focusDistance(value: number);
  66639. get focusDistance(): number;
  66640. /**
  66641. * 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.
  66642. */
  66643. set lensSize(value: number);
  66644. get lensSize(): number;
  66645. /**
  66646. * Creates a new instance DepthOfFieldEffect
  66647. * @param scene The scene the effect belongs to.
  66648. * @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.
  66649. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66650. * @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)
  66651. */
  66652. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  66653. /**
  66654. * Get the current class name of the current effet
  66655. * @returns "DepthOfFieldEffect"
  66656. */
  66657. getClassName(): string;
  66658. /**
  66659. * 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.
  66660. */
  66661. set depthTexture(value: RenderTargetTexture);
  66662. /**
  66663. * Disposes each of the internal effects for a given camera.
  66664. * @param camera The camera to dispose the effect on.
  66665. */
  66666. disposeEffects(camera: Camera): void;
  66667. /**
  66668. * @hidden Internal
  66669. */
  66670. _updateEffects(): void;
  66671. /**
  66672. * Internal
  66673. * @returns if all the contained post processes are ready.
  66674. * @hidden
  66675. */
  66676. _isReady(): boolean;
  66677. }
  66678. }
  66679. declare module "babylonjs/Shaders/displayPass.fragment" {
  66680. /** @hidden */
  66681. export var displayPassPixelShader: {
  66682. name: string;
  66683. shader: string;
  66684. };
  66685. }
  66686. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  66687. import { Nullable } from "babylonjs/types";
  66688. import { Camera } from "babylonjs/Cameras/camera";
  66689. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66690. import { Engine } from "babylonjs/Engines/engine";
  66691. import "babylonjs/Shaders/displayPass.fragment";
  66692. /**
  66693. * DisplayPassPostProcess which produces an output the same as it's input
  66694. */
  66695. export class DisplayPassPostProcess extends PostProcess {
  66696. /**
  66697. * Creates the DisplayPassPostProcess
  66698. * @param name The name of the effect.
  66699. * @param options The required width/height ratio to downsize to before computing the render pass.
  66700. * @param camera The camera to apply the render pass to.
  66701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66702. * @param engine The engine which the post process will be applied. (default: current engine)
  66703. * @param reusable If the post process can be reused on the same frame. (default: false)
  66704. */
  66705. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66706. }
  66707. }
  66708. declare module "babylonjs/Shaders/filter.fragment" {
  66709. /** @hidden */
  66710. export var filterPixelShader: {
  66711. name: string;
  66712. shader: string;
  66713. };
  66714. }
  66715. declare module "babylonjs/PostProcesses/filterPostProcess" {
  66716. import { Nullable } from "babylonjs/types";
  66717. import { Matrix } from "babylonjs/Maths/math.vector";
  66718. import { Camera } from "babylonjs/Cameras/camera";
  66719. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66720. import { Engine } from "babylonjs/Engines/engine";
  66721. import "babylonjs/Shaders/filter.fragment";
  66722. /**
  66723. * Applies a kernel filter to the image
  66724. */
  66725. export class FilterPostProcess extends PostProcess {
  66726. /** The matrix to be applied to the image */
  66727. kernelMatrix: Matrix;
  66728. /**
  66729. *
  66730. * @param name The name of the effect.
  66731. * @param kernelMatrix The matrix to be applied to the image
  66732. * @param options The required width/height ratio to downsize to before computing the render pass.
  66733. * @param camera The camera to apply the render pass to.
  66734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66735. * @param engine The engine which the post process will be applied. (default: current engine)
  66736. * @param reusable If the post process can be reused on the same frame. (default: false)
  66737. */
  66738. constructor(name: string,
  66739. /** The matrix to be applied to the image */
  66740. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66741. }
  66742. }
  66743. declare module "babylonjs/Shaders/fxaa.fragment" {
  66744. /** @hidden */
  66745. export var fxaaPixelShader: {
  66746. name: string;
  66747. shader: string;
  66748. };
  66749. }
  66750. declare module "babylonjs/Shaders/fxaa.vertex" {
  66751. /** @hidden */
  66752. export var fxaaVertexShader: {
  66753. name: string;
  66754. shader: string;
  66755. };
  66756. }
  66757. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  66758. import { Nullable } from "babylonjs/types";
  66759. import { Camera } from "babylonjs/Cameras/camera";
  66760. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66761. import { Engine } from "babylonjs/Engines/engine";
  66762. import "babylonjs/Shaders/fxaa.fragment";
  66763. import "babylonjs/Shaders/fxaa.vertex";
  66764. /**
  66765. * Fxaa post process
  66766. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66767. */
  66768. export class FxaaPostProcess extends PostProcess {
  66769. /** @hidden */
  66770. texelWidth: number;
  66771. /** @hidden */
  66772. texelHeight: number;
  66773. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66774. private _getDefines;
  66775. }
  66776. }
  66777. declare module "babylonjs/Shaders/grain.fragment" {
  66778. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66779. /** @hidden */
  66780. export var grainPixelShader: {
  66781. name: string;
  66782. shader: string;
  66783. };
  66784. }
  66785. declare module "babylonjs/PostProcesses/grainPostProcess" {
  66786. import { Nullable } from "babylonjs/types";
  66787. import { Camera } from "babylonjs/Cameras/camera";
  66788. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66789. import { Engine } from "babylonjs/Engines/engine";
  66790. import "babylonjs/Shaders/grain.fragment";
  66791. /**
  66792. * The GrainPostProcess adds noise to the image at mid luminance levels
  66793. */
  66794. export class GrainPostProcess extends PostProcess {
  66795. /**
  66796. * The intensity of the grain added (default: 30)
  66797. */
  66798. intensity: number;
  66799. /**
  66800. * If the grain should be randomized on every frame
  66801. */
  66802. animated: boolean;
  66803. /**
  66804. * Creates a new instance of @see GrainPostProcess
  66805. * @param name The name of the effect.
  66806. * @param options The required width/height ratio to downsize to before computing the render pass.
  66807. * @param camera The camera to apply the render pass to.
  66808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66809. * @param engine The engine which the post process will be applied. (default: current engine)
  66810. * @param reusable If the post process can be reused on the same frame. (default: false)
  66811. * @param textureType Type of textures used when performing the post process. (default: 0)
  66812. * @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)
  66813. */
  66814. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66815. }
  66816. }
  66817. declare module "babylonjs/Shaders/highlights.fragment" {
  66818. /** @hidden */
  66819. export var highlightsPixelShader: {
  66820. name: string;
  66821. shader: string;
  66822. };
  66823. }
  66824. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66825. import { Nullable } from "babylonjs/types";
  66826. import { Camera } from "babylonjs/Cameras/camera";
  66827. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66828. import { Engine } from "babylonjs/Engines/engine";
  66829. import "babylonjs/Shaders/highlights.fragment";
  66830. /**
  66831. * Extracts highlights from the image
  66832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66833. */
  66834. export class HighlightsPostProcess extends PostProcess {
  66835. /**
  66836. * Extracts highlights from the image
  66837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66838. * @param name The name of the effect.
  66839. * @param options The required width/height ratio to downsize to before computing the render pass.
  66840. * @param camera The camera to apply the render pass to.
  66841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66842. * @param engine The engine which the post process will be applied. (default: current engine)
  66843. * @param reusable If the post process can be reused on the same frame. (default: false)
  66844. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66845. */
  66846. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66847. }
  66848. }
  66849. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66850. /** @hidden */
  66851. export var mrtFragmentDeclaration: {
  66852. name: string;
  66853. shader: string;
  66854. };
  66855. }
  66856. declare module "babylonjs/Shaders/geometry.fragment" {
  66857. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66858. /** @hidden */
  66859. export var geometryPixelShader: {
  66860. name: string;
  66861. shader: string;
  66862. };
  66863. }
  66864. declare module "babylonjs/Shaders/geometry.vertex" {
  66865. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66866. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66868. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66869. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66870. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66871. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66872. /** @hidden */
  66873. export var geometryVertexShader: {
  66874. name: string;
  66875. shader: string;
  66876. };
  66877. }
  66878. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66879. import { Matrix } from "babylonjs/Maths/math.vector";
  66880. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66881. import { Mesh } from "babylonjs/Meshes/mesh";
  66882. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66883. import { Effect } from "babylonjs/Materials/effect";
  66884. import { Scene } from "babylonjs/scene";
  66885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66886. import "babylonjs/Shaders/geometry.fragment";
  66887. import "babylonjs/Shaders/geometry.vertex";
  66888. /** @hidden */
  66889. interface ISavedTransformationMatrix {
  66890. world: Matrix;
  66891. viewProjection: Matrix;
  66892. }
  66893. /**
  66894. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66895. */
  66896. export class GeometryBufferRenderer {
  66897. /**
  66898. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66899. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66900. */
  66901. static readonly POSITION_TEXTURE_TYPE: number;
  66902. /**
  66903. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66904. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66905. */
  66906. static readonly VELOCITY_TEXTURE_TYPE: number;
  66907. /**
  66908. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66909. * in order to compute objects velocities when enableVelocity is set to "true"
  66910. * @hidden
  66911. */
  66912. _previousTransformationMatrices: {
  66913. [index: number]: ISavedTransformationMatrix;
  66914. };
  66915. /**
  66916. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66917. * in order to compute objects velocities when enableVelocity is set to "true"
  66918. * @hidden
  66919. */
  66920. _previousBonesTransformationMatrices: {
  66921. [index: number]: Float32Array;
  66922. };
  66923. /**
  66924. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66925. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66926. */
  66927. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66928. private _scene;
  66929. private _multiRenderTarget;
  66930. private _ratio;
  66931. private _enablePosition;
  66932. private _enableVelocity;
  66933. private _positionIndex;
  66934. private _velocityIndex;
  66935. protected _effect: Effect;
  66936. protected _cachedDefines: string;
  66937. /**
  66938. * Set the render list (meshes to be rendered) used in the G buffer.
  66939. */
  66940. set renderList(meshes: Mesh[]);
  66941. /**
  66942. * Gets wether or not G buffer are supported by the running hardware.
  66943. * This requires draw buffer supports
  66944. */
  66945. get isSupported(): boolean;
  66946. /**
  66947. * Returns the index of the given texture type in the G-Buffer textures array
  66948. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66949. * @returns the index of the given texture type in the G-Buffer textures array
  66950. */
  66951. getTextureIndex(textureType: number): number;
  66952. /**
  66953. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66954. */
  66955. get enablePosition(): boolean;
  66956. /**
  66957. * Sets whether or not objects positions are enabled for the G buffer.
  66958. */
  66959. set enablePosition(enable: boolean);
  66960. /**
  66961. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66962. */
  66963. get enableVelocity(): boolean;
  66964. /**
  66965. * Sets wether or not objects velocities are enabled for the G buffer.
  66966. */
  66967. set enableVelocity(enable: boolean);
  66968. /**
  66969. * Gets the scene associated with the buffer.
  66970. */
  66971. get scene(): Scene;
  66972. /**
  66973. * Gets the ratio used by the buffer during its creation.
  66974. * How big is the buffer related to the main canvas.
  66975. */
  66976. get ratio(): number;
  66977. /** @hidden */
  66978. static _SceneComponentInitialization: (scene: Scene) => void;
  66979. /**
  66980. * Creates a new G Buffer for the scene
  66981. * @param scene The scene the buffer belongs to
  66982. * @param ratio How big is the buffer related to the main canvas.
  66983. */
  66984. constructor(scene: Scene, ratio?: number);
  66985. /**
  66986. * Checks wether everything is ready to render a submesh to the G buffer.
  66987. * @param subMesh the submesh to check readiness for
  66988. * @param useInstances is the mesh drawn using instance or not
  66989. * @returns true if ready otherwise false
  66990. */
  66991. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66992. /**
  66993. * Gets the current underlying G Buffer.
  66994. * @returns the buffer
  66995. */
  66996. getGBuffer(): MultiRenderTarget;
  66997. /**
  66998. * Gets the number of samples used to render the buffer (anti aliasing).
  66999. */
  67000. get samples(): number;
  67001. /**
  67002. * Sets the number of samples used to render the buffer (anti aliasing).
  67003. */
  67004. set samples(value: number);
  67005. /**
  67006. * Disposes the renderer and frees up associated resources.
  67007. */
  67008. dispose(): void;
  67009. protected _createRenderTargets(): void;
  67010. private _copyBonesTransformationMatrices;
  67011. }
  67012. }
  67013. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  67014. import { Nullable } from "babylonjs/types";
  67015. import { Scene } from "babylonjs/scene";
  67016. import { ISceneComponent } from "babylonjs/sceneComponent";
  67017. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  67018. module "babylonjs/scene" {
  67019. interface Scene {
  67020. /** @hidden (Backing field) */
  67021. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67022. /**
  67023. * Gets or Sets the current geometry buffer associated to the scene.
  67024. */
  67025. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67026. /**
  67027. * Enables a GeometryBufferRender and associates it with the scene
  67028. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67029. * @returns the GeometryBufferRenderer
  67030. */
  67031. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67032. /**
  67033. * Disables the GeometryBufferRender associated with the scene
  67034. */
  67035. disableGeometryBufferRenderer(): void;
  67036. }
  67037. }
  67038. /**
  67039. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67040. * in several rendering techniques.
  67041. */
  67042. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67043. /**
  67044. * The component name helpful to identify the component in the list of scene components.
  67045. */
  67046. readonly name: string;
  67047. /**
  67048. * The scene the component belongs to.
  67049. */
  67050. scene: Scene;
  67051. /**
  67052. * Creates a new instance of the component for the given scene
  67053. * @param scene Defines the scene to register the component in
  67054. */
  67055. constructor(scene: Scene);
  67056. /**
  67057. * Registers the component in a given scene
  67058. */
  67059. register(): void;
  67060. /**
  67061. * Rebuilds the elements related to this component in case of
  67062. * context lost for instance.
  67063. */
  67064. rebuild(): void;
  67065. /**
  67066. * Disposes the component and the associated ressources
  67067. */
  67068. dispose(): void;
  67069. private _gatherRenderTargets;
  67070. }
  67071. }
  67072. declare module "babylonjs/Shaders/motionBlur.fragment" {
  67073. /** @hidden */
  67074. export var motionBlurPixelShader: {
  67075. name: string;
  67076. shader: string;
  67077. };
  67078. }
  67079. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  67080. import { Nullable } from "babylonjs/types";
  67081. import { Camera } from "babylonjs/Cameras/camera";
  67082. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67083. import { Scene } from "babylonjs/scene";
  67084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67085. import "babylonjs/Animations/animatable";
  67086. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67087. import "babylonjs/Shaders/motionBlur.fragment";
  67088. import { Engine } from "babylonjs/Engines/engine";
  67089. /**
  67090. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67091. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67092. * As an example, all you have to do is to create the post-process:
  67093. * var mb = new BABYLON.MotionBlurPostProcess(
  67094. * 'mb', // The name of the effect.
  67095. * scene, // The scene containing the objects to blur according to their velocity.
  67096. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67097. * camera // The camera to apply the render pass to.
  67098. * );
  67099. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67100. */
  67101. export class MotionBlurPostProcess extends PostProcess {
  67102. /**
  67103. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67104. */
  67105. motionStrength: number;
  67106. /**
  67107. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67108. */
  67109. get motionBlurSamples(): number;
  67110. /**
  67111. * Sets the number of iterations to be used for motion blur quality
  67112. */
  67113. set motionBlurSamples(samples: number);
  67114. private _motionBlurSamples;
  67115. private _geometryBufferRenderer;
  67116. /**
  67117. * Creates a new instance MotionBlurPostProcess
  67118. * @param name The name of the effect.
  67119. * @param scene The scene containing the objects to blur according to their velocity.
  67120. * @param options The required width/height ratio to downsize to before computing the render pass.
  67121. * @param camera The camera to apply the render pass to.
  67122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67123. * @param engine The engine which the post process will be applied. (default: current engine)
  67124. * @param reusable If the post process can be reused on the same frame. (default: false)
  67125. * @param textureType Type of textures used when performing the post process. (default: 0)
  67126. * @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)
  67127. */
  67128. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67129. /**
  67130. * Excludes the given skinned mesh from computing bones velocities.
  67131. * 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.
  67132. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67133. */
  67134. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67135. /**
  67136. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67137. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67138. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67139. */
  67140. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67141. /**
  67142. * Disposes the post process.
  67143. * @param camera The camera to dispose the post process on.
  67144. */
  67145. dispose(camera?: Camera): void;
  67146. }
  67147. }
  67148. declare module "babylonjs/Shaders/refraction.fragment" {
  67149. /** @hidden */
  67150. export var refractionPixelShader: {
  67151. name: string;
  67152. shader: string;
  67153. };
  67154. }
  67155. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  67156. import { Color3 } from "babylonjs/Maths/math.color";
  67157. import { Camera } from "babylonjs/Cameras/camera";
  67158. import { Texture } from "babylonjs/Materials/Textures/texture";
  67159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67160. import { Engine } from "babylonjs/Engines/engine";
  67161. import "babylonjs/Shaders/refraction.fragment";
  67162. /**
  67163. * Post process which applies a refractin texture
  67164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67165. */
  67166. export class RefractionPostProcess extends PostProcess {
  67167. /** the base color of the refraction (used to taint the rendering) */
  67168. color: Color3;
  67169. /** simulated refraction depth */
  67170. depth: number;
  67171. /** the coefficient of the base color (0 to remove base color tainting) */
  67172. colorLevel: number;
  67173. private _refTexture;
  67174. private _ownRefractionTexture;
  67175. /**
  67176. * Gets or sets the refraction texture
  67177. * Please note that you are responsible for disposing the texture if you set it manually
  67178. */
  67179. get refractionTexture(): Texture;
  67180. set refractionTexture(value: Texture);
  67181. /**
  67182. * Initializes the RefractionPostProcess
  67183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67184. * @param name The name of the effect.
  67185. * @param refractionTextureUrl Url of the refraction texture to use
  67186. * @param color the base color of the refraction (used to taint the rendering)
  67187. * @param depth simulated refraction depth
  67188. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67189. * @param camera The camera to apply the render pass to.
  67190. * @param options The required width/height ratio to downsize to before computing the render pass.
  67191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67192. * @param engine The engine which the post process will be applied. (default: current engine)
  67193. * @param reusable If the post process can be reused on the same frame. (default: false)
  67194. */
  67195. constructor(name: string, refractionTextureUrl: string,
  67196. /** the base color of the refraction (used to taint the rendering) */
  67197. color: Color3,
  67198. /** simulated refraction depth */
  67199. depth: number,
  67200. /** the coefficient of the base color (0 to remove base color tainting) */
  67201. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67202. /**
  67203. * Disposes of the post process
  67204. * @param camera Camera to dispose post process on
  67205. */
  67206. dispose(camera: Camera): void;
  67207. }
  67208. }
  67209. declare module "babylonjs/Shaders/sharpen.fragment" {
  67210. /** @hidden */
  67211. export var sharpenPixelShader: {
  67212. name: string;
  67213. shader: string;
  67214. };
  67215. }
  67216. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  67217. import { Nullable } from "babylonjs/types";
  67218. import { Camera } from "babylonjs/Cameras/camera";
  67219. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67220. import "babylonjs/Shaders/sharpen.fragment";
  67221. import { Engine } from "babylonjs/Engines/engine";
  67222. /**
  67223. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67224. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67225. */
  67226. export class SharpenPostProcess extends PostProcess {
  67227. /**
  67228. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67229. */
  67230. colorAmount: number;
  67231. /**
  67232. * How much sharpness should be applied (default: 0.3)
  67233. */
  67234. edgeAmount: number;
  67235. /**
  67236. * Creates a new instance ConvolutionPostProcess
  67237. * @param name The name of the effect.
  67238. * @param options The required width/height ratio to downsize to before computing the render pass.
  67239. * @param camera The camera to apply the render pass to.
  67240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67241. * @param engine The engine which the post process will be applied. (default: current engine)
  67242. * @param reusable If the post process can be reused on the same frame. (default: false)
  67243. * @param textureType Type of textures used when performing the post process. (default: 0)
  67244. * @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)
  67245. */
  67246. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67247. }
  67248. }
  67249. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  67250. import { Nullable } from "babylonjs/types";
  67251. import { Camera } from "babylonjs/Cameras/camera";
  67252. import { Engine } from "babylonjs/Engines/engine";
  67253. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67254. import { IInspectable } from "babylonjs/Misc/iInspectable";
  67255. /**
  67256. * PostProcessRenderPipeline
  67257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67258. */
  67259. export class PostProcessRenderPipeline {
  67260. private engine;
  67261. private _renderEffects;
  67262. private _renderEffectsForIsolatedPass;
  67263. /**
  67264. * List of inspectable custom properties (used by the Inspector)
  67265. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67266. */
  67267. inspectableCustomProperties: IInspectable[];
  67268. /**
  67269. * @hidden
  67270. */
  67271. protected _cameras: Camera[];
  67272. /** @hidden */
  67273. _name: string;
  67274. /**
  67275. * Gets pipeline name
  67276. */
  67277. get name(): string;
  67278. /** Gets the list of attached cameras */
  67279. get cameras(): Camera[];
  67280. /**
  67281. * Initializes a PostProcessRenderPipeline
  67282. * @param engine engine to add the pipeline to
  67283. * @param name name of the pipeline
  67284. */
  67285. constructor(engine: Engine, name: string);
  67286. /**
  67287. * Gets the class name
  67288. * @returns "PostProcessRenderPipeline"
  67289. */
  67290. getClassName(): string;
  67291. /**
  67292. * If all the render effects in the pipeline are supported
  67293. */
  67294. get isSupported(): boolean;
  67295. /**
  67296. * Adds an effect to the pipeline
  67297. * @param renderEffect the effect to add
  67298. */
  67299. addEffect(renderEffect: PostProcessRenderEffect): void;
  67300. /** @hidden */
  67301. _rebuild(): void;
  67302. /** @hidden */
  67303. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67304. /** @hidden */
  67305. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  67306. /** @hidden */
  67307. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67308. /** @hidden */
  67309. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67310. /** @hidden */
  67311. _attachCameras(cameras: Camera, unique: boolean): void;
  67312. /** @hidden */
  67313. _attachCameras(cameras: Camera[], unique: boolean): void;
  67314. /** @hidden */
  67315. _detachCameras(cameras: Camera): void;
  67316. /** @hidden */
  67317. _detachCameras(cameras: Nullable<Camera[]>): void;
  67318. /** @hidden */
  67319. _update(): void;
  67320. /** @hidden */
  67321. _reset(): void;
  67322. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  67323. /**
  67324. * Disposes of the pipeline
  67325. */
  67326. dispose(): void;
  67327. }
  67328. }
  67329. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  67330. import { Camera } from "babylonjs/Cameras/camera";
  67331. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67332. /**
  67333. * PostProcessRenderPipelineManager class
  67334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67335. */
  67336. export class PostProcessRenderPipelineManager {
  67337. private _renderPipelines;
  67338. /**
  67339. * Initializes a PostProcessRenderPipelineManager
  67340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67341. */
  67342. constructor();
  67343. /**
  67344. * Gets the list of supported render pipelines
  67345. */
  67346. get supportedPipelines(): PostProcessRenderPipeline[];
  67347. /**
  67348. * Adds a pipeline to the manager
  67349. * @param renderPipeline The pipeline to add
  67350. */
  67351. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  67352. /**
  67353. * Attaches a camera to the pipeline
  67354. * @param renderPipelineName The name of the pipeline to attach to
  67355. * @param cameras the camera to attach
  67356. * @param unique if the camera can be attached multiple times to the pipeline
  67357. */
  67358. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  67359. /**
  67360. * Detaches a camera from the pipeline
  67361. * @param renderPipelineName The name of the pipeline to detach from
  67362. * @param cameras the camera to detach
  67363. */
  67364. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  67365. /**
  67366. * Enables an effect by name on a pipeline
  67367. * @param renderPipelineName the name of the pipeline to enable the effect in
  67368. * @param renderEffectName the name of the effect to enable
  67369. * @param cameras the cameras that the effect should be enabled on
  67370. */
  67371. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67372. /**
  67373. * Disables an effect by name on a pipeline
  67374. * @param renderPipelineName the name of the pipeline to disable the effect in
  67375. * @param renderEffectName the name of the effect to disable
  67376. * @param cameras the cameras that the effect should be disabled on
  67377. */
  67378. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67379. /**
  67380. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  67381. */
  67382. update(): void;
  67383. /** @hidden */
  67384. _rebuild(): void;
  67385. /**
  67386. * Disposes of the manager and pipelines
  67387. */
  67388. dispose(): void;
  67389. }
  67390. }
  67391. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  67392. import { ISceneComponent } from "babylonjs/sceneComponent";
  67393. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67394. import { Scene } from "babylonjs/scene";
  67395. module "babylonjs/scene" {
  67396. interface Scene {
  67397. /** @hidden (Backing field) */
  67398. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67399. /**
  67400. * Gets the postprocess render pipeline manager
  67401. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67402. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67403. */
  67404. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67405. }
  67406. }
  67407. /**
  67408. * Defines the Render Pipeline scene component responsible to rendering pipelines
  67409. */
  67410. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  67411. /**
  67412. * The component name helpfull to identify the component in the list of scene components.
  67413. */
  67414. readonly name: string;
  67415. /**
  67416. * The scene the component belongs to.
  67417. */
  67418. scene: Scene;
  67419. /**
  67420. * Creates a new instance of the component for the given scene
  67421. * @param scene Defines the scene to register the component in
  67422. */
  67423. constructor(scene: Scene);
  67424. /**
  67425. * Registers the component in a given scene
  67426. */
  67427. register(): void;
  67428. /**
  67429. * Rebuilds the elements related to this component in case of
  67430. * context lost for instance.
  67431. */
  67432. rebuild(): void;
  67433. /**
  67434. * Disposes the component and the associated ressources
  67435. */
  67436. dispose(): void;
  67437. private _gatherRenderTargets;
  67438. }
  67439. }
  67440. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  67441. import { Nullable } from "babylonjs/types";
  67442. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67443. import { Camera } from "babylonjs/Cameras/camera";
  67444. import { IDisposable } from "babylonjs/scene";
  67445. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  67446. import { Scene } from "babylonjs/scene";
  67447. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  67448. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  67449. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  67450. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  67451. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67452. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67453. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  67454. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67455. import { Animation } from "babylonjs/Animations/animation";
  67456. /**
  67457. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  67458. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67459. */
  67460. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67461. private _scene;
  67462. private _camerasToBeAttached;
  67463. /**
  67464. * ID of the sharpen post process,
  67465. */
  67466. private readonly SharpenPostProcessId;
  67467. /**
  67468. * @ignore
  67469. * ID of the image processing post process;
  67470. */
  67471. readonly ImageProcessingPostProcessId: string;
  67472. /**
  67473. * @ignore
  67474. * ID of the Fast Approximate Anti-Aliasing post process;
  67475. */
  67476. readonly FxaaPostProcessId: string;
  67477. /**
  67478. * ID of the chromatic aberration post process,
  67479. */
  67480. private readonly ChromaticAberrationPostProcessId;
  67481. /**
  67482. * ID of the grain post process
  67483. */
  67484. private readonly GrainPostProcessId;
  67485. /**
  67486. * Sharpen post process which will apply a sharpen convolution to enhance edges
  67487. */
  67488. sharpen: SharpenPostProcess;
  67489. private _sharpenEffect;
  67490. private bloom;
  67491. /**
  67492. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  67493. */
  67494. depthOfField: DepthOfFieldEffect;
  67495. /**
  67496. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67497. */
  67498. fxaa: FxaaPostProcess;
  67499. /**
  67500. * Image post processing pass used to perform operations such as tone mapping or color grading.
  67501. */
  67502. imageProcessing: ImageProcessingPostProcess;
  67503. /**
  67504. * Chromatic aberration post process which will shift rgb colors in the image
  67505. */
  67506. chromaticAberration: ChromaticAberrationPostProcess;
  67507. private _chromaticAberrationEffect;
  67508. /**
  67509. * Grain post process which add noise to the image
  67510. */
  67511. grain: GrainPostProcess;
  67512. private _grainEffect;
  67513. /**
  67514. * Glow post process which adds a glow to emissive areas of the image
  67515. */
  67516. private _glowLayer;
  67517. /**
  67518. * Animations which can be used to tweak settings over a period of time
  67519. */
  67520. animations: Animation[];
  67521. private _imageProcessingConfigurationObserver;
  67522. private _sharpenEnabled;
  67523. private _bloomEnabled;
  67524. private _depthOfFieldEnabled;
  67525. private _depthOfFieldBlurLevel;
  67526. private _fxaaEnabled;
  67527. private _imageProcessingEnabled;
  67528. private _defaultPipelineTextureType;
  67529. private _bloomScale;
  67530. private _chromaticAberrationEnabled;
  67531. private _grainEnabled;
  67532. private _buildAllowed;
  67533. /**
  67534. * Gets active scene
  67535. */
  67536. get scene(): Scene;
  67537. /**
  67538. * Enable or disable the sharpen process from the pipeline
  67539. */
  67540. set sharpenEnabled(enabled: boolean);
  67541. get sharpenEnabled(): boolean;
  67542. private _resizeObserver;
  67543. private _hardwareScaleLevel;
  67544. private _bloomKernel;
  67545. /**
  67546. * Specifies the size of the bloom blur kernel, relative to the final output size
  67547. */
  67548. get bloomKernel(): number;
  67549. set bloomKernel(value: number);
  67550. /**
  67551. * Specifies the weight of the bloom in the final rendering
  67552. */
  67553. private _bloomWeight;
  67554. /**
  67555. * Specifies the luma threshold for the area that will be blurred by the bloom
  67556. */
  67557. private _bloomThreshold;
  67558. private _hdr;
  67559. /**
  67560. * The strength of the bloom.
  67561. */
  67562. set bloomWeight(value: number);
  67563. get bloomWeight(): number;
  67564. /**
  67565. * The strength of the bloom.
  67566. */
  67567. set bloomThreshold(value: number);
  67568. get bloomThreshold(): number;
  67569. /**
  67570. * The scale of the bloom, lower value will provide better performance.
  67571. */
  67572. set bloomScale(value: number);
  67573. get bloomScale(): number;
  67574. /**
  67575. * Enable or disable the bloom from the pipeline
  67576. */
  67577. set bloomEnabled(enabled: boolean);
  67578. get bloomEnabled(): boolean;
  67579. private _rebuildBloom;
  67580. /**
  67581. * If the depth of field is enabled.
  67582. */
  67583. get depthOfFieldEnabled(): boolean;
  67584. set depthOfFieldEnabled(enabled: boolean);
  67585. /**
  67586. * Blur level of the depth of field effect. (Higher blur will effect performance)
  67587. */
  67588. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  67589. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  67590. /**
  67591. * If the anti aliasing is enabled.
  67592. */
  67593. set fxaaEnabled(enabled: boolean);
  67594. get fxaaEnabled(): boolean;
  67595. private _samples;
  67596. /**
  67597. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67598. */
  67599. set samples(sampleCount: number);
  67600. get samples(): number;
  67601. /**
  67602. * If image processing is enabled.
  67603. */
  67604. set imageProcessingEnabled(enabled: boolean);
  67605. get imageProcessingEnabled(): boolean;
  67606. /**
  67607. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  67608. */
  67609. set glowLayerEnabled(enabled: boolean);
  67610. get glowLayerEnabled(): boolean;
  67611. /**
  67612. * Gets the glow layer (or null if not defined)
  67613. */
  67614. get glowLayer(): Nullable<GlowLayer>;
  67615. /**
  67616. * Enable or disable the chromaticAberration process from the pipeline
  67617. */
  67618. set chromaticAberrationEnabled(enabled: boolean);
  67619. get chromaticAberrationEnabled(): boolean;
  67620. /**
  67621. * Enable or disable the grain process from the pipeline
  67622. */
  67623. set grainEnabled(enabled: boolean);
  67624. get grainEnabled(): boolean;
  67625. /**
  67626. * @constructor
  67627. * @param name - The rendering pipeline name (default: "")
  67628. * @param hdr - If high dynamic range textures should be used (default: true)
  67629. * @param scene - The scene linked to this pipeline (default: the last created scene)
  67630. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  67631. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  67632. */
  67633. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  67634. /**
  67635. * Get the class name
  67636. * @returns "DefaultRenderingPipeline"
  67637. */
  67638. getClassName(): string;
  67639. /**
  67640. * Force the compilation of the entire pipeline.
  67641. */
  67642. prepare(): void;
  67643. private _hasCleared;
  67644. private _prevPostProcess;
  67645. private _prevPrevPostProcess;
  67646. private _setAutoClearAndTextureSharing;
  67647. private _depthOfFieldSceneObserver;
  67648. private _buildPipeline;
  67649. private _disposePostProcesses;
  67650. /**
  67651. * Adds a camera to the pipeline
  67652. * @param camera the camera to be added
  67653. */
  67654. addCamera(camera: Camera): void;
  67655. /**
  67656. * Removes a camera from the pipeline
  67657. * @param camera the camera to remove
  67658. */
  67659. removeCamera(camera: Camera): void;
  67660. /**
  67661. * Dispose of the pipeline and stop all post processes
  67662. */
  67663. dispose(): void;
  67664. /**
  67665. * Serialize the rendering pipeline (Used when exporting)
  67666. * @returns the serialized object
  67667. */
  67668. serialize(): any;
  67669. /**
  67670. * Parse the serialized pipeline
  67671. * @param source Source pipeline.
  67672. * @param scene The scene to load the pipeline to.
  67673. * @param rootUrl The URL of the serialized pipeline.
  67674. * @returns An instantiated pipeline from the serialized object.
  67675. */
  67676. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  67677. }
  67678. }
  67679. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  67680. /** @hidden */
  67681. export var lensHighlightsPixelShader: {
  67682. name: string;
  67683. shader: string;
  67684. };
  67685. }
  67686. declare module "babylonjs/Shaders/depthOfField.fragment" {
  67687. /** @hidden */
  67688. export var depthOfFieldPixelShader: {
  67689. name: string;
  67690. shader: string;
  67691. };
  67692. }
  67693. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  67694. import { Camera } from "babylonjs/Cameras/camera";
  67695. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67696. import { Scene } from "babylonjs/scene";
  67697. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67698. import "babylonjs/Shaders/chromaticAberration.fragment";
  67699. import "babylonjs/Shaders/lensHighlights.fragment";
  67700. import "babylonjs/Shaders/depthOfField.fragment";
  67701. /**
  67702. * BABYLON.JS Chromatic Aberration GLSL Shader
  67703. * Author: Olivier Guyot
  67704. * Separates very slightly R, G and B colors on the edges of the screen
  67705. * Inspired by Francois Tarlier & Martins Upitis
  67706. */
  67707. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67708. /**
  67709. * @ignore
  67710. * The chromatic aberration PostProcess id in the pipeline
  67711. */
  67712. LensChromaticAberrationEffect: string;
  67713. /**
  67714. * @ignore
  67715. * The highlights enhancing PostProcess id in the pipeline
  67716. */
  67717. HighlightsEnhancingEffect: string;
  67718. /**
  67719. * @ignore
  67720. * The depth-of-field PostProcess id in the pipeline
  67721. */
  67722. LensDepthOfFieldEffect: string;
  67723. private _scene;
  67724. private _depthTexture;
  67725. private _grainTexture;
  67726. private _chromaticAberrationPostProcess;
  67727. private _highlightsPostProcess;
  67728. private _depthOfFieldPostProcess;
  67729. private _edgeBlur;
  67730. private _grainAmount;
  67731. private _chromaticAberration;
  67732. private _distortion;
  67733. private _highlightsGain;
  67734. private _highlightsThreshold;
  67735. private _dofDistance;
  67736. private _dofAperture;
  67737. private _dofDarken;
  67738. private _dofPentagon;
  67739. private _blurNoise;
  67740. /**
  67741. * @constructor
  67742. *
  67743. * Effect parameters are as follow:
  67744. * {
  67745. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67746. * edge_blur: number; // from 0 to x (1 for realism)
  67747. * distortion: number; // from 0 to x (1 for realism)
  67748. * grain_amount: number; // from 0 to 1
  67749. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67750. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67751. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67752. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67753. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67754. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67755. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67756. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67757. * }
  67758. * Note: if an effect parameter is unset, effect is disabled
  67759. *
  67760. * @param name The rendering pipeline name
  67761. * @param parameters - An object containing all parameters (see above)
  67762. * @param scene The scene linked to this pipeline
  67763. * @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)
  67764. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67765. */
  67766. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67767. /**
  67768. * Get the class name
  67769. * @returns "LensRenderingPipeline"
  67770. */
  67771. getClassName(): string;
  67772. /**
  67773. * Gets associated scene
  67774. */
  67775. get scene(): Scene;
  67776. /**
  67777. * Gets or sets the edge blur
  67778. */
  67779. get edgeBlur(): number;
  67780. set edgeBlur(value: number);
  67781. /**
  67782. * Gets or sets the grain amount
  67783. */
  67784. get grainAmount(): number;
  67785. set grainAmount(value: number);
  67786. /**
  67787. * Gets or sets the chromatic aberration amount
  67788. */
  67789. get chromaticAberration(): number;
  67790. set chromaticAberration(value: number);
  67791. /**
  67792. * Gets or sets the depth of field aperture
  67793. */
  67794. get dofAperture(): number;
  67795. set dofAperture(value: number);
  67796. /**
  67797. * Gets or sets the edge distortion
  67798. */
  67799. get edgeDistortion(): number;
  67800. set edgeDistortion(value: number);
  67801. /**
  67802. * Gets or sets the depth of field distortion
  67803. */
  67804. get dofDistortion(): number;
  67805. set dofDistortion(value: number);
  67806. /**
  67807. * Gets or sets the darken out of focus amount
  67808. */
  67809. get darkenOutOfFocus(): number;
  67810. set darkenOutOfFocus(value: number);
  67811. /**
  67812. * Gets or sets a boolean indicating if blur noise is enabled
  67813. */
  67814. get blurNoise(): boolean;
  67815. set blurNoise(value: boolean);
  67816. /**
  67817. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67818. */
  67819. get pentagonBokeh(): boolean;
  67820. set pentagonBokeh(value: boolean);
  67821. /**
  67822. * Gets or sets the highlight grain amount
  67823. */
  67824. get highlightsGain(): number;
  67825. set highlightsGain(value: number);
  67826. /**
  67827. * Gets or sets the highlight threshold
  67828. */
  67829. get highlightsThreshold(): number;
  67830. set highlightsThreshold(value: number);
  67831. /**
  67832. * Sets the amount of blur at the edges
  67833. * @param amount blur amount
  67834. */
  67835. setEdgeBlur(amount: number): void;
  67836. /**
  67837. * Sets edge blur to 0
  67838. */
  67839. disableEdgeBlur(): void;
  67840. /**
  67841. * Sets the amout of grain
  67842. * @param amount Amount of grain
  67843. */
  67844. setGrainAmount(amount: number): void;
  67845. /**
  67846. * Set grain amount to 0
  67847. */
  67848. disableGrain(): void;
  67849. /**
  67850. * Sets the chromatic aberration amount
  67851. * @param amount amount of chromatic aberration
  67852. */
  67853. setChromaticAberration(amount: number): void;
  67854. /**
  67855. * Sets chromatic aberration amount to 0
  67856. */
  67857. disableChromaticAberration(): void;
  67858. /**
  67859. * Sets the EdgeDistortion amount
  67860. * @param amount amount of EdgeDistortion
  67861. */
  67862. setEdgeDistortion(amount: number): void;
  67863. /**
  67864. * Sets edge distortion to 0
  67865. */
  67866. disableEdgeDistortion(): void;
  67867. /**
  67868. * Sets the FocusDistance amount
  67869. * @param amount amount of FocusDistance
  67870. */
  67871. setFocusDistance(amount: number): void;
  67872. /**
  67873. * Disables depth of field
  67874. */
  67875. disableDepthOfField(): void;
  67876. /**
  67877. * Sets the Aperture amount
  67878. * @param amount amount of Aperture
  67879. */
  67880. setAperture(amount: number): void;
  67881. /**
  67882. * Sets the DarkenOutOfFocus amount
  67883. * @param amount amount of DarkenOutOfFocus
  67884. */
  67885. setDarkenOutOfFocus(amount: number): void;
  67886. private _pentagonBokehIsEnabled;
  67887. /**
  67888. * Creates a pentagon bokeh effect
  67889. */
  67890. enablePentagonBokeh(): void;
  67891. /**
  67892. * Disables the pentagon bokeh effect
  67893. */
  67894. disablePentagonBokeh(): void;
  67895. /**
  67896. * Enables noise blur
  67897. */
  67898. enableNoiseBlur(): void;
  67899. /**
  67900. * Disables noise blur
  67901. */
  67902. disableNoiseBlur(): void;
  67903. /**
  67904. * Sets the HighlightsGain amount
  67905. * @param amount amount of HighlightsGain
  67906. */
  67907. setHighlightsGain(amount: number): void;
  67908. /**
  67909. * Sets the HighlightsThreshold amount
  67910. * @param amount amount of HighlightsThreshold
  67911. */
  67912. setHighlightsThreshold(amount: number): void;
  67913. /**
  67914. * Disables highlights
  67915. */
  67916. disableHighlights(): void;
  67917. /**
  67918. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67919. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67920. */
  67921. dispose(disableDepthRender?: boolean): void;
  67922. private _createChromaticAberrationPostProcess;
  67923. private _createHighlightsPostProcess;
  67924. private _createDepthOfFieldPostProcess;
  67925. private _createGrainTexture;
  67926. }
  67927. }
  67928. declare module "babylonjs/Shaders/ssao2.fragment" {
  67929. /** @hidden */
  67930. export var ssao2PixelShader: {
  67931. name: string;
  67932. shader: string;
  67933. };
  67934. }
  67935. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67936. /** @hidden */
  67937. export var ssaoCombinePixelShader: {
  67938. name: string;
  67939. shader: string;
  67940. };
  67941. }
  67942. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67943. import { Camera } from "babylonjs/Cameras/camera";
  67944. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67945. import { Scene } from "babylonjs/scene";
  67946. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67947. import "babylonjs/Shaders/ssao2.fragment";
  67948. import "babylonjs/Shaders/ssaoCombine.fragment";
  67949. /**
  67950. * Render pipeline to produce ssao effect
  67951. */
  67952. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67953. /**
  67954. * @ignore
  67955. * The PassPostProcess id in the pipeline that contains the original scene color
  67956. */
  67957. SSAOOriginalSceneColorEffect: string;
  67958. /**
  67959. * @ignore
  67960. * The SSAO PostProcess id in the pipeline
  67961. */
  67962. SSAORenderEffect: string;
  67963. /**
  67964. * @ignore
  67965. * The horizontal blur PostProcess id in the pipeline
  67966. */
  67967. SSAOBlurHRenderEffect: string;
  67968. /**
  67969. * @ignore
  67970. * The vertical blur PostProcess id in the pipeline
  67971. */
  67972. SSAOBlurVRenderEffect: string;
  67973. /**
  67974. * @ignore
  67975. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67976. */
  67977. SSAOCombineRenderEffect: string;
  67978. /**
  67979. * The output strength of the SSAO post-process. Default value is 1.0.
  67980. */
  67981. totalStrength: number;
  67982. /**
  67983. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67984. */
  67985. maxZ: number;
  67986. /**
  67987. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67988. */
  67989. minZAspect: number;
  67990. private _samples;
  67991. /**
  67992. * Number of samples used for the SSAO calculations. Default value is 8
  67993. */
  67994. set samples(n: number);
  67995. get samples(): number;
  67996. private _textureSamples;
  67997. /**
  67998. * Number of samples to use for antialiasing
  67999. */
  68000. set textureSamples(n: number);
  68001. get textureSamples(): number;
  68002. /**
  68003. * Ratio object used for SSAO ratio and blur ratio
  68004. */
  68005. private _ratio;
  68006. /**
  68007. * Dynamically generated sphere sampler.
  68008. */
  68009. private _sampleSphere;
  68010. /**
  68011. * Blur filter offsets
  68012. */
  68013. private _samplerOffsets;
  68014. private _expensiveBlur;
  68015. /**
  68016. * If bilateral blur should be used
  68017. */
  68018. set expensiveBlur(b: boolean);
  68019. get expensiveBlur(): boolean;
  68020. /**
  68021. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68022. */
  68023. radius: number;
  68024. /**
  68025. * The base color of the SSAO post-process
  68026. * The final result is "base + ssao" between [0, 1]
  68027. */
  68028. base: number;
  68029. /**
  68030. * Support test.
  68031. */
  68032. static get IsSupported(): boolean;
  68033. private _scene;
  68034. private _depthTexture;
  68035. private _normalTexture;
  68036. private _randomTexture;
  68037. private _originalColorPostProcess;
  68038. private _ssaoPostProcess;
  68039. private _blurHPostProcess;
  68040. private _blurVPostProcess;
  68041. private _ssaoCombinePostProcess;
  68042. /**
  68043. * Gets active scene
  68044. */
  68045. get scene(): Scene;
  68046. /**
  68047. * @constructor
  68048. * @param name The rendering pipeline name
  68049. * @param scene The scene linked to this pipeline
  68050. * @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 }
  68051. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68052. */
  68053. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68054. /**
  68055. * Get the class name
  68056. * @returns "SSAO2RenderingPipeline"
  68057. */
  68058. getClassName(): string;
  68059. /**
  68060. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68061. */
  68062. dispose(disableGeometryBufferRenderer?: boolean): void;
  68063. private _createBlurPostProcess;
  68064. /** @hidden */
  68065. _rebuild(): void;
  68066. private _bits;
  68067. private _radicalInverse_VdC;
  68068. private _hammersley;
  68069. private _hemisphereSample_uniform;
  68070. private _generateHemisphere;
  68071. private _createSSAOPostProcess;
  68072. private _createSSAOCombinePostProcess;
  68073. private _createRandomTexture;
  68074. /**
  68075. * Serialize the rendering pipeline (Used when exporting)
  68076. * @returns the serialized object
  68077. */
  68078. serialize(): any;
  68079. /**
  68080. * Parse the serialized pipeline
  68081. * @param source Source pipeline.
  68082. * @param scene The scene to load the pipeline to.
  68083. * @param rootUrl The URL of the serialized pipeline.
  68084. * @returns An instantiated pipeline from the serialized object.
  68085. */
  68086. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68087. }
  68088. }
  68089. declare module "babylonjs/Shaders/ssao.fragment" {
  68090. /** @hidden */
  68091. export var ssaoPixelShader: {
  68092. name: string;
  68093. shader: string;
  68094. };
  68095. }
  68096. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  68097. import { Camera } from "babylonjs/Cameras/camera";
  68098. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68099. import { Scene } from "babylonjs/scene";
  68100. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68101. import "babylonjs/Shaders/ssao.fragment";
  68102. import "babylonjs/Shaders/ssaoCombine.fragment";
  68103. /**
  68104. * Render pipeline to produce ssao effect
  68105. */
  68106. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68107. /**
  68108. * @ignore
  68109. * The PassPostProcess id in the pipeline that contains the original scene color
  68110. */
  68111. SSAOOriginalSceneColorEffect: string;
  68112. /**
  68113. * @ignore
  68114. * The SSAO PostProcess id in the pipeline
  68115. */
  68116. SSAORenderEffect: string;
  68117. /**
  68118. * @ignore
  68119. * The horizontal blur PostProcess id in the pipeline
  68120. */
  68121. SSAOBlurHRenderEffect: string;
  68122. /**
  68123. * @ignore
  68124. * The vertical blur PostProcess id in the pipeline
  68125. */
  68126. SSAOBlurVRenderEffect: string;
  68127. /**
  68128. * @ignore
  68129. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68130. */
  68131. SSAOCombineRenderEffect: string;
  68132. /**
  68133. * The output strength of the SSAO post-process. Default value is 1.0.
  68134. */
  68135. totalStrength: number;
  68136. /**
  68137. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68138. */
  68139. radius: number;
  68140. /**
  68141. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68142. * Must not be equal to fallOff and superior to fallOff.
  68143. * Default value is 0.0075
  68144. */
  68145. area: number;
  68146. /**
  68147. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68148. * Must not be equal to area and inferior to area.
  68149. * Default value is 0.000001
  68150. */
  68151. fallOff: number;
  68152. /**
  68153. * The base color of the SSAO post-process
  68154. * The final result is "base + ssao" between [0, 1]
  68155. */
  68156. base: number;
  68157. private _scene;
  68158. private _depthTexture;
  68159. private _randomTexture;
  68160. private _originalColorPostProcess;
  68161. private _ssaoPostProcess;
  68162. private _blurHPostProcess;
  68163. private _blurVPostProcess;
  68164. private _ssaoCombinePostProcess;
  68165. private _firstUpdate;
  68166. /**
  68167. * Gets active scene
  68168. */
  68169. get scene(): Scene;
  68170. /**
  68171. * @constructor
  68172. * @param name - The rendering pipeline name
  68173. * @param scene - The scene linked to this pipeline
  68174. * @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 }
  68175. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68176. */
  68177. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68178. /**
  68179. * Get the class name
  68180. * @returns "SSAORenderingPipeline"
  68181. */
  68182. getClassName(): string;
  68183. /**
  68184. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68185. */
  68186. dispose(disableDepthRender?: boolean): void;
  68187. private _createBlurPostProcess;
  68188. /** @hidden */
  68189. _rebuild(): void;
  68190. private _createSSAOPostProcess;
  68191. private _createSSAOCombinePostProcess;
  68192. private _createRandomTexture;
  68193. }
  68194. }
  68195. declare module "babylonjs/Shaders/standard.fragment" {
  68196. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68197. /** @hidden */
  68198. export var standardPixelShader: {
  68199. name: string;
  68200. shader: string;
  68201. };
  68202. }
  68203. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  68204. import { Nullable } from "babylonjs/types";
  68205. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68206. import { Camera } from "babylonjs/Cameras/camera";
  68207. import { Texture } from "babylonjs/Materials/Textures/texture";
  68208. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68209. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68210. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68211. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68212. import { IDisposable } from "babylonjs/scene";
  68213. import { SpotLight } from "babylonjs/Lights/spotLight";
  68214. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  68215. import { Scene } from "babylonjs/scene";
  68216. import { Animation } from "babylonjs/Animations/animation";
  68217. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68218. import "babylonjs/Shaders/standard.fragment";
  68219. /**
  68220. * Standard rendering pipeline
  68221. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68222. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  68223. */
  68224. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68225. /**
  68226. * Public members
  68227. */
  68228. /**
  68229. * Post-process which contains the original scene color before the pipeline applies all the effects
  68230. */
  68231. originalPostProcess: Nullable<PostProcess>;
  68232. /**
  68233. * Post-process used to down scale an image x4
  68234. */
  68235. downSampleX4PostProcess: Nullable<PostProcess>;
  68236. /**
  68237. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  68238. */
  68239. brightPassPostProcess: Nullable<PostProcess>;
  68240. /**
  68241. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  68242. */
  68243. blurHPostProcesses: PostProcess[];
  68244. /**
  68245. * Post-process array storing all the vertical blur post-processes used by the pipeline
  68246. */
  68247. blurVPostProcesses: PostProcess[];
  68248. /**
  68249. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  68250. */
  68251. textureAdderPostProcess: Nullable<PostProcess>;
  68252. /**
  68253. * Post-process used to create volumetric lighting effect
  68254. */
  68255. volumetricLightPostProcess: Nullable<PostProcess>;
  68256. /**
  68257. * Post-process used to smooth the previous volumetric light post-process on the X axis
  68258. */
  68259. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  68260. /**
  68261. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  68262. */
  68263. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  68264. /**
  68265. * Post-process used to merge the volumetric light effect and the real scene color
  68266. */
  68267. volumetricLightMergePostProces: Nullable<PostProcess>;
  68268. /**
  68269. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  68270. */
  68271. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  68272. /**
  68273. * Base post-process used to calculate the average luminance of the final image for HDR
  68274. */
  68275. luminancePostProcess: Nullable<PostProcess>;
  68276. /**
  68277. * Post-processes used to create down sample post-processes in order to get
  68278. * the average luminance of the final image for HDR
  68279. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  68280. */
  68281. luminanceDownSamplePostProcesses: PostProcess[];
  68282. /**
  68283. * Post-process used to create a HDR effect (light adaptation)
  68284. */
  68285. hdrPostProcess: Nullable<PostProcess>;
  68286. /**
  68287. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  68288. */
  68289. textureAdderFinalPostProcess: Nullable<PostProcess>;
  68290. /**
  68291. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  68292. */
  68293. lensFlareFinalPostProcess: Nullable<PostProcess>;
  68294. /**
  68295. * Post-process used to merge the final HDR post-process and the real scene color
  68296. */
  68297. hdrFinalPostProcess: Nullable<PostProcess>;
  68298. /**
  68299. * Post-process used to create a lens flare effect
  68300. */
  68301. lensFlarePostProcess: Nullable<PostProcess>;
  68302. /**
  68303. * Post-process that merges the result of the lens flare post-process and the real scene color
  68304. */
  68305. lensFlareComposePostProcess: Nullable<PostProcess>;
  68306. /**
  68307. * Post-process used to create a motion blur effect
  68308. */
  68309. motionBlurPostProcess: Nullable<PostProcess>;
  68310. /**
  68311. * Post-process used to create a depth of field effect
  68312. */
  68313. depthOfFieldPostProcess: Nullable<PostProcess>;
  68314. /**
  68315. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68316. */
  68317. fxaaPostProcess: Nullable<FxaaPostProcess>;
  68318. /**
  68319. * Represents the brightness threshold in order to configure the illuminated surfaces
  68320. */
  68321. brightThreshold: number;
  68322. /**
  68323. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  68324. */
  68325. blurWidth: number;
  68326. /**
  68327. * Sets if the blur for highlighted surfaces must be only horizontal
  68328. */
  68329. horizontalBlur: boolean;
  68330. /**
  68331. * Gets the overall exposure used by the pipeline
  68332. */
  68333. get exposure(): number;
  68334. /**
  68335. * Sets the overall exposure used by the pipeline
  68336. */
  68337. set exposure(value: number);
  68338. /**
  68339. * Texture used typically to simulate "dirty" on camera lens
  68340. */
  68341. lensTexture: Nullable<Texture>;
  68342. /**
  68343. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  68344. */
  68345. volumetricLightCoefficient: number;
  68346. /**
  68347. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  68348. */
  68349. volumetricLightPower: number;
  68350. /**
  68351. * Used the set the blur intensity to smooth the volumetric lights
  68352. */
  68353. volumetricLightBlurScale: number;
  68354. /**
  68355. * Light (spot or directional) used to generate the volumetric lights rays
  68356. * The source light must have a shadow generate so the pipeline can get its
  68357. * depth map
  68358. */
  68359. sourceLight: Nullable<SpotLight | DirectionalLight>;
  68360. /**
  68361. * For eye adaptation, represents the minimum luminance the eye can see
  68362. */
  68363. hdrMinimumLuminance: number;
  68364. /**
  68365. * For eye adaptation, represents the decrease luminance speed
  68366. */
  68367. hdrDecreaseRate: number;
  68368. /**
  68369. * For eye adaptation, represents the increase luminance speed
  68370. */
  68371. hdrIncreaseRate: number;
  68372. /**
  68373. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68374. */
  68375. get hdrAutoExposure(): boolean;
  68376. /**
  68377. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68378. */
  68379. set hdrAutoExposure(value: boolean);
  68380. /**
  68381. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  68382. */
  68383. lensColorTexture: Nullable<Texture>;
  68384. /**
  68385. * The overall strengh for the lens flare effect
  68386. */
  68387. lensFlareStrength: number;
  68388. /**
  68389. * Dispersion coefficient for lens flare ghosts
  68390. */
  68391. lensFlareGhostDispersal: number;
  68392. /**
  68393. * Main lens flare halo width
  68394. */
  68395. lensFlareHaloWidth: number;
  68396. /**
  68397. * Based on the lens distortion effect, defines how much the lens flare result
  68398. * is distorted
  68399. */
  68400. lensFlareDistortionStrength: number;
  68401. /**
  68402. * Configures the blur intensity used for for lens flare (halo)
  68403. */
  68404. lensFlareBlurWidth: number;
  68405. /**
  68406. * Lens star texture must be used to simulate rays on the flares and is available
  68407. * in the documentation
  68408. */
  68409. lensStarTexture: Nullable<Texture>;
  68410. /**
  68411. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  68412. * flare effect by taking account of the dirt texture
  68413. */
  68414. lensFlareDirtTexture: Nullable<Texture>;
  68415. /**
  68416. * Represents the focal length for the depth of field effect
  68417. */
  68418. depthOfFieldDistance: number;
  68419. /**
  68420. * Represents the blur intensity for the blurred part of the depth of field effect
  68421. */
  68422. depthOfFieldBlurWidth: number;
  68423. /**
  68424. * Gets how much the image is blurred by the movement while using the motion blur post-process
  68425. */
  68426. get motionStrength(): number;
  68427. /**
  68428. * Sets how much the image is blurred by the movement while using the motion blur post-process
  68429. */
  68430. set motionStrength(strength: number);
  68431. /**
  68432. * Gets wether or not the motion blur post-process is object based or screen based.
  68433. */
  68434. get objectBasedMotionBlur(): boolean;
  68435. /**
  68436. * Sets wether or not the motion blur post-process should be object based or screen based
  68437. */
  68438. set objectBasedMotionBlur(value: boolean);
  68439. /**
  68440. * List of animations for the pipeline (IAnimatable implementation)
  68441. */
  68442. animations: Animation[];
  68443. /**
  68444. * Private members
  68445. */
  68446. private _scene;
  68447. private _currentDepthOfFieldSource;
  68448. private _basePostProcess;
  68449. private _fixedExposure;
  68450. private _currentExposure;
  68451. private _hdrAutoExposure;
  68452. private _hdrCurrentLuminance;
  68453. private _motionStrength;
  68454. private _isObjectBasedMotionBlur;
  68455. private _floatTextureType;
  68456. private _camerasToBeAttached;
  68457. private _ratio;
  68458. private _bloomEnabled;
  68459. private _depthOfFieldEnabled;
  68460. private _vlsEnabled;
  68461. private _lensFlareEnabled;
  68462. private _hdrEnabled;
  68463. private _motionBlurEnabled;
  68464. private _fxaaEnabled;
  68465. private _motionBlurSamples;
  68466. private _volumetricLightStepsCount;
  68467. private _samples;
  68468. /**
  68469. * @ignore
  68470. * Specifies if the bloom pipeline is enabled
  68471. */
  68472. get BloomEnabled(): boolean;
  68473. set BloomEnabled(enabled: boolean);
  68474. /**
  68475. * @ignore
  68476. * Specifies if the depth of field pipeline is enabed
  68477. */
  68478. get DepthOfFieldEnabled(): boolean;
  68479. set DepthOfFieldEnabled(enabled: boolean);
  68480. /**
  68481. * @ignore
  68482. * Specifies if the lens flare pipeline is enabed
  68483. */
  68484. get LensFlareEnabled(): boolean;
  68485. set LensFlareEnabled(enabled: boolean);
  68486. /**
  68487. * @ignore
  68488. * Specifies if the HDR pipeline is enabled
  68489. */
  68490. get HDREnabled(): boolean;
  68491. set HDREnabled(enabled: boolean);
  68492. /**
  68493. * @ignore
  68494. * Specifies if the volumetric lights scattering effect is enabled
  68495. */
  68496. get VLSEnabled(): boolean;
  68497. set VLSEnabled(enabled: boolean);
  68498. /**
  68499. * @ignore
  68500. * Specifies if the motion blur effect is enabled
  68501. */
  68502. get MotionBlurEnabled(): boolean;
  68503. set MotionBlurEnabled(enabled: boolean);
  68504. /**
  68505. * Specifies if anti-aliasing is enabled
  68506. */
  68507. get fxaaEnabled(): boolean;
  68508. set fxaaEnabled(enabled: boolean);
  68509. /**
  68510. * Specifies the number of steps used to calculate the volumetric lights
  68511. * Typically in interval [50, 200]
  68512. */
  68513. get volumetricLightStepsCount(): number;
  68514. set volumetricLightStepsCount(count: number);
  68515. /**
  68516. * Specifies the number of samples used for the motion blur effect
  68517. * Typically in interval [16, 64]
  68518. */
  68519. get motionBlurSamples(): number;
  68520. set motionBlurSamples(samples: number);
  68521. /**
  68522. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68523. */
  68524. get samples(): number;
  68525. set samples(sampleCount: number);
  68526. /**
  68527. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68528. * @constructor
  68529. * @param name The rendering pipeline name
  68530. * @param scene The scene linked to this pipeline
  68531. * @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)
  68532. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  68533. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68534. */
  68535. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  68536. private _buildPipeline;
  68537. private _createDownSampleX4PostProcess;
  68538. private _createBrightPassPostProcess;
  68539. private _createBlurPostProcesses;
  68540. private _createTextureAdderPostProcess;
  68541. private _createVolumetricLightPostProcess;
  68542. private _createLuminancePostProcesses;
  68543. private _createHdrPostProcess;
  68544. private _createLensFlarePostProcess;
  68545. private _createDepthOfFieldPostProcess;
  68546. private _createMotionBlurPostProcess;
  68547. private _getDepthTexture;
  68548. private _disposePostProcesses;
  68549. /**
  68550. * Dispose of the pipeline and stop all post processes
  68551. */
  68552. dispose(): void;
  68553. /**
  68554. * Serialize the rendering pipeline (Used when exporting)
  68555. * @returns the serialized object
  68556. */
  68557. serialize(): any;
  68558. /**
  68559. * Parse the serialized pipeline
  68560. * @param source Source pipeline.
  68561. * @param scene The scene to load the pipeline to.
  68562. * @param rootUrl The URL of the serialized pipeline.
  68563. * @returns An instantiated pipeline from the serialized object.
  68564. */
  68565. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  68566. /**
  68567. * Luminance steps
  68568. */
  68569. static LuminanceSteps: number;
  68570. }
  68571. }
  68572. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  68573. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  68574. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  68575. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  68576. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  68577. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  68578. }
  68579. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  68580. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  68581. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68582. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68583. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68584. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68585. }
  68586. declare module "babylonjs/Shaders/tonemap.fragment" {
  68587. /** @hidden */
  68588. export var tonemapPixelShader: {
  68589. name: string;
  68590. shader: string;
  68591. };
  68592. }
  68593. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  68594. import { Camera } from "babylonjs/Cameras/camera";
  68595. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68596. import "babylonjs/Shaders/tonemap.fragment";
  68597. import { Engine } from "babylonjs/Engines/engine";
  68598. /** Defines operator used for tonemapping */
  68599. export enum TonemappingOperator {
  68600. /** Hable */
  68601. Hable = 0,
  68602. /** Reinhard */
  68603. Reinhard = 1,
  68604. /** HejiDawson */
  68605. HejiDawson = 2,
  68606. /** Photographic */
  68607. Photographic = 3
  68608. }
  68609. /**
  68610. * Defines a post process to apply tone mapping
  68611. */
  68612. export class TonemapPostProcess extends PostProcess {
  68613. private _operator;
  68614. /** Defines the required exposure adjustement */
  68615. exposureAdjustment: number;
  68616. /**
  68617. * Creates a new TonemapPostProcess
  68618. * @param name defines the name of the postprocess
  68619. * @param _operator defines the operator to use
  68620. * @param exposureAdjustment defines the required exposure adjustement
  68621. * @param camera defines the camera to use (can be null)
  68622. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  68623. * @param engine defines the hosting engine (can be ignore if camera is set)
  68624. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  68625. */
  68626. constructor(name: string, _operator: TonemappingOperator,
  68627. /** Defines the required exposure adjustement */
  68628. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  68629. }
  68630. }
  68631. declare module "babylonjs/Shaders/depth.vertex" {
  68632. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68633. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68634. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68635. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68636. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68637. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68638. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68639. /** @hidden */
  68640. export var depthVertexShader: {
  68641. name: string;
  68642. shader: string;
  68643. };
  68644. }
  68645. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  68646. /** @hidden */
  68647. export var volumetricLightScatteringPixelShader: {
  68648. name: string;
  68649. shader: string;
  68650. };
  68651. }
  68652. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  68653. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68654. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68655. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68656. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68657. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68658. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68659. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68660. /** @hidden */
  68661. export var volumetricLightScatteringPassVertexShader: {
  68662. name: string;
  68663. shader: string;
  68664. };
  68665. }
  68666. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  68667. /** @hidden */
  68668. export var volumetricLightScatteringPassPixelShader: {
  68669. name: string;
  68670. shader: string;
  68671. };
  68672. }
  68673. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  68674. import { Vector3 } from "babylonjs/Maths/math.vector";
  68675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68676. import { Mesh } from "babylonjs/Meshes/mesh";
  68677. import { Camera } from "babylonjs/Cameras/camera";
  68678. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68679. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68680. import { Scene } from "babylonjs/scene";
  68681. import "babylonjs/Meshes/Builders/planeBuilder";
  68682. import "babylonjs/Shaders/depth.vertex";
  68683. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  68684. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  68685. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  68686. import { Engine } from "babylonjs/Engines/engine";
  68687. /**
  68688. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  68689. */
  68690. export class VolumetricLightScatteringPostProcess extends PostProcess {
  68691. private _volumetricLightScatteringPass;
  68692. private _volumetricLightScatteringRTT;
  68693. private _viewPort;
  68694. private _screenCoordinates;
  68695. private _cachedDefines;
  68696. /**
  68697. * If not undefined, the mesh position is computed from the attached node position
  68698. */
  68699. attachedNode: {
  68700. position: Vector3;
  68701. };
  68702. /**
  68703. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  68704. */
  68705. customMeshPosition: Vector3;
  68706. /**
  68707. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68708. */
  68709. useCustomMeshPosition: boolean;
  68710. /**
  68711. * If the post-process should inverse the light scattering direction
  68712. */
  68713. invert: boolean;
  68714. /**
  68715. * The internal mesh used by the post-process
  68716. */
  68717. mesh: Mesh;
  68718. /**
  68719. * @hidden
  68720. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68721. */
  68722. get useDiffuseColor(): boolean;
  68723. set useDiffuseColor(useDiffuseColor: boolean);
  68724. /**
  68725. * Array containing the excluded meshes not rendered in the internal pass
  68726. */
  68727. excludedMeshes: AbstractMesh[];
  68728. /**
  68729. * Controls the overall intensity of the post-process
  68730. */
  68731. exposure: number;
  68732. /**
  68733. * Dissipates each sample's contribution in range [0, 1]
  68734. */
  68735. decay: number;
  68736. /**
  68737. * Controls the overall intensity of each sample
  68738. */
  68739. weight: number;
  68740. /**
  68741. * Controls the density of each sample
  68742. */
  68743. density: number;
  68744. /**
  68745. * @constructor
  68746. * @param name The post-process name
  68747. * @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)
  68748. * @param camera The camera that the post-process will be attached to
  68749. * @param mesh The mesh used to create the light scattering
  68750. * @param samples The post-process quality, default 100
  68751. * @param samplingModeThe post-process filtering mode
  68752. * @param engine The babylon engine
  68753. * @param reusable If the post-process is reusable
  68754. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68755. */
  68756. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68757. /**
  68758. * Returns the string "VolumetricLightScatteringPostProcess"
  68759. * @returns "VolumetricLightScatteringPostProcess"
  68760. */
  68761. getClassName(): string;
  68762. private _isReady;
  68763. /**
  68764. * Sets the new light position for light scattering effect
  68765. * @param position The new custom light position
  68766. */
  68767. setCustomMeshPosition(position: Vector3): void;
  68768. /**
  68769. * Returns the light position for light scattering effect
  68770. * @return Vector3 The custom light position
  68771. */
  68772. getCustomMeshPosition(): Vector3;
  68773. /**
  68774. * Disposes the internal assets and detaches the post-process from the camera
  68775. */
  68776. dispose(camera: Camera): void;
  68777. /**
  68778. * Returns the render target texture used by the post-process
  68779. * @return the render target texture used by the post-process
  68780. */
  68781. getPass(): RenderTargetTexture;
  68782. private _meshExcluded;
  68783. private _createPass;
  68784. private _updateMeshScreenCoordinates;
  68785. /**
  68786. * Creates a default mesh for the Volumeric Light Scattering post-process
  68787. * @param name The mesh name
  68788. * @param scene The scene where to create the mesh
  68789. * @return the default mesh
  68790. */
  68791. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68792. }
  68793. }
  68794. declare module "babylonjs/PostProcesses/index" {
  68795. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  68796. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  68797. export * from "babylonjs/PostProcesses/bloomEffect";
  68798. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  68799. export * from "babylonjs/PostProcesses/blurPostProcess";
  68800. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68801. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  68802. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  68803. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  68804. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68805. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  68806. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  68807. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  68808. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68809. export * from "babylonjs/PostProcesses/filterPostProcess";
  68810. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  68811. export * from "babylonjs/PostProcesses/grainPostProcess";
  68812. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  68813. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68814. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  68815. export * from "babylonjs/PostProcesses/passPostProcess";
  68816. export * from "babylonjs/PostProcesses/postProcess";
  68817. export * from "babylonjs/PostProcesses/postProcessManager";
  68818. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68819. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68820. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68821. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68822. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68823. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68824. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68825. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68826. }
  68827. declare module "babylonjs/Probes/index" {
  68828. export * from "babylonjs/Probes/reflectionProbe";
  68829. }
  68830. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68831. import { Scene } from "babylonjs/scene";
  68832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68833. import { SmartArray } from "babylonjs/Misc/smartArray";
  68834. import { ISceneComponent } from "babylonjs/sceneComponent";
  68835. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68836. import "babylonjs/Meshes/Builders/boxBuilder";
  68837. import "babylonjs/Shaders/color.fragment";
  68838. import "babylonjs/Shaders/color.vertex";
  68839. import { Color3 } from "babylonjs/Maths/math.color";
  68840. module "babylonjs/scene" {
  68841. interface Scene {
  68842. /** @hidden (Backing field) */
  68843. _boundingBoxRenderer: BoundingBoxRenderer;
  68844. /** @hidden (Backing field) */
  68845. _forceShowBoundingBoxes: boolean;
  68846. /**
  68847. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68848. */
  68849. forceShowBoundingBoxes: boolean;
  68850. /**
  68851. * Gets the bounding box renderer associated with the scene
  68852. * @returns a BoundingBoxRenderer
  68853. */
  68854. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68855. }
  68856. }
  68857. module "babylonjs/Meshes/abstractMesh" {
  68858. interface AbstractMesh {
  68859. /** @hidden (Backing field) */
  68860. _showBoundingBox: boolean;
  68861. /**
  68862. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68863. */
  68864. showBoundingBox: boolean;
  68865. }
  68866. }
  68867. /**
  68868. * Component responsible of rendering the bounding box of the meshes in a scene.
  68869. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68870. */
  68871. export class BoundingBoxRenderer implements ISceneComponent {
  68872. /**
  68873. * The component name helpfull to identify the component in the list of scene components.
  68874. */
  68875. readonly name: string;
  68876. /**
  68877. * The scene the component belongs to.
  68878. */
  68879. scene: Scene;
  68880. /**
  68881. * Color of the bounding box lines placed in front of an object
  68882. */
  68883. frontColor: Color3;
  68884. /**
  68885. * Color of the bounding box lines placed behind an object
  68886. */
  68887. backColor: Color3;
  68888. /**
  68889. * Defines if the renderer should show the back lines or not
  68890. */
  68891. showBackLines: boolean;
  68892. /**
  68893. * @hidden
  68894. */
  68895. renderList: SmartArray<BoundingBox>;
  68896. private _colorShader;
  68897. private _vertexBuffers;
  68898. private _indexBuffer;
  68899. private _fillIndexBuffer;
  68900. private _fillIndexData;
  68901. /**
  68902. * Instantiates a new bounding box renderer in a scene.
  68903. * @param scene the scene the renderer renders in
  68904. */
  68905. constructor(scene: Scene);
  68906. /**
  68907. * Registers the component in a given scene
  68908. */
  68909. register(): void;
  68910. private _evaluateSubMesh;
  68911. private _activeMesh;
  68912. private _prepareRessources;
  68913. private _createIndexBuffer;
  68914. /**
  68915. * Rebuilds the elements related to this component in case of
  68916. * context lost for instance.
  68917. */
  68918. rebuild(): void;
  68919. /**
  68920. * @hidden
  68921. */
  68922. reset(): void;
  68923. /**
  68924. * Render the bounding boxes of a specific rendering group
  68925. * @param renderingGroupId defines the rendering group to render
  68926. */
  68927. render(renderingGroupId: number): void;
  68928. /**
  68929. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68930. * @param mesh Define the mesh to render the occlusion bounding box for
  68931. */
  68932. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68933. /**
  68934. * Dispose and release the resources attached to this renderer.
  68935. */
  68936. dispose(): void;
  68937. }
  68938. }
  68939. declare module "babylonjs/Shaders/depth.fragment" {
  68940. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68941. /** @hidden */
  68942. export var depthPixelShader: {
  68943. name: string;
  68944. shader: string;
  68945. };
  68946. }
  68947. declare module "babylonjs/Rendering/depthRenderer" {
  68948. import { Nullable } from "babylonjs/types";
  68949. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68950. import { Scene } from "babylonjs/scene";
  68951. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68952. import { Camera } from "babylonjs/Cameras/camera";
  68953. import "babylonjs/Shaders/depth.fragment";
  68954. import "babylonjs/Shaders/depth.vertex";
  68955. /**
  68956. * This represents a depth renderer in Babylon.
  68957. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68958. */
  68959. export class DepthRenderer {
  68960. private _scene;
  68961. private _depthMap;
  68962. private _effect;
  68963. private readonly _storeNonLinearDepth;
  68964. private readonly _clearColor;
  68965. /** Get if the depth renderer is using packed depth or not */
  68966. readonly isPacked: boolean;
  68967. private _cachedDefines;
  68968. private _camera;
  68969. /**
  68970. * Specifiess that the depth renderer will only be used within
  68971. * the camera it is created for.
  68972. * This can help forcing its rendering during the camera processing.
  68973. */
  68974. useOnlyInActiveCamera: boolean;
  68975. /** @hidden */
  68976. static _SceneComponentInitialization: (scene: Scene) => void;
  68977. /**
  68978. * Instantiates a depth renderer
  68979. * @param scene The scene the renderer belongs to
  68980. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68981. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68982. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68983. */
  68984. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68985. /**
  68986. * Creates the depth rendering effect and checks if the effect is ready.
  68987. * @param subMesh The submesh to be used to render the depth map of
  68988. * @param useInstances If multiple world instances should be used
  68989. * @returns if the depth renderer is ready to render the depth map
  68990. */
  68991. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68992. /**
  68993. * Gets the texture which the depth map will be written to.
  68994. * @returns The depth map texture
  68995. */
  68996. getDepthMap(): RenderTargetTexture;
  68997. /**
  68998. * Disposes of the depth renderer.
  68999. */
  69000. dispose(): void;
  69001. }
  69002. }
  69003. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  69004. import { Nullable } from "babylonjs/types";
  69005. import { Scene } from "babylonjs/scene";
  69006. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  69007. import { Camera } from "babylonjs/Cameras/camera";
  69008. import { ISceneComponent } from "babylonjs/sceneComponent";
  69009. module "babylonjs/scene" {
  69010. interface Scene {
  69011. /** @hidden (Backing field) */
  69012. _depthRenderer: {
  69013. [id: string]: DepthRenderer;
  69014. };
  69015. /**
  69016. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69017. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69018. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69019. * @returns the created depth renderer
  69020. */
  69021. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69022. /**
  69023. * Disables a depth renderer for a given camera
  69024. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69025. */
  69026. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69027. }
  69028. }
  69029. /**
  69030. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69031. * in several rendering techniques.
  69032. */
  69033. export class DepthRendererSceneComponent implements ISceneComponent {
  69034. /**
  69035. * The component name helpfull to identify the component in the list of scene components.
  69036. */
  69037. readonly name: string;
  69038. /**
  69039. * The scene the component belongs to.
  69040. */
  69041. scene: Scene;
  69042. /**
  69043. * Creates a new instance of the component for the given scene
  69044. * @param scene Defines the scene to register the component in
  69045. */
  69046. constructor(scene: Scene);
  69047. /**
  69048. * Registers the component in a given scene
  69049. */
  69050. register(): void;
  69051. /**
  69052. * Rebuilds the elements related to this component in case of
  69053. * context lost for instance.
  69054. */
  69055. rebuild(): void;
  69056. /**
  69057. * Disposes the component and the associated ressources
  69058. */
  69059. dispose(): void;
  69060. private _gatherRenderTargets;
  69061. private _gatherActiveCameraRenderTargets;
  69062. }
  69063. }
  69064. declare module "babylonjs/Shaders/outline.fragment" {
  69065. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69066. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  69067. /** @hidden */
  69068. export var outlinePixelShader: {
  69069. name: string;
  69070. shader: string;
  69071. };
  69072. }
  69073. declare module "babylonjs/Shaders/outline.vertex" {
  69074. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69075. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69076. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69077. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69078. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69079. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69080. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69081. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69082. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  69083. /** @hidden */
  69084. export var outlineVertexShader: {
  69085. name: string;
  69086. shader: string;
  69087. };
  69088. }
  69089. declare module "babylonjs/Rendering/outlineRenderer" {
  69090. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69091. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  69092. import { Scene } from "babylonjs/scene";
  69093. import { ISceneComponent } from "babylonjs/sceneComponent";
  69094. import "babylonjs/Shaders/outline.fragment";
  69095. import "babylonjs/Shaders/outline.vertex";
  69096. module "babylonjs/scene" {
  69097. interface Scene {
  69098. /** @hidden */
  69099. _outlineRenderer: OutlineRenderer;
  69100. /**
  69101. * Gets the outline renderer associated with the scene
  69102. * @returns a OutlineRenderer
  69103. */
  69104. getOutlineRenderer(): OutlineRenderer;
  69105. }
  69106. }
  69107. module "babylonjs/Meshes/abstractMesh" {
  69108. interface AbstractMesh {
  69109. /** @hidden (Backing field) */
  69110. _renderOutline: boolean;
  69111. /**
  69112. * Gets or sets a boolean indicating if the outline must be rendered as well
  69113. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69114. */
  69115. renderOutline: boolean;
  69116. /** @hidden (Backing field) */
  69117. _renderOverlay: boolean;
  69118. /**
  69119. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69120. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69121. */
  69122. renderOverlay: boolean;
  69123. }
  69124. }
  69125. /**
  69126. * This class is responsible to draw bothe outline/overlay of meshes.
  69127. * It should not be used directly but through the available method on mesh.
  69128. */
  69129. export class OutlineRenderer implements ISceneComponent {
  69130. /**
  69131. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69132. */
  69133. private static _StencilReference;
  69134. /**
  69135. * The name of the component. Each component must have a unique name.
  69136. */
  69137. name: string;
  69138. /**
  69139. * The scene the component belongs to.
  69140. */
  69141. scene: Scene;
  69142. /**
  69143. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69144. */
  69145. zOffset: number;
  69146. private _engine;
  69147. private _effect;
  69148. private _cachedDefines;
  69149. private _savedDepthWrite;
  69150. /**
  69151. * Instantiates a new outline renderer. (There could be only one per scene).
  69152. * @param scene Defines the scene it belongs to
  69153. */
  69154. constructor(scene: Scene);
  69155. /**
  69156. * Register the component to one instance of a scene.
  69157. */
  69158. register(): void;
  69159. /**
  69160. * Rebuilds the elements related to this component in case of
  69161. * context lost for instance.
  69162. */
  69163. rebuild(): void;
  69164. /**
  69165. * Disposes the component and the associated ressources.
  69166. */
  69167. dispose(): void;
  69168. /**
  69169. * Renders the outline in the canvas.
  69170. * @param subMesh Defines the sumesh to render
  69171. * @param batch Defines the batch of meshes in case of instances
  69172. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69173. */
  69174. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69175. /**
  69176. * Returns whether or not the outline renderer is ready for a given submesh.
  69177. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69178. * @param subMesh Defines the submesh to check readyness for
  69179. * @param useInstances Defines wheter wee are trying to render instances or not
  69180. * @returns true if ready otherwise false
  69181. */
  69182. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69183. private _beforeRenderingMesh;
  69184. private _afterRenderingMesh;
  69185. }
  69186. }
  69187. declare module "babylonjs/Rendering/index" {
  69188. export * from "babylonjs/Rendering/boundingBoxRenderer";
  69189. export * from "babylonjs/Rendering/depthRenderer";
  69190. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  69191. export * from "babylonjs/Rendering/edgesRenderer";
  69192. export * from "babylonjs/Rendering/geometryBufferRenderer";
  69193. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  69194. export * from "babylonjs/Rendering/outlineRenderer";
  69195. export * from "babylonjs/Rendering/renderingGroup";
  69196. export * from "babylonjs/Rendering/renderingManager";
  69197. export * from "babylonjs/Rendering/utilityLayerRenderer";
  69198. }
  69199. declare module "babylonjs/Sprites/ISprites" {
  69200. /**
  69201. * Defines the basic options interface of a Sprite Frame Source Size.
  69202. */
  69203. export interface ISpriteJSONSpriteSourceSize {
  69204. /**
  69205. * number of the original width of the Frame
  69206. */
  69207. w: number;
  69208. /**
  69209. * number of the original height of the Frame
  69210. */
  69211. h: number;
  69212. }
  69213. /**
  69214. * Defines the basic options interface of a Sprite Frame Data.
  69215. */
  69216. export interface ISpriteJSONSpriteFrameData {
  69217. /**
  69218. * number of the x offset of the Frame
  69219. */
  69220. x: number;
  69221. /**
  69222. * number of the y offset of the Frame
  69223. */
  69224. y: number;
  69225. /**
  69226. * number of the width of the Frame
  69227. */
  69228. w: number;
  69229. /**
  69230. * number of the height of the Frame
  69231. */
  69232. h: number;
  69233. }
  69234. /**
  69235. * Defines the basic options interface of a JSON Sprite.
  69236. */
  69237. export interface ISpriteJSONSprite {
  69238. /**
  69239. * string name of the Frame
  69240. */
  69241. filename: string;
  69242. /**
  69243. * ISpriteJSONSpriteFrame basic object of the frame data
  69244. */
  69245. frame: ISpriteJSONSpriteFrameData;
  69246. /**
  69247. * boolean to flag is the frame was rotated.
  69248. */
  69249. rotated: boolean;
  69250. /**
  69251. * boolean to flag is the frame was trimmed.
  69252. */
  69253. trimmed: boolean;
  69254. /**
  69255. * ISpriteJSONSpriteFrame basic object of the source data
  69256. */
  69257. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69258. /**
  69259. * ISpriteJSONSpriteFrame basic object of the source data
  69260. */
  69261. sourceSize: ISpriteJSONSpriteSourceSize;
  69262. }
  69263. /**
  69264. * Defines the basic options interface of a JSON atlas.
  69265. */
  69266. export interface ISpriteJSONAtlas {
  69267. /**
  69268. * Array of objects that contain the frame data.
  69269. */
  69270. frames: Array<ISpriteJSONSprite>;
  69271. /**
  69272. * object basic object containing the sprite meta data.
  69273. */
  69274. meta?: object;
  69275. }
  69276. }
  69277. declare module "babylonjs/Shaders/spriteMap.fragment" {
  69278. /** @hidden */
  69279. export var spriteMapPixelShader: {
  69280. name: string;
  69281. shader: string;
  69282. };
  69283. }
  69284. declare module "babylonjs/Shaders/spriteMap.vertex" {
  69285. /** @hidden */
  69286. export var spriteMapVertexShader: {
  69287. name: string;
  69288. shader: string;
  69289. };
  69290. }
  69291. declare module "babylonjs/Sprites/spriteMap" {
  69292. import { IDisposable, Scene } from "babylonjs/scene";
  69293. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  69294. import { Texture } from "babylonjs/Materials/Textures/texture";
  69295. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69296. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  69297. import "babylonjs/Meshes/Builders/planeBuilder";
  69298. import "babylonjs/Shaders/spriteMap.fragment";
  69299. import "babylonjs/Shaders/spriteMap.vertex";
  69300. /**
  69301. * Defines the basic options interface of a SpriteMap
  69302. */
  69303. export interface ISpriteMapOptions {
  69304. /**
  69305. * Vector2 of the number of cells in the grid.
  69306. */
  69307. stageSize?: Vector2;
  69308. /**
  69309. * Vector2 of the size of the output plane in World Units.
  69310. */
  69311. outputSize?: Vector2;
  69312. /**
  69313. * Vector3 of the position of the output plane in World Units.
  69314. */
  69315. outputPosition?: Vector3;
  69316. /**
  69317. * Vector3 of the rotation of the output plane.
  69318. */
  69319. outputRotation?: Vector3;
  69320. /**
  69321. * number of layers that the system will reserve in resources.
  69322. */
  69323. layerCount?: number;
  69324. /**
  69325. * number of max animation frames a single cell will reserve in resources.
  69326. */
  69327. maxAnimationFrames?: number;
  69328. /**
  69329. * number cell index of the base tile when the system compiles.
  69330. */
  69331. baseTile?: number;
  69332. /**
  69333. * boolean flip the sprite after its been repositioned by the framing data.
  69334. */
  69335. flipU?: boolean;
  69336. /**
  69337. * Vector3 scalar of the global RGB values of the SpriteMap.
  69338. */
  69339. colorMultiply?: Vector3;
  69340. }
  69341. /**
  69342. * Defines the IDisposable interface in order to be cleanable from resources.
  69343. */
  69344. export interface ISpriteMap extends IDisposable {
  69345. /**
  69346. * String name of the SpriteMap.
  69347. */
  69348. name: string;
  69349. /**
  69350. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  69351. */
  69352. atlasJSON: ISpriteJSONAtlas;
  69353. /**
  69354. * Texture of the SpriteMap.
  69355. */
  69356. spriteSheet: Texture;
  69357. /**
  69358. * The parameters to initialize the SpriteMap with.
  69359. */
  69360. options: ISpriteMapOptions;
  69361. }
  69362. /**
  69363. * Class used to manage a grid restricted sprite deployment on an Output plane.
  69364. */
  69365. export class SpriteMap implements ISpriteMap {
  69366. /** The Name of the spriteMap */
  69367. name: string;
  69368. /** The JSON file with the frame and meta data */
  69369. atlasJSON: ISpriteJSONAtlas;
  69370. /** The systems Sprite Sheet Texture */
  69371. spriteSheet: Texture;
  69372. /** Arguments passed with the Constructor */
  69373. options: ISpriteMapOptions;
  69374. /** Public Sprite Storage array, parsed from atlasJSON */
  69375. sprites: Array<ISpriteJSONSprite>;
  69376. /** Returns the Number of Sprites in the System */
  69377. get spriteCount(): number;
  69378. /** Returns the Position of Output Plane*/
  69379. get position(): Vector3;
  69380. /** Returns the Position of Output Plane*/
  69381. set position(v: Vector3);
  69382. /** Returns the Rotation of Output Plane*/
  69383. get rotation(): Vector3;
  69384. /** Returns the Rotation of Output Plane*/
  69385. set rotation(v: Vector3);
  69386. /** Sets the AnimationMap*/
  69387. get animationMap(): RawTexture;
  69388. /** Sets the AnimationMap*/
  69389. set animationMap(v: RawTexture);
  69390. /** Scene that the SpriteMap was created in */
  69391. private _scene;
  69392. /** Texture Buffer of Float32 that holds tile frame data*/
  69393. private _frameMap;
  69394. /** Texture Buffers of Float32 that holds tileMap data*/
  69395. private _tileMaps;
  69396. /** Texture Buffer of Float32 that holds Animation Data*/
  69397. private _animationMap;
  69398. /** Custom ShaderMaterial Central to the System*/
  69399. private _material;
  69400. /** Custom ShaderMaterial Central to the System*/
  69401. private _output;
  69402. /** Systems Time Ticker*/
  69403. private _time;
  69404. /**
  69405. * Creates a new SpriteMap
  69406. * @param name defines the SpriteMaps Name
  69407. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  69408. * @param spriteSheet is the Texture that the Sprites are on.
  69409. * @param options a basic deployment configuration
  69410. * @param scene The Scene that the map is deployed on
  69411. */
  69412. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  69413. /**
  69414. * Returns tileID location
  69415. * @returns Vector2 the cell position ID
  69416. */
  69417. getTileID(): Vector2;
  69418. /**
  69419. * Gets the UV location of the mouse over the SpriteMap.
  69420. * @returns Vector2 the UV position of the mouse interaction
  69421. */
  69422. getMousePosition(): Vector2;
  69423. /**
  69424. * Creates the "frame" texture Buffer
  69425. * -------------------------------------
  69426. * Structure of frames
  69427. * "filename": "Falling-Water-2.png",
  69428. * "frame": {"x":69,"y":103,"w":24,"h":32},
  69429. * "rotated": true,
  69430. * "trimmed": true,
  69431. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  69432. * "sourceSize": {"w":32,"h":32}
  69433. * @returns RawTexture of the frameMap
  69434. */
  69435. private _createFrameBuffer;
  69436. /**
  69437. * Creates the tileMap texture Buffer
  69438. * @param buffer normally and array of numbers, or a false to generate from scratch
  69439. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  69440. * @returns RawTexture of the tileMap
  69441. */
  69442. private _createTileBuffer;
  69443. /**
  69444. * Modifies the data of the tileMaps
  69445. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  69446. * @param pos is the iVector2 Coordinates of the Tile
  69447. * @param tile The SpriteIndex of the new Tile
  69448. */
  69449. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  69450. /**
  69451. * Creates the animationMap texture Buffer
  69452. * @param buffer normally and array of numbers, or a false to generate from scratch
  69453. * @returns RawTexture of the animationMap
  69454. */
  69455. private _createTileAnimationBuffer;
  69456. /**
  69457. * Modifies the data of the animationMap
  69458. * @param cellID is the Index of the Sprite
  69459. * @param _frame is the target Animation frame
  69460. * @param toCell is the Target Index of the next frame of the animation
  69461. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  69462. * @param speed is a global scalar of the time variable on the map.
  69463. */
  69464. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  69465. /**
  69466. * Exports the .tilemaps file
  69467. */
  69468. saveTileMaps(): void;
  69469. /**
  69470. * Imports the .tilemaps file
  69471. * @param url of the .tilemaps file
  69472. */
  69473. loadTileMaps(url: string): void;
  69474. /**
  69475. * Release associated resources
  69476. */
  69477. dispose(): void;
  69478. }
  69479. }
  69480. declare module "babylonjs/Sprites/spritePackedManager" {
  69481. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  69482. import { Scene } from "babylonjs/scene";
  69483. /**
  69484. * Class used to manage multiple sprites of different sizes on the same spritesheet
  69485. * @see http://doc.babylonjs.com/babylon101/sprites
  69486. */
  69487. export class SpritePackedManager extends SpriteManager {
  69488. /** defines the packed manager's name */
  69489. name: string;
  69490. /**
  69491. * Creates a new sprite manager from a packed sprite sheet
  69492. * @param name defines the manager's name
  69493. * @param imgUrl defines the sprite sheet url
  69494. * @param capacity defines the maximum allowed number of sprites
  69495. * @param scene defines the hosting scene
  69496. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  69497. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69498. * @param samplingMode defines the smapling mode to use with spritesheet
  69499. * @param fromPacked set to true; do not alter
  69500. */
  69501. constructor(
  69502. /** defines the packed manager's name */
  69503. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  69504. }
  69505. }
  69506. declare module "babylonjs/Sprites/index" {
  69507. export * from "babylonjs/Sprites/sprite";
  69508. export * from "babylonjs/Sprites/ISprites";
  69509. export * from "babylonjs/Sprites/spriteManager";
  69510. export * from "babylonjs/Sprites/spriteMap";
  69511. export * from "babylonjs/Sprites/spritePackedManager";
  69512. export * from "babylonjs/Sprites/spriteSceneComponent";
  69513. }
  69514. declare module "babylonjs/States/index" {
  69515. export * from "babylonjs/States/alphaCullingState";
  69516. export * from "babylonjs/States/depthCullingState";
  69517. export * from "babylonjs/States/stencilState";
  69518. }
  69519. declare module "babylonjs/Misc/assetsManager" {
  69520. import { Scene } from "babylonjs/scene";
  69521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69522. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69523. import { Skeleton } from "babylonjs/Bones/skeleton";
  69524. import { Observable } from "babylonjs/Misc/observable";
  69525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69526. import { Texture } from "babylonjs/Materials/Textures/texture";
  69527. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  69528. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  69529. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  69530. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  69531. /**
  69532. * Defines the list of states available for a task inside a AssetsManager
  69533. */
  69534. export enum AssetTaskState {
  69535. /**
  69536. * Initialization
  69537. */
  69538. INIT = 0,
  69539. /**
  69540. * Running
  69541. */
  69542. RUNNING = 1,
  69543. /**
  69544. * Done
  69545. */
  69546. DONE = 2,
  69547. /**
  69548. * Error
  69549. */
  69550. ERROR = 3
  69551. }
  69552. /**
  69553. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  69554. */
  69555. export abstract class AbstractAssetTask {
  69556. /**
  69557. * Task name
  69558. */ name: string;
  69559. /**
  69560. * Callback called when the task is successful
  69561. */
  69562. onSuccess: (task: any) => void;
  69563. /**
  69564. * Callback called when the task is not successful
  69565. */
  69566. onError: (task: any, message?: string, exception?: any) => void;
  69567. /**
  69568. * Creates a new AssetsManager
  69569. * @param name defines the name of the task
  69570. */
  69571. constructor(
  69572. /**
  69573. * Task name
  69574. */ name: string);
  69575. private _isCompleted;
  69576. private _taskState;
  69577. private _errorObject;
  69578. /**
  69579. * Get if the task is completed
  69580. */
  69581. get isCompleted(): boolean;
  69582. /**
  69583. * Gets the current state of the task
  69584. */
  69585. get taskState(): AssetTaskState;
  69586. /**
  69587. * Gets the current error object (if task is in error)
  69588. */
  69589. get errorObject(): {
  69590. message?: string;
  69591. exception?: any;
  69592. };
  69593. /**
  69594. * Internal only
  69595. * @hidden
  69596. */
  69597. _setErrorObject(message?: string, exception?: any): void;
  69598. /**
  69599. * Execute the current task
  69600. * @param scene defines the scene where you want your assets to be loaded
  69601. * @param onSuccess is a callback called when the task is successfully executed
  69602. * @param onError is a callback called if an error occurs
  69603. */
  69604. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69605. /**
  69606. * Execute the current task
  69607. * @param scene defines the scene where you want your assets to be loaded
  69608. * @param onSuccess is a callback called when the task is successfully executed
  69609. * @param onError is a callback called if an error occurs
  69610. */
  69611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69612. /**
  69613. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  69614. * This can be used with failed tasks that have the reason for failure fixed.
  69615. */
  69616. reset(): void;
  69617. private onErrorCallback;
  69618. private onDoneCallback;
  69619. }
  69620. /**
  69621. * Define the interface used by progress events raised during assets loading
  69622. */
  69623. export interface IAssetsProgressEvent {
  69624. /**
  69625. * Defines the number of remaining tasks to process
  69626. */
  69627. remainingCount: number;
  69628. /**
  69629. * Defines the total number of tasks
  69630. */
  69631. totalCount: number;
  69632. /**
  69633. * Defines the task that was just processed
  69634. */
  69635. task: AbstractAssetTask;
  69636. }
  69637. /**
  69638. * Class used to share progress information about assets loading
  69639. */
  69640. export class AssetsProgressEvent implements IAssetsProgressEvent {
  69641. /**
  69642. * Defines the number of remaining tasks to process
  69643. */
  69644. remainingCount: number;
  69645. /**
  69646. * Defines the total number of tasks
  69647. */
  69648. totalCount: number;
  69649. /**
  69650. * Defines the task that was just processed
  69651. */
  69652. task: AbstractAssetTask;
  69653. /**
  69654. * Creates a AssetsProgressEvent
  69655. * @param remainingCount defines the number of remaining tasks to process
  69656. * @param totalCount defines the total number of tasks
  69657. * @param task defines the task that was just processed
  69658. */
  69659. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  69660. }
  69661. /**
  69662. * Define a task used by AssetsManager to load meshes
  69663. */
  69664. export class MeshAssetTask extends AbstractAssetTask {
  69665. /**
  69666. * Defines the name of the task
  69667. */
  69668. name: string;
  69669. /**
  69670. * Defines the list of mesh's names you want to load
  69671. */
  69672. meshesNames: any;
  69673. /**
  69674. * Defines the root url to use as a base to load your meshes and associated resources
  69675. */
  69676. rootUrl: string;
  69677. /**
  69678. * Defines the filename of the scene to load from
  69679. */
  69680. sceneFilename: string;
  69681. /**
  69682. * Gets the list of loaded meshes
  69683. */
  69684. loadedMeshes: Array<AbstractMesh>;
  69685. /**
  69686. * Gets the list of loaded particle systems
  69687. */
  69688. loadedParticleSystems: Array<IParticleSystem>;
  69689. /**
  69690. * Gets the list of loaded skeletons
  69691. */
  69692. loadedSkeletons: Array<Skeleton>;
  69693. /**
  69694. * Gets the list of loaded animation groups
  69695. */
  69696. loadedAnimationGroups: Array<AnimationGroup>;
  69697. /**
  69698. * Callback called when the task is successful
  69699. */
  69700. onSuccess: (task: MeshAssetTask) => void;
  69701. /**
  69702. * Callback called when the task is successful
  69703. */
  69704. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69705. /**
  69706. * Creates a new MeshAssetTask
  69707. * @param name defines the name of the task
  69708. * @param meshesNames defines the list of mesh's names you want to load
  69709. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69710. * @param sceneFilename defines the filename of the scene to load from
  69711. */
  69712. constructor(
  69713. /**
  69714. * Defines the name of the task
  69715. */
  69716. name: string,
  69717. /**
  69718. * Defines the list of mesh's names you want to load
  69719. */
  69720. meshesNames: any,
  69721. /**
  69722. * Defines the root url to use as a base to load your meshes and associated resources
  69723. */
  69724. rootUrl: string,
  69725. /**
  69726. * Defines the filename of the scene to load from
  69727. */
  69728. sceneFilename: string);
  69729. /**
  69730. * Execute the current task
  69731. * @param scene defines the scene where you want your assets to be loaded
  69732. * @param onSuccess is a callback called when the task is successfully executed
  69733. * @param onError is a callback called if an error occurs
  69734. */
  69735. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69736. }
  69737. /**
  69738. * Define a task used by AssetsManager to load text content
  69739. */
  69740. export class TextFileAssetTask extends AbstractAssetTask {
  69741. /**
  69742. * Defines the name of the task
  69743. */
  69744. name: string;
  69745. /**
  69746. * Defines the location of the file to load
  69747. */
  69748. url: string;
  69749. /**
  69750. * Gets the loaded text string
  69751. */
  69752. text: string;
  69753. /**
  69754. * Callback called when the task is successful
  69755. */
  69756. onSuccess: (task: TextFileAssetTask) => void;
  69757. /**
  69758. * Callback called when the task is successful
  69759. */
  69760. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69761. /**
  69762. * Creates a new TextFileAssetTask object
  69763. * @param name defines the name of the task
  69764. * @param url defines the location of the file to load
  69765. */
  69766. constructor(
  69767. /**
  69768. * Defines the name of the task
  69769. */
  69770. name: string,
  69771. /**
  69772. * Defines the location of the file to load
  69773. */
  69774. url: string);
  69775. /**
  69776. * Execute the current task
  69777. * @param scene defines the scene where you want your assets to be loaded
  69778. * @param onSuccess is a callback called when the task is successfully executed
  69779. * @param onError is a callback called if an error occurs
  69780. */
  69781. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69782. }
  69783. /**
  69784. * Define a task used by AssetsManager to load binary data
  69785. */
  69786. export class BinaryFileAssetTask extends AbstractAssetTask {
  69787. /**
  69788. * Defines the name of the task
  69789. */
  69790. name: string;
  69791. /**
  69792. * Defines the location of the file to load
  69793. */
  69794. url: string;
  69795. /**
  69796. * Gets the lodaded data (as an array buffer)
  69797. */
  69798. data: ArrayBuffer;
  69799. /**
  69800. * Callback called when the task is successful
  69801. */
  69802. onSuccess: (task: BinaryFileAssetTask) => void;
  69803. /**
  69804. * Callback called when the task is successful
  69805. */
  69806. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69807. /**
  69808. * Creates a new BinaryFileAssetTask object
  69809. * @param name defines the name of the new task
  69810. * @param url defines the location of the file to load
  69811. */
  69812. constructor(
  69813. /**
  69814. * Defines the name of the task
  69815. */
  69816. name: string,
  69817. /**
  69818. * Defines the location of the file to load
  69819. */
  69820. url: string);
  69821. /**
  69822. * Execute the current task
  69823. * @param scene defines the scene where you want your assets to be loaded
  69824. * @param onSuccess is a callback called when the task is successfully executed
  69825. * @param onError is a callback called if an error occurs
  69826. */
  69827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69828. }
  69829. /**
  69830. * Define a task used by AssetsManager to load images
  69831. */
  69832. export class ImageAssetTask extends AbstractAssetTask {
  69833. /**
  69834. * Defines the name of the task
  69835. */
  69836. name: string;
  69837. /**
  69838. * Defines the location of the image to load
  69839. */
  69840. url: string;
  69841. /**
  69842. * Gets the loaded images
  69843. */
  69844. image: HTMLImageElement;
  69845. /**
  69846. * Callback called when the task is successful
  69847. */
  69848. onSuccess: (task: ImageAssetTask) => void;
  69849. /**
  69850. * Callback called when the task is successful
  69851. */
  69852. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69853. /**
  69854. * Creates a new ImageAssetTask
  69855. * @param name defines the name of the task
  69856. * @param url defines the location of the image to load
  69857. */
  69858. constructor(
  69859. /**
  69860. * Defines the name of the task
  69861. */
  69862. name: string,
  69863. /**
  69864. * Defines the location of the image to load
  69865. */
  69866. url: string);
  69867. /**
  69868. * Execute the current task
  69869. * @param scene defines the scene where you want your assets to be loaded
  69870. * @param onSuccess is a callback called when the task is successfully executed
  69871. * @param onError is a callback called if an error occurs
  69872. */
  69873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69874. }
  69875. /**
  69876. * Defines the interface used by texture loading tasks
  69877. */
  69878. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69879. /**
  69880. * Gets the loaded texture
  69881. */
  69882. texture: TEX;
  69883. }
  69884. /**
  69885. * Define a task used by AssetsManager to load 2D textures
  69886. */
  69887. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69888. /**
  69889. * Defines the name of the task
  69890. */
  69891. name: string;
  69892. /**
  69893. * Defines the location of the file to load
  69894. */
  69895. url: string;
  69896. /**
  69897. * Defines if mipmap should not be generated (default is false)
  69898. */
  69899. noMipmap?: boolean | undefined;
  69900. /**
  69901. * Defines if texture must be inverted on Y axis (default is false)
  69902. */
  69903. invertY?: boolean | undefined;
  69904. /**
  69905. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69906. */
  69907. samplingMode: number;
  69908. /**
  69909. * Gets the loaded texture
  69910. */
  69911. texture: Texture;
  69912. /**
  69913. * Callback called when the task is successful
  69914. */
  69915. onSuccess: (task: TextureAssetTask) => void;
  69916. /**
  69917. * Callback called when the task is successful
  69918. */
  69919. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69920. /**
  69921. * Creates a new TextureAssetTask object
  69922. * @param name defines the name of the task
  69923. * @param url defines the location of the file to load
  69924. * @param noMipmap defines if mipmap should not be generated (default is false)
  69925. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69926. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69927. */
  69928. constructor(
  69929. /**
  69930. * Defines the name of the task
  69931. */
  69932. name: string,
  69933. /**
  69934. * Defines the location of the file to load
  69935. */
  69936. url: string,
  69937. /**
  69938. * Defines if mipmap should not be generated (default is false)
  69939. */
  69940. noMipmap?: boolean | undefined,
  69941. /**
  69942. * Defines if texture must be inverted on Y axis (default is false)
  69943. */
  69944. invertY?: boolean | undefined,
  69945. /**
  69946. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69947. */
  69948. samplingMode?: number);
  69949. /**
  69950. * Execute the current task
  69951. * @param scene defines the scene where you want your assets to be loaded
  69952. * @param onSuccess is a callback called when the task is successfully executed
  69953. * @param onError is a callback called if an error occurs
  69954. */
  69955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69956. }
  69957. /**
  69958. * Define a task used by AssetsManager to load cube textures
  69959. */
  69960. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69961. /**
  69962. * Defines the name of the task
  69963. */
  69964. name: string;
  69965. /**
  69966. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69967. */
  69968. url: string;
  69969. /**
  69970. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69971. */
  69972. extensions?: string[] | undefined;
  69973. /**
  69974. * Defines if mipmaps should not be generated (default is false)
  69975. */
  69976. noMipmap?: boolean | undefined;
  69977. /**
  69978. * Defines the explicit list of files (undefined by default)
  69979. */
  69980. files?: string[] | undefined;
  69981. /**
  69982. * Gets the loaded texture
  69983. */
  69984. texture: CubeTexture;
  69985. /**
  69986. * Callback called when the task is successful
  69987. */
  69988. onSuccess: (task: CubeTextureAssetTask) => void;
  69989. /**
  69990. * Callback called when the task is successful
  69991. */
  69992. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69993. /**
  69994. * Creates a new CubeTextureAssetTask
  69995. * @param name defines the name of the task
  69996. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69997. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69998. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69999. * @param files defines the explicit list of files (undefined by default)
  70000. */
  70001. constructor(
  70002. /**
  70003. * Defines the name of the task
  70004. */
  70005. name: string,
  70006. /**
  70007. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70008. */
  70009. url: string,
  70010. /**
  70011. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70012. */
  70013. extensions?: string[] | undefined,
  70014. /**
  70015. * Defines if mipmaps should not be generated (default is false)
  70016. */
  70017. noMipmap?: boolean | undefined,
  70018. /**
  70019. * Defines the explicit list of files (undefined by default)
  70020. */
  70021. files?: string[] | undefined);
  70022. /**
  70023. * Execute the current task
  70024. * @param scene defines the scene where you want your assets to be loaded
  70025. * @param onSuccess is a callback called when the task is successfully executed
  70026. * @param onError is a callback called if an error occurs
  70027. */
  70028. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70029. }
  70030. /**
  70031. * Define a task used by AssetsManager to load HDR cube textures
  70032. */
  70033. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70034. /**
  70035. * Defines the name of the task
  70036. */
  70037. name: string;
  70038. /**
  70039. * Defines the location of the file to load
  70040. */
  70041. url: string;
  70042. /**
  70043. * Defines the desired size (the more it increases the longer the generation will be)
  70044. */
  70045. size: number;
  70046. /**
  70047. * Defines if mipmaps should not be generated (default is false)
  70048. */
  70049. noMipmap: boolean;
  70050. /**
  70051. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70052. */
  70053. generateHarmonics: boolean;
  70054. /**
  70055. * 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)
  70056. */
  70057. gammaSpace: boolean;
  70058. /**
  70059. * Internal Use Only
  70060. */
  70061. reserved: boolean;
  70062. /**
  70063. * Gets the loaded texture
  70064. */
  70065. texture: HDRCubeTexture;
  70066. /**
  70067. * Callback called when the task is successful
  70068. */
  70069. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70070. /**
  70071. * Callback called when the task is successful
  70072. */
  70073. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70074. /**
  70075. * Creates a new HDRCubeTextureAssetTask object
  70076. * @param name defines the name of the task
  70077. * @param url defines the location of the file to load
  70078. * @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.
  70079. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70080. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70081. * @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)
  70082. * @param reserved Internal use only
  70083. */
  70084. constructor(
  70085. /**
  70086. * Defines the name of the task
  70087. */
  70088. name: string,
  70089. /**
  70090. * Defines the location of the file to load
  70091. */
  70092. url: string,
  70093. /**
  70094. * Defines the desired size (the more it increases the longer the generation will be)
  70095. */
  70096. size: number,
  70097. /**
  70098. * Defines if mipmaps should not be generated (default is false)
  70099. */
  70100. noMipmap?: boolean,
  70101. /**
  70102. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70103. */
  70104. generateHarmonics?: boolean,
  70105. /**
  70106. * 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)
  70107. */
  70108. gammaSpace?: boolean,
  70109. /**
  70110. * Internal Use Only
  70111. */
  70112. reserved?: boolean);
  70113. /**
  70114. * Execute the current task
  70115. * @param scene defines the scene where you want your assets to be loaded
  70116. * @param onSuccess is a callback called when the task is successfully executed
  70117. * @param onError is a callback called if an error occurs
  70118. */
  70119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70120. }
  70121. /**
  70122. * Define a task used by AssetsManager to load Equirectangular cube textures
  70123. */
  70124. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70125. /**
  70126. * Defines the name of the task
  70127. */
  70128. name: string;
  70129. /**
  70130. * Defines the location of the file to load
  70131. */
  70132. url: string;
  70133. /**
  70134. * Defines the desired size (the more it increases the longer the generation will be)
  70135. */
  70136. size: number;
  70137. /**
  70138. * Defines if mipmaps should not be generated (default is false)
  70139. */
  70140. noMipmap: boolean;
  70141. /**
  70142. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70143. * but the standard material would require them in Gamma space) (default is true)
  70144. */
  70145. gammaSpace: boolean;
  70146. /**
  70147. * Gets the loaded texture
  70148. */
  70149. texture: EquiRectangularCubeTexture;
  70150. /**
  70151. * Callback called when the task is successful
  70152. */
  70153. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70154. /**
  70155. * Callback called when the task is successful
  70156. */
  70157. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70158. /**
  70159. * Creates a new EquiRectangularCubeTextureAssetTask object
  70160. * @param name defines the name of the task
  70161. * @param url defines the location of the file to load
  70162. * @param size defines the desired size (the more it increases the longer the generation will be)
  70163. * If the size is omitted this implies you are using a preprocessed cubemap.
  70164. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70165. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70166. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70167. * (default is true)
  70168. */
  70169. constructor(
  70170. /**
  70171. * Defines the name of the task
  70172. */
  70173. name: string,
  70174. /**
  70175. * Defines the location of the file to load
  70176. */
  70177. url: string,
  70178. /**
  70179. * Defines the desired size (the more it increases the longer the generation will be)
  70180. */
  70181. size: number,
  70182. /**
  70183. * Defines if mipmaps should not be generated (default is false)
  70184. */
  70185. noMipmap?: boolean,
  70186. /**
  70187. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70188. * but the standard material would require them in Gamma space) (default is true)
  70189. */
  70190. gammaSpace?: boolean);
  70191. /**
  70192. * Execute the current task
  70193. * @param scene defines the scene where you want your assets to be loaded
  70194. * @param onSuccess is a callback called when the task is successfully executed
  70195. * @param onError is a callback called if an error occurs
  70196. */
  70197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70198. }
  70199. /**
  70200. * This class can be used to easily import assets into a scene
  70201. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70202. */
  70203. export class AssetsManager {
  70204. private _scene;
  70205. private _isLoading;
  70206. protected _tasks: AbstractAssetTask[];
  70207. protected _waitingTasksCount: number;
  70208. protected _totalTasksCount: number;
  70209. /**
  70210. * Callback called when all tasks are processed
  70211. */
  70212. onFinish: (tasks: AbstractAssetTask[]) => void;
  70213. /**
  70214. * Callback called when a task is successful
  70215. */
  70216. onTaskSuccess: (task: AbstractAssetTask) => void;
  70217. /**
  70218. * Callback called when a task had an error
  70219. */
  70220. onTaskError: (task: AbstractAssetTask) => void;
  70221. /**
  70222. * Callback called when a task is done (whatever the result is)
  70223. */
  70224. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70225. /**
  70226. * Observable called when all tasks are processed
  70227. */
  70228. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70229. /**
  70230. * Observable called when a task had an error
  70231. */
  70232. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70233. /**
  70234. * Observable called when all tasks were executed
  70235. */
  70236. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70237. /**
  70238. * Observable called when a task is done (whatever the result is)
  70239. */
  70240. onProgressObservable: Observable<IAssetsProgressEvent>;
  70241. /**
  70242. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70243. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70244. */
  70245. useDefaultLoadingScreen: boolean;
  70246. /**
  70247. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70248. * when all assets have been downloaded.
  70249. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70250. */
  70251. autoHideLoadingUI: boolean;
  70252. /**
  70253. * Creates a new AssetsManager
  70254. * @param scene defines the scene to work on
  70255. */
  70256. constructor(scene: Scene);
  70257. /**
  70258. * Add a MeshAssetTask to the list of active tasks
  70259. * @param taskName defines the name of the new task
  70260. * @param meshesNames defines the name of meshes to load
  70261. * @param rootUrl defines the root url to use to locate files
  70262. * @param sceneFilename defines the filename of the scene file
  70263. * @returns a new MeshAssetTask object
  70264. */
  70265. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70266. /**
  70267. * Add a TextFileAssetTask to the list of active tasks
  70268. * @param taskName defines the name of the new task
  70269. * @param url defines the url of the file to load
  70270. * @returns a new TextFileAssetTask object
  70271. */
  70272. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70273. /**
  70274. * Add a BinaryFileAssetTask to the list of active tasks
  70275. * @param taskName defines the name of the new task
  70276. * @param url defines the url of the file to load
  70277. * @returns a new BinaryFileAssetTask object
  70278. */
  70279. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70280. /**
  70281. * Add a ImageAssetTask to the list of active tasks
  70282. * @param taskName defines the name of the new task
  70283. * @param url defines the url of the file to load
  70284. * @returns a new ImageAssetTask object
  70285. */
  70286. addImageTask(taskName: string, url: string): ImageAssetTask;
  70287. /**
  70288. * Add a TextureAssetTask to the list of active tasks
  70289. * @param taskName defines the name of the new task
  70290. * @param url defines the url of the file to load
  70291. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70292. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70293. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70294. * @returns a new TextureAssetTask object
  70295. */
  70296. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70297. /**
  70298. * Add a CubeTextureAssetTask to the list of active tasks
  70299. * @param taskName defines the name of the new task
  70300. * @param url defines the url of the file to load
  70301. * @param extensions defines the extension to use to load the cube map (can be null)
  70302. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70303. * @param files defines the list of files to load (can be null)
  70304. * @returns a new CubeTextureAssetTask object
  70305. */
  70306. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70307. /**
  70308. *
  70309. * Add a HDRCubeTextureAssetTask to the list of active tasks
  70310. * @param taskName defines the name of the new task
  70311. * @param url defines the url of the file to load
  70312. * @param size defines the size you want for the cubemap (can be null)
  70313. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70314. * @param generateHarmonics defines if you want to automatically generate (true by default)
  70315. * @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)
  70316. * @param reserved Internal use only
  70317. * @returns a new HDRCubeTextureAssetTask object
  70318. */
  70319. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  70320. /**
  70321. *
  70322. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  70323. * @param taskName defines the name of the new task
  70324. * @param url defines the url of the file to load
  70325. * @param size defines the size you want for the cubemap (can be null)
  70326. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70327. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  70328. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  70329. * @returns a new EquiRectangularCubeTextureAssetTask object
  70330. */
  70331. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  70332. /**
  70333. * Remove a task from the assets manager.
  70334. * @param task the task to remove
  70335. */
  70336. removeTask(task: AbstractAssetTask): void;
  70337. private _decreaseWaitingTasksCount;
  70338. private _runTask;
  70339. /**
  70340. * Reset the AssetsManager and remove all tasks
  70341. * @return the current instance of the AssetsManager
  70342. */
  70343. reset(): AssetsManager;
  70344. /**
  70345. * Start the loading process
  70346. * @return the current instance of the AssetsManager
  70347. */
  70348. load(): AssetsManager;
  70349. /**
  70350. * Start the loading process as an async operation
  70351. * @return a promise returning the list of failed tasks
  70352. */
  70353. loadAsync(): Promise<void>;
  70354. }
  70355. }
  70356. declare module "babylonjs/Misc/deferred" {
  70357. /**
  70358. * Wrapper class for promise with external resolve and reject.
  70359. */
  70360. export class Deferred<T> {
  70361. /**
  70362. * The promise associated with this deferred object.
  70363. */
  70364. readonly promise: Promise<T>;
  70365. private _resolve;
  70366. private _reject;
  70367. /**
  70368. * The resolve method of the promise associated with this deferred object.
  70369. */
  70370. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  70371. /**
  70372. * The reject method of the promise associated with this deferred object.
  70373. */
  70374. get reject(): (reason?: any) => void;
  70375. /**
  70376. * Constructor for this deferred object.
  70377. */
  70378. constructor();
  70379. }
  70380. }
  70381. declare module "babylonjs/Misc/meshExploder" {
  70382. import { Mesh } from "babylonjs/Meshes/mesh";
  70383. /**
  70384. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  70385. */
  70386. export class MeshExploder {
  70387. private _centerMesh;
  70388. private _meshes;
  70389. private _meshesOrigins;
  70390. private _toCenterVectors;
  70391. private _scaledDirection;
  70392. private _newPosition;
  70393. private _centerPosition;
  70394. /**
  70395. * Explodes meshes from a center mesh.
  70396. * @param meshes The meshes to explode.
  70397. * @param centerMesh The mesh to be center of explosion.
  70398. */
  70399. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  70400. private _setCenterMesh;
  70401. /**
  70402. * Get class name
  70403. * @returns "MeshExploder"
  70404. */
  70405. getClassName(): string;
  70406. /**
  70407. * "Exploded meshes"
  70408. * @returns Array of meshes with the centerMesh at index 0.
  70409. */
  70410. getMeshes(): Array<Mesh>;
  70411. /**
  70412. * Explodes meshes giving a specific direction
  70413. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  70414. */
  70415. explode(direction?: number): void;
  70416. }
  70417. }
  70418. declare module "babylonjs/Misc/filesInput" {
  70419. import { Engine } from "babylonjs/Engines/engine";
  70420. import { Scene } from "babylonjs/scene";
  70421. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  70422. /**
  70423. * Class used to help managing file picking and drag'n'drop
  70424. */
  70425. export class FilesInput {
  70426. /**
  70427. * List of files ready to be loaded
  70428. */
  70429. static get FilesToLoad(): {
  70430. [key: string]: File;
  70431. };
  70432. /**
  70433. * Callback called when a file is processed
  70434. */
  70435. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  70436. private _engine;
  70437. private _currentScene;
  70438. private _sceneLoadedCallback;
  70439. private _progressCallback;
  70440. private _additionalRenderLoopLogicCallback;
  70441. private _textureLoadingCallback;
  70442. private _startingProcessingFilesCallback;
  70443. private _onReloadCallback;
  70444. private _errorCallback;
  70445. private _elementToMonitor;
  70446. private _sceneFileToLoad;
  70447. private _filesToLoad;
  70448. /**
  70449. * Creates a new FilesInput
  70450. * @param engine defines the rendering engine
  70451. * @param scene defines the hosting scene
  70452. * @param sceneLoadedCallback callback called when scene is loaded
  70453. * @param progressCallback callback called to track progress
  70454. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  70455. * @param textureLoadingCallback callback called when a texture is loading
  70456. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  70457. * @param onReloadCallback callback called when a reload is requested
  70458. * @param errorCallback callback call if an error occurs
  70459. */
  70460. 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);
  70461. private _dragEnterHandler;
  70462. private _dragOverHandler;
  70463. private _dropHandler;
  70464. /**
  70465. * Calls this function to listen to drag'n'drop events on a specific DOM element
  70466. * @param elementToMonitor defines the DOM element to track
  70467. */
  70468. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  70469. /**
  70470. * Release all associated resources
  70471. */
  70472. dispose(): void;
  70473. private renderFunction;
  70474. private drag;
  70475. private drop;
  70476. private _traverseFolder;
  70477. private _processFiles;
  70478. /**
  70479. * Load files from a drop event
  70480. * @param event defines the drop event to use as source
  70481. */
  70482. loadFiles(event: any): void;
  70483. private _processReload;
  70484. /**
  70485. * Reload the current scene from the loaded files
  70486. */
  70487. reload(): void;
  70488. }
  70489. }
  70490. declare module "babylonjs/Misc/HighDynamicRange/index" {
  70491. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  70492. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  70493. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  70494. }
  70495. declare module "babylonjs/Misc/sceneOptimizer" {
  70496. import { Scene, IDisposable } from "babylonjs/scene";
  70497. import { Observable } from "babylonjs/Misc/observable";
  70498. /**
  70499. * Defines the root class used to create scene optimization to use with SceneOptimizer
  70500. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70501. */
  70502. export class SceneOptimization {
  70503. /**
  70504. * Defines the priority of this optimization (0 by default which means first in the list)
  70505. */
  70506. priority: number;
  70507. /**
  70508. * Gets a string describing the action executed by the current optimization
  70509. * @returns description string
  70510. */
  70511. getDescription(): string;
  70512. /**
  70513. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70514. * @param scene defines the current scene where to apply this optimization
  70515. * @param optimizer defines the current optimizer
  70516. * @returns true if everything that can be done was applied
  70517. */
  70518. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70519. /**
  70520. * Creates the SceneOptimization object
  70521. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70522. * @param desc defines the description associated with the optimization
  70523. */
  70524. constructor(
  70525. /**
  70526. * Defines the priority of this optimization (0 by default which means first in the list)
  70527. */
  70528. priority?: number);
  70529. }
  70530. /**
  70531. * Defines an optimization used to reduce the size of render target textures
  70532. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70533. */
  70534. export class TextureOptimization extends SceneOptimization {
  70535. /**
  70536. * Defines the priority of this optimization (0 by default which means first in the list)
  70537. */
  70538. priority: number;
  70539. /**
  70540. * 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
  70541. */
  70542. maximumSize: number;
  70543. /**
  70544. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70545. */
  70546. step: number;
  70547. /**
  70548. * Gets a string describing the action executed by the current optimization
  70549. * @returns description string
  70550. */
  70551. getDescription(): string;
  70552. /**
  70553. * Creates the TextureOptimization object
  70554. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70555. * @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
  70556. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70557. */
  70558. constructor(
  70559. /**
  70560. * Defines the priority of this optimization (0 by default which means first in the list)
  70561. */
  70562. priority?: number,
  70563. /**
  70564. * 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
  70565. */
  70566. maximumSize?: number,
  70567. /**
  70568. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70569. */
  70570. step?: number);
  70571. /**
  70572. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70573. * @param scene defines the current scene where to apply this optimization
  70574. * @param optimizer defines the current optimizer
  70575. * @returns true if everything that can be done was applied
  70576. */
  70577. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70578. }
  70579. /**
  70580. * Defines an optimization used to increase or decrease the rendering resolution
  70581. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70582. */
  70583. export class HardwareScalingOptimization extends SceneOptimization {
  70584. /**
  70585. * Defines the priority of this optimization (0 by default which means first in the list)
  70586. */
  70587. priority: number;
  70588. /**
  70589. * Defines the maximum scale to use (2 by default)
  70590. */
  70591. maximumScale: number;
  70592. /**
  70593. * Defines the step to use between two passes (0.5 by default)
  70594. */
  70595. step: number;
  70596. private _currentScale;
  70597. private _directionOffset;
  70598. /**
  70599. * Gets a string describing the action executed by the current optimization
  70600. * @return description string
  70601. */
  70602. getDescription(): string;
  70603. /**
  70604. * Creates the HardwareScalingOptimization object
  70605. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70606. * @param maximumScale defines the maximum scale to use (2 by default)
  70607. * @param step defines the step to use between two passes (0.5 by default)
  70608. */
  70609. constructor(
  70610. /**
  70611. * Defines the priority of this optimization (0 by default which means first in the list)
  70612. */
  70613. priority?: number,
  70614. /**
  70615. * Defines the maximum scale to use (2 by default)
  70616. */
  70617. maximumScale?: number,
  70618. /**
  70619. * Defines the step to use between two passes (0.5 by default)
  70620. */
  70621. step?: number);
  70622. /**
  70623. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70624. * @param scene defines the current scene where to apply this optimization
  70625. * @param optimizer defines the current optimizer
  70626. * @returns true if everything that can be done was applied
  70627. */
  70628. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70629. }
  70630. /**
  70631. * Defines an optimization used to remove shadows
  70632. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70633. */
  70634. export class ShadowsOptimization extends SceneOptimization {
  70635. /**
  70636. * Gets a string describing the action executed by the current optimization
  70637. * @return description string
  70638. */
  70639. getDescription(): string;
  70640. /**
  70641. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70642. * @param scene defines the current scene where to apply this optimization
  70643. * @param optimizer defines the current optimizer
  70644. * @returns true if everything that can be done was applied
  70645. */
  70646. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70647. }
  70648. /**
  70649. * Defines an optimization used to turn post-processes off
  70650. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70651. */
  70652. export class PostProcessesOptimization extends SceneOptimization {
  70653. /**
  70654. * Gets a string describing the action executed by the current optimization
  70655. * @return description string
  70656. */
  70657. getDescription(): string;
  70658. /**
  70659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70660. * @param scene defines the current scene where to apply this optimization
  70661. * @param optimizer defines the current optimizer
  70662. * @returns true if everything that can be done was applied
  70663. */
  70664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70665. }
  70666. /**
  70667. * Defines an optimization used to turn lens flares off
  70668. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70669. */
  70670. export class LensFlaresOptimization extends SceneOptimization {
  70671. /**
  70672. * Gets a string describing the action executed by the current optimization
  70673. * @return description string
  70674. */
  70675. getDescription(): string;
  70676. /**
  70677. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70678. * @param scene defines the current scene where to apply this optimization
  70679. * @param optimizer defines the current optimizer
  70680. * @returns true if everything that can be done was applied
  70681. */
  70682. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70683. }
  70684. /**
  70685. * Defines an optimization based on user defined callback.
  70686. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70687. */
  70688. export class CustomOptimization extends SceneOptimization {
  70689. /**
  70690. * Callback called to apply the custom optimization.
  70691. */
  70692. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  70693. /**
  70694. * Callback called to get custom description
  70695. */
  70696. onGetDescription: () => string;
  70697. /**
  70698. * Gets a string describing the action executed by the current optimization
  70699. * @returns description string
  70700. */
  70701. getDescription(): string;
  70702. /**
  70703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70704. * @param scene defines the current scene where to apply this optimization
  70705. * @param optimizer defines the current optimizer
  70706. * @returns true if everything that can be done was applied
  70707. */
  70708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70709. }
  70710. /**
  70711. * Defines an optimization used to turn particles off
  70712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70713. */
  70714. export class ParticlesOptimization extends SceneOptimization {
  70715. /**
  70716. * Gets a string describing the action executed by the current optimization
  70717. * @return description string
  70718. */
  70719. getDescription(): string;
  70720. /**
  70721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70722. * @param scene defines the current scene where to apply this optimization
  70723. * @param optimizer defines the current optimizer
  70724. * @returns true if everything that can be done was applied
  70725. */
  70726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70727. }
  70728. /**
  70729. * Defines an optimization used to turn render targets off
  70730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70731. */
  70732. export class RenderTargetsOptimization extends SceneOptimization {
  70733. /**
  70734. * Gets a string describing the action executed by the current optimization
  70735. * @return description string
  70736. */
  70737. getDescription(): string;
  70738. /**
  70739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70740. * @param scene defines the current scene where to apply this optimization
  70741. * @param optimizer defines the current optimizer
  70742. * @returns true if everything that can be done was applied
  70743. */
  70744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70745. }
  70746. /**
  70747. * Defines an optimization used to merge meshes with compatible materials
  70748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70749. */
  70750. export class MergeMeshesOptimization extends SceneOptimization {
  70751. private static _UpdateSelectionTree;
  70752. /**
  70753. * Gets or sets a boolean which defines if optimization octree has to be updated
  70754. */
  70755. static get UpdateSelectionTree(): boolean;
  70756. /**
  70757. * Gets or sets a boolean which defines if optimization octree has to be updated
  70758. */
  70759. static set UpdateSelectionTree(value: boolean);
  70760. /**
  70761. * Gets a string describing the action executed by the current optimization
  70762. * @return description string
  70763. */
  70764. getDescription(): string;
  70765. private _canBeMerged;
  70766. /**
  70767. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70768. * @param scene defines the current scene where to apply this optimization
  70769. * @param optimizer defines the current optimizer
  70770. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70771. * @returns true if everything that can be done was applied
  70772. */
  70773. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70774. }
  70775. /**
  70776. * Defines a list of options used by SceneOptimizer
  70777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70778. */
  70779. export class SceneOptimizerOptions {
  70780. /**
  70781. * Defines the target frame rate to reach (60 by default)
  70782. */
  70783. targetFrameRate: number;
  70784. /**
  70785. * Defines the interval between two checkes (2000ms by default)
  70786. */
  70787. trackerDuration: number;
  70788. /**
  70789. * Gets the list of optimizations to apply
  70790. */
  70791. optimizations: SceneOptimization[];
  70792. /**
  70793. * Creates a new list of options used by SceneOptimizer
  70794. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70795. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70796. */
  70797. constructor(
  70798. /**
  70799. * Defines the target frame rate to reach (60 by default)
  70800. */
  70801. targetFrameRate?: number,
  70802. /**
  70803. * Defines the interval between two checkes (2000ms by default)
  70804. */
  70805. trackerDuration?: number);
  70806. /**
  70807. * Add a new optimization
  70808. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70809. * @returns the current SceneOptimizerOptions
  70810. */
  70811. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70812. /**
  70813. * Add a new custom optimization
  70814. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70815. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70816. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70817. * @returns the current SceneOptimizerOptions
  70818. */
  70819. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70820. /**
  70821. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70822. * @param targetFrameRate defines the target frame rate (60 by default)
  70823. * @returns a SceneOptimizerOptions object
  70824. */
  70825. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70826. /**
  70827. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70828. * @param targetFrameRate defines the target frame rate (60 by default)
  70829. * @returns a SceneOptimizerOptions object
  70830. */
  70831. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70832. /**
  70833. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70834. * @param targetFrameRate defines the target frame rate (60 by default)
  70835. * @returns a SceneOptimizerOptions object
  70836. */
  70837. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70838. }
  70839. /**
  70840. * Class used to run optimizations in order to reach a target frame rate
  70841. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70842. */
  70843. export class SceneOptimizer implements IDisposable {
  70844. private _isRunning;
  70845. private _options;
  70846. private _scene;
  70847. private _currentPriorityLevel;
  70848. private _targetFrameRate;
  70849. private _trackerDuration;
  70850. private _currentFrameRate;
  70851. private _sceneDisposeObserver;
  70852. private _improvementMode;
  70853. /**
  70854. * Defines an observable called when the optimizer reaches the target frame rate
  70855. */
  70856. onSuccessObservable: Observable<SceneOptimizer>;
  70857. /**
  70858. * Defines an observable called when the optimizer enables an optimization
  70859. */
  70860. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70861. /**
  70862. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70863. */
  70864. onFailureObservable: Observable<SceneOptimizer>;
  70865. /**
  70866. * Gets a boolean indicating if the optimizer is in improvement mode
  70867. */
  70868. get isInImprovementMode(): boolean;
  70869. /**
  70870. * Gets the current priority level (0 at start)
  70871. */
  70872. get currentPriorityLevel(): number;
  70873. /**
  70874. * Gets the current frame rate checked by the SceneOptimizer
  70875. */
  70876. get currentFrameRate(): number;
  70877. /**
  70878. * Gets or sets the current target frame rate (60 by default)
  70879. */
  70880. get targetFrameRate(): number;
  70881. /**
  70882. * Gets or sets the current target frame rate (60 by default)
  70883. */
  70884. set targetFrameRate(value: number);
  70885. /**
  70886. * Gets or sets the current interval between two checks (every 2000ms by default)
  70887. */
  70888. get trackerDuration(): number;
  70889. /**
  70890. * Gets or sets the current interval between two checks (every 2000ms by default)
  70891. */
  70892. set trackerDuration(value: number);
  70893. /**
  70894. * Gets the list of active optimizations
  70895. */
  70896. get optimizations(): SceneOptimization[];
  70897. /**
  70898. * Creates a new SceneOptimizer
  70899. * @param scene defines the scene to work on
  70900. * @param options defines the options to use with the SceneOptimizer
  70901. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70902. * @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)
  70903. */
  70904. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70905. /**
  70906. * Stops the current optimizer
  70907. */
  70908. stop(): void;
  70909. /**
  70910. * Reset the optimizer to initial step (current priority level = 0)
  70911. */
  70912. reset(): void;
  70913. /**
  70914. * Start the optimizer. By default it will try to reach a specific framerate
  70915. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70916. */
  70917. start(): void;
  70918. private _checkCurrentState;
  70919. /**
  70920. * Release all resources
  70921. */
  70922. dispose(): void;
  70923. /**
  70924. * Helper function to create a SceneOptimizer with one single line of code
  70925. * @param scene defines the scene to work on
  70926. * @param options defines the options to use with the SceneOptimizer
  70927. * @param onSuccess defines a callback to call on success
  70928. * @param onFailure defines a callback to call on failure
  70929. * @returns the new SceneOptimizer object
  70930. */
  70931. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70932. }
  70933. }
  70934. declare module "babylonjs/Misc/sceneSerializer" {
  70935. import { Scene } from "babylonjs/scene";
  70936. /**
  70937. * Class used to serialize a scene into a string
  70938. */
  70939. export class SceneSerializer {
  70940. /**
  70941. * Clear cache used by a previous serialization
  70942. */
  70943. static ClearCache(): void;
  70944. /**
  70945. * Serialize a scene into a JSON compatible object
  70946. * @param scene defines the scene to serialize
  70947. * @returns a JSON compatible object
  70948. */
  70949. static Serialize(scene: Scene): any;
  70950. /**
  70951. * Serialize a mesh into a JSON compatible object
  70952. * @param toSerialize defines the mesh to serialize
  70953. * @param withParents defines if parents must be serialized as well
  70954. * @param withChildren defines if children must be serialized as well
  70955. * @returns a JSON compatible object
  70956. */
  70957. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70958. }
  70959. }
  70960. declare module "babylonjs/Misc/textureTools" {
  70961. import { Texture } from "babylonjs/Materials/Textures/texture";
  70962. /**
  70963. * Class used to host texture specific utilities
  70964. */
  70965. export class TextureTools {
  70966. /**
  70967. * Uses the GPU to create a copy texture rescaled at a given size
  70968. * @param texture Texture to copy from
  70969. * @param width defines the desired width
  70970. * @param height defines the desired height
  70971. * @param useBilinearMode defines if bilinear mode has to be used
  70972. * @return the generated texture
  70973. */
  70974. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70975. }
  70976. }
  70977. declare module "babylonjs/Misc/videoRecorder" {
  70978. import { Nullable } from "babylonjs/types";
  70979. import { Engine } from "babylonjs/Engines/engine";
  70980. /**
  70981. * This represents the different options available for the video capture.
  70982. */
  70983. export interface VideoRecorderOptions {
  70984. /** Defines the mime type of the video. */
  70985. mimeType: string;
  70986. /** Defines the FPS the video should be recorded at. */
  70987. fps: number;
  70988. /** Defines the chunk size for the recording data. */
  70989. recordChunckSize: number;
  70990. /** The audio tracks to attach to the recording. */
  70991. audioTracks?: MediaStreamTrack[];
  70992. }
  70993. /**
  70994. * This can help with recording videos from BabylonJS.
  70995. * This is based on the available WebRTC functionalities of the browser.
  70996. *
  70997. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70998. */
  70999. export class VideoRecorder {
  71000. private static readonly _defaultOptions;
  71001. /**
  71002. * Returns whether or not the VideoRecorder is available in your browser.
  71003. * @param engine Defines the Babylon Engine.
  71004. * @returns true if supported otherwise false.
  71005. */
  71006. static IsSupported(engine: Engine): boolean;
  71007. private readonly _options;
  71008. private _canvas;
  71009. private _mediaRecorder;
  71010. private _recordedChunks;
  71011. private _fileName;
  71012. private _resolve;
  71013. private _reject;
  71014. /**
  71015. * True when a recording is already in progress.
  71016. */
  71017. get isRecording(): boolean;
  71018. /**
  71019. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71020. * @param engine Defines the BabylonJS Engine you wish to record.
  71021. * @param options Defines options that can be used to customize the capture.
  71022. */
  71023. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71024. /**
  71025. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71026. */
  71027. stopRecording(): void;
  71028. /**
  71029. * Starts recording the canvas for a max duration specified in parameters.
  71030. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71031. * If null no automatic download will start and you can rely on the promise to get the data back.
  71032. * @param maxDuration Defines the maximum recording time in seconds.
  71033. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71034. * @return A promise callback at the end of the recording with the video data in Blob.
  71035. */
  71036. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71037. /**
  71038. * Releases internal resources used during the recording.
  71039. */
  71040. dispose(): void;
  71041. private _handleDataAvailable;
  71042. private _handleError;
  71043. private _handleStop;
  71044. }
  71045. }
  71046. declare module "babylonjs/Misc/screenshotTools" {
  71047. import { Camera } from "babylonjs/Cameras/camera";
  71048. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  71049. import { Engine } from "babylonjs/Engines/engine";
  71050. /**
  71051. * Class containing a set of static utilities functions for screenshots
  71052. */
  71053. export class ScreenshotTools {
  71054. /**
  71055. * Captures a screenshot of the current rendering
  71056. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71057. * @param engine defines the rendering engine
  71058. * @param camera defines the source camera
  71059. * @param size This parameter can be set to a single number or to an object with the
  71060. * following (optional) properties: precision, width, height. If a single number is passed,
  71061. * it will be used for both width and height. If an object is passed, the screenshot size
  71062. * will be derived from the parameters. The precision property is a multiplier allowing
  71063. * rendering at a higher or lower resolution
  71064. * @param successCallback defines the callback receives a single parameter which contains the
  71065. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71066. * src parameter of an <img> to display it
  71067. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71068. * Check your browser for supported MIME types
  71069. */
  71070. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71071. /**
  71072. * Captures a screenshot of the current rendering
  71073. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71074. * @param engine defines the rendering engine
  71075. * @param camera defines the source camera
  71076. * @param size This parameter can be set to a single number or to an object with the
  71077. * following (optional) properties: precision, width, height. If a single number is passed,
  71078. * it will be used for both width and height. If an object is passed, the screenshot size
  71079. * will be derived from the parameters. The precision property is a multiplier allowing
  71080. * rendering at a higher or lower resolution
  71081. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71082. * Check your browser for supported MIME types
  71083. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71084. * to the src parameter of an <img> to display it
  71085. */
  71086. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71087. /**
  71088. * Generates an image screenshot from the specified camera.
  71089. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71090. * @param engine The engine to use for rendering
  71091. * @param camera The camera to use for rendering
  71092. * @param size This parameter can be set to a single number or to an object with the
  71093. * following (optional) properties: precision, width, height. If a single number is passed,
  71094. * it will be used for both width and height. If an object is passed, the screenshot size
  71095. * will be derived from the parameters. The precision property is a multiplier allowing
  71096. * rendering at a higher or lower resolution
  71097. * @param successCallback The callback receives a single parameter which contains the
  71098. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71099. * src parameter of an <img> to display it
  71100. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71101. * Check your browser for supported MIME types
  71102. * @param samples Texture samples (default: 1)
  71103. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71104. * @param fileName A name for for the downloaded file.
  71105. */
  71106. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  71107. /**
  71108. * Generates an image screenshot from the specified camera.
  71109. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71110. * @param engine The engine to use for rendering
  71111. * @param camera The camera to use for rendering
  71112. * @param size This parameter can be set to a single number or to an object with the
  71113. * following (optional) properties: precision, width, height. If a single number is passed,
  71114. * it will be used for both width and height. If an object is passed, the screenshot size
  71115. * will be derived from the parameters. The precision property is a multiplier allowing
  71116. * rendering at a higher or lower resolution
  71117. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71118. * Check your browser for supported MIME types
  71119. * @param samples Texture samples (default: 1)
  71120. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71121. * @param fileName A name for for the downloaded file.
  71122. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71123. * to the src parameter of an <img> to display it
  71124. */
  71125. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  71126. /**
  71127. * Gets height and width for screenshot size
  71128. * @private
  71129. */
  71130. private static _getScreenshotSize;
  71131. }
  71132. }
  71133. declare module "babylonjs/Misc/dataReader" {
  71134. /**
  71135. * Interface for a data buffer
  71136. */
  71137. export interface IDataBuffer {
  71138. /**
  71139. * Reads bytes from the data buffer.
  71140. * @param byteOffset The byte offset to read
  71141. * @param byteLength The byte length to read
  71142. * @returns A promise that resolves when the bytes are read
  71143. */
  71144. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71145. /**
  71146. * The byte length of the buffer.
  71147. */
  71148. readonly byteLength: number;
  71149. }
  71150. /**
  71151. * Utility class for reading from a data buffer
  71152. */
  71153. export class DataReader {
  71154. /**
  71155. * The data buffer associated with this data reader.
  71156. */
  71157. readonly buffer: IDataBuffer;
  71158. /**
  71159. * The current byte offset from the beginning of the data buffer.
  71160. */
  71161. byteOffset: number;
  71162. private _dataView;
  71163. private _dataByteOffset;
  71164. /**
  71165. * Constructor
  71166. * @param buffer The buffer to read
  71167. */
  71168. constructor(buffer: IDataBuffer);
  71169. /**
  71170. * Loads the given byte length.
  71171. * @param byteLength The byte length to load
  71172. * @returns A promise that resolves when the load is complete
  71173. */
  71174. loadAsync(byteLength: number): Promise<void>;
  71175. /**
  71176. * Read a unsigned 32-bit integer from the currently loaded data range.
  71177. * @returns The 32-bit integer read
  71178. */
  71179. readUint32(): number;
  71180. /**
  71181. * Read a byte array from the currently loaded data range.
  71182. * @param byteLength The byte length to read
  71183. * @returns The byte array read
  71184. */
  71185. readUint8Array(byteLength: number): Uint8Array;
  71186. /**
  71187. * Read a string from the currently loaded data range.
  71188. * @param byteLength The byte length to read
  71189. * @returns The string read
  71190. */
  71191. readString(byteLength: number): string;
  71192. /**
  71193. * Skips the given byte length the currently loaded data range.
  71194. * @param byteLength The byte length to skip
  71195. */
  71196. skipBytes(byteLength: number): void;
  71197. }
  71198. }
  71199. declare module "babylonjs/Misc/index" {
  71200. export * from "babylonjs/Misc/andOrNotEvaluator";
  71201. export * from "babylonjs/Misc/assetsManager";
  71202. export * from "babylonjs/Misc/basis";
  71203. export * from "babylonjs/Misc/dds";
  71204. export * from "babylonjs/Misc/decorators";
  71205. export * from "babylonjs/Misc/deferred";
  71206. export * from "babylonjs/Misc/environmentTextureTools";
  71207. export * from "babylonjs/Misc/meshExploder";
  71208. export * from "babylonjs/Misc/filesInput";
  71209. export * from "babylonjs/Misc/HighDynamicRange/index";
  71210. export * from "babylonjs/Misc/khronosTextureContainer";
  71211. export * from "babylonjs/Misc/observable";
  71212. export * from "babylonjs/Misc/performanceMonitor";
  71213. export * from "babylonjs/Misc/promise";
  71214. export * from "babylonjs/Misc/sceneOptimizer";
  71215. export * from "babylonjs/Misc/sceneSerializer";
  71216. export * from "babylonjs/Misc/smartArray";
  71217. export * from "babylonjs/Misc/stringDictionary";
  71218. export * from "babylonjs/Misc/tags";
  71219. export * from "babylonjs/Misc/textureTools";
  71220. export * from "babylonjs/Misc/tga";
  71221. export * from "babylonjs/Misc/tools";
  71222. export * from "babylonjs/Misc/videoRecorder";
  71223. export * from "babylonjs/Misc/virtualJoystick";
  71224. export * from "babylonjs/Misc/workerPool";
  71225. export * from "babylonjs/Misc/logger";
  71226. export * from "babylonjs/Misc/typeStore";
  71227. export * from "babylonjs/Misc/filesInputStore";
  71228. export * from "babylonjs/Misc/deepCopier";
  71229. export * from "babylonjs/Misc/pivotTools";
  71230. export * from "babylonjs/Misc/precisionDate";
  71231. export * from "babylonjs/Misc/screenshotTools";
  71232. export * from "babylonjs/Misc/typeStore";
  71233. export * from "babylonjs/Misc/webRequest";
  71234. export * from "babylonjs/Misc/iInspectable";
  71235. export * from "babylonjs/Misc/brdfTextureTools";
  71236. export * from "babylonjs/Misc/rgbdTextureTools";
  71237. export * from "babylonjs/Misc/gradients";
  71238. export * from "babylonjs/Misc/perfCounter";
  71239. export * from "babylonjs/Misc/fileRequest";
  71240. export * from "babylonjs/Misc/customAnimationFrameRequester";
  71241. export * from "babylonjs/Misc/retryStrategy";
  71242. export * from "babylonjs/Misc/interfaces/screenshotSize";
  71243. export * from "babylonjs/Misc/canvasGenerator";
  71244. export * from "babylonjs/Misc/fileTools";
  71245. export * from "babylonjs/Misc/stringTools";
  71246. export * from "babylonjs/Misc/dataReader";
  71247. }
  71248. declare module "babylonjs/index" {
  71249. export * from "babylonjs/abstractScene";
  71250. export * from "babylonjs/Actions/index";
  71251. export * from "babylonjs/Animations/index";
  71252. export * from "babylonjs/assetContainer";
  71253. export * from "babylonjs/Audio/index";
  71254. export * from "babylonjs/Behaviors/index";
  71255. export * from "babylonjs/Bones/index";
  71256. export * from "babylonjs/Cameras/index";
  71257. export * from "babylonjs/Collisions/index";
  71258. export * from "babylonjs/Culling/index";
  71259. export * from "babylonjs/Debug/index";
  71260. export * from "babylonjs/Engines/index";
  71261. export * from "babylonjs/Events/index";
  71262. export * from "babylonjs/Gamepads/index";
  71263. export * from "babylonjs/Gizmos/index";
  71264. export * from "babylonjs/Helpers/index";
  71265. export * from "babylonjs/Instrumentation/index";
  71266. export * from "babylonjs/Layers/index";
  71267. export * from "babylonjs/LensFlares/index";
  71268. export * from "babylonjs/Lights/index";
  71269. export * from "babylonjs/Loading/index";
  71270. export * from "babylonjs/Materials/index";
  71271. export * from "babylonjs/Maths/index";
  71272. export * from "babylonjs/Meshes/index";
  71273. export * from "babylonjs/Morph/index";
  71274. export * from "babylonjs/Navigation/index";
  71275. export * from "babylonjs/node";
  71276. export * from "babylonjs/Offline/index";
  71277. export * from "babylonjs/Particles/index";
  71278. export * from "babylonjs/Physics/index";
  71279. export * from "babylonjs/PostProcesses/index";
  71280. export * from "babylonjs/Probes/index";
  71281. export * from "babylonjs/Rendering/index";
  71282. export * from "babylonjs/scene";
  71283. export * from "babylonjs/sceneComponent";
  71284. export * from "babylonjs/Sprites/index";
  71285. export * from "babylonjs/States/index";
  71286. export * from "babylonjs/Misc/index";
  71287. export * from "babylonjs/types";
  71288. }
  71289. declare module "babylonjs/Animations/pathCursor" {
  71290. import { Vector3 } from "babylonjs/Maths/math.vector";
  71291. import { Path2 } from "babylonjs/Maths/math.path";
  71292. /**
  71293. * A cursor which tracks a point on a path
  71294. */
  71295. export class PathCursor {
  71296. private path;
  71297. /**
  71298. * Stores path cursor callbacks for when an onchange event is triggered
  71299. */
  71300. private _onchange;
  71301. /**
  71302. * The value of the path cursor
  71303. */
  71304. value: number;
  71305. /**
  71306. * The animation array of the path cursor
  71307. */
  71308. animations: Animation[];
  71309. /**
  71310. * Initializes the path cursor
  71311. * @param path The path to track
  71312. */
  71313. constructor(path: Path2);
  71314. /**
  71315. * Gets the cursor point on the path
  71316. * @returns A point on the path cursor at the cursor location
  71317. */
  71318. getPoint(): Vector3;
  71319. /**
  71320. * Moves the cursor ahead by the step amount
  71321. * @param step The amount to move the cursor forward
  71322. * @returns This path cursor
  71323. */
  71324. moveAhead(step?: number): PathCursor;
  71325. /**
  71326. * Moves the cursor behind by the step amount
  71327. * @param step The amount to move the cursor back
  71328. * @returns This path cursor
  71329. */
  71330. moveBack(step?: number): PathCursor;
  71331. /**
  71332. * Moves the cursor by the step amount
  71333. * If the step amount is greater than one, an exception is thrown
  71334. * @param step The amount to move the cursor
  71335. * @returns This path cursor
  71336. */
  71337. move(step: number): PathCursor;
  71338. /**
  71339. * Ensures that the value is limited between zero and one
  71340. * @returns This path cursor
  71341. */
  71342. private ensureLimits;
  71343. /**
  71344. * Runs onchange callbacks on change (used by the animation engine)
  71345. * @returns This path cursor
  71346. */
  71347. private raiseOnChange;
  71348. /**
  71349. * Executes a function on change
  71350. * @param f A path cursor onchange callback
  71351. * @returns This path cursor
  71352. */
  71353. onchange(f: (cursor: PathCursor) => void): PathCursor;
  71354. }
  71355. }
  71356. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  71357. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  71358. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  71359. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  71360. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  71361. }
  71362. declare module "babylonjs/Engines/Processors/Expressions/index" {
  71363. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  71364. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  71365. }
  71366. declare module "babylonjs/Engines/Processors/index" {
  71367. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  71368. export * from "babylonjs/Engines/Processors/Expressions/index";
  71369. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  71370. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  71371. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  71372. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  71373. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  71374. export * from "babylonjs/Engines/Processors/shaderProcessor";
  71375. }
  71376. declare module "babylonjs/Legacy/legacy" {
  71377. import * as Babylon from "babylonjs/index";
  71378. export * from "babylonjs/index";
  71379. }
  71380. declare module "babylonjs/Shaders/blur.fragment" {
  71381. /** @hidden */
  71382. export var blurPixelShader: {
  71383. name: string;
  71384. shader: string;
  71385. };
  71386. }
  71387. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  71388. /** @hidden */
  71389. export var pointCloudVertexDeclaration: {
  71390. name: string;
  71391. shader: string;
  71392. };
  71393. }
  71394. declare module "babylonjs" {
  71395. export * from "babylonjs/Legacy/legacy";
  71396. }
  71397. declare module BABYLON {
  71398. /** Alias type for value that can be null */
  71399. export type Nullable<T> = T | null;
  71400. /**
  71401. * Alias type for number that are floats
  71402. * @ignorenaming
  71403. */
  71404. export type float = number;
  71405. /**
  71406. * Alias type for number that are doubles.
  71407. * @ignorenaming
  71408. */
  71409. export type double = number;
  71410. /**
  71411. * Alias type for number that are integer
  71412. * @ignorenaming
  71413. */
  71414. export type int = number;
  71415. /** Alias type for number array or Float32Array */
  71416. export type FloatArray = number[] | Float32Array;
  71417. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  71418. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  71419. /**
  71420. * Alias for types that can be used by a Buffer or VertexBuffer.
  71421. */
  71422. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  71423. /**
  71424. * Alias type for primitive types
  71425. * @ignorenaming
  71426. */
  71427. type Primitive = undefined | null | boolean | string | number | Function;
  71428. /**
  71429. * Type modifier to make all the properties of an object Readonly
  71430. */
  71431. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  71432. /**
  71433. * Type modifier to make all the properties of an object Readonly recursively
  71434. */
  71435. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  71436. /**
  71437. * Type modifier to make object properties readonly.
  71438. */
  71439. export type DeepImmutableObject<T> = {
  71440. readonly [K in keyof T]: DeepImmutable<T[K]>;
  71441. };
  71442. /** @hidden */
  71443. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  71444. }
  71445. }
  71446. declare module BABYLON {
  71447. /**
  71448. * A class serves as a medium between the observable and its observers
  71449. */
  71450. export class EventState {
  71451. /**
  71452. * Create a new EventState
  71453. * @param mask defines the mask associated with this state
  71454. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  71455. * @param target defines the original target of the state
  71456. * @param currentTarget defines the current target of the state
  71457. */
  71458. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  71459. /**
  71460. * Initialize the current event state
  71461. * @param mask defines the mask associated with this state
  71462. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  71463. * @param target defines the original target of the state
  71464. * @param currentTarget defines the current target of the state
  71465. * @returns the current event state
  71466. */
  71467. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71468. /**
  71469. * An Observer can set this property to true to prevent subsequent observers of being notified
  71470. */
  71471. skipNextObservers: boolean;
  71472. /**
  71473. * Get the mask value that were used to trigger the event corresponding to this EventState object
  71474. */
  71475. mask: number;
  71476. /**
  71477. * The object that originally notified the event
  71478. */
  71479. target?: any;
  71480. /**
  71481. * The current object in the bubbling phase
  71482. */
  71483. currentTarget?: any;
  71484. /**
  71485. * This will be populated with the return value of the last function that was executed.
  71486. * If it is the first function in the callback chain it will be the event data.
  71487. */
  71488. lastReturnValue?: any;
  71489. }
  71490. /**
  71491. * Represent an Observer registered to a given Observable object.
  71492. */
  71493. export class Observer<T> {
  71494. /**
  71495. * Defines the callback to call when the observer is notified
  71496. */
  71497. callback: (eventData: T, eventState: EventState) => void;
  71498. /**
  71499. * Defines the mask of the observer (used to filter notifications)
  71500. */
  71501. mask: number;
  71502. /**
  71503. * Defines the current scope used to restore the JS context
  71504. */
  71505. scope: any;
  71506. /** @hidden */
  71507. _willBeUnregistered: boolean;
  71508. /**
  71509. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  71510. */
  71511. unregisterOnNextCall: boolean;
  71512. /**
  71513. * Creates a new observer
  71514. * @param callback defines the callback to call when the observer is notified
  71515. * @param mask defines the mask of the observer (used to filter notifications)
  71516. * @param scope defines the current scope used to restore the JS context
  71517. */
  71518. constructor(
  71519. /**
  71520. * Defines the callback to call when the observer is notified
  71521. */
  71522. callback: (eventData: T, eventState: EventState) => void,
  71523. /**
  71524. * Defines the mask of the observer (used to filter notifications)
  71525. */
  71526. mask: number,
  71527. /**
  71528. * Defines the current scope used to restore the JS context
  71529. */
  71530. scope?: any);
  71531. }
  71532. /**
  71533. * Represent a list of observers registered to multiple Observables object.
  71534. */
  71535. export class MultiObserver<T> {
  71536. private _observers;
  71537. private _observables;
  71538. /**
  71539. * Release associated resources
  71540. */
  71541. dispose(): void;
  71542. /**
  71543. * Raise a callback when one of the observable will notify
  71544. * @param observables defines a list of observables to watch
  71545. * @param callback defines the callback to call on notification
  71546. * @param mask defines the mask used to filter notifications
  71547. * @param scope defines the current scope used to restore the JS context
  71548. * @returns the new MultiObserver
  71549. */
  71550. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  71551. }
  71552. /**
  71553. * The Observable class is a simple implementation of the Observable pattern.
  71554. *
  71555. * 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.
  71556. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  71557. * 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).
  71558. * 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.
  71559. */
  71560. export class Observable<T> {
  71561. private _observers;
  71562. private _eventState;
  71563. private _onObserverAdded;
  71564. /**
  71565. * Gets the list of observers
  71566. */
  71567. get observers(): Array<Observer<T>>;
  71568. /**
  71569. * Creates a new observable
  71570. * @param onObserverAdded defines a callback to call when a new observer is added
  71571. */
  71572. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  71573. /**
  71574. * Create a new Observer with the specified callback
  71575. * @param callback the callback that will be executed for that Observer
  71576. * @param mask the mask used to filter observers
  71577. * @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.
  71578. * @param scope optional scope for the callback to be called from
  71579. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  71580. * @returns the new observer created for the callback
  71581. */
  71582. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  71583. /**
  71584. * Create a new Observer with the specified callback and unregisters after the next notification
  71585. * @param callback the callback that will be executed for that Observer
  71586. * @returns the new observer created for the callback
  71587. */
  71588. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  71589. /**
  71590. * Remove an Observer from the Observable object
  71591. * @param observer the instance of the Observer to remove
  71592. * @returns false if it doesn't belong to this Observable
  71593. */
  71594. remove(observer: Nullable<Observer<T>>): boolean;
  71595. /**
  71596. * Remove a callback from the Observable object
  71597. * @param callback the callback to remove
  71598. * @param scope optional scope. If used only the callbacks with this scope will be removed
  71599. * @returns false if it doesn't belong to this Observable
  71600. */
  71601. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  71602. private _deferUnregister;
  71603. private _remove;
  71604. /**
  71605. * Moves the observable to the top of the observer list making it get called first when notified
  71606. * @param observer the observer to move
  71607. */
  71608. makeObserverTopPriority(observer: Observer<T>): void;
  71609. /**
  71610. * Moves the observable to the bottom of the observer list making it get called last when notified
  71611. * @param observer the observer to move
  71612. */
  71613. makeObserverBottomPriority(observer: Observer<T>): void;
  71614. /**
  71615. * Notify all Observers by calling their respective callback with the given data
  71616. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  71617. * @param eventData defines the data to send to all observers
  71618. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  71619. * @param target defines the original target of the state
  71620. * @param currentTarget defines the current target of the state
  71621. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  71622. */
  71623. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  71624. /**
  71625. * Calling this will execute each callback, expecting it to be a promise or return a value.
  71626. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  71627. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  71628. * and it is crucial that all callbacks will be executed.
  71629. * The order of the callbacks is kept, callbacks are not executed parallel.
  71630. *
  71631. * @param eventData The data to be sent to each callback
  71632. * @param mask is used to filter observers defaults to -1
  71633. * @param target defines the callback target (see EventState)
  71634. * @param currentTarget defines he current object in the bubbling phase
  71635. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  71636. */
  71637. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  71638. /**
  71639. * Notify a specific observer
  71640. * @param observer defines the observer to notify
  71641. * @param eventData defines the data to be sent to each callback
  71642. * @param mask is used to filter observers defaults to -1
  71643. */
  71644. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  71645. /**
  71646. * Gets a boolean indicating if the observable has at least one observer
  71647. * @returns true is the Observable has at least one Observer registered
  71648. */
  71649. hasObservers(): boolean;
  71650. /**
  71651. * Clear the list of observers
  71652. */
  71653. clear(): void;
  71654. /**
  71655. * Clone the current observable
  71656. * @returns a new observable
  71657. */
  71658. clone(): Observable<T>;
  71659. /**
  71660. * Does this observable handles observer registered with a given mask
  71661. * @param mask defines the mask to be tested
  71662. * @return whether or not one observer registered with the given mask is handeled
  71663. **/
  71664. hasSpecificMask(mask?: number): boolean;
  71665. }
  71666. }
  71667. declare module BABYLON {
  71668. /**
  71669. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  71670. * Babylon.js
  71671. */
  71672. export class DomManagement {
  71673. /**
  71674. * Checks if the window object exists
  71675. * @returns true if the window object exists
  71676. */
  71677. static IsWindowObjectExist(): boolean;
  71678. /**
  71679. * Checks if the navigator object exists
  71680. * @returns true if the navigator object exists
  71681. */
  71682. static IsNavigatorAvailable(): boolean;
  71683. /**
  71684. * Extracts text content from a DOM element hierarchy
  71685. * @param element defines the root element
  71686. * @returns a string
  71687. */
  71688. static GetDOMTextContent(element: HTMLElement): string;
  71689. }
  71690. }
  71691. declare module BABYLON {
  71692. /**
  71693. * Logger used througouht the application to allow configuration of
  71694. * the log level required for the messages.
  71695. */
  71696. export class Logger {
  71697. /**
  71698. * No log
  71699. */
  71700. static readonly NoneLogLevel: number;
  71701. /**
  71702. * Only message logs
  71703. */
  71704. static readonly MessageLogLevel: number;
  71705. /**
  71706. * Only warning logs
  71707. */
  71708. static readonly WarningLogLevel: number;
  71709. /**
  71710. * Only error logs
  71711. */
  71712. static readonly ErrorLogLevel: number;
  71713. /**
  71714. * All logs
  71715. */
  71716. static readonly AllLogLevel: number;
  71717. private static _LogCache;
  71718. /**
  71719. * Gets a value indicating the number of loading errors
  71720. * @ignorenaming
  71721. */
  71722. static errorsCount: number;
  71723. /**
  71724. * Callback called when a new log is added
  71725. */
  71726. static OnNewCacheEntry: (entry: string) => void;
  71727. private static _AddLogEntry;
  71728. private static _FormatMessage;
  71729. private static _LogDisabled;
  71730. private static _LogEnabled;
  71731. private static _WarnDisabled;
  71732. private static _WarnEnabled;
  71733. private static _ErrorDisabled;
  71734. private static _ErrorEnabled;
  71735. /**
  71736. * Log a message to the console
  71737. */
  71738. static Log: (message: string) => void;
  71739. /**
  71740. * Write a warning message to the console
  71741. */
  71742. static Warn: (message: string) => void;
  71743. /**
  71744. * Write an error message to the console
  71745. */
  71746. static Error: (message: string) => void;
  71747. /**
  71748. * Gets current log cache (list of logs)
  71749. */
  71750. static get LogCache(): string;
  71751. /**
  71752. * Clears the log cache
  71753. */
  71754. static ClearLogCache(): void;
  71755. /**
  71756. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  71757. */
  71758. static set LogLevels(level: number);
  71759. }
  71760. }
  71761. declare module BABYLON {
  71762. /** @hidden */
  71763. export class _TypeStore {
  71764. /** @hidden */
  71765. static RegisteredTypes: {
  71766. [key: string]: Object;
  71767. };
  71768. /** @hidden */
  71769. static GetClass(fqdn: string): any;
  71770. }
  71771. }
  71772. declare module BABYLON {
  71773. /**
  71774. * Helper to manipulate strings
  71775. */
  71776. export class StringTools {
  71777. /**
  71778. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71779. * @param str Source string
  71780. * @param suffix Suffix to search for in the source string
  71781. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71782. */
  71783. static EndsWith(str: string, suffix: string): boolean;
  71784. /**
  71785. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71786. * @param str Source string
  71787. * @param suffix Suffix to search for in the source string
  71788. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71789. */
  71790. static StartsWith(str: string, suffix: string): boolean;
  71791. /**
  71792. * Decodes a buffer into a string
  71793. * @param buffer The buffer to decode
  71794. * @returns The decoded string
  71795. */
  71796. static Decode(buffer: Uint8Array | Uint16Array): string;
  71797. /**
  71798. * Encode a buffer to a base64 string
  71799. * @param buffer defines the buffer to encode
  71800. * @returns the encoded string
  71801. */
  71802. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  71803. }
  71804. }
  71805. declare module BABYLON {
  71806. /**
  71807. * Class containing a set of static utilities functions for deep copy.
  71808. */
  71809. export class DeepCopier {
  71810. /**
  71811. * Tries to copy an object by duplicating every property
  71812. * @param source defines the source object
  71813. * @param destination defines the target object
  71814. * @param doNotCopyList defines a list of properties to avoid
  71815. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  71816. */
  71817. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  71818. }
  71819. }
  71820. declare module BABYLON {
  71821. /**
  71822. * Class containing a set of static utilities functions for precision date
  71823. */
  71824. export class PrecisionDate {
  71825. /**
  71826. * Gets either window.performance.now() if supported or Date.now() else
  71827. */
  71828. static get Now(): number;
  71829. }
  71830. }
  71831. declare module BABYLON {
  71832. /** @hidden */
  71833. export class _DevTools {
  71834. static WarnImport(name: string): string;
  71835. }
  71836. }
  71837. declare module BABYLON {
  71838. /**
  71839. * Interface used to define the mechanism to get data from the network
  71840. */
  71841. export interface IWebRequest {
  71842. /**
  71843. * Returns client's response url
  71844. */
  71845. responseURL: string;
  71846. /**
  71847. * Returns client's status
  71848. */
  71849. status: number;
  71850. /**
  71851. * Returns client's status as a text
  71852. */
  71853. statusText: string;
  71854. }
  71855. }
  71856. declare module BABYLON {
  71857. /**
  71858. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71859. */
  71860. export class WebRequest implements IWebRequest {
  71861. private _xhr;
  71862. /**
  71863. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71864. * i.e. when loading files, where the server/service expects an Authorization header
  71865. */
  71866. static CustomRequestHeaders: {
  71867. [key: string]: string;
  71868. };
  71869. /**
  71870. * Add callback functions in this array to update all the requests before they get sent to the network
  71871. */
  71872. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71873. private _injectCustomRequestHeaders;
  71874. /**
  71875. * Gets or sets a function to be called when loading progress changes
  71876. */
  71877. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71878. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71879. /**
  71880. * Returns client's state
  71881. */
  71882. get readyState(): number;
  71883. /**
  71884. * Returns client's status
  71885. */
  71886. get status(): number;
  71887. /**
  71888. * Returns client's status as a text
  71889. */
  71890. get statusText(): string;
  71891. /**
  71892. * Returns client's response
  71893. */
  71894. get response(): any;
  71895. /**
  71896. * Returns client's response url
  71897. */
  71898. get responseURL(): string;
  71899. /**
  71900. * Returns client's response as text
  71901. */
  71902. get responseText(): string;
  71903. /**
  71904. * Gets or sets the expected response type
  71905. */
  71906. get responseType(): XMLHttpRequestResponseType;
  71907. set responseType(value: XMLHttpRequestResponseType);
  71908. /** @hidden */
  71909. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71910. /** @hidden */
  71911. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71912. /**
  71913. * Cancels any network activity
  71914. */
  71915. abort(): void;
  71916. /**
  71917. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71918. * @param body defines an optional request body
  71919. */
  71920. send(body?: Document | BodyInit | null): void;
  71921. /**
  71922. * Sets the request method, request URL
  71923. * @param method defines the method to use (GET, POST, etc..)
  71924. * @param url defines the url to connect with
  71925. */
  71926. open(method: string, url: string): void;
  71927. /**
  71928. * Sets the value of a request header.
  71929. * @param name The name of the header whose value is to be set
  71930. * @param value The value to set as the body of the header
  71931. */
  71932. setRequestHeader(name: string, value: string): void;
  71933. /**
  71934. * Get the string containing the text of a particular header's value.
  71935. * @param name The name of the header
  71936. * @returns The string containing the text of the given header name
  71937. */
  71938. getResponseHeader(name: string): Nullable<string>;
  71939. }
  71940. }
  71941. declare module BABYLON {
  71942. /**
  71943. * File request interface
  71944. */
  71945. export interface IFileRequest {
  71946. /**
  71947. * Raised when the request is complete (success or error).
  71948. */
  71949. onCompleteObservable: Observable<IFileRequest>;
  71950. /**
  71951. * Aborts the request for a file.
  71952. */
  71953. abort: () => void;
  71954. }
  71955. }
  71956. declare module BABYLON {
  71957. /**
  71958. * Define options used to create a render target texture
  71959. */
  71960. export class RenderTargetCreationOptions {
  71961. /**
  71962. * Specifies is mipmaps must be generated
  71963. */
  71964. generateMipMaps?: boolean;
  71965. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71966. generateDepthBuffer?: boolean;
  71967. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71968. generateStencilBuffer?: boolean;
  71969. /** Defines texture type (int by default) */
  71970. type?: number;
  71971. /** Defines sampling mode (trilinear by default) */
  71972. samplingMode?: number;
  71973. /** Defines format (RGBA by default) */
  71974. format?: number;
  71975. }
  71976. }
  71977. declare module BABYLON {
  71978. /**
  71979. * @hidden
  71980. **/
  71981. export class _TimeToken {
  71982. _startTimeQuery: Nullable<WebGLQuery>;
  71983. _endTimeQuery: Nullable<WebGLQuery>;
  71984. _timeElapsedQuery: Nullable<WebGLQuery>;
  71985. _timeElapsedQueryEnded: boolean;
  71986. }
  71987. }
  71988. declare module BABYLON {
  71989. /** Defines the cross module used constants to avoid circular dependncies */
  71990. export class Constants {
  71991. /** Defines that alpha blending is disabled */
  71992. static readonly ALPHA_DISABLE: number;
  71993. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  71994. static readonly ALPHA_ADD: number;
  71995. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71996. static readonly ALPHA_COMBINE: number;
  71997. /** Defines that alpha blending is DEST - SRC * DEST */
  71998. static readonly ALPHA_SUBTRACT: number;
  71999. /** Defines that alpha blending is SRC * DEST */
  72000. static readonly ALPHA_MULTIPLY: number;
  72001. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  72002. static readonly ALPHA_MAXIMIZED: number;
  72003. /** Defines that alpha blending is SRC + DEST */
  72004. static readonly ALPHA_ONEONE: number;
  72005. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  72006. static readonly ALPHA_PREMULTIPLIED: number;
  72007. /**
  72008. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  72009. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  72010. */
  72011. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  72012. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  72013. static readonly ALPHA_INTERPOLATE: number;
  72014. /**
  72015. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  72016. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  72017. */
  72018. static readonly ALPHA_SCREENMODE: number;
  72019. /**
  72020. * Defines that alpha blending is SRC + DST
  72021. * Alpha will be set to SRC ALPHA + DST ALPHA
  72022. */
  72023. static readonly ALPHA_ONEONE_ONEONE: number;
  72024. /**
  72025. * Defines that alpha blending is SRC * DST ALPHA + DST
  72026. * Alpha will be set to 0
  72027. */
  72028. static readonly ALPHA_ALPHATOCOLOR: number;
  72029. /**
  72030. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  72031. */
  72032. static readonly ALPHA_REVERSEONEMINUS: number;
  72033. /**
  72034. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  72035. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  72036. */
  72037. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  72038. /**
  72039. * Defines that alpha blending is SRC + DST
  72040. * Alpha will be set to SRC ALPHA
  72041. */
  72042. static readonly ALPHA_ONEONE_ONEZERO: number;
  72043. /**
  72044. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  72045. * Alpha will be set to DST ALPHA
  72046. */
  72047. static readonly ALPHA_EXCLUSION: number;
  72048. /** Defines that alpha blending equation a SUM */
  72049. static readonly ALPHA_EQUATION_ADD: number;
  72050. /** Defines that alpha blending equation a SUBSTRACTION */
  72051. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  72052. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  72053. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  72054. /** Defines that alpha blending equation a MAX operation */
  72055. static readonly ALPHA_EQUATION_MAX: number;
  72056. /** Defines that alpha blending equation a MIN operation */
  72057. static readonly ALPHA_EQUATION_MIN: number;
  72058. /**
  72059. * Defines that alpha blending equation a DARKEN operation:
  72060. * It takes the min of the src and sums the alpha channels.
  72061. */
  72062. static readonly ALPHA_EQUATION_DARKEN: number;
  72063. /** Defines that the ressource is not delayed*/
  72064. static readonly DELAYLOADSTATE_NONE: number;
  72065. /** Defines that the ressource was successfully delay loaded */
  72066. static readonly DELAYLOADSTATE_LOADED: number;
  72067. /** Defines that the ressource is currently delay loading */
  72068. static readonly DELAYLOADSTATE_LOADING: number;
  72069. /** Defines that the ressource is delayed and has not started loading */
  72070. static readonly DELAYLOADSTATE_NOTLOADED: number;
  72071. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  72072. static readonly NEVER: number;
  72073. /** 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 */
  72074. static readonly ALWAYS: number;
  72075. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  72076. static readonly LESS: number;
  72077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  72078. static readonly EQUAL: number;
  72079. /** 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 */
  72080. static readonly LEQUAL: number;
  72081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  72082. static readonly GREATER: number;
  72083. /** 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 */
  72084. static readonly GEQUAL: number;
  72085. /** 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 */
  72086. static readonly NOTEQUAL: number;
  72087. /** Passed to stencilOperation to specify that stencil value must be kept */
  72088. static readonly KEEP: number;
  72089. /** Passed to stencilOperation to specify that stencil value must be replaced */
  72090. static readonly REPLACE: number;
  72091. /** Passed to stencilOperation to specify that stencil value must be incremented */
  72092. static readonly INCR: number;
  72093. /** Passed to stencilOperation to specify that stencil value must be decremented */
  72094. static readonly DECR: number;
  72095. /** Passed to stencilOperation to specify that stencil value must be inverted */
  72096. static readonly INVERT: number;
  72097. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  72098. static readonly INCR_WRAP: number;
  72099. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  72100. static readonly DECR_WRAP: number;
  72101. /** Texture is not repeating outside of 0..1 UVs */
  72102. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  72103. /** Texture is repeating outside of 0..1 UVs */
  72104. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  72105. /** Texture is repeating and mirrored */
  72106. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  72107. /** ALPHA */
  72108. static readonly TEXTUREFORMAT_ALPHA: number;
  72109. /** LUMINANCE */
  72110. static readonly TEXTUREFORMAT_LUMINANCE: number;
  72111. /** LUMINANCE_ALPHA */
  72112. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  72113. /** RGB */
  72114. static readonly TEXTUREFORMAT_RGB: number;
  72115. /** RGBA */
  72116. static readonly TEXTUREFORMAT_RGBA: number;
  72117. /** RED */
  72118. static readonly TEXTUREFORMAT_RED: number;
  72119. /** RED (2nd reference) */
  72120. static readonly TEXTUREFORMAT_R: number;
  72121. /** RG */
  72122. static readonly TEXTUREFORMAT_RG: number;
  72123. /** RED_INTEGER */
  72124. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  72125. /** RED_INTEGER (2nd reference) */
  72126. static readonly TEXTUREFORMAT_R_INTEGER: number;
  72127. /** RG_INTEGER */
  72128. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  72129. /** RGB_INTEGER */
  72130. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  72131. /** RGBA_INTEGER */
  72132. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  72133. /** UNSIGNED_BYTE */
  72134. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  72135. /** UNSIGNED_BYTE (2nd reference) */
  72136. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  72137. /** FLOAT */
  72138. static readonly TEXTURETYPE_FLOAT: number;
  72139. /** HALF_FLOAT */
  72140. static readonly TEXTURETYPE_HALF_FLOAT: number;
  72141. /** BYTE */
  72142. static readonly TEXTURETYPE_BYTE: number;
  72143. /** SHORT */
  72144. static readonly TEXTURETYPE_SHORT: number;
  72145. /** UNSIGNED_SHORT */
  72146. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  72147. /** INT */
  72148. static readonly TEXTURETYPE_INT: number;
  72149. /** UNSIGNED_INT */
  72150. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  72151. /** UNSIGNED_SHORT_4_4_4_4 */
  72152. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  72153. /** UNSIGNED_SHORT_5_5_5_1 */
  72154. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  72155. /** UNSIGNED_SHORT_5_6_5 */
  72156. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  72157. /** UNSIGNED_INT_2_10_10_10_REV */
  72158. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  72159. /** UNSIGNED_INT_24_8 */
  72160. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  72161. /** UNSIGNED_INT_10F_11F_11F_REV */
  72162. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  72163. /** UNSIGNED_INT_5_9_9_9_REV */
  72164. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  72165. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  72166. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72167. /** nearest is mag = nearest and min = nearest and no mip */
  72168. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  72169. /** mag = nearest and min = nearest and mip = none */
  72170. static readonly TEXTURE_NEAREST_NEAREST: number;
  72171. /** Bilinear is mag = linear and min = linear and no mip */
  72172. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  72173. /** mag = linear and min = linear and mip = none */
  72174. static readonly TEXTURE_LINEAR_LINEAR: number;
  72175. /** Trilinear is mag = linear and min = linear and mip = linear */
  72176. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  72177. /** Trilinear is mag = linear and min = linear and mip = linear */
  72178. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  72179. /** mag = nearest and min = nearest and mip = nearest */
  72180. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  72181. /** mag = nearest and min = linear and mip = nearest */
  72182. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  72183. /** mag = nearest and min = linear and mip = linear */
  72184. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  72185. /** mag = nearest and min = linear and mip = none */
  72186. static readonly TEXTURE_NEAREST_LINEAR: number;
  72187. /** nearest is mag = nearest and min = nearest and mip = linear */
  72188. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  72189. /** mag = linear and min = nearest and mip = nearest */
  72190. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  72191. /** mag = linear and min = nearest and mip = linear */
  72192. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  72193. /** Bilinear is mag = linear and min = linear and mip = nearest */
  72194. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  72195. /** mag = linear and min = nearest and mip = none */
  72196. static readonly TEXTURE_LINEAR_NEAREST: number;
  72197. /** Explicit coordinates mode */
  72198. static readonly TEXTURE_EXPLICIT_MODE: number;
  72199. /** Spherical coordinates mode */
  72200. static readonly TEXTURE_SPHERICAL_MODE: number;
  72201. /** Planar coordinates mode */
  72202. static readonly TEXTURE_PLANAR_MODE: number;
  72203. /** Cubic coordinates mode */
  72204. static readonly TEXTURE_CUBIC_MODE: number;
  72205. /** Projection coordinates mode */
  72206. static readonly TEXTURE_PROJECTION_MODE: number;
  72207. /** Skybox coordinates mode */
  72208. static readonly TEXTURE_SKYBOX_MODE: number;
  72209. /** Inverse Cubic coordinates mode */
  72210. static readonly TEXTURE_INVCUBIC_MODE: number;
  72211. /** Equirectangular coordinates mode */
  72212. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  72213. /** Equirectangular Fixed coordinates mode */
  72214. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  72215. /** Equirectangular Fixed Mirrored coordinates mode */
  72216. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  72217. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  72218. static readonly SCALEMODE_FLOOR: number;
  72219. /** Defines that texture rescaling will look for the nearest power of 2 size */
  72220. static readonly SCALEMODE_NEAREST: number;
  72221. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  72222. static readonly SCALEMODE_CEILING: number;
  72223. /**
  72224. * The dirty texture flag value
  72225. */
  72226. static readonly MATERIAL_TextureDirtyFlag: number;
  72227. /**
  72228. * The dirty light flag value
  72229. */
  72230. static readonly MATERIAL_LightDirtyFlag: number;
  72231. /**
  72232. * The dirty fresnel flag value
  72233. */
  72234. static readonly MATERIAL_FresnelDirtyFlag: number;
  72235. /**
  72236. * The dirty attribute flag value
  72237. */
  72238. static readonly MATERIAL_AttributesDirtyFlag: number;
  72239. /**
  72240. * The dirty misc flag value
  72241. */
  72242. static readonly MATERIAL_MiscDirtyFlag: number;
  72243. /**
  72244. * The all dirty flag value
  72245. */
  72246. static readonly MATERIAL_AllDirtyFlag: number;
  72247. /**
  72248. * Returns the triangle fill mode
  72249. */
  72250. static readonly MATERIAL_TriangleFillMode: number;
  72251. /**
  72252. * Returns the wireframe mode
  72253. */
  72254. static readonly MATERIAL_WireFrameFillMode: number;
  72255. /**
  72256. * Returns the point fill mode
  72257. */
  72258. static readonly MATERIAL_PointFillMode: number;
  72259. /**
  72260. * Returns the point list draw mode
  72261. */
  72262. static readonly MATERIAL_PointListDrawMode: number;
  72263. /**
  72264. * Returns the line list draw mode
  72265. */
  72266. static readonly MATERIAL_LineListDrawMode: number;
  72267. /**
  72268. * Returns the line loop draw mode
  72269. */
  72270. static readonly MATERIAL_LineLoopDrawMode: number;
  72271. /**
  72272. * Returns the line strip draw mode
  72273. */
  72274. static readonly MATERIAL_LineStripDrawMode: number;
  72275. /**
  72276. * Returns the triangle strip draw mode
  72277. */
  72278. static readonly MATERIAL_TriangleStripDrawMode: number;
  72279. /**
  72280. * Returns the triangle fan draw mode
  72281. */
  72282. static readonly MATERIAL_TriangleFanDrawMode: number;
  72283. /**
  72284. * Stores the clock-wise side orientation
  72285. */
  72286. static readonly MATERIAL_ClockWiseSideOrientation: number;
  72287. /**
  72288. * Stores the counter clock-wise side orientation
  72289. */
  72290. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  72291. /**
  72292. * Nothing
  72293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72294. */
  72295. static readonly ACTION_NothingTrigger: number;
  72296. /**
  72297. * On pick
  72298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72299. */
  72300. static readonly ACTION_OnPickTrigger: number;
  72301. /**
  72302. * On left pick
  72303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72304. */
  72305. static readonly ACTION_OnLeftPickTrigger: number;
  72306. /**
  72307. * On right pick
  72308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72309. */
  72310. static readonly ACTION_OnRightPickTrigger: number;
  72311. /**
  72312. * On center pick
  72313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72314. */
  72315. static readonly ACTION_OnCenterPickTrigger: number;
  72316. /**
  72317. * On pick down
  72318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72319. */
  72320. static readonly ACTION_OnPickDownTrigger: number;
  72321. /**
  72322. * On double pick
  72323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72324. */
  72325. static readonly ACTION_OnDoublePickTrigger: number;
  72326. /**
  72327. * On pick up
  72328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72329. */
  72330. static readonly ACTION_OnPickUpTrigger: number;
  72331. /**
  72332. * On pick out.
  72333. * This trigger will only be raised if you also declared a OnPickDown
  72334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72335. */
  72336. static readonly ACTION_OnPickOutTrigger: number;
  72337. /**
  72338. * On long press
  72339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72340. */
  72341. static readonly ACTION_OnLongPressTrigger: number;
  72342. /**
  72343. * On pointer over
  72344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72345. */
  72346. static readonly ACTION_OnPointerOverTrigger: number;
  72347. /**
  72348. * On pointer out
  72349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72350. */
  72351. static readonly ACTION_OnPointerOutTrigger: number;
  72352. /**
  72353. * On every frame
  72354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72355. */
  72356. static readonly ACTION_OnEveryFrameTrigger: number;
  72357. /**
  72358. * On intersection enter
  72359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72360. */
  72361. static readonly ACTION_OnIntersectionEnterTrigger: number;
  72362. /**
  72363. * On intersection exit
  72364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72365. */
  72366. static readonly ACTION_OnIntersectionExitTrigger: number;
  72367. /**
  72368. * On key down
  72369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72370. */
  72371. static readonly ACTION_OnKeyDownTrigger: number;
  72372. /**
  72373. * On key up
  72374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72375. */
  72376. static readonly ACTION_OnKeyUpTrigger: number;
  72377. /**
  72378. * Billboard mode will only apply to Y axis
  72379. */
  72380. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  72381. /**
  72382. * Billboard mode will apply to all axes
  72383. */
  72384. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  72385. /**
  72386. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72387. */
  72388. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  72389. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  72390. * Test order :
  72391. * Is the bounding sphere outside the frustum ?
  72392. * If not, are the bounding box vertices outside the frustum ?
  72393. * It not, then the cullable object is in the frustum.
  72394. */
  72395. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  72396. /** Culling strategy : Bounding Sphere Only.
  72397. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  72398. * It's also less accurate than the standard because some not visible objects can still be selected.
  72399. * Test : is the bounding sphere outside the frustum ?
  72400. * If not, then the cullable object is in the frustum.
  72401. */
  72402. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  72403. /** Culling strategy : Optimistic Inclusion.
  72404. * This in an inclusion test first, then the standard exclusion test.
  72405. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  72406. * 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.
  72407. * Anyway, it's as accurate as the standard strategy.
  72408. * Test :
  72409. * Is the cullable object bounding sphere center in the frustum ?
  72410. * If not, apply the default culling strategy.
  72411. */
  72412. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  72413. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  72414. * This in an inclusion test first, then the bounding sphere only exclusion test.
  72415. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  72416. * 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.
  72417. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  72418. * Test :
  72419. * Is the cullable object bounding sphere center in the frustum ?
  72420. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  72421. */
  72422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  72423. /**
  72424. * No logging while loading
  72425. */
  72426. static readonly SCENELOADER_NO_LOGGING: number;
  72427. /**
  72428. * Minimal logging while loading
  72429. */
  72430. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  72431. /**
  72432. * Summary logging while loading
  72433. */
  72434. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  72435. /**
  72436. * Detailled logging while loading
  72437. */
  72438. static readonly SCENELOADER_DETAILED_LOGGING: number;
  72439. }
  72440. }
  72441. declare module BABYLON {
  72442. /**
  72443. * This represents the required contract to create a new type of texture loader.
  72444. */
  72445. export interface IInternalTextureLoader {
  72446. /**
  72447. * Defines wether the loader supports cascade loading the different faces.
  72448. */
  72449. supportCascades: boolean;
  72450. /**
  72451. * This returns if the loader support the current file information.
  72452. * @param extension defines the file extension of the file being loaded
  72453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72454. * @param fallback defines the fallback internal texture if any
  72455. * @param isBase64 defines whether the texture is encoded as a base64
  72456. * @param isBuffer defines whether the texture data are stored as a buffer
  72457. * @returns true if the loader can load the specified file
  72458. */
  72459. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72460. /**
  72461. * Transform the url before loading if required.
  72462. * @param rootUrl the url of the texture
  72463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72464. * @returns the transformed texture
  72465. */
  72466. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72467. /**
  72468. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72469. * @param rootUrl the url of the texture
  72470. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72471. * @returns the fallback texture
  72472. */
  72473. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72474. /**
  72475. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72476. * @param data contains the texture data
  72477. * @param texture defines the BabylonJS internal texture
  72478. * @param createPolynomials will be true if polynomials have been requested
  72479. * @param onLoad defines the callback to trigger once the texture is ready
  72480. * @param onError defines the callback to trigger in case of error
  72481. */
  72482. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72483. /**
  72484. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72485. * @param data contains the texture data
  72486. * @param texture defines the BabylonJS internal texture
  72487. * @param callback defines the method to call once ready to upload
  72488. */
  72489. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72490. }
  72491. }
  72492. declare module BABYLON {
  72493. /**
  72494. * Class used to store and describe the pipeline context associated with an effect
  72495. */
  72496. export interface IPipelineContext {
  72497. /**
  72498. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  72499. */
  72500. isAsync: boolean;
  72501. /**
  72502. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  72503. */
  72504. isReady: boolean;
  72505. /** @hidden */
  72506. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  72507. }
  72508. }
  72509. declare module BABYLON {
  72510. /**
  72511. * Class used to store gfx data (like WebGLBuffer)
  72512. */
  72513. export class DataBuffer {
  72514. /**
  72515. * Gets or sets the number of objects referencing this buffer
  72516. */
  72517. references: number;
  72518. /** Gets or sets the size of the underlying buffer */
  72519. capacity: number;
  72520. /**
  72521. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  72522. */
  72523. is32Bits: boolean;
  72524. /**
  72525. * Gets the underlying buffer
  72526. */
  72527. get underlyingResource(): any;
  72528. }
  72529. }
  72530. declare module BABYLON {
  72531. /** @hidden */
  72532. export interface IShaderProcessor {
  72533. attributeProcessor?: (attribute: string) => string;
  72534. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  72535. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  72536. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  72537. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  72538. lineProcessor?: (line: string, isFragment: boolean) => string;
  72539. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  72540. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  72541. }
  72542. }
  72543. declare module BABYLON {
  72544. /** @hidden */
  72545. export interface ProcessingOptions {
  72546. defines: string[];
  72547. indexParameters: any;
  72548. isFragment: boolean;
  72549. shouldUseHighPrecisionShader: boolean;
  72550. supportsUniformBuffers: boolean;
  72551. shadersRepository: string;
  72552. includesShadersStore: {
  72553. [key: string]: string;
  72554. };
  72555. processor?: IShaderProcessor;
  72556. version: string;
  72557. platformName: string;
  72558. lookForClosingBracketForUniformBuffer?: boolean;
  72559. }
  72560. }
  72561. declare module BABYLON {
  72562. /** @hidden */
  72563. export class ShaderCodeNode {
  72564. line: string;
  72565. children: ShaderCodeNode[];
  72566. additionalDefineKey?: string;
  72567. additionalDefineValue?: string;
  72568. isValid(preprocessors: {
  72569. [key: string]: string;
  72570. }): boolean;
  72571. process(preprocessors: {
  72572. [key: string]: string;
  72573. }, options: ProcessingOptions): string;
  72574. }
  72575. }
  72576. declare module BABYLON {
  72577. /** @hidden */
  72578. export class ShaderCodeCursor {
  72579. private _lines;
  72580. lineIndex: number;
  72581. get currentLine(): string;
  72582. get canRead(): boolean;
  72583. set lines(value: string[]);
  72584. }
  72585. }
  72586. declare module BABYLON {
  72587. /** @hidden */
  72588. export class ShaderCodeConditionNode extends ShaderCodeNode {
  72589. process(preprocessors: {
  72590. [key: string]: string;
  72591. }, options: ProcessingOptions): string;
  72592. }
  72593. }
  72594. declare module BABYLON {
  72595. /** @hidden */
  72596. export class ShaderDefineExpression {
  72597. isTrue(preprocessors: {
  72598. [key: string]: string;
  72599. }): boolean;
  72600. }
  72601. }
  72602. declare module BABYLON {
  72603. /** @hidden */
  72604. export class ShaderCodeTestNode extends ShaderCodeNode {
  72605. testExpression: ShaderDefineExpression;
  72606. isValid(preprocessors: {
  72607. [key: string]: string;
  72608. }): boolean;
  72609. }
  72610. }
  72611. declare module BABYLON {
  72612. /** @hidden */
  72613. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  72614. define: string;
  72615. not: boolean;
  72616. constructor(define: string, not?: boolean);
  72617. isTrue(preprocessors: {
  72618. [key: string]: string;
  72619. }): boolean;
  72620. }
  72621. }
  72622. declare module BABYLON {
  72623. /** @hidden */
  72624. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  72625. leftOperand: ShaderDefineExpression;
  72626. rightOperand: ShaderDefineExpression;
  72627. isTrue(preprocessors: {
  72628. [key: string]: string;
  72629. }): boolean;
  72630. }
  72631. }
  72632. declare module BABYLON {
  72633. /** @hidden */
  72634. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  72635. leftOperand: ShaderDefineExpression;
  72636. rightOperand: ShaderDefineExpression;
  72637. isTrue(preprocessors: {
  72638. [key: string]: string;
  72639. }): boolean;
  72640. }
  72641. }
  72642. declare module BABYLON {
  72643. /** @hidden */
  72644. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  72645. define: string;
  72646. operand: string;
  72647. testValue: string;
  72648. constructor(define: string, operand: string, testValue: string);
  72649. isTrue(preprocessors: {
  72650. [key: string]: string;
  72651. }): boolean;
  72652. }
  72653. }
  72654. declare module BABYLON {
  72655. /**
  72656. * Class used to enable access to offline support
  72657. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72658. */
  72659. export interface IOfflineProvider {
  72660. /**
  72661. * Gets a boolean indicating if scene must be saved in the database
  72662. */
  72663. enableSceneOffline: boolean;
  72664. /**
  72665. * Gets a boolean indicating if textures must be saved in the database
  72666. */
  72667. enableTexturesOffline: boolean;
  72668. /**
  72669. * Open the offline support and make it available
  72670. * @param successCallback defines the callback to call on success
  72671. * @param errorCallback defines the callback to call on error
  72672. */
  72673. open(successCallback: () => void, errorCallback: () => void): void;
  72674. /**
  72675. * Loads an image from the offline support
  72676. * @param url defines the url to load from
  72677. * @param image defines the target DOM image
  72678. */
  72679. loadImage(url: string, image: HTMLImageElement): void;
  72680. /**
  72681. * Loads a file from offline support
  72682. * @param url defines the URL to load from
  72683. * @param sceneLoaded defines a callback to call on success
  72684. * @param progressCallBack defines a callback to call when progress changed
  72685. * @param errorCallback defines a callback to call on error
  72686. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72687. */
  72688. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72689. }
  72690. }
  72691. declare module BABYLON {
  72692. /**
  72693. * Class used to help managing file picking and drag'n'drop
  72694. * File Storage
  72695. */
  72696. export class FilesInputStore {
  72697. /**
  72698. * List of files ready to be loaded
  72699. */
  72700. static FilesToLoad: {
  72701. [key: string]: File;
  72702. };
  72703. }
  72704. }
  72705. declare module BABYLON {
  72706. /**
  72707. * Class used to define a retry strategy when error happens while loading assets
  72708. */
  72709. export class RetryStrategy {
  72710. /**
  72711. * Function used to defines an exponential back off strategy
  72712. * @param maxRetries defines the maximum number of retries (3 by default)
  72713. * @param baseInterval defines the interval between retries
  72714. * @returns the strategy function to use
  72715. */
  72716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  72717. }
  72718. }
  72719. declare module BABYLON {
  72720. /**
  72721. * @ignore
  72722. * Application error to support additional information when loading a file
  72723. */
  72724. export abstract class BaseError extends Error {
  72725. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  72726. }
  72727. }
  72728. declare module BABYLON {
  72729. /** @ignore */
  72730. export class LoadFileError extends BaseError {
  72731. request?: WebRequest;
  72732. file?: File;
  72733. /**
  72734. * Creates a new LoadFileError
  72735. * @param message defines the message of the error
  72736. * @param request defines the optional web request
  72737. * @param file defines the optional file
  72738. */
  72739. constructor(message: string, object?: WebRequest | File);
  72740. }
  72741. /** @ignore */
  72742. export class RequestFileError extends BaseError {
  72743. request: WebRequest;
  72744. /**
  72745. * Creates a new LoadFileError
  72746. * @param message defines the message of the error
  72747. * @param request defines the optional web request
  72748. */
  72749. constructor(message: string, request: WebRequest);
  72750. }
  72751. /** @ignore */
  72752. export class ReadFileError extends BaseError {
  72753. file: File;
  72754. /**
  72755. * Creates a new ReadFileError
  72756. * @param message defines the message of the error
  72757. * @param file defines the optional file
  72758. */
  72759. constructor(message: string, file: File);
  72760. }
  72761. /**
  72762. * @hidden
  72763. */
  72764. export class FileTools {
  72765. /**
  72766. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  72767. */
  72768. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  72769. /**
  72770. * Gets or sets the base URL to use to load assets
  72771. */
  72772. static BaseUrl: string;
  72773. /**
  72774. * Default behaviour for cors in the application.
  72775. * It can be a string if the expected behavior is identical in the entire app.
  72776. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  72777. */
  72778. static CorsBehavior: string | ((url: string | string[]) => string);
  72779. /**
  72780. * Gets or sets a function used to pre-process url before using them to load assets
  72781. */
  72782. static PreprocessUrl: (url: string) => string;
  72783. /**
  72784. * Removes unwanted characters from an url
  72785. * @param url defines the url to clean
  72786. * @returns the cleaned url
  72787. */
  72788. private static _CleanUrl;
  72789. /**
  72790. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  72791. * @param url define the url we are trying
  72792. * @param element define the dom element where to configure the cors policy
  72793. */
  72794. static SetCorsBehavior(url: string | string[], element: {
  72795. crossOrigin: string | null;
  72796. }): void;
  72797. /**
  72798. * Loads an image as an HTMLImageElement.
  72799. * @param input url string, ArrayBuffer, or Blob to load
  72800. * @param onLoad callback called when the image successfully loads
  72801. * @param onError callback called when the image fails to load
  72802. * @param offlineProvider offline provider for caching
  72803. * @param mimeType optional mime type
  72804. * @returns the HTMLImageElement of the loaded image
  72805. */
  72806. 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>;
  72807. /**
  72808. * Reads a file from a File object
  72809. * @param file defines the file to load
  72810. * @param onSuccess defines the callback to call when data is loaded
  72811. * @param onProgress defines the callback to call during loading process
  72812. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  72813. * @param onError defines the callback to call when an error occurs
  72814. * @returns a file request object
  72815. */
  72816. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  72817. /**
  72818. * Loads a file from a url
  72819. * @param url url to load
  72820. * @param onSuccess callback called when the file successfully loads
  72821. * @param onProgress callback called while file is loading (if the server supports this mode)
  72822. * @param offlineProvider defines the offline provider for caching
  72823. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72824. * @param onError callback called when the file fails to load
  72825. * @returns a file request object
  72826. */
  72827. 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;
  72828. /**
  72829. * Loads a file
  72830. * @param url url to load
  72831. * @param onSuccess callback called when the file successfully loads
  72832. * @param onProgress callback called while file is loading (if the server supports this mode)
  72833. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72834. * @param onError callback called when the file fails to load
  72835. * @param onOpened callback called when the web request is opened
  72836. * @returns a file request object
  72837. */
  72838. 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;
  72839. /**
  72840. * Checks if the loaded document was accessed via `file:`-Protocol.
  72841. * @returns boolean
  72842. */
  72843. static IsFileURL(): boolean;
  72844. }
  72845. }
  72846. declare module BABYLON {
  72847. /** @hidden */
  72848. export class ShaderProcessor {
  72849. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72850. private static _ProcessPrecision;
  72851. private static _ExtractOperation;
  72852. private static _BuildSubExpression;
  72853. private static _BuildExpression;
  72854. private static _MoveCursorWithinIf;
  72855. private static _MoveCursor;
  72856. private static _EvaluatePreProcessors;
  72857. private static _PreparePreProcessors;
  72858. private static _ProcessShaderConversion;
  72859. private static _ProcessIncludes;
  72860. /**
  72861. * Loads a file from a url
  72862. * @param url url to load
  72863. * @param onSuccess callback called when the file successfully loads
  72864. * @param onProgress callback called while file is loading (if the server supports this mode)
  72865. * @param offlineProvider defines the offline provider for caching
  72866. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72867. * @param onError callback called when the file fails to load
  72868. * @returns a file request object
  72869. * @hidden
  72870. */
  72871. 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;
  72872. }
  72873. }
  72874. declare module BABYLON {
  72875. /**
  72876. * @hidden
  72877. */
  72878. export interface IColor4Like {
  72879. r: float;
  72880. g: float;
  72881. b: float;
  72882. a: float;
  72883. }
  72884. /**
  72885. * @hidden
  72886. */
  72887. export interface IColor3Like {
  72888. r: float;
  72889. g: float;
  72890. b: float;
  72891. }
  72892. /**
  72893. * @hidden
  72894. */
  72895. export interface IVector4Like {
  72896. x: float;
  72897. y: float;
  72898. z: float;
  72899. w: float;
  72900. }
  72901. /**
  72902. * @hidden
  72903. */
  72904. export interface IVector3Like {
  72905. x: float;
  72906. y: float;
  72907. z: float;
  72908. }
  72909. /**
  72910. * @hidden
  72911. */
  72912. export interface IVector2Like {
  72913. x: float;
  72914. y: float;
  72915. }
  72916. /**
  72917. * @hidden
  72918. */
  72919. export interface IMatrixLike {
  72920. toArray(): DeepImmutable<Float32Array>;
  72921. updateFlag: int;
  72922. }
  72923. /**
  72924. * @hidden
  72925. */
  72926. export interface IViewportLike {
  72927. x: float;
  72928. y: float;
  72929. width: float;
  72930. height: float;
  72931. }
  72932. /**
  72933. * @hidden
  72934. */
  72935. export interface IPlaneLike {
  72936. normal: IVector3Like;
  72937. d: float;
  72938. normalize(): void;
  72939. }
  72940. }
  72941. declare module BABYLON {
  72942. /**
  72943. * Interface used to define common properties for effect fallbacks
  72944. */
  72945. export interface IEffectFallbacks {
  72946. /**
  72947. * Removes the defines that should be removed when falling back.
  72948. * @param currentDefines defines the current define statements for the shader.
  72949. * @param effect defines the current effect we try to compile
  72950. * @returns The resulting defines with defines of the current rank removed.
  72951. */
  72952. reduce(currentDefines: string, effect: Effect): string;
  72953. /**
  72954. * Removes the fallback from the bound mesh.
  72955. */
  72956. unBindMesh(): void;
  72957. /**
  72958. * Checks to see if more fallbacks are still availible.
  72959. */
  72960. hasMoreFallbacks: boolean;
  72961. }
  72962. }
  72963. declare module BABYLON {
  72964. /**
  72965. * Class used to evalaute queries containing `and` and `or` operators
  72966. */
  72967. export class AndOrNotEvaluator {
  72968. /**
  72969. * Evaluate a query
  72970. * @param query defines the query to evaluate
  72971. * @param evaluateCallback defines the callback used to filter result
  72972. * @returns true if the query matches
  72973. */
  72974. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72975. private static _HandleParenthesisContent;
  72976. private static _SimplifyNegation;
  72977. }
  72978. }
  72979. declare module BABYLON {
  72980. /**
  72981. * Class used to store custom tags
  72982. */
  72983. export class Tags {
  72984. /**
  72985. * Adds support for tags on the given object
  72986. * @param obj defines the object to use
  72987. */
  72988. static EnableFor(obj: any): void;
  72989. /**
  72990. * Removes tags support
  72991. * @param obj defines the object to use
  72992. */
  72993. static DisableFor(obj: any): void;
  72994. /**
  72995. * Gets a boolean indicating if the given object has tags
  72996. * @param obj defines the object to use
  72997. * @returns a boolean
  72998. */
  72999. static HasTags(obj: any): boolean;
  73000. /**
  73001. * Gets the tags available on a given object
  73002. * @param obj defines the object to use
  73003. * @param asString defines if the tags must be returned as a string instead of an array of strings
  73004. * @returns the tags
  73005. */
  73006. static GetTags(obj: any, asString?: boolean): any;
  73007. /**
  73008. * Adds tags to an object
  73009. * @param obj defines the object to use
  73010. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  73011. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  73012. */
  73013. static AddTagsTo(obj: any, tagsString: string): void;
  73014. /**
  73015. * @hidden
  73016. */
  73017. static _AddTagTo(obj: any, tag: string): void;
  73018. /**
  73019. * Removes specific tags from a specific object
  73020. * @param obj defines the object to use
  73021. * @param tagsString defines the tags to remove
  73022. */
  73023. static RemoveTagsFrom(obj: any, tagsString: string): void;
  73024. /**
  73025. * @hidden
  73026. */
  73027. static _RemoveTagFrom(obj: any, tag: string): void;
  73028. /**
  73029. * Defines if tags hosted on an object match a given query
  73030. * @param obj defines the object to use
  73031. * @param tagsQuery defines the tag query
  73032. * @returns a boolean
  73033. */
  73034. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  73035. }
  73036. }
  73037. declare module BABYLON {
  73038. /**
  73039. * Scalar computation library
  73040. */
  73041. export class Scalar {
  73042. /**
  73043. * Two pi constants convenient for computation.
  73044. */
  73045. static TwoPi: number;
  73046. /**
  73047. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  73048. * @param a number
  73049. * @param b number
  73050. * @param epsilon (default = 1.401298E-45)
  73051. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  73052. */
  73053. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  73054. /**
  73055. * Returns a string : the upper case translation of the number i to hexadecimal.
  73056. * @param i number
  73057. * @returns the upper case translation of the number i to hexadecimal.
  73058. */
  73059. static ToHex(i: number): string;
  73060. /**
  73061. * Returns -1 if value is negative and +1 is value is positive.
  73062. * @param value the value
  73063. * @returns the value itself if it's equal to zero.
  73064. */
  73065. static Sign(value: number): number;
  73066. /**
  73067. * Returns the value itself if it's between min and max.
  73068. * Returns min if the value is lower than min.
  73069. * Returns max if the value is greater than max.
  73070. * @param value the value to clmap
  73071. * @param min the min value to clamp to (default: 0)
  73072. * @param max the max value to clamp to (default: 1)
  73073. * @returns the clamped value
  73074. */
  73075. static Clamp(value: number, min?: number, max?: number): number;
  73076. /**
  73077. * the log2 of value.
  73078. * @param value the value to compute log2 of
  73079. * @returns the log2 of value.
  73080. */
  73081. static Log2(value: number): number;
  73082. /**
  73083. * Loops the value, so that it is never larger than length and never smaller than 0.
  73084. *
  73085. * This is similar to the modulo operator but it works with floating point numbers.
  73086. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  73087. * With t = 5 and length = 2.5, the result would be 0.0.
  73088. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  73089. * @param value the value
  73090. * @param length the length
  73091. * @returns the looped value
  73092. */
  73093. static Repeat(value: number, length: number): number;
  73094. /**
  73095. * Normalize the value between 0.0 and 1.0 using min and max values
  73096. * @param value value to normalize
  73097. * @param min max to normalize between
  73098. * @param max min to normalize between
  73099. * @returns the normalized value
  73100. */
  73101. static Normalize(value: number, min: number, max: number): number;
  73102. /**
  73103. * Denormalize the value from 0.0 and 1.0 using min and max values
  73104. * @param normalized value to denormalize
  73105. * @param min max to denormalize between
  73106. * @param max min to denormalize between
  73107. * @returns the denormalized value
  73108. */
  73109. static Denormalize(normalized: number, min: number, max: number): number;
  73110. /**
  73111. * Calculates the shortest difference between two given angles given in degrees.
  73112. * @param current current angle in degrees
  73113. * @param target target angle in degrees
  73114. * @returns the delta
  73115. */
  73116. static DeltaAngle(current: number, target: number): number;
  73117. /**
  73118. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  73119. * @param tx value
  73120. * @param length length
  73121. * @returns The returned value will move back and forth between 0 and length
  73122. */
  73123. static PingPong(tx: number, length: number): number;
  73124. /**
  73125. * Interpolates between min and max with smoothing at the limits.
  73126. *
  73127. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  73128. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  73129. * @param from from
  73130. * @param to to
  73131. * @param tx value
  73132. * @returns the smooth stepped value
  73133. */
  73134. static SmoothStep(from: number, to: number, tx: number): number;
  73135. /**
  73136. * Moves a value current towards target.
  73137. *
  73138. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  73139. * Negative values of maxDelta pushes the value away from target.
  73140. * @param current current value
  73141. * @param target target value
  73142. * @param maxDelta max distance to move
  73143. * @returns resulting value
  73144. */
  73145. static MoveTowards(current: number, target: number, maxDelta: number): number;
  73146. /**
  73147. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  73148. *
  73149. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  73150. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  73151. * @param current current value
  73152. * @param target target value
  73153. * @param maxDelta max distance to move
  73154. * @returns resulting angle
  73155. */
  73156. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  73157. /**
  73158. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  73159. * @param start start value
  73160. * @param end target value
  73161. * @param amount amount to lerp between
  73162. * @returns the lerped value
  73163. */
  73164. static Lerp(start: number, end: number, amount: number): number;
  73165. /**
  73166. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  73167. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  73168. * @param start start value
  73169. * @param end target value
  73170. * @param amount amount to lerp between
  73171. * @returns the lerped value
  73172. */
  73173. static LerpAngle(start: number, end: number, amount: number): number;
  73174. /**
  73175. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  73176. * @param a start value
  73177. * @param b target value
  73178. * @param value value between a and b
  73179. * @returns the inverseLerp value
  73180. */
  73181. static InverseLerp(a: number, b: number, value: number): number;
  73182. /**
  73183. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  73184. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  73185. * @param value1 spline value
  73186. * @param tangent1 spline value
  73187. * @param value2 spline value
  73188. * @param tangent2 spline value
  73189. * @param amount input value
  73190. * @returns hermite result
  73191. */
  73192. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  73193. /**
  73194. * Returns a random float number between and min and max values
  73195. * @param min min value of random
  73196. * @param max max value of random
  73197. * @returns random value
  73198. */
  73199. static RandomRange(min: number, max: number): number;
  73200. /**
  73201. * This function returns percentage of a number in a given range.
  73202. *
  73203. * RangeToPercent(40,20,60) will return 0.5 (50%)
  73204. * RangeToPercent(34,0,100) will return 0.34 (34%)
  73205. * @param number to convert to percentage
  73206. * @param min min range
  73207. * @param max max range
  73208. * @returns the percentage
  73209. */
  73210. static RangeToPercent(number: number, min: number, max: number): number;
  73211. /**
  73212. * This function returns number that corresponds to the percentage in a given range.
  73213. *
  73214. * PercentToRange(0.34,0,100) will return 34.
  73215. * @param percent to convert to number
  73216. * @param min min range
  73217. * @param max max range
  73218. * @returns the number
  73219. */
  73220. static PercentToRange(percent: number, min: number, max: number): number;
  73221. /**
  73222. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  73223. * @param angle The angle to normalize in radian.
  73224. * @return The converted angle.
  73225. */
  73226. static NormalizeRadians(angle: number): number;
  73227. }
  73228. }
  73229. declare module BABYLON {
  73230. /**
  73231. * Constant used to convert a value to gamma space
  73232. * @ignorenaming
  73233. */
  73234. export const ToGammaSpace: number;
  73235. /**
  73236. * Constant used to convert a value to linear space
  73237. * @ignorenaming
  73238. */
  73239. export const ToLinearSpace = 2.2;
  73240. /**
  73241. * Constant used to define the minimal number value in Babylon.js
  73242. * @ignorenaming
  73243. */
  73244. let Epsilon: number;
  73245. }
  73246. declare module BABYLON {
  73247. /**
  73248. * Class used to represent a viewport on screen
  73249. */
  73250. export class Viewport {
  73251. /** viewport left coordinate */
  73252. x: number;
  73253. /** viewport top coordinate */
  73254. y: number;
  73255. /**viewport width */
  73256. width: number;
  73257. /** viewport height */
  73258. height: number;
  73259. /**
  73260. * Creates a Viewport object located at (x, y) and sized (width, height)
  73261. * @param x defines viewport left coordinate
  73262. * @param y defines viewport top coordinate
  73263. * @param width defines the viewport width
  73264. * @param height defines the viewport height
  73265. */
  73266. constructor(
  73267. /** viewport left coordinate */
  73268. x: number,
  73269. /** viewport top coordinate */
  73270. y: number,
  73271. /**viewport width */
  73272. width: number,
  73273. /** viewport height */
  73274. height: number);
  73275. /**
  73276. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  73277. * @param renderWidth defines the rendering width
  73278. * @param renderHeight defines the rendering height
  73279. * @returns a new Viewport
  73280. */
  73281. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  73282. /**
  73283. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  73284. * @param renderWidth defines the rendering width
  73285. * @param renderHeight defines the rendering height
  73286. * @param ref defines the target viewport
  73287. * @returns the current viewport
  73288. */
  73289. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  73290. /**
  73291. * Returns a new Viewport copied from the current one
  73292. * @returns a new Viewport
  73293. */
  73294. clone(): Viewport;
  73295. }
  73296. }
  73297. declare module BABYLON {
  73298. /**
  73299. * Class containing a set of static utilities functions for arrays.
  73300. */
  73301. export class ArrayTools {
  73302. /**
  73303. * Returns an array of the given size filled with element built from the given constructor and the paramters
  73304. * @param size the number of element to construct and put in the array
  73305. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  73306. * @returns a new array filled with new objects
  73307. */
  73308. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  73309. }
  73310. }
  73311. declare module BABYLON {
  73312. /**
  73313. * Class representing a vector containing 2 coordinates
  73314. */
  73315. export class Vector2 {
  73316. /** defines the first coordinate */
  73317. x: number;
  73318. /** defines the second coordinate */
  73319. y: number;
  73320. /**
  73321. * Creates a new Vector2 from the given x and y coordinates
  73322. * @param x defines the first coordinate
  73323. * @param y defines the second coordinate
  73324. */
  73325. constructor(
  73326. /** defines the first coordinate */
  73327. x?: number,
  73328. /** defines the second coordinate */
  73329. y?: number);
  73330. /**
  73331. * Gets a string with the Vector2 coordinates
  73332. * @returns a string with the Vector2 coordinates
  73333. */
  73334. toString(): string;
  73335. /**
  73336. * Gets class name
  73337. * @returns the string "Vector2"
  73338. */
  73339. getClassName(): string;
  73340. /**
  73341. * Gets current vector hash code
  73342. * @returns the Vector2 hash code as a number
  73343. */
  73344. getHashCode(): number;
  73345. /**
  73346. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  73347. * @param array defines the source array
  73348. * @param index defines the offset in source array
  73349. * @returns the current Vector2
  73350. */
  73351. toArray(array: FloatArray, index?: number): Vector2;
  73352. /**
  73353. * Copy the current vector to an array
  73354. * @returns a new array with 2 elements: the Vector2 coordinates.
  73355. */
  73356. asArray(): number[];
  73357. /**
  73358. * Sets the Vector2 coordinates with the given Vector2 coordinates
  73359. * @param source defines the source Vector2
  73360. * @returns the current updated Vector2
  73361. */
  73362. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  73363. /**
  73364. * Sets the Vector2 coordinates with the given floats
  73365. * @param x defines the first coordinate
  73366. * @param y defines the second coordinate
  73367. * @returns the current updated Vector2
  73368. */
  73369. copyFromFloats(x: number, y: number): Vector2;
  73370. /**
  73371. * Sets the Vector2 coordinates with the given floats
  73372. * @param x defines the first coordinate
  73373. * @param y defines the second coordinate
  73374. * @returns the current updated Vector2
  73375. */
  73376. set(x: number, y: number): Vector2;
  73377. /**
  73378. * Add another vector with the current one
  73379. * @param otherVector defines the other vector
  73380. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  73381. */
  73382. add(otherVector: DeepImmutable<Vector2>): Vector2;
  73383. /**
  73384. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  73385. * @param otherVector defines the other vector
  73386. * @param result defines the target vector
  73387. * @returns the unmodified current Vector2
  73388. */
  73389. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73390. /**
  73391. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  73392. * @param otherVector defines the other vector
  73393. * @returns the current updated Vector2
  73394. */
  73395. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73396. /**
  73397. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  73398. * @param otherVector defines the other vector
  73399. * @returns a new Vector2
  73400. */
  73401. addVector3(otherVector: Vector3): Vector2;
  73402. /**
  73403. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  73404. * @param otherVector defines the other vector
  73405. * @returns a new Vector2
  73406. */
  73407. subtract(otherVector: Vector2): Vector2;
  73408. /**
  73409. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  73410. * @param otherVector defines the other vector
  73411. * @param result defines the target vector
  73412. * @returns the unmodified current Vector2
  73413. */
  73414. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73415. /**
  73416. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  73417. * @param otherVector defines the other vector
  73418. * @returns the current updated Vector2
  73419. */
  73420. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73421. /**
  73422. * Multiplies in place the current Vector2 coordinates by the given ones
  73423. * @param otherVector defines the other vector
  73424. * @returns the current updated Vector2
  73425. */
  73426. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73427. /**
  73428. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  73429. * @param otherVector defines the other vector
  73430. * @returns a new Vector2
  73431. */
  73432. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  73433. /**
  73434. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  73435. * @param otherVector defines the other vector
  73436. * @param result defines the target vector
  73437. * @returns the unmodified current Vector2
  73438. */
  73439. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73440. /**
  73441. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  73442. * @param x defines the first coordinate
  73443. * @param y defines the second coordinate
  73444. * @returns a new Vector2
  73445. */
  73446. multiplyByFloats(x: number, y: number): Vector2;
  73447. /**
  73448. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  73449. * @param otherVector defines the other vector
  73450. * @returns a new Vector2
  73451. */
  73452. divide(otherVector: Vector2): Vector2;
  73453. /**
  73454. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  73455. * @param otherVector defines the other vector
  73456. * @param result defines the target vector
  73457. * @returns the unmodified current Vector2
  73458. */
  73459. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73460. /**
  73461. * Divides the current Vector2 coordinates by the given ones
  73462. * @param otherVector defines the other vector
  73463. * @returns the current updated Vector2
  73464. */
  73465. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73466. /**
  73467. * Gets a new Vector2 with current Vector2 negated coordinates
  73468. * @returns a new Vector2
  73469. */
  73470. negate(): Vector2;
  73471. /**
  73472. * Multiply the Vector2 coordinates by scale
  73473. * @param scale defines the scaling factor
  73474. * @returns the current updated Vector2
  73475. */
  73476. scaleInPlace(scale: number): Vector2;
  73477. /**
  73478. * Returns a new Vector2 scaled by "scale" from the current Vector2
  73479. * @param scale defines the scaling factor
  73480. * @returns a new Vector2
  73481. */
  73482. scale(scale: number): Vector2;
  73483. /**
  73484. * Scale the current Vector2 values by a factor to a given Vector2
  73485. * @param scale defines the scale factor
  73486. * @param result defines the Vector2 object where to store the result
  73487. * @returns the unmodified current Vector2
  73488. */
  73489. scaleToRef(scale: number, result: Vector2): Vector2;
  73490. /**
  73491. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  73492. * @param scale defines the scale factor
  73493. * @param result defines the Vector2 object where to store the result
  73494. * @returns the unmodified current Vector2
  73495. */
  73496. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  73497. /**
  73498. * Gets a boolean if two vectors are equals
  73499. * @param otherVector defines the other vector
  73500. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  73501. */
  73502. equals(otherVector: DeepImmutable<Vector2>): boolean;
  73503. /**
  73504. * Gets a boolean if two vectors are equals (using an epsilon value)
  73505. * @param otherVector defines the other vector
  73506. * @param epsilon defines the minimal distance to consider equality
  73507. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  73508. */
  73509. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  73510. /**
  73511. * Gets a new Vector2 from current Vector2 floored values
  73512. * @returns a new Vector2
  73513. */
  73514. floor(): Vector2;
  73515. /**
  73516. * Gets a new Vector2 from current Vector2 floored values
  73517. * @returns a new Vector2
  73518. */
  73519. fract(): Vector2;
  73520. /**
  73521. * Gets the length of the vector
  73522. * @returns the vector length (float)
  73523. */
  73524. length(): number;
  73525. /**
  73526. * Gets the vector squared length
  73527. * @returns the vector squared length (float)
  73528. */
  73529. lengthSquared(): number;
  73530. /**
  73531. * Normalize the vector
  73532. * @returns the current updated Vector2
  73533. */
  73534. normalize(): Vector2;
  73535. /**
  73536. * Gets a new Vector2 copied from the Vector2
  73537. * @returns a new Vector2
  73538. */
  73539. clone(): Vector2;
  73540. /**
  73541. * Gets a new Vector2(0, 0)
  73542. * @returns a new Vector2
  73543. */
  73544. static Zero(): Vector2;
  73545. /**
  73546. * Gets a new Vector2(1, 1)
  73547. * @returns a new Vector2
  73548. */
  73549. static One(): Vector2;
  73550. /**
  73551. * Gets a new Vector2 set from the given index element of the given array
  73552. * @param array defines the data source
  73553. * @param offset defines the offset in the data source
  73554. * @returns a new Vector2
  73555. */
  73556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  73557. /**
  73558. * Sets "result" from the given index element of the given array
  73559. * @param array defines the data source
  73560. * @param offset defines the offset in the data source
  73561. * @param result defines the target vector
  73562. */
  73563. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  73564. /**
  73565. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  73566. * @param value1 defines 1st point of control
  73567. * @param value2 defines 2nd point of control
  73568. * @param value3 defines 3rd point of control
  73569. * @param value4 defines 4th point of control
  73570. * @param amount defines the interpolation factor
  73571. * @returns a new Vector2
  73572. */
  73573. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  73574. /**
  73575. * 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".
  73576. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  73577. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  73578. * @param value defines the value to clamp
  73579. * @param min defines the lower limit
  73580. * @param max defines the upper limit
  73581. * @returns a new Vector2
  73582. */
  73583. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  73584. /**
  73585. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  73586. * @param value1 defines the 1st control point
  73587. * @param tangent1 defines the outgoing tangent
  73588. * @param value2 defines the 2nd control point
  73589. * @param tangent2 defines the incoming tangent
  73590. * @param amount defines the interpolation factor
  73591. * @returns a new Vector2
  73592. */
  73593. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  73594. /**
  73595. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  73596. * @param start defines the start vector
  73597. * @param end defines the end vector
  73598. * @param amount defines the interpolation factor
  73599. * @returns a new Vector2
  73600. */
  73601. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  73602. /**
  73603. * Gets the dot product of the vector "left" and the vector "right"
  73604. * @param left defines first vector
  73605. * @param right defines second vector
  73606. * @returns the dot product (float)
  73607. */
  73608. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  73609. /**
  73610. * Returns a new Vector2 equal to the normalized given vector
  73611. * @param vector defines the vector to normalize
  73612. * @returns a new Vector2
  73613. */
  73614. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  73615. /**
  73616. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  73617. * @param left defines 1st vector
  73618. * @param right defines 2nd vector
  73619. * @returns a new Vector2
  73620. */
  73621. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  73622. /**
  73623. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  73624. * @param left defines 1st vector
  73625. * @param right defines 2nd vector
  73626. * @returns a new Vector2
  73627. */
  73628. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  73629. /**
  73630. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  73631. * @param vector defines the vector to transform
  73632. * @param transformation defines the matrix to apply
  73633. * @returns a new Vector2
  73634. */
  73635. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  73636. /**
  73637. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  73638. * @param vector defines the vector to transform
  73639. * @param transformation defines the matrix to apply
  73640. * @param result defines the target vector
  73641. */
  73642. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  73643. /**
  73644. * Determines if a given vector is included in a triangle
  73645. * @param p defines the vector to test
  73646. * @param p0 defines 1st triangle point
  73647. * @param p1 defines 2nd triangle point
  73648. * @param p2 defines 3rd triangle point
  73649. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  73650. */
  73651. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  73652. /**
  73653. * Gets the distance between the vectors "value1" and "value2"
  73654. * @param value1 defines first vector
  73655. * @param value2 defines second vector
  73656. * @returns the distance between vectors
  73657. */
  73658. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  73659. /**
  73660. * Returns the squared distance between the vectors "value1" and "value2"
  73661. * @param value1 defines first vector
  73662. * @param value2 defines second vector
  73663. * @returns the squared distance between vectors
  73664. */
  73665. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  73666. /**
  73667. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  73668. * @param value1 defines first vector
  73669. * @param value2 defines second vector
  73670. * @returns a new Vector2
  73671. */
  73672. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  73673. /**
  73674. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  73675. * @param p defines the middle point
  73676. * @param segA defines one point of the segment
  73677. * @param segB defines the other point of the segment
  73678. * @returns the shortest distance
  73679. */
  73680. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  73681. }
  73682. /**
  73683. * Class used to store (x,y,z) vector representation
  73684. * A Vector3 is the main object used in 3D geometry
  73685. * It can represent etiher the coordinates of a point the space, either a direction
  73686. * Reminder: js uses a left handed forward facing system
  73687. */
  73688. export class Vector3 {
  73689. /**
  73690. * Defines the first coordinates (on X axis)
  73691. */
  73692. x: number;
  73693. /**
  73694. * Defines the second coordinates (on Y axis)
  73695. */
  73696. y: number;
  73697. /**
  73698. * Defines the third coordinates (on Z axis)
  73699. */
  73700. z: number;
  73701. private static _UpReadOnly;
  73702. private static _ZeroReadOnly;
  73703. /**
  73704. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  73705. * @param x defines the first coordinates (on X axis)
  73706. * @param y defines the second coordinates (on Y axis)
  73707. * @param z defines the third coordinates (on Z axis)
  73708. */
  73709. constructor(
  73710. /**
  73711. * Defines the first coordinates (on X axis)
  73712. */
  73713. x?: number,
  73714. /**
  73715. * Defines the second coordinates (on Y axis)
  73716. */
  73717. y?: number,
  73718. /**
  73719. * Defines the third coordinates (on Z axis)
  73720. */
  73721. z?: number);
  73722. /**
  73723. * Creates a string representation of the Vector3
  73724. * @returns a string with the Vector3 coordinates.
  73725. */
  73726. toString(): string;
  73727. /**
  73728. * Gets the class name
  73729. * @returns the string "Vector3"
  73730. */
  73731. getClassName(): string;
  73732. /**
  73733. * Creates the Vector3 hash code
  73734. * @returns a number which tends to be unique between Vector3 instances
  73735. */
  73736. getHashCode(): number;
  73737. /**
  73738. * Creates an array containing three elements : the coordinates of the Vector3
  73739. * @returns a new array of numbers
  73740. */
  73741. asArray(): number[];
  73742. /**
  73743. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  73744. * @param array defines the destination array
  73745. * @param index defines the offset in the destination array
  73746. * @returns the current Vector3
  73747. */
  73748. toArray(array: FloatArray, index?: number): Vector3;
  73749. /**
  73750. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  73751. * @returns a new Quaternion object, computed from the Vector3 coordinates
  73752. */
  73753. toQuaternion(): Quaternion;
  73754. /**
  73755. * Adds the given vector to the current Vector3
  73756. * @param otherVector defines the second operand
  73757. * @returns the current updated Vector3
  73758. */
  73759. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73760. /**
  73761. * Adds the given coordinates to the current Vector3
  73762. * @param x defines the x coordinate of the operand
  73763. * @param y defines the y coordinate of the operand
  73764. * @param z defines the z coordinate of the operand
  73765. * @returns the current updated Vector3
  73766. */
  73767. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73768. /**
  73769. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  73770. * @param otherVector defines the second operand
  73771. * @returns the resulting Vector3
  73772. */
  73773. add(otherVector: DeepImmutable<Vector3>): Vector3;
  73774. /**
  73775. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  73776. * @param otherVector defines the second operand
  73777. * @param result defines the Vector3 object where to store the result
  73778. * @returns the current Vector3
  73779. */
  73780. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73781. /**
  73782. * Subtract the given vector from the current Vector3
  73783. * @param otherVector defines the second operand
  73784. * @returns the current updated Vector3
  73785. */
  73786. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73787. /**
  73788. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  73789. * @param otherVector defines the second operand
  73790. * @returns the resulting Vector3
  73791. */
  73792. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  73793. /**
  73794. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  73795. * @param otherVector defines the second operand
  73796. * @param result defines the Vector3 object where to store the result
  73797. * @returns the current Vector3
  73798. */
  73799. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73800. /**
  73801. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  73802. * @param x defines the x coordinate of the operand
  73803. * @param y defines the y coordinate of the operand
  73804. * @param z defines the z coordinate of the operand
  73805. * @returns the resulting Vector3
  73806. */
  73807. subtractFromFloats(x: number, y: number, z: number): Vector3;
  73808. /**
  73809. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  73810. * @param x defines the x coordinate of the operand
  73811. * @param y defines the y coordinate of the operand
  73812. * @param z defines the z coordinate of the operand
  73813. * @param result defines the Vector3 object where to store the result
  73814. * @returns the current Vector3
  73815. */
  73816. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  73817. /**
  73818. * Gets a new Vector3 set with the current Vector3 negated coordinates
  73819. * @returns a new Vector3
  73820. */
  73821. negate(): Vector3;
  73822. /**
  73823. * Negate this vector in place
  73824. * @returns this
  73825. */
  73826. negateInPlace(): Vector3;
  73827. /**
  73828. * Multiplies the Vector3 coordinates by the float "scale"
  73829. * @param scale defines the multiplier factor
  73830. * @returns the current updated Vector3
  73831. */
  73832. scaleInPlace(scale: number): Vector3;
  73833. /**
  73834. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  73835. * @param scale defines the multiplier factor
  73836. * @returns a new Vector3
  73837. */
  73838. scale(scale: number): Vector3;
  73839. /**
  73840. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73841. * @param scale defines the multiplier factor
  73842. * @param result defines the Vector3 object where to store the result
  73843. * @returns the current Vector3
  73844. */
  73845. scaleToRef(scale: number, result: Vector3): Vector3;
  73846. /**
  73847. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73848. * @param scale defines the scale factor
  73849. * @param result defines the Vector3 object where to store the result
  73850. * @returns the unmodified current Vector3
  73851. */
  73852. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73853. /**
  73854. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73855. * @param otherVector defines the second operand
  73856. * @returns true if both vectors are equals
  73857. */
  73858. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73859. /**
  73860. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73861. * @param otherVector defines the second operand
  73862. * @param epsilon defines the minimal distance to define values as equals
  73863. * @returns true if both vectors are distant less than epsilon
  73864. */
  73865. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73866. /**
  73867. * Returns true if the current Vector3 coordinates equals the given floats
  73868. * @param x defines the x coordinate of the operand
  73869. * @param y defines the y coordinate of the operand
  73870. * @param z defines the z coordinate of the operand
  73871. * @returns true if both vectors are equals
  73872. */
  73873. equalsToFloats(x: number, y: number, z: number): boolean;
  73874. /**
  73875. * Multiplies the current Vector3 coordinates by the given ones
  73876. * @param otherVector defines the second operand
  73877. * @returns the current updated Vector3
  73878. */
  73879. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73880. /**
  73881. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73882. * @param otherVector defines the second operand
  73883. * @returns the new Vector3
  73884. */
  73885. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73886. /**
  73887. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73888. * @param otherVector defines the second operand
  73889. * @param result defines the Vector3 object where to store the result
  73890. * @returns the current Vector3
  73891. */
  73892. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73893. /**
  73894. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73895. * @param x defines the x coordinate of the operand
  73896. * @param y defines the y coordinate of the operand
  73897. * @param z defines the z coordinate of the operand
  73898. * @returns the new Vector3
  73899. */
  73900. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73901. /**
  73902. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73903. * @param otherVector defines the second operand
  73904. * @returns the new Vector3
  73905. */
  73906. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73907. /**
  73908. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73909. * @param otherVector defines the second operand
  73910. * @param result defines the Vector3 object where to store the result
  73911. * @returns the current Vector3
  73912. */
  73913. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73914. /**
  73915. * Divides the current Vector3 coordinates by the given ones.
  73916. * @param otherVector defines the second operand
  73917. * @returns the current updated Vector3
  73918. */
  73919. divideInPlace(otherVector: Vector3): Vector3;
  73920. /**
  73921. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73922. * @param other defines the second operand
  73923. * @returns the current updated Vector3
  73924. */
  73925. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73926. /**
  73927. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73928. * @param other defines the second operand
  73929. * @returns the current updated Vector3
  73930. */
  73931. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73932. /**
  73933. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73934. * @param x defines the x coordinate of the operand
  73935. * @param y defines the y coordinate of the operand
  73936. * @param z defines the z coordinate of the operand
  73937. * @returns the current updated Vector3
  73938. */
  73939. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73940. /**
  73941. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73942. * @param x defines the x coordinate of the operand
  73943. * @param y defines the y coordinate of the operand
  73944. * @param z defines the z coordinate of the operand
  73945. * @returns the current updated Vector3
  73946. */
  73947. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73948. /**
  73949. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73950. * Check if is non uniform within a certain amount of decimal places to account for this
  73951. * @param epsilon the amount the values can differ
  73952. * @returns if the the vector is non uniform to a certain number of decimal places
  73953. */
  73954. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73955. /**
  73956. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73957. */
  73958. get isNonUniform(): boolean;
  73959. /**
  73960. * Gets a new Vector3 from current Vector3 floored values
  73961. * @returns a new Vector3
  73962. */
  73963. floor(): Vector3;
  73964. /**
  73965. * Gets a new Vector3 from current Vector3 floored values
  73966. * @returns a new Vector3
  73967. */
  73968. fract(): Vector3;
  73969. /**
  73970. * Gets the length of the Vector3
  73971. * @returns the length of the Vector3
  73972. */
  73973. length(): number;
  73974. /**
  73975. * Gets the squared length of the Vector3
  73976. * @returns squared length of the Vector3
  73977. */
  73978. lengthSquared(): number;
  73979. /**
  73980. * Normalize the current Vector3.
  73981. * Please note that this is an in place operation.
  73982. * @returns the current updated Vector3
  73983. */
  73984. normalize(): Vector3;
  73985. /**
  73986. * Reorders the x y z properties of the vector in place
  73987. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73988. * @returns the current updated vector
  73989. */
  73990. reorderInPlace(order: string): this;
  73991. /**
  73992. * Rotates the vector around 0,0,0 by a quaternion
  73993. * @param quaternion the rotation quaternion
  73994. * @param result vector to store the result
  73995. * @returns the resulting vector
  73996. */
  73997. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  73998. /**
  73999. * Rotates a vector around a given point
  74000. * @param quaternion the rotation quaternion
  74001. * @param point the point to rotate around
  74002. * @param result vector to store the result
  74003. * @returns the resulting vector
  74004. */
  74005. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  74006. /**
  74007. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  74008. * The cross product is then orthogonal to both current and "other"
  74009. * @param other defines the right operand
  74010. * @returns the cross product
  74011. */
  74012. cross(other: Vector3): Vector3;
  74013. /**
  74014. * Normalize the current Vector3 with the given input length.
  74015. * Please note that this is an in place operation.
  74016. * @param len the length of the vector
  74017. * @returns the current updated Vector3
  74018. */
  74019. normalizeFromLength(len: number): Vector3;
  74020. /**
  74021. * Normalize the current Vector3 to a new vector
  74022. * @returns the new Vector3
  74023. */
  74024. normalizeToNew(): Vector3;
  74025. /**
  74026. * Normalize the current Vector3 to the reference
  74027. * @param reference define the Vector3 to update
  74028. * @returns the updated Vector3
  74029. */
  74030. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  74031. /**
  74032. * Creates a new Vector3 copied from the current Vector3
  74033. * @returns the new Vector3
  74034. */
  74035. clone(): Vector3;
  74036. /**
  74037. * Copies the given vector coordinates to the current Vector3 ones
  74038. * @param source defines the source Vector3
  74039. * @returns the current updated Vector3
  74040. */
  74041. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  74042. /**
  74043. * Copies the given floats to the current Vector3 coordinates
  74044. * @param x defines the x coordinate of the operand
  74045. * @param y defines the y coordinate of the operand
  74046. * @param z defines the z coordinate of the operand
  74047. * @returns the current updated Vector3
  74048. */
  74049. copyFromFloats(x: number, y: number, z: number): Vector3;
  74050. /**
  74051. * Copies the given floats to the current Vector3 coordinates
  74052. * @param x defines the x coordinate of the operand
  74053. * @param y defines the y coordinate of the operand
  74054. * @param z defines the z coordinate of the operand
  74055. * @returns the current updated Vector3
  74056. */
  74057. set(x: number, y: number, z: number): Vector3;
  74058. /**
  74059. * Copies the given float to the current Vector3 coordinates
  74060. * @param v defines the x, y and z coordinates of the operand
  74061. * @returns the current updated Vector3
  74062. */
  74063. setAll(v: number): Vector3;
  74064. /**
  74065. * Get the clip factor between two vectors
  74066. * @param vector0 defines the first operand
  74067. * @param vector1 defines the second operand
  74068. * @param axis defines the axis to use
  74069. * @param size defines the size along the axis
  74070. * @returns the clip factor
  74071. */
  74072. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  74073. /**
  74074. * Get angle between two vectors
  74075. * @param vector0 angle between vector0 and vector1
  74076. * @param vector1 angle between vector0 and vector1
  74077. * @param normal direction of the normal
  74078. * @return the angle between vector0 and vector1
  74079. */
  74080. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  74081. /**
  74082. * Returns a new Vector3 set from the index "offset" of the given array
  74083. * @param array defines the source array
  74084. * @param offset defines the offset in the source array
  74085. * @returns the new Vector3
  74086. */
  74087. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  74088. /**
  74089. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  74090. * @param array defines the source array
  74091. * @param offset defines the offset in the source array
  74092. * @returns the new Vector3
  74093. * @deprecated Please use FromArray instead.
  74094. */
  74095. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  74096. /**
  74097. * Sets the given vector "result" with the element values from the index "offset" of the given array
  74098. * @param array defines the source array
  74099. * @param offset defines the offset in the source array
  74100. * @param result defines the Vector3 where to store the result
  74101. */
  74102. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  74103. /**
  74104. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  74105. * @param array defines the source array
  74106. * @param offset defines the offset in the source array
  74107. * @param result defines the Vector3 where to store the result
  74108. * @deprecated Please use FromArrayToRef instead.
  74109. */
  74110. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  74111. /**
  74112. * Sets the given vector "result" with the given floats.
  74113. * @param x defines the x coordinate of the source
  74114. * @param y defines the y coordinate of the source
  74115. * @param z defines the z coordinate of the source
  74116. * @param result defines the Vector3 where to store the result
  74117. */
  74118. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  74119. /**
  74120. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  74121. * @returns a new empty Vector3
  74122. */
  74123. static Zero(): Vector3;
  74124. /**
  74125. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  74126. * @returns a new unit Vector3
  74127. */
  74128. static One(): Vector3;
  74129. /**
  74130. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  74131. * @returns a new up Vector3
  74132. */
  74133. static Up(): Vector3;
  74134. /**
  74135. * Gets a up Vector3 that must not be updated
  74136. */
  74137. static get UpReadOnly(): DeepImmutable<Vector3>;
  74138. /**
  74139. * Gets a zero Vector3 that must not be updated
  74140. */
  74141. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  74142. /**
  74143. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  74144. * @returns a new down Vector3
  74145. */
  74146. static Down(): Vector3;
  74147. /**
  74148. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  74149. * @returns a new forward Vector3
  74150. */
  74151. static Forward(): Vector3;
  74152. /**
  74153. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  74154. * @returns a new forward Vector3
  74155. */
  74156. static Backward(): Vector3;
  74157. /**
  74158. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  74159. * @returns a new right Vector3
  74160. */
  74161. static Right(): Vector3;
  74162. /**
  74163. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  74164. * @returns a new left Vector3
  74165. */
  74166. static Left(): Vector3;
  74167. /**
  74168. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  74169. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  74170. * @param vector defines the Vector3 to transform
  74171. * @param transformation defines the transformation matrix
  74172. * @returns the transformed Vector3
  74173. */
  74174. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  74175. /**
  74176. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  74177. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  74178. * @param vector defines the Vector3 to transform
  74179. * @param transformation defines the transformation matrix
  74180. * @param result defines the Vector3 where to store the result
  74181. */
  74182. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74183. /**
  74184. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  74185. * This method computes tranformed coordinates only, not transformed direction vectors
  74186. * @param x define the x coordinate of the source vector
  74187. * @param y define the y coordinate of the source vector
  74188. * @param z define the z coordinate of the source vector
  74189. * @param transformation defines the transformation matrix
  74190. * @param result defines the Vector3 where to store the result
  74191. */
  74192. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74193. /**
  74194. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  74195. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74196. * @param vector defines the Vector3 to transform
  74197. * @param transformation defines the transformation matrix
  74198. * @returns the new Vector3
  74199. */
  74200. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  74201. /**
  74202. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  74203. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74204. * @param vector defines the Vector3 to transform
  74205. * @param transformation defines the transformation matrix
  74206. * @param result defines the Vector3 where to store the result
  74207. */
  74208. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74209. /**
  74210. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  74211. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74212. * @param x define the x coordinate of the source vector
  74213. * @param y define the y coordinate of the source vector
  74214. * @param z define the z coordinate of the source vector
  74215. * @param transformation defines the transformation matrix
  74216. * @param result defines the Vector3 where to store the result
  74217. */
  74218. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74219. /**
  74220. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  74221. * @param value1 defines the first control point
  74222. * @param value2 defines the second control point
  74223. * @param value3 defines the third control point
  74224. * @param value4 defines the fourth control point
  74225. * @param amount defines the amount on the spline to use
  74226. * @returns the new Vector3
  74227. */
  74228. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  74229. /**
  74230. * 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"
  74231. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  74232. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  74233. * @param value defines the current value
  74234. * @param min defines the lower range value
  74235. * @param max defines the upper range value
  74236. * @returns the new Vector3
  74237. */
  74238. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  74239. /**
  74240. * 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"
  74241. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  74242. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  74243. * @param value defines the current value
  74244. * @param min defines the lower range value
  74245. * @param max defines the upper range value
  74246. * @param result defines the Vector3 where to store the result
  74247. */
  74248. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  74249. /**
  74250. * Checks if a given vector is inside a specific range
  74251. * @param v defines the vector to test
  74252. * @param min defines the minimum range
  74253. * @param max defines the maximum range
  74254. */
  74255. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  74256. /**
  74257. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  74258. * @param value1 defines the first control point
  74259. * @param tangent1 defines the first tangent vector
  74260. * @param value2 defines the second control point
  74261. * @param tangent2 defines the second tangent vector
  74262. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  74263. * @returns the new Vector3
  74264. */
  74265. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  74266. /**
  74267. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  74268. * @param start defines the start value
  74269. * @param end defines the end value
  74270. * @param amount max defines amount between both (between 0 and 1)
  74271. * @returns the new Vector3
  74272. */
  74273. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  74274. /**
  74275. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  74276. * @param start defines the start value
  74277. * @param end defines the end value
  74278. * @param amount max defines amount between both (between 0 and 1)
  74279. * @param result defines the Vector3 where to store the result
  74280. */
  74281. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  74282. /**
  74283. * Returns the dot product (float) between the vectors "left" and "right"
  74284. * @param left defines the left operand
  74285. * @param right defines the right operand
  74286. * @returns the dot product
  74287. */
  74288. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  74289. /**
  74290. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  74291. * The cross product is then orthogonal to both "left" and "right"
  74292. * @param left defines the left operand
  74293. * @param right defines the right operand
  74294. * @returns the cross product
  74295. */
  74296. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  74297. /**
  74298. * Sets the given vector "result" with the cross product of "left" and "right"
  74299. * The cross product is then orthogonal to both "left" and "right"
  74300. * @param left defines the left operand
  74301. * @param right defines the right operand
  74302. * @param result defines the Vector3 where to store the result
  74303. */
  74304. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  74305. /**
  74306. * Returns a new Vector3 as the normalization of the given vector
  74307. * @param vector defines the Vector3 to normalize
  74308. * @returns the new Vector3
  74309. */
  74310. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  74311. /**
  74312. * Sets the given vector "result" with the normalization of the given first vector
  74313. * @param vector defines the Vector3 to normalize
  74314. * @param result defines the Vector3 where to store the result
  74315. */
  74316. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  74317. /**
  74318. * Project a Vector3 onto screen space
  74319. * @param vector defines the Vector3 to project
  74320. * @param world defines the world matrix to use
  74321. * @param transform defines the transform (view x projection) matrix to use
  74322. * @param viewport defines the screen viewport to use
  74323. * @returns the new Vector3
  74324. */
  74325. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  74326. /** @hidden */
  74327. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  74328. /**
  74329. * Unproject from screen space to object space
  74330. * @param source defines the screen space Vector3 to use
  74331. * @param viewportWidth defines the current width of the viewport
  74332. * @param viewportHeight defines the current height of the viewport
  74333. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74334. * @param transform defines the transform (view x projection) matrix to use
  74335. * @returns the new Vector3
  74336. */
  74337. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  74338. /**
  74339. * Unproject from screen space to object space
  74340. * @param source defines the screen space Vector3 to use
  74341. * @param viewportWidth defines the current width of the viewport
  74342. * @param viewportHeight defines the current height of the viewport
  74343. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74344. * @param view defines the view matrix to use
  74345. * @param projection defines the projection matrix to use
  74346. * @returns the new Vector3
  74347. */
  74348. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  74349. /**
  74350. * Unproject from screen space to object space
  74351. * @param source defines the screen space Vector3 to use
  74352. * @param viewportWidth defines the current width of the viewport
  74353. * @param viewportHeight defines the current height of the viewport
  74354. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74355. * @param view defines the view matrix to use
  74356. * @param projection defines the projection matrix to use
  74357. * @param result defines the Vector3 where to store the result
  74358. */
  74359. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  74360. /**
  74361. * Unproject from screen space to object space
  74362. * @param sourceX defines the screen space x coordinate to use
  74363. * @param sourceY defines the screen space y coordinate to use
  74364. * @param sourceZ defines the screen space z coordinate to use
  74365. * @param viewportWidth defines the current width of the viewport
  74366. * @param viewportHeight defines the current height of the viewport
  74367. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74368. * @param view defines the view matrix to use
  74369. * @param projection defines the projection matrix to use
  74370. * @param result defines the Vector3 where to store the result
  74371. */
  74372. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  74373. /**
  74374. * Gets the minimal coordinate values between two Vector3
  74375. * @param left defines the first operand
  74376. * @param right defines the second operand
  74377. * @returns the new Vector3
  74378. */
  74379. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  74380. /**
  74381. * Gets the maximal coordinate values between two Vector3
  74382. * @param left defines the first operand
  74383. * @param right defines the second operand
  74384. * @returns the new Vector3
  74385. */
  74386. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  74387. /**
  74388. * Returns the distance between the vectors "value1" and "value2"
  74389. * @param value1 defines the first operand
  74390. * @param value2 defines the second operand
  74391. * @returns the distance
  74392. */
  74393. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  74394. /**
  74395. * Returns the squared distance between the vectors "value1" and "value2"
  74396. * @param value1 defines the first operand
  74397. * @param value2 defines the second operand
  74398. * @returns the squared distance
  74399. */
  74400. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  74401. /**
  74402. * Returns a new Vector3 located at the center between "value1" and "value2"
  74403. * @param value1 defines the first operand
  74404. * @param value2 defines the second operand
  74405. * @returns the new Vector3
  74406. */
  74407. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  74408. /**
  74409. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  74410. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  74411. * to something in order to rotate it from its local system to the given target system
  74412. * Note: axis1, axis2 and axis3 are normalized during this operation
  74413. * @param axis1 defines the first axis
  74414. * @param axis2 defines the second axis
  74415. * @param axis3 defines the third axis
  74416. * @returns a new Vector3
  74417. */
  74418. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  74419. /**
  74420. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  74421. * @param axis1 defines the first axis
  74422. * @param axis2 defines the second axis
  74423. * @param axis3 defines the third axis
  74424. * @param ref defines the Vector3 where to store the result
  74425. */
  74426. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  74427. }
  74428. /**
  74429. * Vector4 class created for EulerAngle class conversion to Quaternion
  74430. */
  74431. export class Vector4 {
  74432. /** x value of the vector */
  74433. x: number;
  74434. /** y value of the vector */
  74435. y: number;
  74436. /** z value of the vector */
  74437. z: number;
  74438. /** w value of the vector */
  74439. w: number;
  74440. /**
  74441. * Creates a Vector4 object from the given floats.
  74442. * @param x x value of the vector
  74443. * @param y y value of the vector
  74444. * @param z z value of the vector
  74445. * @param w w value of the vector
  74446. */
  74447. constructor(
  74448. /** x value of the vector */
  74449. x: number,
  74450. /** y value of the vector */
  74451. y: number,
  74452. /** z value of the vector */
  74453. z: number,
  74454. /** w value of the vector */
  74455. w: number);
  74456. /**
  74457. * Returns the string with the Vector4 coordinates.
  74458. * @returns a string containing all the vector values
  74459. */
  74460. toString(): string;
  74461. /**
  74462. * Returns the string "Vector4".
  74463. * @returns "Vector4"
  74464. */
  74465. getClassName(): string;
  74466. /**
  74467. * Returns the Vector4 hash code.
  74468. * @returns a unique hash code
  74469. */
  74470. getHashCode(): number;
  74471. /**
  74472. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  74473. * @returns the resulting array
  74474. */
  74475. asArray(): number[];
  74476. /**
  74477. * Populates the given array from the given index with the Vector4 coordinates.
  74478. * @param array array to populate
  74479. * @param index index of the array to start at (default: 0)
  74480. * @returns the Vector4.
  74481. */
  74482. toArray(array: FloatArray, index?: number): Vector4;
  74483. /**
  74484. * Adds the given vector to the current Vector4.
  74485. * @param otherVector the vector to add
  74486. * @returns the updated Vector4.
  74487. */
  74488. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  74489. /**
  74490. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  74491. * @param otherVector the vector to add
  74492. * @returns the resulting vector
  74493. */
  74494. add(otherVector: DeepImmutable<Vector4>): Vector4;
  74495. /**
  74496. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  74497. * @param otherVector the vector to add
  74498. * @param result the vector to store the result
  74499. * @returns the current Vector4.
  74500. */
  74501. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74502. /**
  74503. * Subtract in place the given vector from the current Vector4.
  74504. * @param otherVector the vector to subtract
  74505. * @returns the updated Vector4.
  74506. */
  74507. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  74508. /**
  74509. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  74510. * @param otherVector the vector to add
  74511. * @returns the new vector with the result
  74512. */
  74513. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  74514. /**
  74515. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  74516. * @param otherVector the vector to subtract
  74517. * @param result the vector to store the result
  74518. * @returns the current Vector4.
  74519. */
  74520. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74521. /**
  74522. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74523. */
  74524. /**
  74525. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74526. * @param x value to subtract
  74527. * @param y value to subtract
  74528. * @param z value to subtract
  74529. * @param w value to subtract
  74530. * @returns new vector containing the result
  74531. */
  74532. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  74533. /**
  74534. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74535. * @param x value to subtract
  74536. * @param y value to subtract
  74537. * @param z value to subtract
  74538. * @param w value to subtract
  74539. * @param result the vector to store the result in
  74540. * @returns the current Vector4.
  74541. */
  74542. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  74543. /**
  74544. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  74545. * @returns a new vector with the negated values
  74546. */
  74547. negate(): Vector4;
  74548. /**
  74549. * Multiplies the current Vector4 coordinates by scale (float).
  74550. * @param scale the number to scale with
  74551. * @returns the updated Vector4.
  74552. */
  74553. scaleInPlace(scale: number): Vector4;
  74554. /**
  74555. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  74556. * @param scale the number to scale with
  74557. * @returns a new vector with the result
  74558. */
  74559. scale(scale: number): Vector4;
  74560. /**
  74561. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  74562. * @param scale the number to scale with
  74563. * @param result a vector to store the result in
  74564. * @returns the current Vector4.
  74565. */
  74566. scaleToRef(scale: number, result: Vector4): Vector4;
  74567. /**
  74568. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  74569. * @param scale defines the scale factor
  74570. * @param result defines the Vector4 object where to store the result
  74571. * @returns the unmodified current Vector4
  74572. */
  74573. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  74574. /**
  74575. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  74576. * @param otherVector the vector to compare against
  74577. * @returns true if they are equal
  74578. */
  74579. equals(otherVector: DeepImmutable<Vector4>): boolean;
  74580. /**
  74581. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  74582. * @param otherVector vector to compare against
  74583. * @param epsilon (Default: very small number)
  74584. * @returns true if they are equal
  74585. */
  74586. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  74587. /**
  74588. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  74589. * @param x x value to compare against
  74590. * @param y y value to compare against
  74591. * @param z z value to compare against
  74592. * @param w w value to compare against
  74593. * @returns true if equal
  74594. */
  74595. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  74596. /**
  74597. * Multiplies in place the current Vector4 by the given one.
  74598. * @param otherVector vector to multiple with
  74599. * @returns the updated Vector4.
  74600. */
  74601. multiplyInPlace(otherVector: Vector4): Vector4;
  74602. /**
  74603. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  74604. * @param otherVector vector to multiple with
  74605. * @returns resulting new vector
  74606. */
  74607. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  74608. /**
  74609. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  74610. * @param otherVector vector to multiple with
  74611. * @param result vector to store the result
  74612. * @returns the current Vector4.
  74613. */
  74614. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74615. /**
  74616. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  74617. * @param x x value multiply with
  74618. * @param y y value multiply with
  74619. * @param z z value multiply with
  74620. * @param w w value multiply with
  74621. * @returns resulting new vector
  74622. */
  74623. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  74624. /**
  74625. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  74626. * @param otherVector vector to devide with
  74627. * @returns resulting new vector
  74628. */
  74629. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  74630. /**
  74631. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  74632. * @param otherVector vector to devide with
  74633. * @param result vector to store the result
  74634. * @returns the current Vector4.
  74635. */
  74636. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74637. /**
  74638. * Divides the current Vector3 coordinates by the given ones.
  74639. * @param otherVector vector to devide with
  74640. * @returns the updated Vector3.
  74641. */
  74642. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  74643. /**
  74644. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  74645. * @param other defines the second operand
  74646. * @returns the current updated Vector4
  74647. */
  74648. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  74649. /**
  74650. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  74651. * @param other defines the second operand
  74652. * @returns the current updated Vector4
  74653. */
  74654. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  74655. /**
  74656. * Gets a new Vector4 from current Vector4 floored values
  74657. * @returns a new Vector4
  74658. */
  74659. floor(): Vector4;
  74660. /**
  74661. * Gets a new Vector4 from current Vector3 floored values
  74662. * @returns a new Vector4
  74663. */
  74664. fract(): Vector4;
  74665. /**
  74666. * Returns the Vector4 length (float).
  74667. * @returns the length
  74668. */
  74669. length(): number;
  74670. /**
  74671. * Returns the Vector4 squared length (float).
  74672. * @returns the length squared
  74673. */
  74674. lengthSquared(): number;
  74675. /**
  74676. * Normalizes in place the Vector4.
  74677. * @returns the updated Vector4.
  74678. */
  74679. normalize(): Vector4;
  74680. /**
  74681. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  74682. * @returns this converted to a new vector3
  74683. */
  74684. toVector3(): Vector3;
  74685. /**
  74686. * Returns a new Vector4 copied from the current one.
  74687. * @returns the new cloned vector
  74688. */
  74689. clone(): Vector4;
  74690. /**
  74691. * Updates the current Vector4 with the given one coordinates.
  74692. * @param source the source vector to copy from
  74693. * @returns the updated Vector4.
  74694. */
  74695. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  74696. /**
  74697. * Updates the current Vector4 coordinates with the given floats.
  74698. * @param x float to copy from
  74699. * @param y float to copy from
  74700. * @param z float to copy from
  74701. * @param w float to copy from
  74702. * @returns the updated Vector4.
  74703. */
  74704. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  74705. /**
  74706. * Updates the current Vector4 coordinates with the given floats.
  74707. * @param x float to set from
  74708. * @param y float to set from
  74709. * @param z float to set from
  74710. * @param w float to set from
  74711. * @returns the updated Vector4.
  74712. */
  74713. set(x: number, y: number, z: number, w: number): Vector4;
  74714. /**
  74715. * Copies the given float to the current Vector3 coordinates
  74716. * @param v defines the x, y, z and w coordinates of the operand
  74717. * @returns the current updated Vector3
  74718. */
  74719. setAll(v: number): Vector4;
  74720. /**
  74721. * Returns a new Vector4 set from the starting index of the given array.
  74722. * @param array the array to pull values from
  74723. * @param offset the offset into the array to start at
  74724. * @returns the new vector
  74725. */
  74726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  74727. /**
  74728. * Updates the given vector "result" from the starting index of the given array.
  74729. * @param array the array to pull values from
  74730. * @param offset the offset into the array to start at
  74731. * @param result the vector to store the result in
  74732. */
  74733. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  74734. /**
  74735. * Updates the given vector "result" from the starting index of the given Float32Array.
  74736. * @param array the array to pull values from
  74737. * @param offset the offset into the array to start at
  74738. * @param result the vector to store the result in
  74739. */
  74740. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  74741. /**
  74742. * Updates the given vector "result" coordinates from the given floats.
  74743. * @param x float to set from
  74744. * @param y float to set from
  74745. * @param z float to set from
  74746. * @param w float to set from
  74747. * @param result the vector to the floats in
  74748. */
  74749. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  74750. /**
  74751. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74752. * @returns the new vector
  74753. */
  74754. static Zero(): Vector4;
  74755. /**
  74756. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74757. * @returns the new vector
  74758. */
  74759. static One(): Vector4;
  74760. /**
  74761. * Returns a new normalized Vector4 from the given one.
  74762. * @param vector the vector to normalize
  74763. * @returns the vector
  74764. */
  74765. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  74766. /**
  74767. * Updates the given vector "result" from the normalization of the given one.
  74768. * @param vector the vector to normalize
  74769. * @param result the vector to store the result in
  74770. */
  74771. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  74772. /**
  74773. * Returns a vector with the minimum values from the left and right vectors
  74774. * @param left left vector to minimize
  74775. * @param right right vector to minimize
  74776. * @returns a new vector with the minimum of the left and right vector values
  74777. */
  74778. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74779. /**
  74780. * Returns a vector with the maximum values from the left and right vectors
  74781. * @param left left vector to maximize
  74782. * @param right right vector to maximize
  74783. * @returns a new vector with the maximum of the left and right vector values
  74784. */
  74785. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74786. /**
  74787. * Returns the distance (float) between the vectors "value1" and "value2".
  74788. * @param value1 value to calulate the distance between
  74789. * @param value2 value to calulate the distance between
  74790. * @return the distance between the two vectors
  74791. */
  74792. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74793. /**
  74794. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74795. * @param value1 value to calulate the distance between
  74796. * @param value2 value to calulate the distance between
  74797. * @return the distance between the two vectors squared
  74798. */
  74799. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74800. /**
  74801. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74802. * @param value1 value to calulate the center between
  74803. * @param value2 value to calulate the center between
  74804. * @return the center between the two vectors
  74805. */
  74806. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  74807. /**
  74808. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74809. * This methods computes transformed normalized direction vectors only.
  74810. * @param vector the vector to transform
  74811. * @param transformation the transformation matrix to apply
  74812. * @returns the new vector
  74813. */
  74814. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  74815. /**
  74816. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74817. * This methods computes transformed normalized direction vectors only.
  74818. * @param vector the vector to transform
  74819. * @param transformation the transformation matrix to apply
  74820. * @param result the vector to store the result in
  74821. */
  74822. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74823. /**
  74824. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74825. * This methods computes transformed normalized direction vectors only.
  74826. * @param x value to transform
  74827. * @param y value to transform
  74828. * @param z value to transform
  74829. * @param w value to transform
  74830. * @param transformation the transformation matrix to apply
  74831. * @param result the vector to store the results in
  74832. */
  74833. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74834. /**
  74835. * Creates a new Vector4 from a Vector3
  74836. * @param source defines the source data
  74837. * @param w defines the 4th component (default is 0)
  74838. * @returns a new Vector4
  74839. */
  74840. static FromVector3(source: Vector3, w?: number): Vector4;
  74841. }
  74842. /**
  74843. * Class used to store quaternion data
  74844. * @see https://en.wikipedia.org/wiki/Quaternion
  74845. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74846. */
  74847. export class Quaternion {
  74848. /** defines the first component (0 by default) */
  74849. x: number;
  74850. /** defines the second component (0 by default) */
  74851. y: number;
  74852. /** defines the third component (0 by default) */
  74853. z: number;
  74854. /** defines the fourth component (1.0 by default) */
  74855. w: number;
  74856. /**
  74857. * Creates a new Quaternion from the given floats
  74858. * @param x defines the first component (0 by default)
  74859. * @param y defines the second component (0 by default)
  74860. * @param z defines the third component (0 by default)
  74861. * @param w defines the fourth component (1.0 by default)
  74862. */
  74863. constructor(
  74864. /** defines the first component (0 by default) */
  74865. x?: number,
  74866. /** defines the second component (0 by default) */
  74867. y?: number,
  74868. /** defines the third component (0 by default) */
  74869. z?: number,
  74870. /** defines the fourth component (1.0 by default) */
  74871. w?: number);
  74872. /**
  74873. * Gets a string representation for the current quaternion
  74874. * @returns a string with the Quaternion coordinates
  74875. */
  74876. toString(): string;
  74877. /**
  74878. * Gets the class name of the quaternion
  74879. * @returns the string "Quaternion"
  74880. */
  74881. getClassName(): string;
  74882. /**
  74883. * Gets a hash code for this quaternion
  74884. * @returns the quaternion hash code
  74885. */
  74886. getHashCode(): number;
  74887. /**
  74888. * Copy the quaternion to an array
  74889. * @returns a new array populated with 4 elements from the quaternion coordinates
  74890. */
  74891. asArray(): number[];
  74892. /**
  74893. * Check if two quaternions are equals
  74894. * @param otherQuaternion defines the second operand
  74895. * @return true if the current quaternion and the given one coordinates are strictly equals
  74896. */
  74897. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74898. /**
  74899. * Gets a boolean if two quaternions are equals (using an epsilon value)
  74900. * @param otherQuaternion defines the other quaternion
  74901. * @param epsilon defines the minimal distance to consider equality
  74902. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  74903. */
  74904. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  74905. /**
  74906. * Clone the current quaternion
  74907. * @returns a new quaternion copied from the current one
  74908. */
  74909. clone(): Quaternion;
  74910. /**
  74911. * Copy a quaternion to the current one
  74912. * @param other defines the other quaternion
  74913. * @returns the updated current quaternion
  74914. */
  74915. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74916. /**
  74917. * Updates the current quaternion with the given float coordinates
  74918. * @param x defines the x coordinate
  74919. * @param y defines the y coordinate
  74920. * @param z defines the z coordinate
  74921. * @param w defines the w coordinate
  74922. * @returns the updated current quaternion
  74923. */
  74924. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74925. /**
  74926. * Updates the current quaternion from the given float coordinates
  74927. * @param x defines the x coordinate
  74928. * @param y defines the y coordinate
  74929. * @param z defines the z coordinate
  74930. * @param w defines the w coordinate
  74931. * @returns the updated current quaternion
  74932. */
  74933. set(x: number, y: number, z: number, w: number): Quaternion;
  74934. /**
  74935. * Adds two quaternions
  74936. * @param other defines the second operand
  74937. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74938. */
  74939. add(other: DeepImmutable<Quaternion>): Quaternion;
  74940. /**
  74941. * Add a quaternion to the current one
  74942. * @param other defines the quaternion to add
  74943. * @returns the current quaternion
  74944. */
  74945. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74946. /**
  74947. * Subtract two quaternions
  74948. * @param other defines the second operand
  74949. * @returns a new quaternion as the subtraction result of the given one from the current one
  74950. */
  74951. subtract(other: Quaternion): Quaternion;
  74952. /**
  74953. * Multiplies the current quaternion by a scale factor
  74954. * @param value defines the scale factor
  74955. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74956. */
  74957. scale(value: number): Quaternion;
  74958. /**
  74959. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74960. * @param scale defines the scale factor
  74961. * @param result defines the Quaternion object where to store the result
  74962. * @returns the unmodified current quaternion
  74963. */
  74964. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74965. /**
  74966. * Multiplies in place the current quaternion by a scale factor
  74967. * @param value defines the scale factor
  74968. * @returns the current modified quaternion
  74969. */
  74970. scaleInPlace(value: number): Quaternion;
  74971. /**
  74972. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74973. * @param scale defines the scale factor
  74974. * @param result defines the Quaternion object where to store the result
  74975. * @returns the unmodified current quaternion
  74976. */
  74977. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74978. /**
  74979. * Multiplies two quaternions
  74980. * @param q1 defines the second operand
  74981. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74982. */
  74983. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74984. /**
  74985. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74986. * @param q1 defines the second operand
  74987. * @param result defines the target quaternion
  74988. * @returns the current quaternion
  74989. */
  74990. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74991. /**
  74992. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74993. * @param q1 defines the second operand
  74994. * @returns the currentupdated quaternion
  74995. */
  74996. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  74997. /**
  74998. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74999. * @param ref defines the target quaternion
  75000. * @returns the current quaternion
  75001. */
  75002. conjugateToRef(ref: Quaternion): Quaternion;
  75003. /**
  75004. * Conjugates in place (1-q) the current quaternion
  75005. * @returns the current updated quaternion
  75006. */
  75007. conjugateInPlace(): Quaternion;
  75008. /**
  75009. * Conjugates in place (1-q) the current quaternion
  75010. * @returns a new quaternion
  75011. */
  75012. conjugate(): Quaternion;
  75013. /**
  75014. * Gets length of current quaternion
  75015. * @returns the quaternion length (float)
  75016. */
  75017. length(): number;
  75018. /**
  75019. * Normalize in place the current quaternion
  75020. * @returns the current updated quaternion
  75021. */
  75022. normalize(): Quaternion;
  75023. /**
  75024. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  75025. * @param order is a reserved parameter and is ignore for now
  75026. * @returns a new Vector3 containing the Euler angles
  75027. */
  75028. toEulerAngles(order?: string): Vector3;
  75029. /**
  75030. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  75031. * @param result defines the vector which will be filled with the Euler angles
  75032. * @param order is a reserved parameter and is ignore for now
  75033. * @returns the current unchanged quaternion
  75034. */
  75035. toEulerAnglesToRef(result: Vector3): Quaternion;
  75036. /**
  75037. * Updates the given rotation matrix with the current quaternion values
  75038. * @param result defines the target matrix
  75039. * @returns the current unchanged quaternion
  75040. */
  75041. toRotationMatrix(result: Matrix): Quaternion;
  75042. /**
  75043. * Updates the current quaternion from the given rotation matrix values
  75044. * @param matrix defines the source matrix
  75045. * @returns the current updated quaternion
  75046. */
  75047. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  75048. /**
  75049. * Creates a new quaternion from a rotation matrix
  75050. * @param matrix defines the source matrix
  75051. * @returns a new quaternion created from the given rotation matrix values
  75052. */
  75053. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  75054. /**
  75055. * Updates the given quaternion with the given rotation matrix values
  75056. * @param matrix defines the source matrix
  75057. * @param result defines the target quaternion
  75058. */
  75059. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  75060. /**
  75061. * Returns the dot product (float) between the quaternions "left" and "right"
  75062. * @param left defines the left operand
  75063. * @param right defines the right operand
  75064. * @returns the dot product
  75065. */
  75066. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  75067. /**
  75068. * Checks if the two quaternions are close to each other
  75069. * @param quat0 defines the first quaternion to check
  75070. * @param quat1 defines the second quaternion to check
  75071. * @returns true if the two quaternions are close to each other
  75072. */
  75073. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  75074. /**
  75075. * Creates an empty quaternion
  75076. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  75077. */
  75078. static Zero(): Quaternion;
  75079. /**
  75080. * Inverse a given quaternion
  75081. * @param q defines the source quaternion
  75082. * @returns a new quaternion as the inverted current quaternion
  75083. */
  75084. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  75085. /**
  75086. * Inverse a given quaternion
  75087. * @param q defines the source quaternion
  75088. * @param result the quaternion the result will be stored in
  75089. * @returns the result quaternion
  75090. */
  75091. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  75092. /**
  75093. * Creates an identity quaternion
  75094. * @returns the identity quaternion
  75095. */
  75096. static Identity(): Quaternion;
  75097. /**
  75098. * Gets a boolean indicating if the given quaternion is identity
  75099. * @param quaternion defines the quaternion to check
  75100. * @returns true if the quaternion is identity
  75101. */
  75102. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  75103. /**
  75104. * Creates a quaternion from a rotation around an axis
  75105. * @param axis defines the axis to use
  75106. * @param angle defines the angle to use
  75107. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  75108. */
  75109. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  75110. /**
  75111. * Creates a rotation around an axis and stores it into the given quaternion
  75112. * @param axis defines the axis to use
  75113. * @param angle defines the angle to use
  75114. * @param result defines the target quaternion
  75115. * @returns the target quaternion
  75116. */
  75117. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  75118. /**
  75119. * Creates a new quaternion from data stored into an array
  75120. * @param array defines the data source
  75121. * @param offset defines the offset in the source array where the data starts
  75122. * @returns a new quaternion
  75123. */
  75124. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  75125. /**
  75126. * Create a quaternion from Euler rotation angles
  75127. * @param x Pitch
  75128. * @param y Yaw
  75129. * @param z Roll
  75130. * @returns the new Quaternion
  75131. */
  75132. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  75133. /**
  75134. * Updates a quaternion from Euler rotation angles
  75135. * @param x Pitch
  75136. * @param y Yaw
  75137. * @param z Roll
  75138. * @param result the quaternion to store the result
  75139. * @returns the updated quaternion
  75140. */
  75141. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  75142. /**
  75143. * Create a quaternion from Euler rotation vector
  75144. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  75145. * @returns the new Quaternion
  75146. */
  75147. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  75148. /**
  75149. * Updates a quaternion from Euler rotation vector
  75150. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  75151. * @param result the quaternion to store the result
  75152. * @returns the updated quaternion
  75153. */
  75154. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  75155. /**
  75156. * Creates a new quaternion from the given Euler float angles (y, x, z)
  75157. * @param yaw defines the rotation around Y axis
  75158. * @param pitch defines the rotation around X axis
  75159. * @param roll defines the rotation around Z axis
  75160. * @returns the new quaternion
  75161. */
  75162. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  75163. /**
  75164. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  75165. * @param yaw defines the rotation around Y axis
  75166. * @param pitch defines the rotation around X axis
  75167. * @param roll defines the rotation around Z axis
  75168. * @param result defines the target quaternion
  75169. */
  75170. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  75171. /**
  75172. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  75173. * @param alpha defines the rotation around first axis
  75174. * @param beta defines the rotation around second axis
  75175. * @param gamma defines the rotation around third axis
  75176. * @returns the new quaternion
  75177. */
  75178. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  75179. /**
  75180. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  75181. * @param alpha defines the rotation around first axis
  75182. * @param beta defines the rotation around second axis
  75183. * @param gamma defines the rotation around third axis
  75184. * @param result defines the target quaternion
  75185. */
  75186. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  75187. /**
  75188. * 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)
  75189. * @param axis1 defines the first axis
  75190. * @param axis2 defines the second axis
  75191. * @param axis3 defines the third axis
  75192. * @returns the new quaternion
  75193. */
  75194. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  75195. /**
  75196. * 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
  75197. * @param axis1 defines the first axis
  75198. * @param axis2 defines the second axis
  75199. * @param axis3 defines the third axis
  75200. * @param ref defines the target quaternion
  75201. */
  75202. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  75203. /**
  75204. * Interpolates between two quaternions
  75205. * @param left defines first quaternion
  75206. * @param right defines second quaternion
  75207. * @param amount defines the gradient to use
  75208. * @returns the new interpolated quaternion
  75209. */
  75210. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  75211. /**
  75212. * Interpolates between two quaternions and stores it into a target quaternion
  75213. * @param left defines first quaternion
  75214. * @param right defines second quaternion
  75215. * @param amount defines the gradient to use
  75216. * @param result defines the target quaternion
  75217. */
  75218. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  75219. /**
  75220. * Interpolate between two quaternions using Hermite interpolation
  75221. * @param value1 defines first quaternion
  75222. * @param tangent1 defines the incoming tangent
  75223. * @param value2 defines second quaternion
  75224. * @param tangent2 defines the outgoing tangent
  75225. * @param amount defines the target quaternion
  75226. * @returns the new interpolated quaternion
  75227. */
  75228. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  75229. }
  75230. /**
  75231. * Class used to store matrix data (4x4)
  75232. */
  75233. export class Matrix {
  75234. private static _updateFlagSeed;
  75235. private static _identityReadOnly;
  75236. private _isIdentity;
  75237. private _isIdentityDirty;
  75238. private _isIdentity3x2;
  75239. private _isIdentity3x2Dirty;
  75240. /**
  75241. * Gets the update flag of the matrix which is an unique number for the matrix.
  75242. * It will be incremented every time the matrix data change.
  75243. * You can use it to speed the comparison between two versions of the same matrix.
  75244. */
  75245. updateFlag: number;
  75246. private readonly _m;
  75247. /**
  75248. * Gets the internal data of the matrix
  75249. */
  75250. get m(): DeepImmutable<Float32Array>;
  75251. /** @hidden */
  75252. _markAsUpdated(): void;
  75253. /** @hidden */
  75254. private _updateIdentityStatus;
  75255. /**
  75256. * Creates an empty matrix (filled with zeros)
  75257. */
  75258. constructor();
  75259. /**
  75260. * Check if the current matrix is identity
  75261. * @returns true is the matrix is the identity matrix
  75262. */
  75263. isIdentity(): boolean;
  75264. /**
  75265. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  75266. * @returns true is the matrix is the identity matrix
  75267. */
  75268. isIdentityAs3x2(): boolean;
  75269. /**
  75270. * Gets the determinant of the matrix
  75271. * @returns the matrix determinant
  75272. */
  75273. determinant(): number;
  75274. /**
  75275. * Returns the matrix as a Float32Array
  75276. * @returns the matrix underlying array
  75277. */
  75278. toArray(): DeepImmutable<Float32Array>;
  75279. /**
  75280. * Returns the matrix as a Float32Array
  75281. * @returns the matrix underlying array.
  75282. */
  75283. asArray(): DeepImmutable<Float32Array>;
  75284. /**
  75285. * Inverts the current matrix in place
  75286. * @returns the current inverted matrix
  75287. */
  75288. invert(): Matrix;
  75289. /**
  75290. * Sets all the matrix elements to zero
  75291. * @returns the current matrix
  75292. */
  75293. reset(): Matrix;
  75294. /**
  75295. * Adds the current matrix with a second one
  75296. * @param other defines the matrix to add
  75297. * @returns a new matrix as the addition of the current matrix and the given one
  75298. */
  75299. add(other: DeepImmutable<Matrix>): Matrix;
  75300. /**
  75301. * Sets the given matrix "result" to the addition of the current matrix and the given one
  75302. * @param other defines the matrix to add
  75303. * @param result defines the target matrix
  75304. * @returns the current matrix
  75305. */
  75306. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  75307. /**
  75308. * Adds in place the given matrix to the current matrix
  75309. * @param other defines the second operand
  75310. * @returns the current updated matrix
  75311. */
  75312. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  75313. /**
  75314. * Sets the given matrix to the current inverted Matrix
  75315. * @param other defines the target matrix
  75316. * @returns the unmodified current matrix
  75317. */
  75318. invertToRef(other: Matrix): Matrix;
  75319. /**
  75320. * add a value at the specified position in the current Matrix
  75321. * @param index the index of the value within the matrix. between 0 and 15.
  75322. * @param value the value to be added
  75323. * @returns the current updated matrix
  75324. */
  75325. addAtIndex(index: number, value: number): Matrix;
  75326. /**
  75327. * mutiply the specified position in the current Matrix by a value
  75328. * @param index the index of the value within the matrix. between 0 and 15.
  75329. * @param value the value to be added
  75330. * @returns the current updated matrix
  75331. */
  75332. multiplyAtIndex(index: number, value: number): Matrix;
  75333. /**
  75334. * Inserts the translation vector (using 3 floats) in the current matrix
  75335. * @param x defines the 1st component of the translation
  75336. * @param y defines the 2nd component of the translation
  75337. * @param z defines the 3rd component of the translation
  75338. * @returns the current updated matrix
  75339. */
  75340. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  75341. /**
  75342. * Adds the translation vector (using 3 floats) in the current matrix
  75343. * @param x defines the 1st component of the translation
  75344. * @param y defines the 2nd component of the translation
  75345. * @param z defines the 3rd component of the translation
  75346. * @returns the current updated matrix
  75347. */
  75348. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  75349. /**
  75350. * Inserts the translation vector in the current matrix
  75351. * @param vector3 defines the translation to insert
  75352. * @returns the current updated matrix
  75353. */
  75354. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  75355. /**
  75356. * Gets the translation value of the current matrix
  75357. * @returns a new Vector3 as the extracted translation from the matrix
  75358. */
  75359. getTranslation(): Vector3;
  75360. /**
  75361. * Fill a Vector3 with the extracted translation from the matrix
  75362. * @param result defines the Vector3 where to store the translation
  75363. * @returns the current matrix
  75364. */
  75365. getTranslationToRef(result: Vector3): Matrix;
  75366. /**
  75367. * Remove rotation and scaling part from the matrix
  75368. * @returns the updated matrix
  75369. */
  75370. removeRotationAndScaling(): Matrix;
  75371. /**
  75372. * Multiply two matrices
  75373. * @param other defines the second operand
  75374. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  75375. */
  75376. multiply(other: DeepImmutable<Matrix>): Matrix;
  75377. /**
  75378. * Copy the current matrix from the given one
  75379. * @param other defines the source matrix
  75380. * @returns the current updated matrix
  75381. */
  75382. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  75383. /**
  75384. * Populates the given array from the starting index with the current matrix values
  75385. * @param array defines the target array
  75386. * @param offset defines the offset in the target array where to start storing values
  75387. * @returns the current matrix
  75388. */
  75389. copyToArray(array: Float32Array, offset?: number): Matrix;
  75390. /**
  75391. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  75392. * @param other defines the second operand
  75393. * @param result defines the matrix where to store the multiplication
  75394. * @returns the current matrix
  75395. */
  75396. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  75397. /**
  75398. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  75399. * @param other defines the second operand
  75400. * @param result defines the array where to store the multiplication
  75401. * @param offset defines the offset in the target array where to start storing values
  75402. * @returns the current matrix
  75403. */
  75404. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  75405. /**
  75406. * Check equality between this matrix and a second one
  75407. * @param value defines the second matrix to compare
  75408. * @returns true is the current matrix and the given one values are strictly equal
  75409. */
  75410. equals(value: DeepImmutable<Matrix>): boolean;
  75411. /**
  75412. * Clone the current matrix
  75413. * @returns a new matrix from the current matrix
  75414. */
  75415. clone(): Matrix;
  75416. /**
  75417. * Returns the name of the current matrix class
  75418. * @returns the string "Matrix"
  75419. */
  75420. getClassName(): string;
  75421. /**
  75422. * Gets the hash code of the current matrix
  75423. * @returns the hash code
  75424. */
  75425. getHashCode(): number;
  75426. /**
  75427. * Decomposes the current Matrix into a translation, rotation and scaling components
  75428. * @param scale defines the scale vector3 given as a reference to update
  75429. * @param rotation defines the rotation quaternion given as a reference to update
  75430. * @param translation defines the translation vector3 given as a reference to update
  75431. * @returns true if operation was successful
  75432. */
  75433. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  75434. /**
  75435. * Gets specific row of the matrix
  75436. * @param index defines the number of the row to get
  75437. * @returns the index-th row of the current matrix as a new Vector4
  75438. */
  75439. getRow(index: number): Nullable<Vector4>;
  75440. /**
  75441. * Sets the index-th row of the current matrix to the vector4 values
  75442. * @param index defines the number of the row to set
  75443. * @param row defines the target vector4
  75444. * @returns the updated current matrix
  75445. */
  75446. setRow(index: number, row: Vector4): Matrix;
  75447. /**
  75448. * Compute the transpose of the matrix
  75449. * @returns the new transposed matrix
  75450. */
  75451. transpose(): Matrix;
  75452. /**
  75453. * Compute the transpose of the matrix and store it in a given matrix
  75454. * @param result defines the target matrix
  75455. * @returns the current matrix
  75456. */
  75457. transposeToRef(result: Matrix): Matrix;
  75458. /**
  75459. * Sets the index-th row of the current matrix with the given 4 x float values
  75460. * @param index defines the row index
  75461. * @param x defines the x component to set
  75462. * @param y defines the y component to set
  75463. * @param z defines the z component to set
  75464. * @param w defines the w component to set
  75465. * @returns the updated current matrix
  75466. */
  75467. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  75468. /**
  75469. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  75470. * @param scale defines the scale factor
  75471. * @returns a new matrix
  75472. */
  75473. scale(scale: number): Matrix;
  75474. /**
  75475. * Scale the current matrix values by a factor to a given result matrix
  75476. * @param scale defines the scale factor
  75477. * @param result defines the matrix to store the result
  75478. * @returns the current matrix
  75479. */
  75480. scaleToRef(scale: number, result: Matrix): Matrix;
  75481. /**
  75482. * Scale the current matrix values by a factor and add the result to a given matrix
  75483. * @param scale defines the scale factor
  75484. * @param result defines the Matrix to store the result
  75485. * @returns the current matrix
  75486. */
  75487. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  75488. /**
  75489. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  75490. * @param ref matrix to store the result
  75491. */
  75492. toNormalMatrix(ref: Matrix): void;
  75493. /**
  75494. * Gets only rotation part of the current matrix
  75495. * @returns a new matrix sets to the extracted rotation matrix from the current one
  75496. */
  75497. getRotationMatrix(): Matrix;
  75498. /**
  75499. * Extracts the rotation matrix from the current one and sets it as the given "result"
  75500. * @param result defines the target matrix to store data to
  75501. * @returns the current matrix
  75502. */
  75503. getRotationMatrixToRef(result: Matrix): Matrix;
  75504. /**
  75505. * Toggles model matrix from being right handed to left handed in place and vice versa
  75506. */
  75507. toggleModelMatrixHandInPlace(): void;
  75508. /**
  75509. * Toggles projection matrix from being right handed to left handed in place and vice versa
  75510. */
  75511. toggleProjectionMatrixHandInPlace(): void;
  75512. /**
  75513. * Creates a matrix from an array
  75514. * @param array defines the source array
  75515. * @param offset defines an offset in the source array
  75516. * @returns a new Matrix set from the starting index of the given array
  75517. */
  75518. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  75519. /**
  75520. * Copy the content of an array into a given matrix
  75521. * @param array defines the source array
  75522. * @param offset defines an offset in the source array
  75523. * @param result defines the target matrix
  75524. */
  75525. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  75526. /**
  75527. * Stores an array into a matrix after having multiplied each component by a given factor
  75528. * @param array defines the source array
  75529. * @param offset defines the offset in the source array
  75530. * @param scale defines the scaling factor
  75531. * @param result defines the target matrix
  75532. */
  75533. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  75534. /**
  75535. * Gets an identity matrix that must not be updated
  75536. */
  75537. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  75538. /**
  75539. * Stores a list of values (16) inside a given matrix
  75540. * @param initialM11 defines 1st value of 1st row
  75541. * @param initialM12 defines 2nd value of 1st row
  75542. * @param initialM13 defines 3rd value of 1st row
  75543. * @param initialM14 defines 4th value of 1st row
  75544. * @param initialM21 defines 1st value of 2nd row
  75545. * @param initialM22 defines 2nd value of 2nd row
  75546. * @param initialM23 defines 3rd value of 2nd row
  75547. * @param initialM24 defines 4th value of 2nd row
  75548. * @param initialM31 defines 1st value of 3rd row
  75549. * @param initialM32 defines 2nd value of 3rd row
  75550. * @param initialM33 defines 3rd value of 3rd row
  75551. * @param initialM34 defines 4th value of 3rd row
  75552. * @param initialM41 defines 1st value of 4th row
  75553. * @param initialM42 defines 2nd value of 4th row
  75554. * @param initialM43 defines 3rd value of 4th row
  75555. * @param initialM44 defines 4th value of 4th row
  75556. * @param result defines the target matrix
  75557. */
  75558. 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;
  75559. /**
  75560. * Creates new matrix from a list of values (16)
  75561. * @param initialM11 defines 1st value of 1st row
  75562. * @param initialM12 defines 2nd value of 1st row
  75563. * @param initialM13 defines 3rd value of 1st row
  75564. * @param initialM14 defines 4th value of 1st row
  75565. * @param initialM21 defines 1st value of 2nd row
  75566. * @param initialM22 defines 2nd value of 2nd row
  75567. * @param initialM23 defines 3rd value of 2nd row
  75568. * @param initialM24 defines 4th value of 2nd row
  75569. * @param initialM31 defines 1st value of 3rd row
  75570. * @param initialM32 defines 2nd value of 3rd row
  75571. * @param initialM33 defines 3rd value of 3rd row
  75572. * @param initialM34 defines 4th value of 3rd row
  75573. * @param initialM41 defines 1st value of 4th row
  75574. * @param initialM42 defines 2nd value of 4th row
  75575. * @param initialM43 defines 3rd value of 4th row
  75576. * @param initialM44 defines 4th value of 4th row
  75577. * @returns the new matrix
  75578. */
  75579. 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;
  75580. /**
  75581. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75582. * @param scale defines the scale vector3
  75583. * @param rotation defines the rotation quaternion
  75584. * @param translation defines the translation vector3
  75585. * @returns a new matrix
  75586. */
  75587. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  75588. /**
  75589. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75590. * @param scale defines the scale vector3
  75591. * @param rotation defines the rotation quaternion
  75592. * @param translation defines the translation vector3
  75593. * @param result defines the target matrix
  75594. */
  75595. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  75596. /**
  75597. * Creates a new identity matrix
  75598. * @returns a new identity matrix
  75599. */
  75600. static Identity(): Matrix;
  75601. /**
  75602. * Creates a new identity matrix and stores the result in a given matrix
  75603. * @param result defines the target matrix
  75604. */
  75605. static IdentityToRef(result: Matrix): void;
  75606. /**
  75607. * Creates a new zero matrix
  75608. * @returns a new zero matrix
  75609. */
  75610. static Zero(): Matrix;
  75611. /**
  75612. * Creates a new rotation matrix for "angle" radians around the X axis
  75613. * @param angle defines the angle (in radians) to use
  75614. * @return the new matrix
  75615. */
  75616. static RotationX(angle: number): Matrix;
  75617. /**
  75618. * Creates a new matrix as the invert of a given matrix
  75619. * @param source defines the source matrix
  75620. * @returns the new matrix
  75621. */
  75622. static Invert(source: DeepImmutable<Matrix>): Matrix;
  75623. /**
  75624. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  75625. * @param angle defines the angle (in radians) to use
  75626. * @param result defines the target matrix
  75627. */
  75628. static RotationXToRef(angle: number, result: Matrix): void;
  75629. /**
  75630. * Creates a new rotation matrix for "angle" radians around the Y axis
  75631. * @param angle defines the angle (in radians) to use
  75632. * @return the new matrix
  75633. */
  75634. static RotationY(angle: number): Matrix;
  75635. /**
  75636. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  75637. * @param angle defines the angle (in radians) to use
  75638. * @param result defines the target matrix
  75639. */
  75640. static RotationYToRef(angle: number, result: Matrix): void;
  75641. /**
  75642. * Creates a new rotation matrix for "angle" radians around the Z axis
  75643. * @param angle defines the angle (in radians) to use
  75644. * @return the new matrix
  75645. */
  75646. static RotationZ(angle: number): Matrix;
  75647. /**
  75648. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  75649. * @param angle defines the angle (in radians) to use
  75650. * @param result defines the target matrix
  75651. */
  75652. static RotationZToRef(angle: number, result: Matrix): void;
  75653. /**
  75654. * Creates a new rotation matrix for "angle" radians around the given axis
  75655. * @param axis defines the axis to use
  75656. * @param angle defines the angle (in radians) to use
  75657. * @return the new matrix
  75658. */
  75659. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  75660. /**
  75661. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  75662. * @param axis defines the axis to use
  75663. * @param angle defines the angle (in radians) to use
  75664. * @param result defines the target matrix
  75665. */
  75666. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  75667. /**
  75668. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  75669. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  75670. * @param from defines the vector to align
  75671. * @param to defines the vector to align to
  75672. * @param result defines the target matrix
  75673. */
  75674. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  75675. /**
  75676. * Creates a rotation matrix
  75677. * @param yaw defines the yaw angle in radians (Y axis)
  75678. * @param pitch defines the pitch angle in radians (X axis)
  75679. * @param roll defines the roll angle in radians (X axis)
  75680. * @returns the new rotation matrix
  75681. */
  75682. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  75683. /**
  75684. * Creates a rotation matrix and stores it in a given matrix
  75685. * @param yaw defines the yaw angle in radians (Y axis)
  75686. * @param pitch defines the pitch angle in radians (X axis)
  75687. * @param roll defines the roll angle in radians (X axis)
  75688. * @param result defines the target matrix
  75689. */
  75690. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  75691. /**
  75692. * Creates a scaling matrix
  75693. * @param x defines the scale factor on X axis
  75694. * @param y defines the scale factor on Y axis
  75695. * @param z defines the scale factor on Z axis
  75696. * @returns the new matrix
  75697. */
  75698. static Scaling(x: number, y: number, z: number): Matrix;
  75699. /**
  75700. * Creates a scaling matrix and stores it in a given matrix
  75701. * @param x defines the scale factor on X axis
  75702. * @param y defines the scale factor on Y axis
  75703. * @param z defines the scale factor on Z axis
  75704. * @param result defines the target matrix
  75705. */
  75706. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  75707. /**
  75708. * Creates a translation matrix
  75709. * @param x defines the translation on X axis
  75710. * @param y defines the translation on Y axis
  75711. * @param z defines the translationon Z axis
  75712. * @returns the new matrix
  75713. */
  75714. static Translation(x: number, y: number, z: number): Matrix;
  75715. /**
  75716. * Creates a translation matrix and stores it in a given matrix
  75717. * @param x defines the translation on X axis
  75718. * @param y defines the translation on Y axis
  75719. * @param z defines the translationon Z axis
  75720. * @param result defines the target matrix
  75721. */
  75722. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  75723. /**
  75724. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75725. * @param startValue defines the start value
  75726. * @param endValue defines the end value
  75727. * @param gradient defines the gradient factor
  75728. * @returns the new matrix
  75729. */
  75730. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75731. /**
  75732. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75733. * @param startValue defines the start value
  75734. * @param endValue defines the end value
  75735. * @param gradient defines the gradient factor
  75736. * @param result defines the Matrix object where to store data
  75737. */
  75738. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75739. /**
  75740. * Builds a new matrix whose values are computed by:
  75741. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75742. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75743. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75744. * @param startValue defines the first matrix
  75745. * @param endValue defines the second matrix
  75746. * @param gradient defines the gradient between the two matrices
  75747. * @returns the new matrix
  75748. */
  75749. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75750. /**
  75751. * Update a matrix to values which are computed by:
  75752. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75753. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75754. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75755. * @param startValue defines the first matrix
  75756. * @param endValue defines the second matrix
  75757. * @param gradient defines the gradient between the two matrices
  75758. * @param result defines the target matrix
  75759. */
  75760. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75761. /**
  75762. * 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"
  75763. * This function works in left handed mode
  75764. * @param eye defines the final position of the entity
  75765. * @param target defines where the entity should look at
  75766. * @param up defines the up vector for the entity
  75767. * @returns the new matrix
  75768. */
  75769. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75770. /**
  75771. * 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".
  75772. * This function works in left handed mode
  75773. * @param eye defines the final position of the entity
  75774. * @param target defines where the entity should look at
  75775. * @param up defines the up vector for the entity
  75776. * @param result defines the target matrix
  75777. */
  75778. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75779. /**
  75780. * 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"
  75781. * This function works in right handed mode
  75782. * @param eye defines the final position of the entity
  75783. * @param target defines where the entity should look at
  75784. * @param up defines the up vector for the entity
  75785. * @returns the new matrix
  75786. */
  75787. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75788. /**
  75789. * 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".
  75790. * This function works in right handed mode
  75791. * @param eye defines the final position of the entity
  75792. * @param target defines where the entity should look at
  75793. * @param up defines the up vector for the entity
  75794. * @param result defines the target matrix
  75795. */
  75796. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75797. /**
  75798. * Create a left-handed orthographic projection matrix
  75799. * @param width defines the viewport width
  75800. * @param height defines the viewport height
  75801. * @param znear defines the near clip plane
  75802. * @param zfar defines the far clip plane
  75803. * @returns a new matrix as a left-handed orthographic projection matrix
  75804. */
  75805. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75806. /**
  75807. * Store a left-handed orthographic projection to a given matrix
  75808. * @param width defines the viewport width
  75809. * @param height defines the viewport height
  75810. * @param znear defines the near clip plane
  75811. * @param zfar defines the far clip plane
  75812. * @param result defines the target matrix
  75813. */
  75814. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  75815. /**
  75816. * Create a left-handed orthographic projection matrix
  75817. * @param left defines the viewport left coordinate
  75818. * @param right defines the viewport right coordinate
  75819. * @param bottom defines the viewport bottom coordinate
  75820. * @param top defines the viewport top coordinate
  75821. * @param znear defines the near clip plane
  75822. * @param zfar defines the far clip plane
  75823. * @returns a new matrix as a left-handed orthographic projection matrix
  75824. */
  75825. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75826. /**
  75827. * Stores a left-handed orthographic projection into a given matrix
  75828. * @param left defines the viewport left coordinate
  75829. * @param right defines the viewport right coordinate
  75830. * @param bottom defines the viewport bottom coordinate
  75831. * @param top defines the viewport top coordinate
  75832. * @param znear defines the near clip plane
  75833. * @param zfar defines the far clip plane
  75834. * @param result defines the target matrix
  75835. */
  75836. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75837. /**
  75838. * Creates a right-handed orthographic projection matrix
  75839. * @param left defines the viewport left coordinate
  75840. * @param right defines the viewport right coordinate
  75841. * @param bottom defines the viewport bottom coordinate
  75842. * @param top defines the viewport top coordinate
  75843. * @param znear defines the near clip plane
  75844. * @param zfar defines the far clip plane
  75845. * @returns a new matrix as a right-handed orthographic projection matrix
  75846. */
  75847. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75848. /**
  75849. * Stores a right-handed orthographic projection into a given matrix
  75850. * @param left defines the viewport left coordinate
  75851. * @param right defines the viewport right coordinate
  75852. * @param bottom defines the viewport bottom coordinate
  75853. * @param top defines the viewport top coordinate
  75854. * @param znear defines the near clip plane
  75855. * @param zfar defines the far clip plane
  75856. * @param result defines the target matrix
  75857. */
  75858. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75859. /**
  75860. * Creates a left-handed perspective projection matrix
  75861. * @param width defines the viewport width
  75862. * @param height defines the viewport height
  75863. * @param znear defines the near clip plane
  75864. * @param zfar defines the far clip plane
  75865. * @returns a new matrix as a left-handed perspective projection matrix
  75866. */
  75867. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75868. /**
  75869. * Creates a left-handed perspective projection matrix
  75870. * @param fov defines the horizontal field of view
  75871. * @param aspect defines the aspect ratio
  75872. * @param znear defines the near clip plane
  75873. * @param zfar defines the far clip plane
  75874. * @returns a new matrix as a left-handed perspective projection matrix
  75875. */
  75876. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75877. /**
  75878. * Stores a left-handed perspective projection into a given matrix
  75879. * @param fov defines the horizontal field of view
  75880. * @param aspect defines the aspect ratio
  75881. * @param znear defines the near clip plane
  75882. * @param zfar defines the far clip plane
  75883. * @param result defines the target matrix
  75884. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75885. */
  75886. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75887. /**
  75888. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75889. * @param fov defines the horizontal field of view
  75890. * @param aspect defines the aspect ratio
  75891. * @param znear defines the near clip plane
  75892. * @param zfar not used as infinity is used as far clip
  75893. * @param result defines the target matrix
  75894. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75895. */
  75896. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75897. /**
  75898. * Creates a right-handed perspective projection matrix
  75899. * @param fov defines the horizontal field of view
  75900. * @param aspect defines the aspect ratio
  75901. * @param znear defines the near clip plane
  75902. * @param zfar defines the far clip plane
  75903. * @returns a new matrix as a right-handed perspective projection matrix
  75904. */
  75905. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75906. /**
  75907. * Stores a right-handed perspective projection into a given matrix
  75908. * @param fov defines the horizontal field of view
  75909. * @param aspect defines the aspect ratio
  75910. * @param znear defines the near clip plane
  75911. * @param zfar defines the far clip plane
  75912. * @param result defines the target matrix
  75913. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75914. */
  75915. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75916. /**
  75917. * Stores a right-handed perspective projection into a given matrix
  75918. * @param fov defines the horizontal field of view
  75919. * @param aspect defines the aspect ratio
  75920. * @param znear defines the near clip plane
  75921. * @param zfar not used as infinity is used as far clip
  75922. * @param result defines the target matrix
  75923. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75924. */
  75925. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75926. /**
  75927. * Stores a perspective projection for WebVR info a given matrix
  75928. * @param fov defines the field of view
  75929. * @param znear defines the near clip plane
  75930. * @param zfar defines the far clip plane
  75931. * @param result defines the target matrix
  75932. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75933. */
  75934. static PerspectiveFovWebVRToRef(fov: {
  75935. upDegrees: number;
  75936. downDegrees: number;
  75937. leftDegrees: number;
  75938. rightDegrees: number;
  75939. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75940. /**
  75941. * Computes a complete transformation matrix
  75942. * @param viewport defines the viewport to use
  75943. * @param world defines the world matrix
  75944. * @param view defines the view matrix
  75945. * @param projection defines the projection matrix
  75946. * @param zmin defines the near clip plane
  75947. * @param zmax defines the far clip plane
  75948. * @returns the transformation matrix
  75949. */
  75950. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75951. /**
  75952. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75953. * @param matrix defines the matrix to use
  75954. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75955. */
  75956. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75957. /**
  75958. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75959. * @param matrix defines the matrix to use
  75960. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75961. */
  75962. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75963. /**
  75964. * Compute the transpose of a given matrix
  75965. * @param matrix defines the matrix to transpose
  75966. * @returns the new matrix
  75967. */
  75968. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75969. /**
  75970. * Compute the transpose of a matrix and store it in a target matrix
  75971. * @param matrix defines the matrix to transpose
  75972. * @param result defines the target matrix
  75973. */
  75974. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75975. /**
  75976. * Computes a reflection matrix from a plane
  75977. * @param plane defines the reflection plane
  75978. * @returns a new matrix
  75979. */
  75980. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75981. /**
  75982. * Computes a reflection matrix from a plane
  75983. * @param plane defines the reflection plane
  75984. * @param result defines the target matrix
  75985. */
  75986. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75987. /**
  75988. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75989. * @param xaxis defines the value of the 1st axis
  75990. * @param yaxis defines the value of the 2nd axis
  75991. * @param zaxis defines the value of the 3rd axis
  75992. * @param result defines the target matrix
  75993. */
  75994. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  75995. /**
  75996. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75997. * @param quat defines the quaternion to use
  75998. * @param result defines the target matrix
  75999. */
  76000. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  76001. }
  76002. /**
  76003. * @hidden
  76004. */
  76005. export class TmpVectors {
  76006. static Vector2: Vector2[];
  76007. static Vector3: Vector3[];
  76008. static Vector4: Vector4[];
  76009. static Quaternion: Quaternion[];
  76010. static Matrix: Matrix[];
  76011. }
  76012. }
  76013. declare module BABYLON {
  76014. /**
  76015. * Defines potential orientation for back face culling
  76016. */
  76017. export enum Orientation {
  76018. /**
  76019. * Clockwise
  76020. */
  76021. CW = 0,
  76022. /** Counter clockwise */
  76023. CCW = 1
  76024. }
  76025. /** Class used to represent a Bezier curve */
  76026. export class BezierCurve {
  76027. /**
  76028. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  76029. * @param t defines the time
  76030. * @param x1 defines the left coordinate on X axis
  76031. * @param y1 defines the left coordinate on Y axis
  76032. * @param x2 defines the right coordinate on X axis
  76033. * @param y2 defines the right coordinate on Y axis
  76034. * @returns the interpolated value
  76035. */
  76036. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  76037. }
  76038. /**
  76039. * Defines angle representation
  76040. */
  76041. export class Angle {
  76042. private _radians;
  76043. /**
  76044. * Creates an Angle object of "radians" radians (float).
  76045. * @param radians the angle in radians
  76046. */
  76047. constructor(radians: number);
  76048. /**
  76049. * Get value in degrees
  76050. * @returns the Angle value in degrees (float)
  76051. */
  76052. degrees(): number;
  76053. /**
  76054. * Get value in radians
  76055. * @returns the Angle value in radians (float)
  76056. */
  76057. radians(): number;
  76058. /**
  76059. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  76060. * @param a defines first vector
  76061. * @param b defines second vector
  76062. * @returns a new Angle
  76063. */
  76064. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  76065. /**
  76066. * Gets a new Angle object from the given float in radians
  76067. * @param radians defines the angle value in radians
  76068. * @returns a new Angle
  76069. */
  76070. static FromRadians(radians: number): Angle;
  76071. /**
  76072. * Gets a new Angle object from the given float in degrees
  76073. * @param degrees defines the angle value in degrees
  76074. * @returns a new Angle
  76075. */
  76076. static FromDegrees(degrees: number): Angle;
  76077. }
  76078. /**
  76079. * This represents an arc in a 2d space.
  76080. */
  76081. export class Arc2 {
  76082. /** Defines the start point of the arc */
  76083. startPoint: Vector2;
  76084. /** Defines the mid point of the arc */
  76085. midPoint: Vector2;
  76086. /** Defines the end point of the arc */
  76087. endPoint: Vector2;
  76088. /**
  76089. * Defines the center point of the arc.
  76090. */
  76091. centerPoint: Vector2;
  76092. /**
  76093. * Defines the radius of the arc.
  76094. */
  76095. radius: number;
  76096. /**
  76097. * Defines the angle of the arc (from mid point to end point).
  76098. */
  76099. angle: Angle;
  76100. /**
  76101. * Defines the start angle of the arc (from start point to middle point).
  76102. */
  76103. startAngle: Angle;
  76104. /**
  76105. * Defines the orientation of the arc (clock wise/counter clock wise).
  76106. */
  76107. orientation: Orientation;
  76108. /**
  76109. * Creates an Arc object from the three given points : start, middle and end.
  76110. * @param startPoint Defines the start point of the arc
  76111. * @param midPoint Defines the midlle point of the arc
  76112. * @param endPoint Defines the end point of the arc
  76113. */
  76114. constructor(
  76115. /** Defines the start point of the arc */
  76116. startPoint: Vector2,
  76117. /** Defines the mid point of the arc */
  76118. midPoint: Vector2,
  76119. /** Defines the end point of the arc */
  76120. endPoint: Vector2);
  76121. }
  76122. /**
  76123. * Represents a 2D path made up of multiple 2D points
  76124. */
  76125. export class Path2 {
  76126. private _points;
  76127. private _length;
  76128. /**
  76129. * If the path start and end point are the same
  76130. */
  76131. closed: boolean;
  76132. /**
  76133. * Creates a Path2 object from the starting 2D coordinates x and y.
  76134. * @param x the starting points x value
  76135. * @param y the starting points y value
  76136. */
  76137. constructor(x: number, y: number);
  76138. /**
  76139. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  76140. * @param x the added points x value
  76141. * @param y the added points y value
  76142. * @returns the updated Path2.
  76143. */
  76144. addLineTo(x: number, y: number): Path2;
  76145. /**
  76146. * 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.
  76147. * @param midX middle point x value
  76148. * @param midY middle point y value
  76149. * @param endX end point x value
  76150. * @param endY end point y value
  76151. * @param numberOfSegments (default: 36)
  76152. * @returns the updated Path2.
  76153. */
  76154. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  76155. /**
  76156. * Closes the Path2.
  76157. * @returns the Path2.
  76158. */
  76159. close(): Path2;
  76160. /**
  76161. * Gets the sum of the distance between each sequential point in the path
  76162. * @returns the Path2 total length (float).
  76163. */
  76164. length(): number;
  76165. /**
  76166. * Gets the points which construct the path
  76167. * @returns the Path2 internal array of points.
  76168. */
  76169. getPoints(): Vector2[];
  76170. /**
  76171. * Retreives the point at the distance aways from the starting point
  76172. * @param normalizedLengthPosition the length along the path to retreive the point from
  76173. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  76174. */
  76175. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  76176. /**
  76177. * Creates a new path starting from an x and y position
  76178. * @param x starting x value
  76179. * @param y starting y value
  76180. * @returns a new Path2 starting at the coordinates (x, y).
  76181. */
  76182. static StartingAt(x: number, y: number): Path2;
  76183. }
  76184. /**
  76185. * Represents a 3D path made up of multiple 3D points
  76186. */
  76187. export class Path3D {
  76188. /**
  76189. * an array of Vector3, the curve axis of the Path3D
  76190. */
  76191. path: Vector3[];
  76192. private _curve;
  76193. private _distances;
  76194. private _tangents;
  76195. private _normals;
  76196. private _binormals;
  76197. private _raw;
  76198. private _alignTangentsWithPath;
  76199. private readonly _pointAtData;
  76200. /**
  76201. * new Path3D(path, normal, raw)
  76202. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  76203. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  76204. * @param path an array of Vector3, the curve axis of the Path3D
  76205. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  76206. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  76207. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  76208. */
  76209. constructor(
  76210. /**
  76211. * an array of Vector3, the curve axis of the Path3D
  76212. */
  76213. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  76214. /**
  76215. * Returns the Path3D array of successive Vector3 designing its curve.
  76216. * @returns the Path3D array of successive Vector3 designing its curve.
  76217. */
  76218. getCurve(): Vector3[];
  76219. /**
  76220. * Returns the Path3D array of successive Vector3 designing its curve.
  76221. * @returns the Path3D array of successive Vector3 designing its curve.
  76222. */
  76223. getPoints(): Vector3[];
  76224. /**
  76225. * @returns the computed length (float) of the path.
  76226. */
  76227. length(): number;
  76228. /**
  76229. * Returns an array populated with tangent vectors on each Path3D curve point.
  76230. * @returns an array populated with tangent vectors on each Path3D curve point.
  76231. */
  76232. getTangents(): Vector3[];
  76233. /**
  76234. * Returns an array populated with normal vectors on each Path3D curve point.
  76235. * @returns an array populated with normal vectors on each Path3D curve point.
  76236. */
  76237. getNormals(): Vector3[];
  76238. /**
  76239. * Returns an array populated with binormal vectors on each Path3D curve point.
  76240. * @returns an array populated with binormal vectors on each Path3D curve point.
  76241. */
  76242. getBinormals(): Vector3[];
  76243. /**
  76244. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  76245. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  76246. */
  76247. getDistances(): number[];
  76248. /**
  76249. * Returns an interpolated point along this path
  76250. * @param position the position of the point along this path, from 0.0 to 1.0
  76251. * @returns a new Vector3 as the point
  76252. */
  76253. getPointAt(position: number): Vector3;
  76254. /**
  76255. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  76256. * @param position the position of the point along this path, from 0.0 to 1.0
  76257. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  76258. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  76259. */
  76260. getTangentAt(position: number, interpolated?: boolean): Vector3;
  76261. /**
  76262. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  76263. * @param position the position of the point along this path, from 0.0 to 1.0
  76264. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  76265. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  76266. */
  76267. getNormalAt(position: number, interpolated?: boolean): Vector3;
  76268. /**
  76269. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  76270. * @param position the position of the point along this path, from 0.0 to 1.0
  76271. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  76272. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  76273. */
  76274. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  76275. /**
  76276. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  76277. * @param position the position of the point along this path, from 0.0 to 1.0
  76278. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  76279. */
  76280. getDistanceAt(position: number): number;
  76281. /**
  76282. * Returns the array index of the previous point of an interpolated point along this path
  76283. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  76284. * @returns the array index
  76285. */
  76286. getPreviousPointIndexAt(position: number): number;
  76287. /**
  76288. * 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)
  76289. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  76290. * @returns the sub position
  76291. */
  76292. getSubPositionAt(position: number): number;
  76293. /**
  76294. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  76295. * @param target the vector of which to get the closest position to
  76296. * @returns the position of the closest virtual point on this path to the target vector
  76297. */
  76298. getClosestPositionTo(target: Vector3): number;
  76299. /**
  76300. * Returns a sub path (slice) of this path
  76301. * @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
  76302. * @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
  76303. * @returns a sub path (slice) of this path
  76304. */
  76305. slice(start?: number, end?: number): Path3D;
  76306. /**
  76307. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  76308. * @param path path which all values are copied into the curves points
  76309. * @param firstNormal which should be projected onto the curve
  76310. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  76311. * @returns the same object updated.
  76312. */
  76313. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  76314. private _compute;
  76315. private _getFirstNonNullVector;
  76316. private _getLastNonNullVector;
  76317. private _normalVector;
  76318. /**
  76319. * Updates the point at data for an interpolated point along this curve
  76320. * @param position the position of the point along this curve, from 0.0 to 1.0
  76321. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  76322. * @returns the (updated) point at data
  76323. */
  76324. private _updatePointAtData;
  76325. /**
  76326. * Updates the point at data from the specified parameters
  76327. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  76328. * @param point the interpolated point
  76329. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  76330. */
  76331. private _setPointAtData;
  76332. /**
  76333. * Updates the point at interpolation matrix for the tangents, normals and binormals
  76334. */
  76335. private _updateInterpolationMatrix;
  76336. }
  76337. /**
  76338. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76339. * A Curve3 is designed from a series of successive Vector3.
  76340. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  76341. */
  76342. export class Curve3 {
  76343. private _points;
  76344. private _length;
  76345. /**
  76346. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  76347. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  76348. * @param v1 (Vector3) the control point
  76349. * @param v2 (Vector3) the end point of the Quadratic Bezier
  76350. * @param nbPoints (integer) the wanted number of points in the curve
  76351. * @returns the created Curve3
  76352. */
  76353. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  76354. /**
  76355. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  76356. * @param v0 (Vector3) the origin point of the Cubic Bezier
  76357. * @param v1 (Vector3) the first control point
  76358. * @param v2 (Vector3) the second control point
  76359. * @param v3 (Vector3) the end point of the Cubic Bezier
  76360. * @param nbPoints (integer) the wanted number of points in the curve
  76361. * @returns the created Curve3
  76362. */
  76363. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  76364. /**
  76365. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  76366. * @param p1 (Vector3) the origin point of the Hermite Spline
  76367. * @param t1 (Vector3) the tangent vector at the origin point
  76368. * @param p2 (Vector3) the end point of the Hermite Spline
  76369. * @param t2 (Vector3) the tangent vector at the end point
  76370. * @param nbPoints (integer) the wanted number of points in the curve
  76371. * @returns the created Curve3
  76372. */
  76373. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  76374. /**
  76375. * Returns a Curve3 object along a CatmullRom Spline curve :
  76376. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  76377. * @param nbPoints (integer) the wanted number of points between each curve control points
  76378. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  76379. * @returns the created Curve3
  76380. */
  76381. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  76382. /**
  76383. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76384. * A Curve3 is designed from a series of successive Vector3.
  76385. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  76386. * @param points points which make up the curve
  76387. */
  76388. constructor(points: Vector3[]);
  76389. /**
  76390. * @returns the Curve3 stored array of successive Vector3
  76391. */
  76392. getPoints(): Vector3[];
  76393. /**
  76394. * @returns the computed length (float) of the curve.
  76395. */
  76396. length(): number;
  76397. /**
  76398. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  76399. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  76400. * curveA and curveB keep unchanged.
  76401. * @param curve the curve to continue from this curve
  76402. * @returns the newly constructed curve
  76403. */
  76404. continue(curve: DeepImmutable<Curve3>): Curve3;
  76405. private _computeLength;
  76406. }
  76407. }
  76408. declare module BABYLON {
  76409. /**
  76410. * This represents the main contract an easing function should follow.
  76411. * Easing functions are used throughout the animation system.
  76412. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76413. */
  76414. export interface IEasingFunction {
  76415. /**
  76416. * Given an input gradient between 0 and 1, this returns the corrseponding value
  76417. * of the easing function.
  76418. * The link below provides some of the most common examples of easing functions.
  76419. * @see https://easings.net/
  76420. * @param gradient Defines the value between 0 and 1 we want the easing value for
  76421. * @returns the corresponding value on the curve defined by the easing function
  76422. */
  76423. ease(gradient: number): number;
  76424. }
  76425. /**
  76426. * Base class used for every default easing function.
  76427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76428. */
  76429. export class EasingFunction implements IEasingFunction {
  76430. /**
  76431. * Interpolation follows the mathematical formula associated with the easing function.
  76432. */
  76433. static readonly EASINGMODE_EASEIN: number;
  76434. /**
  76435. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  76436. */
  76437. static readonly EASINGMODE_EASEOUT: number;
  76438. /**
  76439. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  76440. */
  76441. static readonly EASINGMODE_EASEINOUT: number;
  76442. private _easingMode;
  76443. /**
  76444. * Sets the easing mode of the current function.
  76445. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  76446. */
  76447. setEasingMode(easingMode: number): void;
  76448. /**
  76449. * Gets the current easing mode.
  76450. * @returns the easing mode
  76451. */
  76452. getEasingMode(): number;
  76453. /**
  76454. * @hidden
  76455. */
  76456. easeInCore(gradient: number): number;
  76457. /**
  76458. * Given an input gradient between 0 and 1, this returns the corresponding value
  76459. * of the easing function.
  76460. * @param gradient Defines the value between 0 and 1 we want the easing value for
  76461. * @returns the corresponding value on the curve defined by the easing function
  76462. */
  76463. ease(gradient: number): number;
  76464. }
  76465. /**
  76466. * Easing function with a circle shape (see link below).
  76467. * @see https://easings.net/#easeInCirc
  76468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76469. */
  76470. export class CircleEase extends EasingFunction implements IEasingFunction {
  76471. /** @hidden */
  76472. easeInCore(gradient: number): number;
  76473. }
  76474. /**
  76475. * Easing function with a ease back shape (see link below).
  76476. * @see https://easings.net/#easeInBack
  76477. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76478. */
  76479. export class BackEase extends EasingFunction implements IEasingFunction {
  76480. /** Defines the amplitude of the function */
  76481. amplitude: number;
  76482. /**
  76483. * Instantiates a back ease easing
  76484. * @see https://easings.net/#easeInBack
  76485. * @param amplitude Defines the amplitude of the function
  76486. */
  76487. constructor(
  76488. /** Defines the amplitude of the function */
  76489. amplitude?: number);
  76490. /** @hidden */
  76491. easeInCore(gradient: number): number;
  76492. }
  76493. /**
  76494. * Easing function with a bouncing shape (see link below).
  76495. * @see https://easings.net/#easeInBounce
  76496. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76497. */
  76498. export class BounceEase extends EasingFunction implements IEasingFunction {
  76499. /** Defines the number of bounces */
  76500. bounces: number;
  76501. /** Defines the amplitude of the bounce */
  76502. bounciness: number;
  76503. /**
  76504. * Instantiates a bounce easing
  76505. * @see https://easings.net/#easeInBounce
  76506. * @param bounces Defines the number of bounces
  76507. * @param bounciness Defines the amplitude of the bounce
  76508. */
  76509. constructor(
  76510. /** Defines the number of bounces */
  76511. bounces?: number,
  76512. /** Defines the amplitude of the bounce */
  76513. bounciness?: number);
  76514. /** @hidden */
  76515. easeInCore(gradient: number): number;
  76516. }
  76517. /**
  76518. * Easing function with a power of 3 shape (see link below).
  76519. * @see https://easings.net/#easeInCubic
  76520. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76521. */
  76522. export class CubicEase extends EasingFunction implements IEasingFunction {
  76523. /** @hidden */
  76524. easeInCore(gradient: number): number;
  76525. }
  76526. /**
  76527. * Easing function with an elastic shape (see link below).
  76528. * @see https://easings.net/#easeInElastic
  76529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76530. */
  76531. export class ElasticEase extends EasingFunction implements IEasingFunction {
  76532. /** Defines the number of oscillations*/
  76533. oscillations: number;
  76534. /** Defines the amplitude of the oscillations*/
  76535. springiness: number;
  76536. /**
  76537. * Instantiates an elastic easing function
  76538. * @see https://easings.net/#easeInElastic
  76539. * @param oscillations Defines the number of oscillations
  76540. * @param springiness Defines the amplitude of the oscillations
  76541. */
  76542. constructor(
  76543. /** Defines the number of oscillations*/
  76544. oscillations?: number,
  76545. /** Defines the amplitude of the oscillations*/
  76546. springiness?: number);
  76547. /** @hidden */
  76548. easeInCore(gradient: number): number;
  76549. }
  76550. /**
  76551. * Easing function with an exponential shape (see link below).
  76552. * @see https://easings.net/#easeInExpo
  76553. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76554. */
  76555. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  76556. /** Defines the exponent of the function */
  76557. exponent: number;
  76558. /**
  76559. * Instantiates an exponential easing function
  76560. * @see https://easings.net/#easeInExpo
  76561. * @param exponent Defines the exponent of the function
  76562. */
  76563. constructor(
  76564. /** Defines the exponent of the function */
  76565. exponent?: number);
  76566. /** @hidden */
  76567. easeInCore(gradient: number): number;
  76568. }
  76569. /**
  76570. * Easing function with a power shape (see link below).
  76571. * @see https://easings.net/#easeInQuad
  76572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76573. */
  76574. export class PowerEase extends EasingFunction implements IEasingFunction {
  76575. /** Defines the power of the function */
  76576. power: number;
  76577. /**
  76578. * Instantiates an power base easing function
  76579. * @see https://easings.net/#easeInQuad
  76580. * @param power Defines the power of the function
  76581. */
  76582. constructor(
  76583. /** Defines the power of the function */
  76584. power?: number);
  76585. /** @hidden */
  76586. easeInCore(gradient: number): number;
  76587. }
  76588. /**
  76589. * Easing function with a power of 2 shape (see link below).
  76590. * @see https://easings.net/#easeInQuad
  76591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76592. */
  76593. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  76594. /** @hidden */
  76595. easeInCore(gradient: number): number;
  76596. }
  76597. /**
  76598. * Easing function with a power of 4 shape (see link below).
  76599. * @see https://easings.net/#easeInQuart
  76600. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76601. */
  76602. export class QuarticEase extends EasingFunction implements IEasingFunction {
  76603. /** @hidden */
  76604. easeInCore(gradient: number): number;
  76605. }
  76606. /**
  76607. * Easing function with a power of 5 shape (see link below).
  76608. * @see https://easings.net/#easeInQuint
  76609. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76610. */
  76611. export class QuinticEase extends EasingFunction implements IEasingFunction {
  76612. /** @hidden */
  76613. easeInCore(gradient: number): number;
  76614. }
  76615. /**
  76616. * Easing function with a sin shape (see link below).
  76617. * @see https://easings.net/#easeInSine
  76618. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76619. */
  76620. export class SineEase extends EasingFunction implements IEasingFunction {
  76621. /** @hidden */
  76622. easeInCore(gradient: number): number;
  76623. }
  76624. /**
  76625. * Easing function with a bezier shape (see link below).
  76626. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  76627. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76628. */
  76629. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  76630. /** Defines the x component of the start tangent in the bezier curve */
  76631. x1: number;
  76632. /** Defines the y component of the start tangent in the bezier curve */
  76633. y1: number;
  76634. /** Defines the x component of the end tangent in the bezier curve */
  76635. x2: number;
  76636. /** Defines the y component of the end tangent in the bezier curve */
  76637. y2: number;
  76638. /**
  76639. * Instantiates a bezier function
  76640. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  76641. * @param x1 Defines the x component of the start tangent in the bezier curve
  76642. * @param y1 Defines the y component of the start tangent in the bezier curve
  76643. * @param x2 Defines the x component of the end tangent in the bezier curve
  76644. * @param y2 Defines the y component of the end tangent in the bezier curve
  76645. */
  76646. constructor(
  76647. /** Defines the x component of the start tangent in the bezier curve */
  76648. x1?: number,
  76649. /** Defines the y component of the start tangent in the bezier curve */
  76650. y1?: number,
  76651. /** Defines the x component of the end tangent in the bezier curve */
  76652. x2?: number,
  76653. /** Defines the y component of the end tangent in the bezier curve */
  76654. y2?: number);
  76655. /** @hidden */
  76656. easeInCore(gradient: number): number;
  76657. }
  76658. }
  76659. declare module BABYLON {
  76660. /**
  76661. * Class used to hold a RBG color
  76662. */
  76663. export class Color3 {
  76664. /**
  76665. * Defines the red component (between 0 and 1, default is 0)
  76666. */
  76667. r: number;
  76668. /**
  76669. * Defines the green component (between 0 and 1, default is 0)
  76670. */
  76671. g: number;
  76672. /**
  76673. * Defines the blue component (between 0 and 1, default is 0)
  76674. */
  76675. b: number;
  76676. /**
  76677. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  76678. * @param r defines the red component (between 0 and 1, default is 0)
  76679. * @param g defines the green component (between 0 and 1, default is 0)
  76680. * @param b defines the blue component (between 0 and 1, default is 0)
  76681. */
  76682. constructor(
  76683. /**
  76684. * Defines the red component (between 0 and 1, default is 0)
  76685. */
  76686. r?: number,
  76687. /**
  76688. * Defines the green component (between 0 and 1, default is 0)
  76689. */
  76690. g?: number,
  76691. /**
  76692. * Defines the blue component (between 0 and 1, default is 0)
  76693. */
  76694. b?: number);
  76695. /**
  76696. * Creates a string with the Color3 current values
  76697. * @returns the string representation of the Color3 object
  76698. */
  76699. toString(): string;
  76700. /**
  76701. * Returns the string "Color3"
  76702. * @returns "Color3"
  76703. */
  76704. getClassName(): string;
  76705. /**
  76706. * Compute the Color3 hash code
  76707. * @returns an unique number that can be used to hash Color3 objects
  76708. */
  76709. getHashCode(): number;
  76710. /**
  76711. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  76712. * @param array defines the array where to store the r,g,b components
  76713. * @param index defines an optional index in the target array to define where to start storing values
  76714. * @returns the current Color3 object
  76715. */
  76716. toArray(array: FloatArray, index?: number): Color3;
  76717. /**
  76718. * Returns a new Color4 object from the current Color3 and the given alpha
  76719. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  76720. * @returns a new Color4 object
  76721. */
  76722. toColor4(alpha?: number): Color4;
  76723. /**
  76724. * Returns a new array populated with 3 numeric elements : red, green and blue values
  76725. * @returns the new array
  76726. */
  76727. asArray(): number[];
  76728. /**
  76729. * Returns the luminance value
  76730. * @returns a float value
  76731. */
  76732. toLuminance(): number;
  76733. /**
  76734. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  76735. * @param otherColor defines the second operand
  76736. * @returns the new Color3 object
  76737. */
  76738. multiply(otherColor: DeepImmutable<Color3>): Color3;
  76739. /**
  76740. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  76741. * @param otherColor defines the second operand
  76742. * @param result defines the Color3 object where to store the result
  76743. * @returns the current Color3
  76744. */
  76745. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76746. /**
  76747. * Determines equality between Color3 objects
  76748. * @param otherColor defines the second operand
  76749. * @returns true if the rgb values are equal to the given ones
  76750. */
  76751. equals(otherColor: DeepImmutable<Color3>): boolean;
  76752. /**
  76753. * Determines equality between the current Color3 object and a set of r,b,g values
  76754. * @param r defines the red component to check
  76755. * @param g defines the green component to check
  76756. * @param b defines the blue component to check
  76757. * @returns true if the rgb values are equal to the given ones
  76758. */
  76759. equalsFloats(r: number, g: number, b: number): boolean;
  76760. /**
  76761. * Multiplies in place each rgb value by scale
  76762. * @param scale defines the scaling factor
  76763. * @returns the updated Color3
  76764. */
  76765. scale(scale: number): Color3;
  76766. /**
  76767. * Multiplies the rgb values by scale and stores the result into "result"
  76768. * @param scale defines the scaling factor
  76769. * @param result defines the Color3 object where to store the result
  76770. * @returns the unmodified current Color3
  76771. */
  76772. scaleToRef(scale: number, result: Color3): Color3;
  76773. /**
  76774. * Scale the current Color3 values by a factor and add the result to a given Color3
  76775. * @param scale defines the scale factor
  76776. * @param result defines color to store the result into
  76777. * @returns the unmodified current Color3
  76778. */
  76779. scaleAndAddToRef(scale: number, result: Color3): Color3;
  76780. /**
  76781. * Clamps the rgb values by the min and max values and stores the result into "result"
  76782. * @param min defines minimum clamping value (default is 0)
  76783. * @param max defines maximum clamping value (default is 1)
  76784. * @param result defines color to store the result into
  76785. * @returns the original Color3
  76786. */
  76787. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  76788. /**
  76789. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  76790. * @param otherColor defines the second operand
  76791. * @returns the new Color3
  76792. */
  76793. add(otherColor: DeepImmutable<Color3>): Color3;
  76794. /**
  76795. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  76796. * @param otherColor defines the second operand
  76797. * @param result defines Color3 object to store the result into
  76798. * @returns the unmodified current Color3
  76799. */
  76800. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76801. /**
  76802. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  76803. * @param otherColor defines the second operand
  76804. * @returns the new Color3
  76805. */
  76806. subtract(otherColor: DeepImmutable<Color3>): Color3;
  76807. /**
  76808. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  76809. * @param otherColor defines the second operand
  76810. * @param result defines Color3 object to store the result into
  76811. * @returns the unmodified current Color3
  76812. */
  76813. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76814. /**
  76815. * Copy the current object
  76816. * @returns a new Color3 copied the current one
  76817. */
  76818. clone(): Color3;
  76819. /**
  76820. * Copies the rgb values from the source in the current Color3
  76821. * @param source defines the source Color3 object
  76822. * @returns the updated Color3 object
  76823. */
  76824. copyFrom(source: DeepImmutable<Color3>): Color3;
  76825. /**
  76826. * Updates the Color3 rgb values from the given floats
  76827. * @param r defines the red component to read from
  76828. * @param g defines the green component to read from
  76829. * @param b defines the blue component to read from
  76830. * @returns the current Color3 object
  76831. */
  76832. copyFromFloats(r: number, g: number, b: number): Color3;
  76833. /**
  76834. * Updates the Color3 rgb values from the given floats
  76835. * @param r defines the red component to read from
  76836. * @param g defines the green component to read from
  76837. * @param b defines the blue component to read from
  76838. * @returns the current Color3 object
  76839. */
  76840. set(r: number, g: number, b: number): Color3;
  76841. /**
  76842. * Compute the Color3 hexadecimal code as a string
  76843. * @returns a string containing the hexadecimal representation of the Color3 object
  76844. */
  76845. toHexString(): string;
  76846. /**
  76847. * Computes a new Color3 converted from the current one to linear space
  76848. * @returns a new Color3 object
  76849. */
  76850. toLinearSpace(): Color3;
  76851. /**
  76852. * Converts current color in rgb space to HSV values
  76853. * @returns a new color3 representing the HSV values
  76854. */
  76855. toHSV(): Color3;
  76856. /**
  76857. * Converts current color in rgb space to HSV values
  76858. * @param result defines the Color3 where to store the HSV values
  76859. */
  76860. toHSVToRef(result: Color3): void;
  76861. /**
  76862. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76863. * @param convertedColor defines the Color3 object where to store the linear space version
  76864. * @returns the unmodified Color3
  76865. */
  76866. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76867. /**
  76868. * Computes a new Color3 converted from the current one to gamma space
  76869. * @returns a new Color3 object
  76870. */
  76871. toGammaSpace(): Color3;
  76872. /**
  76873. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76874. * @param convertedColor defines the Color3 object where to store the gamma space version
  76875. * @returns the unmodified Color3
  76876. */
  76877. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76878. private static _BlackReadOnly;
  76879. /**
  76880. * Convert Hue, saturation and value to a Color3 (RGB)
  76881. * @param hue defines the hue
  76882. * @param saturation defines the saturation
  76883. * @param value defines the value
  76884. * @param result defines the Color3 where to store the RGB values
  76885. */
  76886. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76887. /**
  76888. * Creates a new Color3 from the string containing valid hexadecimal values
  76889. * @param hex defines a string containing valid hexadecimal values
  76890. * @returns a new Color3 object
  76891. */
  76892. static FromHexString(hex: string): Color3;
  76893. /**
  76894. * Creates a new Color3 from the starting index of the given array
  76895. * @param array defines the source array
  76896. * @param offset defines an offset in the source array
  76897. * @returns a new Color3 object
  76898. */
  76899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76900. /**
  76901. * Creates a new Color3 from integer values (< 256)
  76902. * @param r defines the red component to read from (value between 0 and 255)
  76903. * @param g defines the green component to read from (value between 0 and 255)
  76904. * @param b defines the blue component to read from (value between 0 and 255)
  76905. * @returns a new Color3 object
  76906. */
  76907. static FromInts(r: number, g: number, b: number): Color3;
  76908. /**
  76909. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76910. * @param start defines the start Color3 value
  76911. * @param end defines the end Color3 value
  76912. * @param amount defines the gradient value between start and end
  76913. * @returns a new Color3 object
  76914. */
  76915. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76916. /**
  76917. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76918. * @param left defines the start value
  76919. * @param right defines the end value
  76920. * @param amount defines the gradient factor
  76921. * @param result defines the Color3 object where to store the result
  76922. */
  76923. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76924. /**
  76925. * Returns a Color3 value containing a red color
  76926. * @returns a new Color3 object
  76927. */
  76928. static Red(): Color3;
  76929. /**
  76930. * Returns a Color3 value containing a green color
  76931. * @returns a new Color3 object
  76932. */
  76933. static Green(): Color3;
  76934. /**
  76935. * Returns a Color3 value containing a blue color
  76936. * @returns a new Color3 object
  76937. */
  76938. static Blue(): Color3;
  76939. /**
  76940. * Returns a Color3 value containing a black color
  76941. * @returns a new Color3 object
  76942. */
  76943. static Black(): Color3;
  76944. /**
  76945. * Gets a Color3 value containing a black color that must not be updated
  76946. */
  76947. static get BlackReadOnly(): DeepImmutable<Color3>;
  76948. /**
  76949. * Returns a Color3 value containing a white color
  76950. * @returns a new Color3 object
  76951. */
  76952. static White(): Color3;
  76953. /**
  76954. * Returns a Color3 value containing a purple color
  76955. * @returns a new Color3 object
  76956. */
  76957. static Purple(): Color3;
  76958. /**
  76959. * Returns a Color3 value containing a magenta color
  76960. * @returns a new Color3 object
  76961. */
  76962. static Magenta(): Color3;
  76963. /**
  76964. * Returns a Color3 value containing a yellow color
  76965. * @returns a new Color3 object
  76966. */
  76967. static Yellow(): Color3;
  76968. /**
  76969. * Returns a Color3 value containing a gray color
  76970. * @returns a new Color3 object
  76971. */
  76972. static Gray(): Color3;
  76973. /**
  76974. * Returns a Color3 value containing a teal color
  76975. * @returns a new Color3 object
  76976. */
  76977. static Teal(): Color3;
  76978. /**
  76979. * Returns a Color3 value containing a random color
  76980. * @returns a new Color3 object
  76981. */
  76982. static Random(): Color3;
  76983. }
  76984. /**
  76985. * Class used to hold a RBGA color
  76986. */
  76987. export class Color4 {
  76988. /**
  76989. * Defines the red component (between 0 and 1, default is 0)
  76990. */
  76991. r: number;
  76992. /**
  76993. * Defines the green component (between 0 and 1, default is 0)
  76994. */
  76995. g: number;
  76996. /**
  76997. * Defines the blue component (between 0 and 1, default is 0)
  76998. */
  76999. b: number;
  77000. /**
  77001. * Defines the alpha component (between 0 and 1, default is 1)
  77002. */
  77003. a: number;
  77004. /**
  77005. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  77006. * @param r defines the red component (between 0 and 1, default is 0)
  77007. * @param g defines the green component (between 0 and 1, default is 0)
  77008. * @param b defines the blue component (between 0 and 1, default is 0)
  77009. * @param a defines the alpha component (between 0 and 1, default is 1)
  77010. */
  77011. constructor(
  77012. /**
  77013. * Defines the red component (between 0 and 1, default is 0)
  77014. */
  77015. r?: number,
  77016. /**
  77017. * Defines the green component (between 0 and 1, default is 0)
  77018. */
  77019. g?: number,
  77020. /**
  77021. * Defines the blue component (between 0 and 1, default is 0)
  77022. */
  77023. b?: number,
  77024. /**
  77025. * Defines the alpha component (between 0 and 1, default is 1)
  77026. */
  77027. a?: number);
  77028. /**
  77029. * Adds in place the given Color4 values to the current Color4 object
  77030. * @param right defines the second operand
  77031. * @returns the current updated Color4 object
  77032. */
  77033. addInPlace(right: DeepImmutable<Color4>): Color4;
  77034. /**
  77035. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  77036. * @returns the new array
  77037. */
  77038. asArray(): number[];
  77039. /**
  77040. * Stores from the starting index in the given array the Color4 successive values
  77041. * @param array defines the array where to store the r,g,b components
  77042. * @param index defines an optional index in the target array to define where to start storing values
  77043. * @returns the current Color4 object
  77044. */
  77045. toArray(array: number[], index?: number): Color4;
  77046. /**
  77047. * Determines equality between Color4 objects
  77048. * @param otherColor defines the second operand
  77049. * @returns true if the rgba values are equal to the given ones
  77050. */
  77051. equals(otherColor: DeepImmutable<Color4>): boolean;
  77052. /**
  77053. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  77054. * @param right defines the second operand
  77055. * @returns a new Color4 object
  77056. */
  77057. add(right: DeepImmutable<Color4>): Color4;
  77058. /**
  77059. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  77060. * @param right defines the second operand
  77061. * @returns a new Color4 object
  77062. */
  77063. subtract(right: DeepImmutable<Color4>): Color4;
  77064. /**
  77065. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  77066. * @param right defines the second operand
  77067. * @param result defines the Color4 object where to store the result
  77068. * @returns the current Color4 object
  77069. */
  77070. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  77071. /**
  77072. * Creates a new Color4 with the current Color4 values multiplied by scale
  77073. * @param scale defines the scaling factor to apply
  77074. * @returns a new Color4 object
  77075. */
  77076. scale(scale: number): Color4;
  77077. /**
  77078. * Multiplies the current Color4 values by scale and stores the result in "result"
  77079. * @param scale defines the scaling factor to apply
  77080. * @param result defines the Color4 object where to store the result
  77081. * @returns the current unmodified Color4
  77082. */
  77083. scaleToRef(scale: number, result: Color4): Color4;
  77084. /**
  77085. * Scale the current Color4 values by a factor and add the result to a given Color4
  77086. * @param scale defines the scale factor
  77087. * @param result defines the Color4 object where to store the result
  77088. * @returns the unmodified current Color4
  77089. */
  77090. scaleAndAddToRef(scale: number, result: Color4): Color4;
  77091. /**
  77092. * Clamps the rgb values by the min and max values and stores the result into "result"
  77093. * @param min defines minimum clamping value (default is 0)
  77094. * @param max defines maximum clamping value (default is 1)
  77095. * @param result defines color to store the result into.
  77096. * @returns the cuurent Color4
  77097. */
  77098. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  77099. /**
  77100. * Multipy an Color4 value by another and return a new Color4 object
  77101. * @param color defines the Color4 value to multiply by
  77102. * @returns a new Color4 object
  77103. */
  77104. multiply(color: Color4): Color4;
  77105. /**
  77106. * Multipy a Color4 value by another and push the result in a reference value
  77107. * @param color defines the Color4 value to multiply by
  77108. * @param result defines the Color4 to fill the result in
  77109. * @returns the result Color4
  77110. */
  77111. multiplyToRef(color: Color4, result: Color4): Color4;
  77112. /**
  77113. * Creates a string with the Color4 current values
  77114. * @returns the string representation of the Color4 object
  77115. */
  77116. toString(): string;
  77117. /**
  77118. * Returns the string "Color4"
  77119. * @returns "Color4"
  77120. */
  77121. getClassName(): string;
  77122. /**
  77123. * Compute the Color4 hash code
  77124. * @returns an unique number that can be used to hash Color4 objects
  77125. */
  77126. getHashCode(): number;
  77127. /**
  77128. * Creates a new Color4 copied from the current one
  77129. * @returns a new Color4 object
  77130. */
  77131. clone(): Color4;
  77132. /**
  77133. * Copies the given Color4 values into the current one
  77134. * @param source defines the source Color4 object
  77135. * @returns the current updated Color4 object
  77136. */
  77137. copyFrom(source: Color4): Color4;
  77138. /**
  77139. * Copies the given float values into the current one
  77140. * @param r defines the red component to read from
  77141. * @param g defines the green component to read from
  77142. * @param b defines the blue component to read from
  77143. * @param a defines the alpha component to read from
  77144. * @returns the current updated Color4 object
  77145. */
  77146. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  77147. /**
  77148. * Copies the given float values into the current one
  77149. * @param r defines the red component to read from
  77150. * @param g defines the green component to read from
  77151. * @param b defines the blue component to read from
  77152. * @param a defines the alpha component to read from
  77153. * @returns the current updated Color4 object
  77154. */
  77155. set(r: number, g: number, b: number, a: number): Color4;
  77156. /**
  77157. * Compute the Color4 hexadecimal code as a string
  77158. * @returns a string containing the hexadecimal representation of the Color4 object
  77159. */
  77160. toHexString(): string;
  77161. /**
  77162. * Computes a new Color4 converted from the current one to linear space
  77163. * @returns a new Color4 object
  77164. */
  77165. toLinearSpace(): Color4;
  77166. /**
  77167. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  77168. * @param convertedColor defines the Color4 object where to store the linear space version
  77169. * @returns the unmodified Color4
  77170. */
  77171. toLinearSpaceToRef(convertedColor: Color4): Color4;
  77172. /**
  77173. * Computes a new Color4 converted from the current one to gamma space
  77174. * @returns a new Color4 object
  77175. */
  77176. toGammaSpace(): Color4;
  77177. /**
  77178. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  77179. * @param convertedColor defines the Color4 object where to store the gamma space version
  77180. * @returns the unmodified Color4
  77181. */
  77182. toGammaSpaceToRef(convertedColor: Color4): Color4;
  77183. /**
  77184. * Creates a new Color4 from the string containing valid hexadecimal values
  77185. * @param hex defines a string containing valid hexadecimal values
  77186. * @returns a new Color4 object
  77187. */
  77188. static FromHexString(hex: string): Color4;
  77189. /**
  77190. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  77191. * @param left defines the start value
  77192. * @param right defines the end value
  77193. * @param amount defines the gradient factor
  77194. * @returns a new Color4 object
  77195. */
  77196. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  77197. /**
  77198. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  77199. * @param left defines the start value
  77200. * @param right defines the end value
  77201. * @param amount defines the gradient factor
  77202. * @param result defines the Color4 object where to store data
  77203. */
  77204. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  77205. /**
  77206. * Creates a new Color4 from a Color3 and an alpha value
  77207. * @param color3 defines the source Color3 to read from
  77208. * @param alpha defines the alpha component (1.0 by default)
  77209. * @returns a new Color4 object
  77210. */
  77211. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  77212. /**
  77213. * Creates a new Color4 from the starting index element of the given array
  77214. * @param array defines the source array to read from
  77215. * @param offset defines the offset in the source array
  77216. * @returns a new Color4 object
  77217. */
  77218. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  77219. /**
  77220. * Creates a new Color3 from integer values (< 256)
  77221. * @param r defines the red component to read from (value between 0 and 255)
  77222. * @param g defines the green component to read from (value between 0 and 255)
  77223. * @param b defines the blue component to read from (value between 0 and 255)
  77224. * @param a defines the alpha component to read from (value between 0 and 255)
  77225. * @returns a new Color3 object
  77226. */
  77227. static FromInts(r: number, g: number, b: number, a: number): Color4;
  77228. /**
  77229. * Check the content of a given array and convert it to an array containing RGBA data
  77230. * If the original array was already containing count * 4 values then it is returned directly
  77231. * @param colors defines the array to check
  77232. * @param count defines the number of RGBA data to expect
  77233. * @returns an array containing count * 4 values (RGBA)
  77234. */
  77235. static CheckColors4(colors: number[], count: number): number[];
  77236. }
  77237. /**
  77238. * @hidden
  77239. */
  77240. export class TmpColors {
  77241. static Color3: Color3[];
  77242. static Color4: Color4[];
  77243. }
  77244. }
  77245. declare module BABYLON {
  77246. /**
  77247. * Defines an interface which represents an animation key frame
  77248. */
  77249. export interface IAnimationKey {
  77250. /**
  77251. * Frame of the key frame
  77252. */
  77253. frame: number;
  77254. /**
  77255. * Value at the specifies key frame
  77256. */
  77257. value: any;
  77258. /**
  77259. * The input tangent for the cubic hermite spline
  77260. */
  77261. inTangent?: any;
  77262. /**
  77263. * The output tangent for the cubic hermite spline
  77264. */
  77265. outTangent?: any;
  77266. /**
  77267. * The animation interpolation type
  77268. */
  77269. interpolation?: AnimationKeyInterpolation;
  77270. }
  77271. /**
  77272. * Enum for the animation key frame interpolation type
  77273. */
  77274. export enum AnimationKeyInterpolation {
  77275. /**
  77276. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  77277. */
  77278. STEP = 1
  77279. }
  77280. }
  77281. declare module BABYLON {
  77282. /**
  77283. * Represents the range of an animation
  77284. */
  77285. export class AnimationRange {
  77286. /**The name of the animation range**/
  77287. name: string;
  77288. /**The starting frame of the animation */
  77289. from: number;
  77290. /**The ending frame of the animation*/
  77291. to: number;
  77292. /**
  77293. * Initializes the range of an animation
  77294. * @param name The name of the animation range
  77295. * @param from The starting frame of the animation
  77296. * @param to The ending frame of the animation
  77297. */
  77298. constructor(
  77299. /**The name of the animation range**/
  77300. name: string,
  77301. /**The starting frame of the animation */
  77302. from: number,
  77303. /**The ending frame of the animation*/
  77304. to: number);
  77305. /**
  77306. * Makes a copy of the animation range
  77307. * @returns A copy of the animation range
  77308. */
  77309. clone(): AnimationRange;
  77310. }
  77311. }
  77312. declare module BABYLON {
  77313. /**
  77314. * Composed of a frame, and an action function
  77315. */
  77316. export class AnimationEvent {
  77317. /** The frame for which the event is triggered **/
  77318. frame: number;
  77319. /** The event to perform when triggered **/
  77320. action: (currentFrame: number) => void;
  77321. /** Specifies if the event should be triggered only once**/
  77322. onlyOnce?: boolean | undefined;
  77323. /**
  77324. * Specifies if the animation event is done
  77325. */
  77326. isDone: boolean;
  77327. /**
  77328. * Initializes the animation event
  77329. * @param frame The frame for which the event is triggered
  77330. * @param action The event to perform when triggered
  77331. * @param onlyOnce Specifies if the event should be triggered only once
  77332. */
  77333. constructor(
  77334. /** The frame for which the event is triggered **/
  77335. frame: number,
  77336. /** The event to perform when triggered **/
  77337. action: (currentFrame: number) => void,
  77338. /** Specifies if the event should be triggered only once**/
  77339. onlyOnce?: boolean | undefined);
  77340. /** @hidden */
  77341. _clone(): AnimationEvent;
  77342. }
  77343. }
  77344. declare module BABYLON {
  77345. /**
  77346. * Interface used to define a behavior
  77347. */
  77348. export interface Behavior<T> {
  77349. /** gets or sets behavior's name */
  77350. name: string;
  77351. /**
  77352. * Function called when the behavior needs to be initialized (after attaching it to a target)
  77353. */
  77354. init(): void;
  77355. /**
  77356. * Called when the behavior is attached to a target
  77357. * @param target defines the target where the behavior is attached to
  77358. */
  77359. attach(target: T): void;
  77360. /**
  77361. * Called when the behavior is detached from its target
  77362. */
  77363. detach(): void;
  77364. }
  77365. /**
  77366. * Interface implemented by classes supporting behaviors
  77367. */
  77368. export interface IBehaviorAware<T> {
  77369. /**
  77370. * Attach a behavior
  77371. * @param behavior defines the behavior to attach
  77372. * @returns the current host
  77373. */
  77374. addBehavior(behavior: Behavior<T>): T;
  77375. /**
  77376. * Remove a behavior from the current object
  77377. * @param behavior defines the behavior to detach
  77378. * @returns the current host
  77379. */
  77380. removeBehavior(behavior: Behavior<T>): T;
  77381. /**
  77382. * Gets a behavior using its name to search
  77383. * @param name defines the name to search
  77384. * @returns the behavior or null if not found
  77385. */
  77386. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  77387. }
  77388. }
  77389. declare module BABYLON {
  77390. /**
  77391. * Defines an array and its length.
  77392. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  77393. */
  77394. export interface ISmartArrayLike<T> {
  77395. /**
  77396. * The data of the array.
  77397. */
  77398. data: Array<T>;
  77399. /**
  77400. * The active length of the array.
  77401. */
  77402. length: number;
  77403. }
  77404. /**
  77405. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  77406. */
  77407. export class SmartArray<T> implements ISmartArrayLike<T> {
  77408. /**
  77409. * The full set of data from the array.
  77410. */
  77411. data: Array<T>;
  77412. /**
  77413. * The active length of the array.
  77414. */
  77415. length: number;
  77416. protected _id: number;
  77417. /**
  77418. * Instantiates a Smart Array.
  77419. * @param capacity defines the default capacity of the array.
  77420. */
  77421. constructor(capacity: number);
  77422. /**
  77423. * Pushes a value at the end of the active data.
  77424. * @param value defines the object to push in the array.
  77425. */
  77426. push(value: T): void;
  77427. /**
  77428. * Iterates over the active data and apply the lambda to them.
  77429. * @param func defines the action to apply on each value.
  77430. */
  77431. forEach(func: (content: T) => void): void;
  77432. /**
  77433. * Sorts the full sets of data.
  77434. * @param compareFn defines the comparison function to apply.
  77435. */
  77436. sort(compareFn: (a: T, b: T) => number): void;
  77437. /**
  77438. * Resets the active data to an empty array.
  77439. */
  77440. reset(): void;
  77441. /**
  77442. * Releases all the data from the array as well as the array.
  77443. */
  77444. dispose(): void;
  77445. /**
  77446. * Concats the active data with a given array.
  77447. * @param array defines the data to concatenate with.
  77448. */
  77449. concat(array: any): void;
  77450. /**
  77451. * Returns the position of a value in the active data.
  77452. * @param value defines the value to find the index for
  77453. * @returns the index if found in the active data otherwise -1
  77454. */
  77455. indexOf(value: T): number;
  77456. /**
  77457. * Returns whether an element is part of the active data.
  77458. * @param value defines the value to look for
  77459. * @returns true if found in the active data otherwise false
  77460. */
  77461. contains(value: T): boolean;
  77462. private static _GlobalId;
  77463. }
  77464. /**
  77465. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  77466. * The data in this array can only be present once
  77467. */
  77468. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  77469. private _duplicateId;
  77470. /**
  77471. * Pushes a value at the end of the active data.
  77472. * THIS DOES NOT PREVENT DUPPLICATE DATA
  77473. * @param value defines the object to push in the array.
  77474. */
  77475. push(value: T): void;
  77476. /**
  77477. * Pushes a value at the end of the active data.
  77478. * If the data is already present, it won t be added again
  77479. * @param value defines the object to push in the array.
  77480. * @returns true if added false if it was already present
  77481. */
  77482. pushNoDuplicate(value: T): boolean;
  77483. /**
  77484. * Resets the active data to an empty array.
  77485. */
  77486. reset(): void;
  77487. /**
  77488. * Concats the active data with a given array.
  77489. * This ensures no dupplicate will be present in the result.
  77490. * @param array defines the data to concatenate with.
  77491. */
  77492. concatWithNoDuplicate(array: any): void;
  77493. }
  77494. }
  77495. declare module BABYLON {
  77496. /**
  77497. * @ignore
  77498. * This is a list of all the different input types that are available in the application.
  77499. * Fo instance: ArcRotateCameraGamepadInput...
  77500. */
  77501. export var CameraInputTypes: {};
  77502. /**
  77503. * This is the contract to implement in order to create a new input class.
  77504. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  77505. */
  77506. export interface ICameraInput<TCamera extends Camera> {
  77507. /**
  77508. * Defines the camera the input is attached to.
  77509. */
  77510. camera: Nullable<TCamera>;
  77511. /**
  77512. * Gets the class name of the current intput.
  77513. * @returns the class name
  77514. */
  77515. getClassName(): string;
  77516. /**
  77517. * Get the friendly name associated with the input class.
  77518. * @returns the input friendly name
  77519. */
  77520. getSimpleName(): string;
  77521. /**
  77522. * Attach the input controls to a specific dom element to get the input from.
  77523. * @param element Defines the element the controls should be listened from
  77524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77525. */
  77526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77527. /**
  77528. * Detach the current controls from the specified dom element.
  77529. * @param element Defines the element to stop listening the inputs from
  77530. */
  77531. detachControl(element: Nullable<HTMLElement>): void;
  77532. /**
  77533. * Update the current camera state depending on the inputs that have been used this frame.
  77534. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77535. */
  77536. checkInputs?: () => void;
  77537. }
  77538. /**
  77539. * Represents a map of input types to input instance or input index to input instance.
  77540. */
  77541. export interface CameraInputsMap<TCamera extends Camera> {
  77542. /**
  77543. * Accessor to the input by input type.
  77544. */
  77545. [name: string]: ICameraInput<TCamera>;
  77546. /**
  77547. * Accessor to the input by input index.
  77548. */
  77549. [idx: number]: ICameraInput<TCamera>;
  77550. }
  77551. /**
  77552. * This represents the input manager used within a camera.
  77553. * It helps dealing with all the different kind of input attached to a camera.
  77554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77555. */
  77556. export class CameraInputsManager<TCamera extends Camera> {
  77557. /**
  77558. * Defines the list of inputs attahed to the camera.
  77559. */
  77560. attached: CameraInputsMap<TCamera>;
  77561. /**
  77562. * Defines the dom element the camera is collecting inputs from.
  77563. * This is null if the controls have not been attached.
  77564. */
  77565. attachedElement: Nullable<HTMLElement>;
  77566. /**
  77567. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77568. */
  77569. noPreventDefault: boolean;
  77570. /**
  77571. * Defined the camera the input manager belongs to.
  77572. */
  77573. camera: TCamera;
  77574. /**
  77575. * Update the current camera state depending on the inputs that have been used this frame.
  77576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77577. */
  77578. checkInputs: () => void;
  77579. /**
  77580. * Instantiate a new Camera Input Manager.
  77581. * @param camera Defines the camera the input manager blongs to
  77582. */
  77583. constructor(camera: TCamera);
  77584. /**
  77585. * Add an input method to a camera
  77586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77587. * @param input camera input method
  77588. */
  77589. add(input: ICameraInput<TCamera>): void;
  77590. /**
  77591. * Remove a specific input method from a camera
  77592. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  77593. * @param inputToRemove camera input method
  77594. */
  77595. remove(inputToRemove: ICameraInput<TCamera>): void;
  77596. /**
  77597. * Remove a specific input type from a camera
  77598. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  77599. * @param inputType the type of the input to remove
  77600. */
  77601. removeByType(inputType: string): void;
  77602. private _addCheckInputs;
  77603. /**
  77604. * Attach the input controls to the currently attached dom element to listen the events from.
  77605. * @param input Defines the input to attach
  77606. */
  77607. attachInput(input: ICameraInput<TCamera>): void;
  77608. /**
  77609. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  77610. * @param element Defines the dom element to collect the events from
  77611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77612. */
  77613. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  77614. /**
  77615. * Detach the current manager inputs controls from a specific dom element.
  77616. * @param element Defines the dom element to collect the events from
  77617. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  77618. */
  77619. detachElement(element: HTMLElement, disconnect?: boolean): void;
  77620. /**
  77621. * Rebuild the dynamic inputCheck function from the current list of
  77622. * defined inputs in the manager.
  77623. */
  77624. rebuildInputCheck(): void;
  77625. /**
  77626. * Remove all attached input methods from a camera
  77627. */
  77628. clear(): void;
  77629. /**
  77630. * Serialize the current input manager attached to a camera.
  77631. * This ensures than once parsed,
  77632. * the input associated to the camera will be identical to the current ones
  77633. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  77634. */
  77635. serialize(serializedCamera: any): void;
  77636. /**
  77637. * Parses an input manager serialized JSON to restore the previous list of inputs
  77638. * and states associated to a camera.
  77639. * @param parsedCamera Defines the JSON to parse
  77640. */
  77641. parse(parsedCamera: any): void;
  77642. }
  77643. }
  77644. declare module BABYLON {
  77645. /**
  77646. * Class used to store data that will be store in GPU memory
  77647. */
  77648. export class Buffer {
  77649. private _engine;
  77650. private _buffer;
  77651. /** @hidden */
  77652. _data: Nullable<DataArray>;
  77653. private _updatable;
  77654. private _instanced;
  77655. private _divisor;
  77656. /**
  77657. * Gets the byte stride.
  77658. */
  77659. readonly byteStride: number;
  77660. /**
  77661. * Constructor
  77662. * @param engine the engine
  77663. * @param data the data to use for this buffer
  77664. * @param updatable whether the data is updatable
  77665. * @param stride the stride (optional)
  77666. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77667. * @param instanced whether the buffer is instanced (optional)
  77668. * @param useBytes set to true if the stride in in bytes (optional)
  77669. * @param divisor sets an optional divisor for instances (1 by default)
  77670. */
  77671. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  77672. /**
  77673. * Create a new VertexBuffer based on the current buffer
  77674. * @param kind defines the vertex buffer kind (position, normal, etc.)
  77675. * @param offset defines offset in the buffer (0 by default)
  77676. * @param size defines the size in floats of attributes (position is 3 for instance)
  77677. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  77678. * @param instanced defines if the vertex buffer contains indexed data
  77679. * @param useBytes defines if the offset and stride are in bytes *
  77680. * @param divisor sets an optional divisor for instances (1 by default)
  77681. * @returns the new vertex buffer
  77682. */
  77683. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  77684. /**
  77685. * Gets a boolean indicating if the Buffer is updatable?
  77686. * @returns true if the buffer is updatable
  77687. */
  77688. isUpdatable(): boolean;
  77689. /**
  77690. * Gets current buffer's data
  77691. * @returns a DataArray or null
  77692. */
  77693. getData(): Nullable<DataArray>;
  77694. /**
  77695. * Gets underlying native buffer
  77696. * @returns underlying native buffer
  77697. */
  77698. getBuffer(): Nullable<DataBuffer>;
  77699. /**
  77700. * Gets the stride in float32 units (i.e. byte stride / 4).
  77701. * May not be an integer if the byte stride is not divisible by 4.
  77702. * @returns the stride in float32 units
  77703. * @deprecated Please use byteStride instead.
  77704. */
  77705. getStrideSize(): number;
  77706. /**
  77707. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77708. * @param data defines the data to store
  77709. */
  77710. create(data?: Nullable<DataArray>): void;
  77711. /** @hidden */
  77712. _rebuild(): void;
  77713. /**
  77714. * Update current buffer data
  77715. * @param data defines the data to store
  77716. */
  77717. update(data: DataArray): void;
  77718. /**
  77719. * Updates the data directly.
  77720. * @param data the new data
  77721. * @param offset the new offset
  77722. * @param vertexCount the vertex count (optional)
  77723. * @param useBytes set to true if the offset is in bytes
  77724. */
  77725. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  77726. /**
  77727. * Release all resources
  77728. */
  77729. dispose(): void;
  77730. }
  77731. /**
  77732. * Specialized buffer used to store vertex data
  77733. */
  77734. export class VertexBuffer {
  77735. /** @hidden */
  77736. _buffer: Buffer;
  77737. private _kind;
  77738. private _size;
  77739. private _ownsBuffer;
  77740. private _instanced;
  77741. private _instanceDivisor;
  77742. /**
  77743. * The byte type.
  77744. */
  77745. static readonly BYTE: number;
  77746. /**
  77747. * The unsigned byte type.
  77748. */
  77749. static readonly UNSIGNED_BYTE: number;
  77750. /**
  77751. * The short type.
  77752. */
  77753. static readonly SHORT: number;
  77754. /**
  77755. * The unsigned short type.
  77756. */
  77757. static readonly UNSIGNED_SHORT: number;
  77758. /**
  77759. * The integer type.
  77760. */
  77761. static readonly INT: number;
  77762. /**
  77763. * The unsigned integer type.
  77764. */
  77765. static readonly UNSIGNED_INT: number;
  77766. /**
  77767. * The float type.
  77768. */
  77769. static readonly FLOAT: number;
  77770. /**
  77771. * Gets or sets the instance divisor when in instanced mode
  77772. */
  77773. get instanceDivisor(): number;
  77774. set instanceDivisor(value: number);
  77775. /**
  77776. * Gets the byte stride.
  77777. */
  77778. readonly byteStride: number;
  77779. /**
  77780. * Gets the byte offset.
  77781. */
  77782. readonly byteOffset: number;
  77783. /**
  77784. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  77785. */
  77786. readonly normalized: boolean;
  77787. /**
  77788. * Gets the data type of each component in the array.
  77789. */
  77790. readonly type: number;
  77791. /**
  77792. * Constructor
  77793. * @param engine the engine
  77794. * @param data the data to use for this vertex buffer
  77795. * @param kind the vertex buffer kind
  77796. * @param updatable whether the data is updatable
  77797. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77798. * @param stride the stride (optional)
  77799. * @param instanced whether the buffer is instanced (optional)
  77800. * @param offset the offset of the data (optional)
  77801. * @param size the number of components (optional)
  77802. * @param type the type of the component (optional)
  77803. * @param normalized whether the data contains normalized data (optional)
  77804. * @param useBytes set to true if stride and offset are in bytes (optional)
  77805. * @param divisor defines the instance divisor to use (1 by default)
  77806. */
  77807. 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);
  77808. /** @hidden */
  77809. _rebuild(): void;
  77810. /**
  77811. * Returns the kind of the VertexBuffer (string)
  77812. * @returns a string
  77813. */
  77814. getKind(): string;
  77815. /**
  77816. * Gets a boolean indicating if the VertexBuffer is updatable?
  77817. * @returns true if the buffer is updatable
  77818. */
  77819. isUpdatable(): boolean;
  77820. /**
  77821. * Gets current buffer's data
  77822. * @returns a DataArray or null
  77823. */
  77824. getData(): Nullable<DataArray>;
  77825. /**
  77826. * Gets underlying native buffer
  77827. * @returns underlying native buffer
  77828. */
  77829. getBuffer(): Nullable<DataBuffer>;
  77830. /**
  77831. * Gets the stride in float32 units (i.e. byte stride / 4).
  77832. * May not be an integer if the byte stride is not divisible by 4.
  77833. * @returns the stride in float32 units
  77834. * @deprecated Please use byteStride instead.
  77835. */
  77836. getStrideSize(): number;
  77837. /**
  77838. * Returns the offset as a multiple of the type byte length.
  77839. * @returns the offset in bytes
  77840. * @deprecated Please use byteOffset instead.
  77841. */
  77842. getOffset(): number;
  77843. /**
  77844. * Returns the number of components per vertex attribute (integer)
  77845. * @returns the size in float
  77846. */
  77847. getSize(): number;
  77848. /**
  77849. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77850. * @returns true if this buffer is instanced
  77851. */
  77852. getIsInstanced(): boolean;
  77853. /**
  77854. * Returns the instancing divisor, zero for non-instanced (integer).
  77855. * @returns a number
  77856. */
  77857. getInstanceDivisor(): number;
  77858. /**
  77859. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77860. * @param data defines the data to store
  77861. */
  77862. create(data?: DataArray): void;
  77863. /**
  77864. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77865. * This function will create a new buffer if the current one is not updatable
  77866. * @param data defines the data to store
  77867. */
  77868. update(data: DataArray): void;
  77869. /**
  77870. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77871. * Returns the directly updated WebGLBuffer.
  77872. * @param data the new data
  77873. * @param offset the new offset
  77874. * @param useBytes set to true if the offset is in bytes
  77875. */
  77876. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77877. /**
  77878. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77879. */
  77880. dispose(): void;
  77881. /**
  77882. * Enumerates each value of this vertex buffer as numbers.
  77883. * @param count the number of values to enumerate
  77884. * @param callback the callback function called for each value
  77885. */
  77886. forEach(count: number, callback: (value: number, index: number) => void): void;
  77887. /**
  77888. * Positions
  77889. */
  77890. static readonly PositionKind: string;
  77891. /**
  77892. * Normals
  77893. */
  77894. static readonly NormalKind: string;
  77895. /**
  77896. * Tangents
  77897. */
  77898. static readonly TangentKind: string;
  77899. /**
  77900. * Texture coordinates
  77901. */
  77902. static readonly UVKind: string;
  77903. /**
  77904. * Texture coordinates 2
  77905. */
  77906. static readonly UV2Kind: string;
  77907. /**
  77908. * Texture coordinates 3
  77909. */
  77910. static readonly UV3Kind: string;
  77911. /**
  77912. * Texture coordinates 4
  77913. */
  77914. static readonly UV4Kind: string;
  77915. /**
  77916. * Texture coordinates 5
  77917. */
  77918. static readonly UV5Kind: string;
  77919. /**
  77920. * Texture coordinates 6
  77921. */
  77922. static readonly UV6Kind: string;
  77923. /**
  77924. * Colors
  77925. */
  77926. static readonly ColorKind: string;
  77927. /**
  77928. * Matrix indices (for bones)
  77929. */
  77930. static readonly MatricesIndicesKind: string;
  77931. /**
  77932. * Matrix weights (for bones)
  77933. */
  77934. static readonly MatricesWeightsKind: string;
  77935. /**
  77936. * Additional matrix indices (for bones)
  77937. */
  77938. static readonly MatricesIndicesExtraKind: string;
  77939. /**
  77940. * Additional matrix weights (for bones)
  77941. */
  77942. static readonly MatricesWeightsExtraKind: string;
  77943. /**
  77944. * Deduces the stride given a kind.
  77945. * @param kind The kind string to deduce
  77946. * @returns The deduced stride
  77947. */
  77948. static DeduceStride(kind: string): number;
  77949. /**
  77950. * Gets the byte length of the given type.
  77951. * @param type the type
  77952. * @returns the number of bytes
  77953. */
  77954. static GetTypeByteLength(type: number): number;
  77955. /**
  77956. * Enumerates each value of the given parameters as numbers.
  77957. * @param data the data to enumerate
  77958. * @param byteOffset the byte offset of the data
  77959. * @param byteStride the byte stride of the data
  77960. * @param componentCount the number of components per element
  77961. * @param componentType the type of the component
  77962. * @param count the number of values to enumerate
  77963. * @param normalized whether the data is normalized
  77964. * @param callback the callback function called for each value
  77965. */
  77966. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77967. private static _GetFloatValue;
  77968. }
  77969. }
  77970. declare module BABYLON {
  77971. /**
  77972. * @hidden
  77973. */
  77974. export class IntersectionInfo {
  77975. bu: Nullable<number>;
  77976. bv: Nullable<number>;
  77977. distance: number;
  77978. faceId: number;
  77979. subMeshId: number;
  77980. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77981. }
  77982. }
  77983. declare module BABYLON {
  77984. /**
  77985. * Represens a plane by the equation ax + by + cz + d = 0
  77986. */
  77987. export class Plane {
  77988. private static _TmpMatrix;
  77989. /**
  77990. * Normal of the plane (a,b,c)
  77991. */
  77992. normal: Vector3;
  77993. /**
  77994. * d component of the plane
  77995. */
  77996. d: number;
  77997. /**
  77998. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77999. * @param a a component of the plane
  78000. * @param b b component of the plane
  78001. * @param c c component of the plane
  78002. * @param d d component of the plane
  78003. */
  78004. constructor(a: number, b: number, c: number, d: number);
  78005. /**
  78006. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  78007. */
  78008. asArray(): number[];
  78009. /**
  78010. * @returns a new plane copied from the current Plane.
  78011. */
  78012. clone(): Plane;
  78013. /**
  78014. * @returns the string "Plane".
  78015. */
  78016. getClassName(): string;
  78017. /**
  78018. * @returns the Plane hash code.
  78019. */
  78020. getHashCode(): number;
  78021. /**
  78022. * Normalize the current Plane in place.
  78023. * @returns the updated Plane.
  78024. */
  78025. normalize(): Plane;
  78026. /**
  78027. * Applies a transformation the plane and returns the result
  78028. * @param transformation the transformation matrix to be applied to the plane
  78029. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  78030. */
  78031. transform(transformation: DeepImmutable<Matrix>): Plane;
  78032. /**
  78033. * Calcualtte the dot product between the point and the plane normal
  78034. * @param point point to calculate the dot product with
  78035. * @returns the dot product (float) of the point coordinates and the plane normal.
  78036. */
  78037. dotCoordinate(point: DeepImmutable<Vector3>): number;
  78038. /**
  78039. * Updates the current Plane from the plane defined by the three given points.
  78040. * @param point1 one of the points used to contruct the plane
  78041. * @param point2 one of the points used to contruct the plane
  78042. * @param point3 one of the points used to contruct the plane
  78043. * @returns the updated Plane.
  78044. */
  78045. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78046. /**
  78047. * Checks if the plane is facing a given direction
  78048. * @param direction the direction to check if the plane is facing
  78049. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  78050. * @returns True is the vector "direction" is the same side than the plane normal.
  78051. */
  78052. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  78053. /**
  78054. * Calculates the distance to a point
  78055. * @param point point to calculate distance to
  78056. * @returns the signed distance (float) from the given point to the Plane.
  78057. */
  78058. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  78059. /**
  78060. * Creates a plane from an array
  78061. * @param array the array to create a plane from
  78062. * @returns a new Plane from the given array.
  78063. */
  78064. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  78065. /**
  78066. * Creates a plane from three points
  78067. * @param point1 point used to create the plane
  78068. * @param point2 point used to create the plane
  78069. * @param point3 point used to create the plane
  78070. * @returns a new Plane defined by the three given points.
  78071. */
  78072. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78073. /**
  78074. * Creates a plane from an origin point and a normal
  78075. * @param origin origin of the plane to be constructed
  78076. * @param normal normal of the plane to be constructed
  78077. * @returns a new Plane the normal vector to this plane at the given origin point.
  78078. * Note : the vector "normal" is updated because normalized.
  78079. */
  78080. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  78081. /**
  78082. * Calculates the distance from a plane and a point
  78083. * @param origin origin of the plane to be constructed
  78084. * @param normal normal of the plane to be constructed
  78085. * @param point point to calculate distance to
  78086. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  78087. */
  78088. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  78089. }
  78090. }
  78091. declare module BABYLON {
  78092. /**
  78093. * Class used to store bounding sphere information
  78094. */
  78095. export class BoundingSphere {
  78096. /**
  78097. * Gets the center of the bounding sphere in local space
  78098. */
  78099. readonly center: Vector3;
  78100. /**
  78101. * Radius of the bounding sphere in local space
  78102. */
  78103. radius: number;
  78104. /**
  78105. * Gets the center of the bounding sphere in world space
  78106. */
  78107. readonly centerWorld: Vector3;
  78108. /**
  78109. * Radius of the bounding sphere in world space
  78110. */
  78111. radiusWorld: number;
  78112. /**
  78113. * Gets the minimum vector in local space
  78114. */
  78115. readonly minimum: Vector3;
  78116. /**
  78117. * Gets the maximum vector in local space
  78118. */
  78119. readonly maximum: Vector3;
  78120. private _worldMatrix;
  78121. private static readonly TmpVector3;
  78122. /**
  78123. * Creates a new bounding sphere
  78124. * @param min defines the minimum vector (in local space)
  78125. * @param max defines the maximum vector (in local space)
  78126. * @param worldMatrix defines the new world matrix
  78127. */
  78128. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  78129. /**
  78130. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  78131. * @param min defines the new minimum vector (in local space)
  78132. * @param max defines the new maximum vector (in local space)
  78133. * @param worldMatrix defines the new world matrix
  78134. */
  78135. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  78136. /**
  78137. * Scale the current bounding sphere by applying a scale factor
  78138. * @param factor defines the scale factor to apply
  78139. * @returns the current bounding box
  78140. */
  78141. scale(factor: number): BoundingSphere;
  78142. /**
  78143. * Gets the world matrix of the bounding box
  78144. * @returns a matrix
  78145. */
  78146. getWorldMatrix(): DeepImmutable<Matrix>;
  78147. /** @hidden */
  78148. _update(worldMatrix: DeepImmutable<Matrix>): void;
  78149. /**
  78150. * Tests if the bounding sphere is intersecting the frustum planes
  78151. * @param frustumPlanes defines the frustum planes to test
  78152. * @returns true if there is an intersection
  78153. */
  78154. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78155. /**
  78156. * Tests if the bounding sphere center is in between the frustum planes.
  78157. * Used for optimistic fast inclusion.
  78158. * @param frustumPlanes defines the frustum planes to test
  78159. * @returns true if the sphere center is in between the frustum planes
  78160. */
  78161. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78162. /**
  78163. * Tests if a point is inside the bounding sphere
  78164. * @param point defines the point to test
  78165. * @returns true if the point is inside the bounding sphere
  78166. */
  78167. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  78168. /**
  78169. * Checks if two sphere intersct
  78170. * @param sphere0 sphere 0
  78171. * @param sphere1 sphere 1
  78172. * @returns true if the speres intersect
  78173. */
  78174. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  78175. }
  78176. }
  78177. declare module BABYLON {
  78178. /**
  78179. * Class used to store bounding box information
  78180. */
  78181. export class BoundingBox implements ICullable {
  78182. /**
  78183. * Gets the 8 vectors representing the bounding box in local space
  78184. */
  78185. readonly vectors: Vector3[];
  78186. /**
  78187. * Gets the center of the bounding box in local space
  78188. */
  78189. readonly center: Vector3;
  78190. /**
  78191. * Gets the center of the bounding box in world space
  78192. */
  78193. readonly centerWorld: Vector3;
  78194. /**
  78195. * Gets the extend size in local space
  78196. */
  78197. readonly extendSize: Vector3;
  78198. /**
  78199. * Gets the extend size in world space
  78200. */
  78201. readonly extendSizeWorld: Vector3;
  78202. /**
  78203. * Gets the OBB (object bounding box) directions
  78204. */
  78205. readonly directions: Vector3[];
  78206. /**
  78207. * Gets the 8 vectors representing the bounding box in world space
  78208. */
  78209. readonly vectorsWorld: Vector3[];
  78210. /**
  78211. * Gets the minimum vector in world space
  78212. */
  78213. readonly minimumWorld: Vector3;
  78214. /**
  78215. * Gets the maximum vector in world space
  78216. */
  78217. readonly maximumWorld: Vector3;
  78218. /**
  78219. * Gets the minimum vector in local space
  78220. */
  78221. readonly minimum: Vector3;
  78222. /**
  78223. * Gets the maximum vector in local space
  78224. */
  78225. readonly maximum: Vector3;
  78226. private _worldMatrix;
  78227. private static readonly TmpVector3;
  78228. /**
  78229. * @hidden
  78230. */
  78231. _tag: number;
  78232. /**
  78233. * Creates a new bounding box
  78234. * @param min defines the minimum vector (in local space)
  78235. * @param max defines the maximum vector (in local space)
  78236. * @param worldMatrix defines the new world matrix
  78237. */
  78238. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  78239. /**
  78240. * Recreates the entire bounding box from scratch as if we call the constructor in place
  78241. * @param min defines the new minimum vector (in local space)
  78242. * @param max defines the new maximum vector (in local space)
  78243. * @param worldMatrix defines the new world matrix
  78244. */
  78245. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  78246. /**
  78247. * Scale the current bounding box by applying a scale factor
  78248. * @param factor defines the scale factor to apply
  78249. * @returns the current bounding box
  78250. */
  78251. scale(factor: number): BoundingBox;
  78252. /**
  78253. * Gets the world matrix of the bounding box
  78254. * @returns a matrix
  78255. */
  78256. getWorldMatrix(): DeepImmutable<Matrix>;
  78257. /** @hidden */
  78258. _update(world: DeepImmutable<Matrix>): void;
  78259. /**
  78260. * Tests if the bounding box is intersecting the frustum planes
  78261. * @param frustumPlanes defines the frustum planes to test
  78262. * @returns true if there is an intersection
  78263. */
  78264. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78265. /**
  78266. * Tests if the bounding box is entirely inside the frustum planes
  78267. * @param frustumPlanes defines the frustum planes to test
  78268. * @returns true if there is an inclusion
  78269. */
  78270. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78271. /**
  78272. * Tests if a point is inside the bounding box
  78273. * @param point defines the point to test
  78274. * @returns true if the point is inside the bounding box
  78275. */
  78276. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  78277. /**
  78278. * Tests if the bounding box intersects with a bounding sphere
  78279. * @param sphere defines the sphere to test
  78280. * @returns true if there is an intersection
  78281. */
  78282. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  78283. /**
  78284. * Tests if the bounding box intersects with a box defined by a min and max vectors
  78285. * @param min defines the min vector to use
  78286. * @param max defines the max vector to use
  78287. * @returns true if there is an intersection
  78288. */
  78289. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  78290. /**
  78291. * Tests if two bounding boxes are intersections
  78292. * @param box0 defines the first box to test
  78293. * @param box1 defines the second box to test
  78294. * @returns true if there is an intersection
  78295. */
  78296. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  78297. /**
  78298. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  78299. * @param minPoint defines the minimum vector of the bounding box
  78300. * @param maxPoint defines the maximum vector of the bounding box
  78301. * @param sphereCenter defines the sphere center
  78302. * @param sphereRadius defines the sphere radius
  78303. * @returns true if there is an intersection
  78304. */
  78305. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  78306. /**
  78307. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  78308. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  78309. * @param frustumPlanes defines the frustum planes to test
  78310. * @return true if there is an inclusion
  78311. */
  78312. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78313. /**
  78314. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  78315. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  78316. * @param frustumPlanes defines the frustum planes to test
  78317. * @return true if there is an intersection
  78318. */
  78319. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78320. }
  78321. }
  78322. declare module BABYLON {
  78323. /** @hidden */
  78324. export class Collider {
  78325. /** Define if a collision was found */
  78326. collisionFound: boolean;
  78327. /**
  78328. * Define last intersection point in local space
  78329. */
  78330. intersectionPoint: Vector3;
  78331. /**
  78332. * Define last collided mesh
  78333. */
  78334. collidedMesh: Nullable<AbstractMesh>;
  78335. private _collisionPoint;
  78336. private _planeIntersectionPoint;
  78337. private _tempVector;
  78338. private _tempVector2;
  78339. private _tempVector3;
  78340. private _tempVector4;
  78341. private _edge;
  78342. private _baseToVertex;
  78343. private _destinationPoint;
  78344. private _slidePlaneNormal;
  78345. private _displacementVector;
  78346. /** @hidden */
  78347. _radius: Vector3;
  78348. /** @hidden */
  78349. _retry: number;
  78350. private _velocity;
  78351. private _basePoint;
  78352. private _epsilon;
  78353. /** @hidden */
  78354. _velocityWorldLength: number;
  78355. /** @hidden */
  78356. _basePointWorld: Vector3;
  78357. private _velocityWorld;
  78358. private _normalizedVelocity;
  78359. /** @hidden */
  78360. _initialVelocity: Vector3;
  78361. /** @hidden */
  78362. _initialPosition: Vector3;
  78363. private _nearestDistance;
  78364. private _collisionMask;
  78365. get collisionMask(): number;
  78366. set collisionMask(mask: number);
  78367. /**
  78368. * Gets the plane normal used to compute the sliding response (in local space)
  78369. */
  78370. get slidePlaneNormal(): Vector3;
  78371. /** @hidden */
  78372. _initialize(source: Vector3, dir: Vector3, e: number): void;
  78373. /** @hidden */
  78374. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  78375. /** @hidden */
  78376. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  78377. /** @hidden */
  78378. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  78379. /** @hidden */
  78380. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  78381. /** @hidden */
  78382. _getResponse(pos: Vector3, vel: Vector3): void;
  78383. }
  78384. }
  78385. declare module BABYLON {
  78386. /**
  78387. * Interface for cullable objects
  78388. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  78389. */
  78390. export interface ICullable {
  78391. /**
  78392. * Checks if the object or part of the object is in the frustum
  78393. * @param frustumPlanes Camera near/planes
  78394. * @returns true if the object is in frustum otherwise false
  78395. */
  78396. isInFrustum(frustumPlanes: Plane[]): boolean;
  78397. /**
  78398. * Checks if a cullable object (mesh...) is in the camera frustum
  78399. * Unlike isInFrustum this cheks the full bounding box
  78400. * @param frustumPlanes Camera near/planes
  78401. * @returns true if the object is in frustum otherwise false
  78402. */
  78403. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  78404. }
  78405. /**
  78406. * Info for a bounding data of a mesh
  78407. */
  78408. export class BoundingInfo implements ICullable {
  78409. /**
  78410. * Bounding box for the mesh
  78411. */
  78412. readonly boundingBox: BoundingBox;
  78413. /**
  78414. * Bounding sphere for the mesh
  78415. */
  78416. readonly boundingSphere: BoundingSphere;
  78417. private _isLocked;
  78418. private static readonly TmpVector3;
  78419. /**
  78420. * Constructs bounding info
  78421. * @param minimum min vector of the bounding box/sphere
  78422. * @param maximum max vector of the bounding box/sphere
  78423. * @param worldMatrix defines the new world matrix
  78424. */
  78425. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  78426. /**
  78427. * Recreates the entire bounding info from scratch as if we call the constructor in place
  78428. * @param min defines the new minimum vector (in local space)
  78429. * @param max defines the new maximum vector (in local space)
  78430. * @param worldMatrix defines the new world matrix
  78431. */
  78432. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  78433. /**
  78434. * min vector of the bounding box/sphere
  78435. */
  78436. get minimum(): Vector3;
  78437. /**
  78438. * max vector of the bounding box/sphere
  78439. */
  78440. get maximum(): Vector3;
  78441. /**
  78442. * If the info is locked and won't be updated to avoid perf overhead
  78443. */
  78444. get isLocked(): boolean;
  78445. set isLocked(value: boolean);
  78446. /**
  78447. * Updates the bounding sphere and box
  78448. * @param world world matrix to be used to update
  78449. */
  78450. update(world: DeepImmutable<Matrix>): void;
  78451. /**
  78452. * Recreate the bounding info to be centered around a specific point given a specific extend.
  78453. * @param center New center of the bounding info
  78454. * @param extend New extend of the bounding info
  78455. * @returns the current bounding info
  78456. */
  78457. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  78458. /**
  78459. * Scale the current bounding info by applying a scale factor
  78460. * @param factor defines the scale factor to apply
  78461. * @returns the current bounding info
  78462. */
  78463. scale(factor: number): BoundingInfo;
  78464. /**
  78465. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  78466. * @param frustumPlanes defines the frustum to test
  78467. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  78468. * @returns true if the bounding info is in the frustum planes
  78469. */
  78470. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  78471. /**
  78472. * Gets the world distance between the min and max points of the bounding box
  78473. */
  78474. get diagonalLength(): number;
  78475. /**
  78476. * Checks if a cullable object (mesh...) is in the camera frustum
  78477. * Unlike isInFrustum this cheks the full bounding box
  78478. * @param frustumPlanes Camera near/planes
  78479. * @returns true if the object is in frustum otherwise false
  78480. */
  78481. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78482. /** @hidden */
  78483. _checkCollision(collider: Collider): boolean;
  78484. /**
  78485. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  78486. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  78487. * @param point the point to check intersection with
  78488. * @returns if the point intersects
  78489. */
  78490. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  78491. /**
  78492. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  78493. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  78494. * @param boundingInfo the bounding info to check intersection with
  78495. * @param precise if the intersection should be done using OBB
  78496. * @returns if the bounding info intersects
  78497. */
  78498. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  78499. }
  78500. }
  78501. declare module BABYLON {
  78502. /**
  78503. * Extracts minimum and maximum values from a list of indexed positions
  78504. * @param positions defines the positions to use
  78505. * @param indices defines the indices to the positions
  78506. * @param indexStart defines the start index
  78507. * @param indexCount defines the end index
  78508. * @param bias defines bias value to add to the result
  78509. * @return minimum and maximum values
  78510. */
  78511. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  78512. minimum: Vector3;
  78513. maximum: Vector3;
  78514. };
  78515. /**
  78516. * Extracts minimum and maximum values from a list of positions
  78517. * @param positions defines the positions to use
  78518. * @param start defines the start index in the positions array
  78519. * @param count defines the number of positions to handle
  78520. * @param bias defines bias value to add to the result
  78521. * @param stride defines the stride size to use (distance between two positions in the positions array)
  78522. * @return minimum and maximum values
  78523. */
  78524. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  78525. minimum: Vector3;
  78526. maximum: Vector3;
  78527. };
  78528. }
  78529. declare module BABYLON {
  78530. /** @hidden */
  78531. export class WebGLDataBuffer extends DataBuffer {
  78532. private _buffer;
  78533. constructor(resource: WebGLBuffer);
  78534. get underlyingResource(): any;
  78535. }
  78536. }
  78537. declare module BABYLON {
  78538. /** @hidden */
  78539. export class WebGLPipelineContext implements IPipelineContext {
  78540. engine: ThinEngine;
  78541. program: Nullable<WebGLProgram>;
  78542. context?: WebGLRenderingContext;
  78543. vertexShader?: WebGLShader;
  78544. fragmentShader?: WebGLShader;
  78545. isParallelCompiled: boolean;
  78546. onCompiled?: () => void;
  78547. transformFeedback?: WebGLTransformFeedback | null;
  78548. vertexCompilationError: Nullable<string>;
  78549. fragmentCompilationError: Nullable<string>;
  78550. programLinkError: Nullable<string>;
  78551. programValidationError: Nullable<string>;
  78552. get isAsync(): boolean;
  78553. get isReady(): boolean;
  78554. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  78555. }
  78556. }
  78557. declare module BABYLON {
  78558. interface ThinEngine {
  78559. /**
  78560. * Create an uniform buffer
  78561. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  78562. * @param elements defines the content of the uniform buffer
  78563. * @returns the webGL uniform buffer
  78564. */
  78565. createUniformBuffer(elements: FloatArray): DataBuffer;
  78566. /**
  78567. * Create a dynamic uniform buffer
  78568. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  78569. * @param elements defines the content of the uniform buffer
  78570. * @returns the webGL uniform buffer
  78571. */
  78572. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  78573. /**
  78574. * Update an existing uniform buffer
  78575. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  78576. * @param uniformBuffer defines the target uniform buffer
  78577. * @param elements defines the content to update
  78578. * @param offset defines the offset in the uniform buffer where update should start
  78579. * @param count defines the size of the data to update
  78580. */
  78581. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  78582. /**
  78583. * Bind an uniform buffer to the current webGL context
  78584. * @param buffer defines the buffer to bind
  78585. */
  78586. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  78587. /**
  78588. * Bind a buffer to the current webGL context at a given location
  78589. * @param buffer defines the buffer to bind
  78590. * @param location defines the index where to bind the buffer
  78591. */
  78592. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  78593. /**
  78594. * Bind a specific block at a given index in a specific shader program
  78595. * @param pipelineContext defines the pipeline context to use
  78596. * @param blockName defines the block name
  78597. * @param index defines the index where to bind the block
  78598. */
  78599. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  78600. }
  78601. }
  78602. declare module BABYLON {
  78603. /**
  78604. * Uniform buffer objects.
  78605. *
  78606. * Handles blocks of uniform on the GPU.
  78607. *
  78608. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  78609. *
  78610. * For more information, please refer to :
  78611. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  78612. */
  78613. export class UniformBuffer {
  78614. private _engine;
  78615. private _buffer;
  78616. private _data;
  78617. private _bufferData;
  78618. private _dynamic?;
  78619. private _uniformLocations;
  78620. private _uniformSizes;
  78621. private _uniformLocationPointer;
  78622. private _needSync;
  78623. private _noUBO;
  78624. private _currentEffect;
  78625. /** @hidden */
  78626. _alreadyBound: boolean;
  78627. private static _MAX_UNIFORM_SIZE;
  78628. private static _tempBuffer;
  78629. /**
  78630. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  78631. * This is dynamic to allow compat with webgl 1 and 2.
  78632. * You will need to pass the name of the uniform as well as the value.
  78633. */
  78634. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  78635. /**
  78636. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  78637. * This is dynamic to allow compat with webgl 1 and 2.
  78638. * You will need to pass the name of the uniform as well as the value.
  78639. */
  78640. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  78641. /**
  78642. * Lambda to Update a single float in a uniform buffer.
  78643. * This is dynamic to allow compat with webgl 1 and 2.
  78644. * You will need to pass the name of the uniform as well as the value.
  78645. */
  78646. updateFloat: (name: string, x: number) => void;
  78647. /**
  78648. * Lambda to Update a vec2 of float in a uniform buffer.
  78649. * This is dynamic to allow compat with webgl 1 and 2.
  78650. * You will need to pass the name of the uniform as well as the value.
  78651. */
  78652. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  78653. /**
  78654. * Lambda to Update a vec3 of float in a uniform buffer.
  78655. * This is dynamic to allow compat with webgl 1 and 2.
  78656. * You will need to pass the name of the uniform as well as the value.
  78657. */
  78658. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  78659. /**
  78660. * Lambda to Update a vec4 of float in a uniform buffer.
  78661. * This is dynamic to allow compat with webgl 1 and 2.
  78662. * You will need to pass the name of the uniform as well as the value.
  78663. */
  78664. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  78665. /**
  78666. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  78667. * This is dynamic to allow compat with webgl 1 and 2.
  78668. * You will need to pass the name of the uniform as well as the value.
  78669. */
  78670. updateMatrix: (name: string, mat: Matrix) => void;
  78671. /**
  78672. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  78673. * This is dynamic to allow compat with webgl 1 and 2.
  78674. * You will need to pass the name of the uniform as well as the value.
  78675. */
  78676. updateVector3: (name: string, vector: Vector3) => void;
  78677. /**
  78678. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  78679. * This is dynamic to allow compat with webgl 1 and 2.
  78680. * You will need to pass the name of the uniform as well as the value.
  78681. */
  78682. updateVector4: (name: string, vector: Vector4) => void;
  78683. /**
  78684. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  78685. * This is dynamic to allow compat with webgl 1 and 2.
  78686. * You will need to pass the name of the uniform as well as the value.
  78687. */
  78688. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  78689. /**
  78690. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  78691. * This is dynamic to allow compat with webgl 1 and 2.
  78692. * You will need to pass the name of the uniform as well as the value.
  78693. */
  78694. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  78695. /**
  78696. * Instantiates a new Uniform buffer objects.
  78697. *
  78698. * Handles blocks of uniform on the GPU.
  78699. *
  78700. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  78701. *
  78702. * For more information, please refer to :
  78703. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  78704. * @param engine Define the engine the buffer is associated with
  78705. * @param data Define the data contained in the buffer
  78706. * @param dynamic Define if the buffer is updatable
  78707. */
  78708. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  78709. /**
  78710. * Indicates if the buffer is using the WebGL2 UBO implementation,
  78711. * or just falling back on setUniformXXX calls.
  78712. */
  78713. get useUbo(): boolean;
  78714. /**
  78715. * Indicates if the WebGL underlying uniform buffer is in sync
  78716. * with the javascript cache data.
  78717. */
  78718. get isSync(): boolean;
  78719. /**
  78720. * Indicates if the WebGL underlying uniform buffer is dynamic.
  78721. * Also, a dynamic UniformBuffer will disable cache verification and always
  78722. * update the underlying WebGL uniform buffer to the GPU.
  78723. * @returns if Dynamic, otherwise false
  78724. */
  78725. isDynamic(): boolean;
  78726. /**
  78727. * The data cache on JS side.
  78728. * @returns the underlying data as a float array
  78729. */
  78730. getData(): Float32Array;
  78731. /**
  78732. * The underlying WebGL Uniform buffer.
  78733. * @returns the webgl buffer
  78734. */
  78735. getBuffer(): Nullable<DataBuffer>;
  78736. /**
  78737. * std140 layout specifies how to align data within an UBO structure.
  78738. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  78739. * for specs.
  78740. */
  78741. private _fillAlignment;
  78742. /**
  78743. * Adds an uniform in the buffer.
  78744. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  78745. * for the layout to be correct !
  78746. * @param name Name of the uniform, as used in the uniform block in the shader.
  78747. * @param size Data size, or data directly.
  78748. */
  78749. addUniform(name: string, size: number | number[]): void;
  78750. /**
  78751. * Adds a Matrix 4x4 to the uniform buffer.
  78752. * @param name Name of the uniform, as used in the uniform block in the shader.
  78753. * @param mat A 4x4 matrix.
  78754. */
  78755. addMatrix(name: string, mat: Matrix): void;
  78756. /**
  78757. * Adds a vec2 to the uniform buffer.
  78758. * @param name Name of the uniform, as used in the uniform block in the shader.
  78759. * @param x Define the x component value of the vec2
  78760. * @param y Define the y component value of the vec2
  78761. */
  78762. addFloat2(name: string, x: number, y: number): void;
  78763. /**
  78764. * Adds a vec3 to the uniform buffer.
  78765. * @param name Name of the uniform, as used in the uniform block in the shader.
  78766. * @param x Define the x component value of the vec3
  78767. * @param y Define the y component value of the vec3
  78768. * @param z Define the z component value of the vec3
  78769. */
  78770. addFloat3(name: string, x: number, y: number, z: number): void;
  78771. /**
  78772. * Adds a vec3 to the uniform buffer.
  78773. * @param name Name of the uniform, as used in the uniform block in the shader.
  78774. * @param color Define the vec3 from a Color
  78775. */
  78776. addColor3(name: string, color: Color3): void;
  78777. /**
  78778. * Adds a vec4 to the uniform buffer.
  78779. * @param name Name of the uniform, as used in the uniform block in the shader.
  78780. * @param color Define the rgb components from a Color
  78781. * @param alpha Define the a component of the vec4
  78782. */
  78783. addColor4(name: string, color: Color3, alpha: number): void;
  78784. /**
  78785. * Adds a vec3 to the uniform buffer.
  78786. * @param name Name of the uniform, as used in the uniform block in the shader.
  78787. * @param vector Define the vec3 components from a Vector
  78788. */
  78789. addVector3(name: string, vector: Vector3): void;
  78790. /**
  78791. * Adds a Matrix 3x3 to the uniform buffer.
  78792. * @param name Name of the uniform, as used in the uniform block in the shader.
  78793. */
  78794. addMatrix3x3(name: string): void;
  78795. /**
  78796. * Adds a Matrix 2x2 to the uniform buffer.
  78797. * @param name Name of the uniform, as used in the uniform block in the shader.
  78798. */
  78799. addMatrix2x2(name: string): void;
  78800. /**
  78801. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  78802. */
  78803. create(): void;
  78804. /** @hidden */
  78805. _rebuild(): void;
  78806. /**
  78807. * Updates the WebGL Uniform Buffer on the GPU.
  78808. * If the `dynamic` flag is set to true, no cache comparison is done.
  78809. * Otherwise, the buffer will be updated only if the cache differs.
  78810. */
  78811. update(): void;
  78812. /**
  78813. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  78814. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78815. * @param data Define the flattened data
  78816. * @param size Define the size of the data.
  78817. */
  78818. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  78819. private _valueCache;
  78820. private _cacheMatrix;
  78821. private _updateMatrix3x3ForUniform;
  78822. private _updateMatrix3x3ForEffect;
  78823. private _updateMatrix2x2ForEffect;
  78824. private _updateMatrix2x2ForUniform;
  78825. private _updateFloatForEffect;
  78826. private _updateFloatForUniform;
  78827. private _updateFloat2ForEffect;
  78828. private _updateFloat2ForUniform;
  78829. private _updateFloat3ForEffect;
  78830. private _updateFloat3ForUniform;
  78831. private _updateFloat4ForEffect;
  78832. private _updateFloat4ForUniform;
  78833. private _updateMatrixForEffect;
  78834. private _updateMatrixForUniform;
  78835. private _updateVector3ForEffect;
  78836. private _updateVector3ForUniform;
  78837. private _updateVector4ForEffect;
  78838. private _updateVector4ForUniform;
  78839. private _updateColor3ForEffect;
  78840. private _updateColor3ForUniform;
  78841. private _updateColor4ForEffect;
  78842. private _updateColor4ForUniform;
  78843. /**
  78844. * Sets a sampler uniform on the effect.
  78845. * @param name Define the name of the sampler.
  78846. * @param texture Define the texture to set in the sampler
  78847. */
  78848. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78849. /**
  78850. * Directly updates the value of the uniform in the cache AND on the GPU.
  78851. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78852. * @param data Define the flattened data
  78853. */
  78854. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78855. /**
  78856. * Binds this uniform buffer to an effect.
  78857. * @param effect Define the effect to bind the buffer to
  78858. * @param name Name of the uniform block in the shader.
  78859. */
  78860. bindToEffect(effect: Effect, name: string): void;
  78861. /**
  78862. * Disposes the uniform buffer.
  78863. */
  78864. dispose(): void;
  78865. }
  78866. }
  78867. declare module BABYLON {
  78868. /**
  78869. * Enum that determines the text-wrapping mode to use.
  78870. */
  78871. export enum InspectableType {
  78872. /**
  78873. * Checkbox for booleans
  78874. */
  78875. Checkbox = 0,
  78876. /**
  78877. * Sliders for numbers
  78878. */
  78879. Slider = 1,
  78880. /**
  78881. * Vector3
  78882. */
  78883. Vector3 = 2,
  78884. /**
  78885. * Quaternions
  78886. */
  78887. Quaternion = 3,
  78888. /**
  78889. * Color3
  78890. */
  78891. Color3 = 4,
  78892. /**
  78893. * String
  78894. */
  78895. String = 5
  78896. }
  78897. /**
  78898. * Interface used to define custom inspectable properties.
  78899. * This interface is used by the inspector to display custom property grids
  78900. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78901. */
  78902. export interface IInspectable {
  78903. /**
  78904. * Gets the label to display
  78905. */
  78906. label: string;
  78907. /**
  78908. * Gets the name of the property to edit
  78909. */
  78910. propertyName: string;
  78911. /**
  78912. * Gets the type of the editor to use
  78913. */
  78914. type: InspectableType;
  78915. /**
  78916. * Gets the minimum value of the property when using in "slider" mode
  78917. */
  78918. min?: number;
  78919. /**
  78920. * Gets the maximum value of the property when using in "slider" mode
  78921. */
  78922. max?: number;
  78923. /**
  78924. * Gets the setp to use when using in "slider" mode
  78925. */
  78926. step?: number;
  78927. }
  78928. }
  78929. declare module BABYLON {
  78930. /**
  78931. * Class used to provide helper for timing
  78932. */
  78933. export class TimingTools {
  78934. /**
  78935. * Polyfill for setImmediate
  78936. * @param action defines the action to execute after the current execution block
  78937. */
  78938. static SetImmediate(action: () => void): void;
  78939. }
  78940. }
  78941. declare module BABYLON {
  78942. /**
  78943. * Class used to enable instatition of objects by class name
  78944. */
  78945. export class InstantiationTools {
  78946. /**
  78947. * Use this object to register external classes like custom textures or material
  78948. * to allow the laoders to instantiate them
  78949. */
  78950. static RegisteredExternalClasses: {
  78951. [key: string]: Object;
  78952. };
  78953. /**
  78954. * Tries to instantiate a new object from a given class name
  78955. * @param className defines the class name to instantiate
  78956. * @returns the new object or null if the system was not able to do the instantiation
  78957. */
  78958. static Instantiate(className: string): any;
  78959. }
  78960. }
  78961. declare module BABYLON {
  78962. /**
  78963. * Define options used to create a depth texture
  78964. */
  78965. export class DepthTextureCreationOptions {
  78966. /** Specifies whether or not a stencil should be allocated in the texture */
  78967. generateStencil?: boolean;
  78968. /** Specifies whether or not bilinear filtering is enable on the texture */
  78969. bilinearFiltering?: boolean;
  78970. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78971. comparisonFunction?: number;
  78972. /** Specifies if the created texture is a cube texture */
  78973. isCube?: boolean;
  78974. }
  78975. }
  78976. declare module BABYLON {
  78977. interface ThinEngine {
  78978. /**
  78979. * Creates a depth stencil cube texture.
  78980. * This is only available in WebGL 2.
  78981. * @param size The size of face edge in the cube texture.
  78982. * @param options The options defining the cube texture.
  78983. * @returns The cube texture
  78984. */
  78985. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78986. /**
  78987. * Creates a cube texture
  78988. * @param rootUrl defines the url where the files to load is located
  78989. * @param scene defines the current scene
  78990. * @param files defines the list of files to load (1 per face)
  78991. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78992. * @param onLoad defines an optional callback raised when the texture is loaded
  78993. * @param onError defines an optional callback raised if there is an issue to load the texture
  78994. * @param format defines the format of the data
  78995. * @param forcedExtension defines the extension to use to pick the right loader
  78996. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78997. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78998. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78999. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  79000. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  79001. * @returns the cube texture as an InternalTexture
  79002. */
  79003. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  79004. /**
  79005. * Creates a cube texture
  79006. * @param rootUrl defines the url where the files to load is located
  79007. * @param scene defines the current scene
  79008. * @param files defines the list of files to load (1 per face)
  79009. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  79010. * @param onLoad defines an optional callback raised when the texture is loaded
  79011. * @param onError defines an optional callback raised if there is an issue to load the texture
  79012. * @param format defines the format of the data
  79013. * @param forcedExtension defines the extension to use to pick the right loader
  79014. * @returns the cube texture as an InternalTexture
  79015. */
  79016. 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;
  79017. /**
  79018. * Creates a cube texture
  79019. * @param rootUrl defines the url where the files to load is located
  79020. * @param scene defines the current scene
  79021. * @param files defines the list of files to load (1 per face)
  79022. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  79023. * @param onLoad defines an optional callback raised when the texture is loaded
  79024. * @param onError defines an optional callback raised if there is an issue to load the texture
  79025. * @param format defines the format of the data
  79026. * @param forcedExtension defines the extension to use to pick the right loader
  79027. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  79028. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  79029. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  79030. * @returns the cube texture as an InternalTexture
  79031. */
  79032. 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;
  79033. /** @hidden */
  79034. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  79035. /** @hidden */
  79036. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  79037. /** @hidden */
  79038. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  79039. /** @hidden */
  79040. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  79041. /**
  79042. * @hidden
  79043. */
  79044. _setCubeMapTextureParams(loadMipmap: boolean): void;
  79045. }
  79046. }
  79047. declare module BABYLON {
  79048. /**
  79049. * Class for creating a cube texture
  79050. */
  79051. export class CubeTexture extends BaseTexture {
  79052. private _delayedOnLoad;
  79053. /**
  79054. * The url of the texture
  79055. */
  79056. url: string;
  79057. /**
  79058. * Gets or sets the center of the bounding box associated with the cube texture.
  79059. * It must define where the camera used to render the texture was set
  79060. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  79061. */
  79062. boundingBoxPosition: Vector3;
  79063. private _boundingBoxSize;
  79064. /**
  79065. * Gets or sets the size of the bounding box associated with the cube texture
  79066. * When defined, the cubemap will switch to local mode
  79067. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  79068. * @example https://www.babylonjs-playground.com/#RNASML
  79069. */
  79070. set boundingBoxSize(value: Vector3);
  79071. /**
  79072. * Returns the bounding box size
  79073. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  79074. */
  79075. get boundingBoxSize(): Vector3;
  79076. protected _rotationY: number;
  79077. /**
  79078. * Sets texture matrix rotation angle around Y axis in radians.
  79079. */
  79080. set rotationY(value: number);
  79081. /**
  79082. * Gets texture matrix rotation angle around Y axis radians.
  79083. */
  79084. get rotationY(): number;
  79085. /**
  79086. * Are mip maps generated for this texture or not.
  79087. */
  79088. get noMipmap(): boolean;
  79089. private _noMipmap;
  79090. private _files;
  79091. protected _forcedExtension: Nullable<string>;
  79092. private _extensions;
  79093. private _textureMatrix;
  79094. private _format;
  79095. private _createPolynomials;
  79096. /** @hidden */
  79097. _prefiltered: boolean;
  79098. /**
  79099. * Creates a cube texture from an array of image urls
  79100. * @param files defines an array of image urls
  79101. * @param scene defines the hosting scene
  79102. * @param noMipmap specifies if mip maps are not used
  79103. * @returns a cube texture
  79104. */
  79105. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  79106. /**
  79107. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  79108. * @param url defines the url of the prefiltered texture
  79109. * @param scene defines the scene the texture is attached to
  79110. * @param forcedExtension defines the extension of the file if different from the url
  79111. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  79112. * @return the prefiltered texture
  79113. */
  79114. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  79115. /**
  79116. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  79117. * as prefiltered data.
  79118. * @param rootUrl defines the url of the texture or the root name of the six images
  79119. * @param scene defines the scene the texture is attached to
  79120. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  79121. * @param noMipmap defines if mipmaps should be created or not
  79122. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  79123. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  79124. * @param onError defines a callback triggered in case of error during load
  79125. * @param format defines the internal format to use for the texture once loaded
  79126. * @param prefiltered defines whether or not the texture is created from prefiltered data
  79127. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  79128. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  79129. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  79130. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  79131. * @return the cube texture
  79132. */
  79133. 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);
  79134. /**
  79135. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  79136. */
  79137. get isPrefiltered(): boolean;
  79138. /**
  79139. * Get the current class name of the texture useful for serialization or dynamic coding.
  79140. * @returns "CubeTexture"
  79141. */
  79142. getClassName(): string;
  79143. /**
  79144. * Update the url (and optional buffer) of this texture if url was null during construction.
  79145. * @param url the url of the texture
  79146. * @param forcedExtension defines the extension to use
  79147. * @param onLoad callback called when the texture is loaded (defaults to null)
  79148. * @param prefiltered Defines whether the updated texture is prefiltered or not
  79149. */
  79150. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  79151. /**
  79152. * Delays loading of the cube texture
  79153. * @param forcedExtension defines the extension to use
  79154. */
  79155. delayLoad(forcedExtension?: string): void;
  79156. /**
  79157. * Returns the reflection texture matrix
  79158. * @returns the reflection texture matrix
  79159. */
  79160. getReflectionTextureMatrix(): Matrix;
  79161. /**
  79162. * Sets the reflection texture matrix
  79163. * @param value Reflection texture matrix
  79164. */
  79165. setReflectionTextureMatrix(value: Matrix): void;
  79166. /**
  79167. * Parses text to create a cube texture
  79168. * @param parsedTexture define the serialized text to read from
  79169. * @param scene defines the hosting scene
  79170. * @param rootUrl defines the root url of the cube texture
  79171. * @returns a cube texture
  79172. */
  79173. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  79174. /**
  79175. * Makes a clone, or deep copy, of the cube texture
  79176. * @returns a new cube texture
  79177. */
  79178. clone(): CubeTexture;
  79179. }
  79180. }
  79181. declare module BABYLON {
  79182. /**
  79183. * Manages the defines for the Material
  79184. */
  79185. export class MaterialDefines {
  79186. /** @hidden */
  79187. protected _keys: string[];
  79188. private _isDirty;
  79189. /** @hidden */
  79190. _renderId: number;
  79191. /** @hidden */
  79192. _areLightsDirty: boolean;
  79193. /** @hidden */
  79194. _areLightsDisposed: boolean;
  79195. /** @hidden */
  79196. _areAttributesDirty: boolean;
  79197. /** @hidden */
  79198. _areTexturesDirty: boolean;
  79199. /** @hidden */
  79200. _areFresnelDirty: boolean;
  79201. /** @hidden */
  79202. _areMiscDirty: boolean;
  79203. /** @hidden */
  79204. _areImageProcessingDirty: boolean;
  79205. /** @hidden */
  79206. _normals: boolean;
  79207. /** @hidden */
  79208. _uvs: boolean;
  79209. /** @hidden */
  79210. _needNormals: boolean;
  79211. /** @hidden */
  79212. _needUVs: boolean;
  79213. [id: string]: any;
  79214. /**
  79215. * Specifies if the material needs to be re-calculated
  79216. */
  79217. get isDirty(): boolean;
  79218. /**
  79219. * Marks the material to indicate that it has been re-calculated
  79220. */
  79221. markAsProcessed(): void;
  79222. /**
  79223. * Marks the material to indicate that it needs to be re-calculated
  79224. */
  79225. markAsUnprocessed(): void;
  79226. /**
  79227. * Marks the material to indicate all of its defines need to be re-calculated
  79228. */
  79229. markAllAsDirty(): void;
  79230. /**
  79231. * Marks the material to indicate that image processing needs to be re-calculated
  79232. */
  79233. markAsImageProcessingDirty(): void;
  79234. /**
  79235. * Marks the material to indicate the lights need to be re-calculated
  79236. * @param disposed Defines whether the light is dirty due to dispose or not
  79237. */
  79238. markAsLightDirty(disposed?: boolean): void;
  79239. /**
  79240. * Marks the attribute state as changed
  79241. */
  79242. markAsAttributesDirty(): void;
  79243. /**
  79244. * Marks the texture state as changed
  79245. */
  79246. markAsTexturesDirty(): void;
  79247. /**
  79248. * Marks the fresnel state as changed
  79249. */
  79250. markAsFresnelDirty(): void;
  79251. /**
  79252. * Marks the misc state as changed
  79253. */
  79254. markAsMiscDirty(): void;
  79255. /**
  79256. * Rebuilds the material defines
  79257. */
  79258. rebuild(): void;
  79259. /**
  79260. * Specifies if two material defines are equal
  79261. * @param other - A material define instance to compare to
  79262. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  79263. */
  79264. isEqual(other: MaterialDefines): boolean;
  79265. /**
  79266. * Clones this instance's defines to another instance
  79267. * @param other - material defines to clone values to
  79268. */
  79269. cloneTo(other: MaterialDefines): void;
  79270. /**
  79271. * Resets the material define values
  79272. */
  79273. reset(): void;
  79274. /**
  79275. * Converts the material define values to a string
  79276. * @returns - String of material define information
  79277. */
  79278. toString(): string;
  79279. }
  79280. }
  79281. declare module BABYLON {
  79282. /**
  79283. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  79284. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  79285. * 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;
  79286. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  79287. */
  79288. export class ColorCurves {
  79289. private _dirty;
  79290. private _tempColor;
  79291. private _globalCurve;
  79292. private _highlightsCurve;
  79293. private _midtonesCurve;
  79294. private _shadowsCurve;
  79295. private _positiveCurve;
  79296. private _negativeCurve;
  79297. private _globalHue;
  79298. private _globalDensity;
  79299. private _globalSaturation;
  79300. private _globalExposure;
  79301. /**
  79302. * Gets the global Hue value.
  79303. * 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).
  79304. */
  79305. get globalHue(): number;
  79306. /**
  79307. * Sets the global Hue value.
  79308. * 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).
  79309. */
  79310. set globalHue(value: number);
  79311. /**
  79312. * Gets the global Density value.
  79313. * 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.
  79314. * Values less than zero provide a filter of opposite hue.
  79315. */
  79316. get globalDensity(): number;
  79317. /**
  79318. * Sets the global Density value.
  79319. * 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.
  79320. * Values less than zero provide a filter of opposite hue.
  79321. */
  79322. set globalDensity(value: number);
  79323. /**
  79324. * Gets the global Saturation value.
  79325. * 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.
  79326. */
  79327. get globalSaturation(): number;
  79328. /**
  79329. * Sets the global Saturation value.
  79330. * 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.
  79331. */
  79332. set globalSaturation(value: number);
  79333. /**
  79334. * Gets the global Exposure value.
  79335. * 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.
  79336. */
  79337. get globalExposure(): number;
  79338. /**
  79339. * Sets the global Exposure value.
  79340. * 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.
  79341. */
  79342. set globalExposure(value: number);
  79343. private _highlightsHue;
  79344. private _highlightsDensity;
  79345. private _highlightsSaturation;
  79346. private _highlightsExposure;
  79347. /**
  79348. * Gets the highlights Hue value.
  79349. * 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).
  79350. */
  79351. get highlightsHue(): number;
  79352. /**
  79353. * Sets the highlights Hue value.
  79354. * 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).
  79355. */
  79356. set highlightsHue(value: number);
  79357. /**
  79358. * Gets the highlights Density value.
  79359. * 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.
  79360. * Values less than zero provide a filter of opposite hue.
  79361. */
  79362. get highlightsDensity(): number;
  79363. /**
  79364. * Sets the highlights Density value.
  79365. * 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.
  79366. * Values less than zero provide a filter of opposite hue.
  79367. */
  79368. set highlightsDensity(value: number);
  79369. /**
  79370. * Gets the highlights Saturation value.
  79371. * 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.
  79372. */
  79373. get highlightsSaturation(): number;
  79374. /**
  79375. * Sets the highlights Saturation value.
  79376. * 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.
  79377. */
  79378. set highlightsSaturation(value: number);
  79379. /**
  79380. * Gets the highlights Exposure value.
  79381. * 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.
  79382. */
  79383. get highlightsExposure(): number;
  79384. /**
  79385. * Sets the highlights Exposure value.
  79386. * 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.
  79387. */
  79388. set highlightsExposure(value: number);
  79389. private _midtonesHue;
  79390. private _midtonesDensity;
  79391. private _midtonesSaturation;
  79392. private _midtonesExposure;
  79393. /**
  79394. * Gets the midtones Hue value.
  79395. * 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).
  79396. */
  79397. get midtonesHue(): number;
  79398. /**
  79399. * Sets the midtones Hue value.
  79400. * 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).
  79401. */
  79402. set midtonesHue(value: number);
  79403. /**
  79404. * Gets the midtones Density value.
  79405. * 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.
  79406. * Values less than zero provide a filter of opposite hue.
  79407. */
  79408. get midtonesDensity(): number;
  79409. /**
  79410. * Sets the midtones Density value.
  79411. * 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.
  79412. * Values less than zero provide a filter of opposite hue.
  79413. */
  79414. set midtonesDensity(value: number);
  79415. /**
  79416. * Gets the midtones Saturation value.
  79417. * 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.
  79418. */
  79419. get midtonesSaturation(): number;
  79420. /**
  79421. * Sets the midtones Saturation value.
  79422. * 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.
  79423. */
  79424. set midtonesSaturation(value: number);
  79425. /**
  79426. * Gets the midtones Exposure value.
  79427. * 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.
  79428. */
  79429. get midtonesExposure(): number;
  79430. /**
  79431. * Sets the midtones Exposure value.
  79432. * 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.
  79433. */
  79434. set midtonesExposure(value: number);
  79435. private _shadowsHue;
  79436. private _shadowsDensity;
  79437. private _shadowsSaturation;
  79438. private _shadowsExposure;
  79439. /**
  79440. * Gets the shadows Hue value.
  79441. * 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).
  79442. */
  79443. get shadowsHue(): number;
  79444. /**
  79445. * Sets the shadows Hue value.
  79446. * 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).
  79447. */
  79448. set shadowsHue(value: number);
  79449. /**
  79450. * Gets the shadows Density value.
  79451. * 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.
  79452. * Values less than zero provide a filter of opposite hue.
  79453. */
  79454. get shadowsDensity(): number;
  79455. /**
  79456. * Sets the shadows Density value.
  79457. * 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.
  79458. * Values less than zero provide a filter of opposite hue.
  79459. */
  79460. set shadowsDensity(value: number);
  79461. /**
  79462. * Gets the shadows Saturation value.
  79463. * 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.
  79464. */
  79465. get shadowsSaturation(): number;
  79466. /**
  79467. * Sets the shadows Saturation value.
  79468. * 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.
  79469. */
  79470. set shadowsSaturation(value: number);
  79471. /**
  79472. * Gets the shadows Exposure value.
  79473. * 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.
  79474. */
  79475. get shadowsExposure(): number;
  79476. /**
  79477. * Sets the shadows Exposure value.
  79478. * 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.
  79479. */
  79480. set shadowsExposure(value: number);
  79481. /**
  79482. * Returns the class name
  79483. * @returns The class name
  79484. */
  79485. getClassName(): string;
  79486. /**
  79487. * Binds the color curves to the shader.
  79488. * @param colorCurves The color curve to bind
  79489. * @param effect The effect to bind to
  79490. * @param positiveUniform The positive uniform shader parameter
  79491. * @param neutralUniform The neutral uniform shader parameter
  79492. * @param negativeUniform The negative uniform shader parameter
  79493. */
  79494. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  79495. /**
  79496. * Prepare the list of uniforms associated with the ColorCurves effects.
  79497. * @param uniformsList The list of uniforms used in the effect
  79498. */
  79499. static PrepareUniforms(uniformsList: string[]): void;
  79500. /**
  79501. * Returns color grading data based on a hue, density, saturation and exposure value.
  79502. * @param filterHue The hue of the color filter.
  79503. * @param filterDensity The density of the color filter.
  79504. * @param saturation The saturation.
  79505. * @param exposure The exposure.
  79506. * @param result The result data container.
  79507. */
  79508. private getColorGradingDataToRef;
  79509. /**
  79510. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  79511. * @param value The input slider value in range [-100,100].
  79512. * @returns Adjusted value.
  79513. */
  79514. private static applyColorGradingSliderNonlinear;
  79515. /**
  79516. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  79517. * @param hue The hue (H) input.
  79518. * @param saturation The saturation (S) input.
  79519. * @param brightness The brightness (B) input.
  79520. * @result An RGBA color represented as Vector4.
  79521. */
  79522. private static fromHSBToRef;
  79523. /**
  79524. * Returns a value clamped between min and max
  79525. * @param value The value to clamp
  79526. * @param min The minimum of value
  79527. * @param max The maximum of value
  79528. * @returns The clamped value.
  79529. */
  79530. private static clamp;
  79531. /**
  79532. * Clones the current color curve instance.
  79533. * @return The cloned curves
  79534. */
  79535. clone(): ColorCurves;
  79536. /**
  79537. * Serializes the current color curve instance to a json representation.
  79538. * @return a JSON representation
  79539. */
  79540. serialize(): any;
  79541. /**
  79542. * Parses the color curve from a json representation.
  79543. * @param source the JSON source to parse
  79544. * @return The parsed curves
  79545. */
  79546. static Parse(source: any): ColorCurves;
  79547. }
  79548. }
  79549. declare module BABYLON {
  79550. /**
  79551. * Interface to follow in your material defines to integrate easily the
  79552. * Image proccessing functions.
  79553. * @hidden
  79554. */
  79555. export interface IImageProcessingConfigurationDefines {
  79556. IMAGEPROCESSING: boolean;
  79557. VIGNETTE: boolean;
  79558. VIGNETTEBLENDMODEMULTIPLY: boolean;
  79559. VIGNETTEBLENDMODEOPAQUE: boolean;
  79560. TONEMAPPING: boolean;
  79561. TONEMAPPING_ACES: boolean;
  79562. CONTRAST: boolean;
  79563. EXPOSURE: boolean;
  79564. COLORCURVES: boolean;
  79565. COLORGRADING: boolean;
  79566. COLORGRADING3D: boolean;
  79567. SAMPLER3DGREENDEPTH: boolean;
  79568. SAMPLER3DBGRMAP: boolean;
  79569. IMAGEPROCESSINGPOSTPROCESS: boolean;
  79570. }
  79571. /**
  79572. * @hidden
  79573. */
  79574. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  79575. IMAGEPROCESSING: boolean;
  79576. VIGNETTE: boolean;
  79577. VIGNETTEBLENDMODEMULTIPLY: boolean;
  79578. VIGNETTEBLENDMODEOPAQUE: boolean;
  79579. TONEMAPPING: boolean;
  79580. TONEMAPPING_ACES: boolean;
  79581. CONTRAST: boolean;
  79582. COLORCURVES: boolean;
  79583. COLORGRADING: boolean;
  79584. COLORGRADING3D: boolean;
  79585. SAMPLER3DGREENDEPTH: boolean;
  79586. SAMPLER3DBGRMAP: boolean;
  79587. IMAGEPROCESSINGPOSTPROCESS: boolean;
  79588. EXPOSURE: boolean;
  79589. constructor();
  79590. }
  79591. /**
  79592. * This groups together the common properties used for image processing either in direct forward pass
  79593. * or through post processing effect depending on the use of the image processing pipeline in your scene
  79594. * or not.
  79595. */
  79596. export class ImageProcessingConfiguration {
  79597. /**
  79598. * Default tone mapping applied in BabylonJS.
  79599. */
  79600. static readonly TONEMAPPING_STANDARD: number;
  79601. /**
  79602. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  79603. * to other engines rendering to increase portability.
  79604. */
  79605. static readonly TONEMAPPING_ACES: number;
  79606. /**
  79607. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  79608. */
  79609. colorCurves: Nullable<ColorCurves>;
  79610. private _colorCurvesEnabled;
  79611. /**
  79612. * Gets wether the color curves effect is enabled.
  79613. */
  79614. get colorCurvesEnabled(): boolean;
  79615. /**
  79616. * Sets wether the color curves effect is enabled.
  79617. */
  79618. set colorCurvesEnabled(value: boolean);
  79619. private _colorGradingTexture;
  79620. /**
  79621. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  79622. */
  79623. get colorGradingTexture(): Nullable<BaseTexture>;
  79624. /**
  79625. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  79626. */
  79627. set colorGradingTexture(value: Nullable<BaseTexture>);
  79628. private _colorGradingEnabled;
  79629. /**
  79630. * Gets wether the color grading effect is enabled.
  79631. */
  79632. get colorGradingEnabled(): boolean;
  79633. /**
  79634. * Sets wether the color grading effect is enabled.
  79635. */
  79636. set colorGradingEnabled(value: boolean);
  79637. private _colorGradingWithGreenDepth;
  79638. /**
  79639. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  79640. */
  79641. get colorGradingWithGreenDepth(): boolean;
  79642. /**
  79643. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  79644. */
  79645. set colorGradingWithGreenDepth(value: boolean);
  79646. private _colorGradingBGR;
  79647. /**
  79648. * Gets wether the color grading texture contains BGR values.
  79649. */
  79650. get colorGradingBGR(): boolean;
  79651. /**
  79652. * Sets wether the color grading texture contains BGR values.
  79653. */
  79654. set colorGradingBGR(value: boolean);
  79655. /** @hidden */
  79656. _exposure: number;
  79657. /**
  79658. * Gets the Exposure used in the effect.
  79659. */
  79660. get exposure(): number;
  79661. /**
  79662. * Sets the Exposure used in the effect.
  79663. */
  79664. set exposure(value: number);
  79665. private _toneMappingEnabled;
  79666. /**
  79667. * Gets wether the tone mapping effect is enabled.
  79668. */
  79669. get toneMappingEnabled(): boolean;
  79670. /**
  79671. * Sets wether the tone mapping effect is enabled.
  79672. */
  79673. set toneMappingEnabled(value: boolean);
  79674. private _toneMappingType;
  79675. /**
  79676. * Gets the type of tone mapping effect.
  79677. */
  79678. get toneMappingType(): number;
  79679. /**
  79680. * Sets the type of tone mapping effect used in BabylonJS.
  79681. */
  79682. set toneMappingType(value: number);
  79683. protected _contrast: number;
  79684. /**
  79685. * Gets the contrast used in the effect.
  79686. */
  79687. get contrast(): number;
  79688. /**
  79689. * Sets the contrast used in the effect.
  79690. */
  79691. set contrast(value: number);
  79692. /**
  79693. * Vignette stretch size.
  79694. */
  79695. vignetteStretch: number;
  79696. /**
  79697. * Vignette centre X Offset.
  79698. */
  79699. vignetteCentreX: number;
  79700. /**
  79701. * Vignette centre Y Offset.
  79702. */
  79703. vignetteCentreY: number;
  79704. /**
  79705. * Vignette weight or intensity of the vignette effect.
  79706. */
  79707. vignetteWeight: number;
  79708. /**
  79709. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  79710. * if vignetteEnabled is set to true.
  79711. */
  79712. vignetteColor: Color4;
  79713. /**
  79714. * Camera field of view used by the Vignette effect.
  79715. */
  79716. vignetteCameraFov: number;
  79717. private _vignetteBlendMode;
  79718. /**
  79719. * Gets the vignette blend mode allowing different kind of effect.
  79720. */
  79721. get vignetteBlendMode(): number;
  79722. /**
  79723. * Sets the vignette blend mode allowing different kind of effect.
  79724. */
  79725. set vignetteBlendMode(value: number);
  79726. private _vignetteEnabled;
  79727. /**
  79728. * Gets wether the vignette effect is enabled.
  79729. */
  79730. get vignetteEnabled(): boolean;
  79731. /**
  79732. * Sets wether the vignette effect is enabled.
  79733. */
  79734. set vignetteEnabled(value: boolean);
  79735. private _applyByPostProcess;
  79736. /**
  79737. * Gets wether the image processing is applied through a post process or not.
  79738. */
  79739. get applyByPostProcess(): boolean;
  79740. /**
  79741. * Sets wether the image processing is applied through a post process or not.
  79742. */
  79743. set applyByPostProcess(value: boolean);
  79744. private _isEnabled;
  79745. /**
  79746. * Gets wether the image processing is enabled or not.
  79747. */
  79748. get isEnabled(): boolean;
  79749. /**
  79750. * Sets wether the image processing is enabled or not.
  79751. */
  79752. set isEnabled(value: boolean);
  79753. /**
  79754. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  79755. */
  79756. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  79757. /**
  79758. * Method called each time the image processing information changes requires to recompile the effect.
  79759. */
  79760. protected _updateParameters(): void;
  79761. /**
  79762. * Gets the current class name.
  79763. * @return "ImageProcessingConfiguration"
  79764. */
  79765. getClassName(): string;
  79766. /**
  79767. * Prepare the list of uniforms associated with the Image Processing effects.
  79768. * @param uniforms The list of uniforms used in the effect
  79769. * @param defines the list of defines currently in use
  79770. */
  79771. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  79772. /**
  79773. * Prepare the list of samplers associated with the Image Processing effects.
  79774. * @param samplersList The list of uniforms used in the effect
  79775. * @param defines the list of defines currently in use
  79776. */
  79777. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  79778. /**
  79779. * Prepare the list of defines associated to the shader.
  79780. * @param defines the list of defines to complete
  79781. * @param forPostProcess Define if we are currently in post process mode or not
  79782. */
  79783. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  79784. /**
  79785. * Returns true if all the image processing information are ready.
  79786. * @returns True if ready, otherwise, false
  79787. */
  79788. isReady(): boolean;
  79789. /**
  79790. * Binds the image processing to the shader.
  79791. * @param effect The effect to bind to
  79792. * @param overrideAspectRatio Override the aspect ratio of the effect
  79793. */
  79794. bind(effect: Effect, overrideAspectRatio?: number): void;
  79795. /**
  79796. * Clones the current image processing instance.
  79797. * @return The cloned image processing
  79798. */
  79799. clone(): ImageProcessingConfiguration;
  79800. /**
  79801. * Serializes the current image processing instance to a json representation.
  79802. * @return a JSON representation
  79803. */
  79804. serialize(): any;
  79805. /**
  79806. * Parses the image processing from a json representation.
  79807. * @param source the JSON source to parse
  79808. * @return The parsed image processing
  79809. */
  79810. static Parse(source: any): ImageProcessingConfiguration;
  79811. private static _VIGNETTEMODE_MULTIPLY;
  79812. private static _VIGNETTEMODE_OPAQUE;
  79813. /**
  79814. * Used to apply the vignette as a mix with the pixel color.
  79815. */
  79816. static get VIGNETTEMODE_MULTIPLY(): number;
  79817. /**
  79818. * Used to apply the vignette as a replacement of the pixel color.
  79819. */
  79820. static get VIGNETTEMODE_OPAQUE(): number;
  79821. }
  79822. }
  79823. declare module BABYLON {
  79824. /** @hidden */
  79825. export var postprocessVertexShader: {
  79826. name: string;
  79827. shader: string;
  79828. };
  79829. }
  79830. declare module BABYLON {
  79831. interface ThinEngine {
  79832. /**
  79833. * Creates a new render target texture
  79834. * @param size defines the size of the texture
  79835. * @param options defines the options used to create the texture
  79836. * @returns a new render target texture stored in an InternalTexture
  79837. */
  79838. createRenderTargetTexture(size: number | {
  79839. width: number;
  79840. height: number;
  79841. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  79842. /**
  79843. * Creates a depth stencil texture.
  79844. * This is only available in WebGL 2 or with the depth texture extension available.
  79845. * @param size The size of face edge in the texture.
  79846. * @param options The options defining the texture.
  79847. * @returns The texture
  79848. */
  79849. createDepthStencilTexture(size: number | {
  79850. width: number;
  79851. height: number;
  79852. }, options: DepthTextureCreationOptions): InternalTexture;
  79853. /** @hidden */
  79854. _createDepthStencilTexture(size: number | {
  79855. width: number;
  79856. height: number;
  79857. }, options: DepthTextureCreationOptions): InternalTexture;
  79858. }
  79859. }
  79860. declare module BABYLON {
  79861. /** Defines supported spaces */
  79862. export enum Space {
  79863. /** Local (object) space */
  79864. LOCAL = 0,
  79865. /** World space */
  79866. WORLD = 1,
  79867. /** Bone space */
  79868. BONE = 2
  79869. }
  79870. /** Defines the 3 main axes */
  79871. export class Axis {
  79872. /** X axis */
  79873. static X: Vector3;
  79874. /** Y axis */
  79875. static Y: Vector3;
  79876. /** Z axis */
  79877. static Z: Vector3;
  79878. }
  79879. }
  79880. declare module BABYLON {
  79881. /**
  79882. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79883. * This is the base of the follow, arc rotate cameras and Free camera
  79884. * @see http://doc.babylonjs.com/features/cameras
  79885. */
  79886. export class TargetCamera extends Camera {
  79887. private static _RigCamTransformMatrix;
  79888. private static _TargetTransformMatrix;
  79889. private static _TargetFocalPoint;
  79890. /**
  79891. * Define the current direction the camera is moving to
  79892. */
  79893. cameraDirection: Vector3;
  79894. /**
  79895. * Define the current rotation the camera is rotating to
  79896. */
  79897. cameraRotation: Vector2;
  79898. /**
  79899. * When set, the up vector of the camera will be updated by the rotation of the camera
  79900. */
  79901. updateUpVectorFromRotation: boolean;
  79902. private _tmpQuaternion;
  79903. /**
  79904. * Define the current rotation of the camera
  79905. */
  79906. rotation: Vector3;
  79907. /**
  79908. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79909. */
  79910. rotationQuaternion: Quaternion;
  79911. /**
  79912. * Define the current speed of the camera
  79913. */
  79914. speed: number;
  79915. /**
  79916. * Add constraint to the camera to prevent it to move freely in all directions and
  79917. * around all axis.
  79918. */
  79919. noRotationConstraint: boolean;
  79920. /**
  79921. * Define the current target of the camera as an object or a position.
  79922. */
  79923. lockedTarget: any;
  79924. /** @hidden */
  79925. _currentTarget: Vector3;
  79926. /** @hidden */
  79927. _initialFocalDistance: number;
  79928. /** @hidden */
  79929. _viewMatrix: Matrix;
  79930. /** @hidden */
  79931. _camMatrix: Matrix;
  79932. /** @hidden */
  79933. _cameraTransformMatrix: Matrix;
  79934. /** @hidden */
  79935. _cameraRotationMatrix: Matrix;
  79936. /** @hidden */
  79937. _referencePoint: Vector3;
  79938. /** @hidden */
  79939. _transformedReferencePoint: Vector3;
  79940. protected _globalCurrentTarget: Vector3;
  79941. protected _globalCurrentUpVector: Vector3;
  79942. /** @hidden */
  79943. _reset: () => void;
  79944. private _defaultUp;
  79945. /**
  79946. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79947. * This is the base of the follow, arc rotate cameras and Free camera
  79948. * @see http://doc.babylonjs.com/features/cameras
  79949. * @param name Defines the name of the camera in the scene
  79950. * @param position Defines the start position of the camera in the scene
  79951. * @param scene Defines the scene the camera belongs to
  79952. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79953. */
  79954. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79955. /**
  79956. * Gets the position in front of the camera at a given distance.
  79957. * @param distance The distance from the camera we want the position to be
  79958. * @returns the position
  79959. */
  79960. getFrontPosition(distance: number): Vector3;
  79961. /** @hidden */
  79962. _getLockedTargetPosition(): Nullable<Vector3>;
  79963. private _storedPosition;
  79964. private _storedRotation;
  79965. private _storedRotationQuaternion;
  79966. /**
  79967. * Store current camera state of the camera (fov, position, rotation, etc..)
  79968. * @returns the camera
  79969. */
  79970. storeState(): Camera;
  79971. /**
  79972. * Restored camera state. You must call storeState() first
  79973. * @returns whether it was successful or not
  79974. * @hidden
  79975. */
  79976. _restoreStateValues(): boolean;
  79977. /** @hidden */
  79978. _initCache(): void;
  79979. /** @hidden */
  79980. _updateCache(ignoreParentClass?: boolean): void;
  79981. /** @hidden */
  79982. _isSynchronizedViewMatrix(): boolean;
  79983. /** @hidden */
  79984. _computeLocalCameraSpeed(): number;
  79985. /**
  79986. * Defines the target the camera should look at.
  79987. * @param target Defines the new target as a Vector or a mesh
  79988. */
  79989. setTarget(target: Vector3): void;
  79990. /**
  79991. * Return the current target position of the camera. This value is expressed in local space.
  79992. * @returns the target position
  79993. */
  79994. getTarget(): Vector3;
  79995. /** @hidden */
  79996. _decideIfNeedsToMove(): boolean;
  79997. /** @hidden */
  79998. _updatePosition(): void;
  79999. /** @hidden */
  80000. _checkInputs(): void;
  80001. protected _updateCameraRotationMatrix(): void;
  80002. /**
  80003. * 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)
  80004. * @returns the current camera
  80005. */
  80006. private _rotateUpVectorWithCameraRotationMatrix;
  80007. private _cachedRotationZ;
  80008. private _cachedQuaternionRotationZ;
  80009. /** @hidden */
  80010. _getViewMatrix(): Matrix;
  80011. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  80012. /**
  80013. * @hidden
  80014. */
  80015. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  80016. /**
  80017. * @hidden
  80018. */
  80019. _updateRigCameras(): void;
  80020. private _getRigCamPositionAndTarget;
  80021. /**
  80022. * Gets the current object class name.
  80023. * @return the class name
  80024. */
  80025. getClassName(): string;
  80026. }
  80027. }
  80028. declare module BABYLON {
  80029. /**
  80030. * Gather the list of keyboard event types as constants.
  80031. */
  80032. export class KeyboardEventTypes {
  80033. /**
  80034. * The keydown event is fired when a key becomes active (pressed).
  80035. */
  80036. static readonly KEYDOWN: number;
  80037. /**
  80038. * The keyup event is fired when a key has been released.
  80039. */
  80040. static readonly KEYUP: number;
  80041. }
  80042. /**
  80043. * This class is used to store keyboard related info for the onKeyboardObservable event.
  80044. */
  80045. export class KeyboardInfo {
  80046. /**
  80047. * Defines the type of event (KeyboardEventTypes)
  80048. */
  80049. type: number;
  80050. /**
  80051. * Defines the related dom event
  80052. */
  80053. event: KeyboardEvent;
  80054. /**
  80055. * Instantiates a new keyboard info.
  80056. * This class is used to store keyboard related info for the onKeyboardObservable event.
  80057. * @param type Defines the type of event (KeyboardEventTypes)
  80058. * @param event Defines the related dom event
  80059. */
  80060. constructor(
  80061. /**
  80062. * Defines the type of event (KeyboardEventTypes)
  80063. */
  80064. type: number,
  80065. /**
  80066. * Defines the related dom event
  80067. */
  80068. event: KeyboardEvent);
  80069. }
  80070. /**
  80071. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  80072. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  80073. */
  80074. export class KeyboardInfoPre extends KeyboardInfo {
  80075. /**
  80076. * Defines the type of event (KeyboardEventTypes)
  80077. */
  80078. type: number;
  80079. /**
  80080. * Defines the related dom event
  80081. */
  80082. event: KeyboardEvent;
  80083. /**
  80084. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  80085. */
  80086. skipOnPointerObservable: boolean;
  80087. /**
  80088. * Instantiates a new keyboard pre info.
  80089. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  80090. * @param type Defines the type of event (KeyboardEventTypes)
  80091. * @param event Defines the related dom event
  80092. */
  80093. constructor(
  80094. /**
  80095. * Defines the type of event (KeyboardEventTypes)
  80096. */
  80097. type: number,
  80098. /**
  80099. * Defines the related dom event
  80100. */
  80101. event: KeyboardEvent);
  80102. }
  80103. }
  80104. declare module BABYLON {
  80105. /**
  80106. * Manage the keyboard inputs to control the movement of a free camera.
  80107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80108. */
  80109. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  80110. /**
  80111. * Defines the camera the input is attached to.
  80112. */
  80113. camera: FreeCamera;
  80114. /**
  80115. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80116. */
  80117. keysUp: number[];
  80118. /**
  80119. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80120. */
  80121. keysDown: number[];
  80122. /**
  80123. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80124. */
  80125. keysLeft: number[];
  80126. /**
  80127. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80128. */
  80129. keysRight: number[];
  80130. private _keys;
  80131. private _onCanvasBlurObserver;
  80132. private _onKeyboardObserver;
  80133. private _engine;
  80134. private _scene;
  80135. /**
  80136. * Attach the input controls to a specific dom element to get the input from.
  80137. * @param element Defines the element the controls should be listened from
  80138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80139. */
  80140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80141. /**
  80142. * Detach the current controls from the specified dom element.
  80143. * @param element Defines the element to stop listening the inputs from
  80144. */
  80145. detachControl(element: Nullable<HTMLElement>): void;
  80146. /**
  80147. * Update the current camera state depending on the inputs that have been used this frame.
  80148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80149. */
  80150. checkInputs(): void;
  80151. /**
  80152. * Gets the class name of the current intput.
  80153. * @returns the class name
  80154. */
  80155. getClassName(): string;
  80156. /** @hidden */
  80157. _onLostFocus(): void;
  80158. /**
  80159. * Get the friendly name associated with the input class.
  80160. * @returns the input friendly name
  80161. */
  80162. getSimpleName(): string;
  80163. }
  80164. }
  80165. declare module BABYLON {
  80166. /**
  80167. * Interface describing all the common properties and methods a shadow light needs to implement.
  80168. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  80169. * as well as binding the different shadow properties to the effects.
  80170. */
  80171. export interface IShadowLight extends Light {
  80172. /**
  80173. * The light id in the scene (used in scene.findLighById for instance)
  80174. */
  80175. id: string;
  80176. /**
  80177. * The position the shdow will be casted from.
  80178. */
  80179. position: Vector3;
  80180. /**
  80181. * In 2d mode (needCube being false), the direction used to cast the shadow.
  80182. */
  80183. direction: Vector3;
  80184. /**
  80185. * The transformed position. Position of the light in world space taking parenting in account.
  80186. */
  80187. transformedPosition: Vector3;
  80188. /**
  80189. * The transformed direction. Direction of the light in world space taking parenting in account.
  80190. */
  80191. transformedDirection: Vector3;
  80192. /**
  80193. * The friendly name of the light in the scene.
  80194. */
  80195. name: string;
  80196. /**
  80197. * Defines the shadow projection clipping minimum z value.
  80198. */
  80199. shadowMinZ: number;
  80200. /**
  80201. * Defines the shadow projection clipping maximum z value.
  80202. */
  80203. shadowMaxZ: number;
  80204. /**
  80205. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  80206. * @returns true if the information has been computed, false if it does not need to (no parenting)
  80207. */
  80208. computeTransformedInformation(): boolean;
  80209. /**
  80210. * Gets the scene the light belongs to.
  80211. * @returns The scene
  80212. */
  80213. getScene(): Scene;
  80214. /**
  80215. * Callback defining a custom Projection Matrix Builder.
  80216. * This can be used to override the default projection matrix computation.
  80217. */
  80218. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  80219. /**
  80220. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  80221. * @param matrix The materix to updated with the projection information
  80222. * @param viewMatrix The transform matrix of the light
  80223. * @param renderList The list of mesh to render in the map
  80224. * @returns The current light
  80225. */
  80226. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  80227. /**
  80228. * Gets the current depth scale used in ESM.
  80229. * @returns The scale
  80230. */
  80231. getDepthScale(): number;
  80232. /**
  80233. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  80234. * @returns true if a cube texture needs to be use
  80235. */
  80236. needCube(): boolean;
  80237. /**
  80238. * Detects if the projection matrix requires to be recomputed this frame.
  80239. * @returns true if it requires to be recomputed otherwise, false.
  80240. */
  80241. needProjectionMatrixCompute(): boolean;
  80242. /**
  80243. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  80244. */
  80245. forceProjectionMatrixCompute(): void;
  80246. /**
  80247. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  80248. * @param faceIndex The index of the face we are computed the direction to generate shadow
  80249. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  80250. */
  80251. getShadowDirection(faceIndex?: number): Vector3;
  80252. /**
  80253. * Gets the minZ used for shadow according to both the scene and the light.
  80254. * @param activeCamera The camera we are returning the min for
  80255. * @returns the depth min z
  80256. */
  80257. getDepthMinZ(activeCamera: Camera): number;
  80258. /**
  80259. * Gets the maxZ used for shadow according to both the scene and the light.
  80260. * @param activeCamera The camera we are returning the max for
  80261. * @returns the depth max z
  80262. */
  80263. getDepthMaxZ(activeCamera: Camera): number;
  80264. }
  80265. /**
  80266. * Base implementation IShadowLight
  80267. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  80268. */
  80269. export abstract class ShadowLight extends Light implements IShadowLight {
  80270. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  80271. protected _position: Vector3;
  80272. protected _setPosition(value: Vector3): void;
  80273. /**
  80274. * Sets the position the shadow will be casted from. Also use as the light position for both
  80275. * point and spot lights.
  80276. */
  80277. get position(): Vector3;
  80278. /**
  80279. * Sets the position the shadow will be casted from. Also use as the light position for both
  80280. * point and spot lights.
  80281. */
  80282. set position(value: Vector3);
  80283. protected _direction: Vector3;
  80284. protected _setDirection(value: Vector3): void;
  80285. /**
  80286. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  80287. * Also use as the light direction on spot and directional lights.
  80288. */
  80289. get direction(): Vector3;
  80290. /**
  80291. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  80292. * Also use as the light direction on spot and directional lights.
  80293. */
  80294. set direction(value: Vector3);
  80295. protected _shadowMinZ: number;
  80296. /**
  80297. * Gets the shadow projection clipping minimum z value.
  80298. */
  80299. get shadowMinZ(): number;
  80300. /**
  80301. * Sets the shadow projection clipping minimum z value.
  80302. */
  80303. set shadowMinZ(value: number);
  80304. protected _shadowMaxZ: number;
  80305. /**
  80306. * Sets the shadow projection clipping maximum z value.
  80307. */
  80308. get shadowMaxZ(): number;
  80309. /**
  80310. * Gets the shadow projection clipping maximum z value.
  80311. */
  80312. set shadowMaxZ(value: number);
  80313. /**
  80314. * Callback defining a custom Projection Matrix Builder.
  80315. * This can be used to override the default projection matrix computation.
  80316. */
  80317. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  80318. /**
  80319. * The transformed position. Position of the light in world space taking parenting in account.
  80320. */
  80321. transformedPosition: Vector3;
  80322. /**
  80323. * The transformed direction. Direction of the light in world space taking parenting in account.
  80324. */
  80325. transformedDirection: Vector3;
  80326. private _needProjectionMatrixCompute;
  80327. /**
  80328. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  80329. * @returns true if the information has been computed, false if it does not need to (no parenting)
  80330. */
  80331. computeTransformedInformation(): boolean;
  80332. /**
  80333. * Return the depth scale used for the shadow map.
  80334. * @returns the depth scale.
  80335. */
  80336. getDepthScale(): number;
  80337. /**
  80338. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  80339. * @param faceIndex The index of the face we are computed the direction to generate shadow
  80340. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  80341. */
  80342. getShadowDirection(faceIndex?: number): Vector3;
  80343. /**
  80344. * Returns the ShadowLight absolute position in the World.
  80345. * @returns the position vector in world space
  80346. */
  80347. getAbsolutePosition(): Vector3;
  80348. /**
  80349. * Sets the ShadowLight direction toward the passed target.
  80350. * @param target The point to target in local space
  80351. * @returns the updated ShadowLight direction
  80352. */
  80353. setDirectionToTarget(target: Vector3): Vector3;
  80354. /**
  80355. * Returns the light rotation in euler definition.
  80356. * @returns the x y z rotation in local space.
  80357. */
  80358. getRotation(): Vector3;
  80359. /**
  80360. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  80361. * @returns true if a cube texture needs to be use
  80362. */
  80363. needCube(): boolean;
  80364. /**
  80365. * Detects if the projection matrix requires to be recomputed this frame.
  80366. * @returns true if it requires to be recomputed otherwise, false.
  80367. */
  80368. needProjectionMatrixCompute(): boolean;
  80369. /**
  80370. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  80371. */
  80372. forceProjectionMatrixCompute(): void;
  80373. /** @hidden */
  80374. _initCache(): void;
  80375. /** @hidden */
  80376. _isSynchronized(): boolean;
  80377. /**
  80378. * Computes the world matrix of the node
  80379. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80380. * @returns the world matrix
  80381. */
  80382. computeWorldMatrix(force?: boolean): Matrix;
  80383. /**
  80384. * Gets the minZ used for shadow according to both the scene and the light.
  80385. * @param activeCamera The camera we are returning the min for
  80386. * @returns the depth min z
  80387. */
  80388. getDepthMinZ(activeCamera: Camera): number;
  80389. /**
  80390. * Gets the maxZ used for shadow according to both the scene and the light.
  80391. * @param activeCamera The camera we are returning the max for
  80392. * @returns the depth max z
  80393. */
  80394. getDepthMaxZ(activeCamera: Camera): number;
  80395. /**
  80396. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  80397. * @param matrix The materix to updated with the projection information
  80398. * @param viewMatrix The transform matrix of the light
  80399. * @param renderList The list of mesh to render in the map
  80400. * @returns The current light
  80401. */
  80402. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  80403. }
  80404. }
  80405. declare module BABYLON {
  80406. /**
  80407. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  80408. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  80409. */
  80410. export class EffectFallbacks implements IEffectFallbacks {
  80411. private _defines;
  80412. private _currentRank;
  80413. private _maxRank;
  80414. private _mesh;
  80415. /**
  80416. * Removes the fallback from the bound mesh.
  80417. */
  80418. unBindMesh(): void;
  80419. /**
  80420. * Adds a fallback on the specified property.
  80421. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  80422. * @param define The name of the define in the shader
  80423. */
  80424. addFallback(rank: number, define: string): void;
  80425. /**
  80426. * Sets the mesh to use CPU skinning when needing to fallback.
  80427. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  80428. * @param mesh The mesh to use the fallbacks.
  80429. */
  80430. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  80431. /**
  80432. * Checks to see if more fallbacks are still availible.
  80433. */
  80434. get hasMoreFallbacks(): boolean;
  80435. /**
  80436. * Removes the defines that should be removed when falling back.
  80437. * @param currentDefines defines the current define statements for the shader.
  80438. * @param effect defines the current effect we try to compile
  80439. * @returns The resulting defines with defines of the current rank removed.
  80440. */
  80441. reduce(currentDefines: string, effect: Effect): string;
  80442. }
  80443. }
  80444. declare module BABYLON {
  80445. /**
  80446. * "Static Class" containing the most commonly used helper while dealing with material for
  80447. * rendering purpose.
  80448. *
  80449. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  80450. *
  80451. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  80452. */
  80453. export class MaterialHelper {
  80454. /**
  80455. * Bind the current view position to an effect.
  80456. * @param effect The effect to be bound
  80457. * @param scene The scene the eyes position is used from
  80458. */
  80459. static BindEyePosition(effect: Effect, scene: Scene): void;
  80460. /**
  80461. * Helps preparing the defines values about the UVs in used in the effect.
  80462. * UVs are shared as much as we can accross channels in the shaders.
  80463. * @param texture The texture we are preparing the UVs for
  80464. * @param defines The defines to update
  80465. * @param key The channel key "diffuse", "specular"... used in the shader
  80466. */
  80467. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  80468. /**
  80469. * Binds a texture matrix value to its corrsponding uniform
  80470. * @param texture The texture to bind the matrix for
  80471. * @param uniformBuffer The uniform buffer receivin the data
  80472. * @param key The channel key "diffuse", "specular"... used in the shader
  80473. */
  80474. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  80475. /**
  80476. * Gets the current status of the fog (should it be enabled?)
  80477. * @param mesh defines the mesh to evaluate for fog support
  80478. * @param scene defines the hosting scene
  80479. * @returns true if fog must be enabled
  80480. */
  80481. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  80482. /**
  80483. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  80484. * @param mesh defines the current mesh
  80485. * @param scene defines the current scene
  80486. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  80487. * @param pointsCloud defines if point cloud rendering has to be turned on
  80488. * @param fogEnabled defines if fog has to be turned on
  80489. * @param alphaTest defines if alpha testing has to be turned on
  80490. * @param defines defines the current list of defines
  80491. */
  80492. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  80493. /**
  80494. * Helper used to prepare the list of defines associated with frame values for shader compilation
  80495. * @param scene defines the current scene
  80496. * @param engine defines the current engine
  80497. * @param defines specifies the list of active defines
  80498. * @param useInstances defines if instances have to be turned on
  80499. * @param useClipPlane defines if clip plane have to be turned on
  80500. */
  80501. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  80502. /**
  80503. * Prepares the defines for bones
  80504. * @param mesh The mesh containing the geometry data we will draw
  80505. * @param defines The defines to update
  80506. */
  80507. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  80508. /**
  80509. * Prepares the defines for morph targets
  80510. * @param mesh The mesh containing the geometry data we will draw
  80511. * @param defines The defines to update
  80512. */
  80513. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  80514. /**
  80515. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  80516. * @param mesh The mesh containing the geometry data we will draw
  80517. * @param defines The defines to update
  80518. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  80519. * @param useBones Precise whether bones should be used or not (override mesh info)
  80520. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  80521. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  80522. * @returns false if defines are considered not dirty and have not been checked
  80523. */
  80524. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  80525. /**
  80526. * Prepares the defines related to multiview
  80527. * @param scene The scene we are intending to draw
  80528. * @param defines The defines to update
  80529. */
  80530. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  80531. /**
  80532. * Prepares the defines related to the light information passed in parameter
  80533. * @param scene The scene we are intending to draw
  80534. * @param mesh The mesh the effect is compiling for
  80535. * @param light The light the effect is compiling for
  80536. * @param lightIndex The index of the light
  80537. * @param defines The defines to update
  80538. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  80539. * @param state Defines the current state regarding what is needed (normals, etc...)
  80540. */
  80541. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  80542. needNormals: boolean;
  80543. needRebuild: boolean;
  80544. shadowEnabled: boolean;
  80545. specularEnabled: boolean;
  80546. lightmapMode: boolean;
  80547. }): void;
  80548. /**
  80549. * Prepares the defines related to the light information passed in parameter
  80550. * @param scene The scene we are intending to draw
  80551. * @param mesh The mesh the effect is compiling for
  80552. * @param defines The defines to update
  80553. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  80554. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  80555. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  80556. * @returns true if normals will be required for the rest of the effect
  80557. */
  80558. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  80559. /**
  80560. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  80561. * @param lightIndex defines the light index
  80562. * @param uniformsList The uniform list
  80563. * @param samplersList The sampler list
  80564. * @param projectedLightTexture defines if projected texture must be used
  80565. * @param uniformBuffersList defines an optional list of uniform buffers
  80566. */
  80567. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  80568. /**
  80569. * Prepares the uniforms and samplers list to be used in the effect
  80570. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  80571. * @param samplersList The sampler list
  80572. * @param defines The defines helping in the list generation
  80573. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  80574. */
  80575. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  80576. /**
  80577. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  80578. * @param defines The defines to update while falling back
  80579. * @param fallbacks The authorized effect fallbacks
  80580. * @param maxSimultaneousLights The maximum number of lights allowed
  80581. * @param rank the current rank of the Effect
  80582. * @returns The newly affected rank
  80583. */
  80584. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  80585. private static _TmpMorphInfluencers;
  80586. /**
  80587. * Prepares the list of attributes required for morph targets according to the effect defines.
  80588. * @param attribs The current list of supported attribs
  80589. * @param mesh The mesh to prepare the morph targets attributes for
  80590. * @param influencers The number of influencers
  80591. */
  80592. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  80593. /**
  80594. * Prepares the list of attributes required for morph targets according to the effect defines.
  80595. * @param attribs The current list of supported attribs
  80596. * @param mesh The mesh to prepare the morph targets attributes for
  80597. * @param defines The current Defines of the effect
  80598. */
  80599. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  80600. /**
  80601. * Prepares the list of attributes required for bones according to the effect defines.
  80602. * @param attribs The current list of supported attribs
  80603. * @param mesh The mesh to prepare the bones attributes for
  80604. * @param defines The current Defines of the effect
  80605. * @param fallbacks The current efffect fallback strategy
  80606. */
  80607. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  80608. /**
  80609. * Check and prepare the list of attributes required for instances according to the effect defines.
  80610. * @param attribs The current list of supported attribs
  80611. * @param defines The current MaterialDefines of the effect
  80612. */
  80613. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  80614. /**
  80615. * Add the list of attributes required for instances to the attribs array.
  80616. * @param attribs The current list of supported attribs
  80617. */
  80618. static PushAttributesForInstances(attribs: string[]): void;
  80619. /**
  80620. * Binds the light information to the effect.
  80621. * @param light The light containing the generator
  80622. * @param effect The effect we are binding the data to
  80623. * @param lightIndex The light index in the effect used to render
  80624. */
  80625. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  80626. /**
  80627. * Binds the lights information from the scene to the effect for the given mesh.
  80628. * @param light Light to bind
  80629. * @param lightIndex Light index
  80630. * @param scene The scene where the light belongs to
  80631. * @param effect The effect we are binding the data to
  80632. * @param useSpecular Defines if specular is supported
  80633. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80634. */
  80635. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  80636. /**
  80637. * Binds the lights information from the scene to the effect for the given mesh.
  80638. * @param scene The scene the lights belongs to
  80639. * @param mesh The mesh we are binding the information to render
  80640. * @param effect The effect we are binding the data to
  80641. * @param defines The generated defines for the effect
  80642. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  80643. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80644. */
  80645. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  80646. private static _tempFogColor;
  80647. /**
  80648. * Binds the fog information from the scene to the effect for the given mesh.
  80649. * @param scene The scene the lights belongs to
  80650. * @param mesh The mesh we are binding the information to render
  80651. * @param effect The effect we are binding the data to
  80652. * @param linearSpace Defines if the fog effect is applied in linear space
  80653. */
  80654. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  80655. /**
  80656. * Binds the bones information from the mesh to the effect.
  80657. * @param mesh The mesh we are binding the information to render
  80658. * @param effect The effect we are binding the data to
  80659. */
  80660. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  80661. /**
  80662. * Binds the morph targets information from the mesh to the effect.
  80663. * @param abstractMesh The mesh we are binding the information to render
  80664. * @param effect The effect we are binding the data to
  80665. */
  80666. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  80667. /**
  80668. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  80669. * @param defines The generated defines used in the effect
  80670. * @param effect The effect we are binding the data to
  80671. * @param scene The scene we are willing to render with logarithmic scale for
  80672. */
  80673. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  80674. /**
  80675. * Binds the clip plane information from the scene to the effect.
  80676. * @param scene The scene the clip plane information are extracted from
  80677. * @param effect The effect we are binding the data to
  80678. */
  80679. static BindClipPlane(effect: Effect, scene: Scene): void;
  80680. }
  80681. }
  80682. declare module BABYLON {
  80683. /** @hidden */
  80684. export var packingFunctions: {
  80685. name: string;
  80686. shader: string;
  80687. };
  80688. }
  80689. declare module BABYLON {
  80690. /** @hidden */
  80691. export var shadowMapPixelShader: {
  80692. name: string;
  80693. shader: string;
  80694. };
  80695. }
  80696. declare module BABYLON {
  80697. /** @hidden */
  80698. export var bonesDeclaration: {
  80699. name: string;
  80700. shader: string;
  80701. };
  80702. }
  80703. declare module BABYLON {
  80704. /** @hidden */
  80705. export var morphTargetsVertexGlobalDeclaration: {
  80706. name: string;
  80707. shader: string;
  80708. };
  80709. }
  80710. declare module BABYLON {
  80711. /** @hidden */
  80712. export var morphTargetsVertexDeclaration: {
  80713. name: string;
  80714. shader: string;
  80715. };
  80716. }
  80717. declare module BABYLON {
  80718. /** @hidden */
  80719. export var instancesDeclaration: {
  80720. name: string;
  80721. shader: string;
  80722. };
  80723. }
  80724. declare module BABYLON {
  80725. /** @hidden */
  80726. export var helperFunctions: {
  80727. name: string;
  80728. shader: string;
  80729. };
  80730. }
  80731. declare module BABYLON {
  80732. /** @hidden */
  80733. export var morphTargetsVertex: {
  80734. name: string;
  80735. shader: string;
  80736. };
  80737. }
  80738. declare module BABYLON {
  80739. /** @hidden */
  80740. export var instancesVertex: {
  80741. name: string;
  80742. shader: string;
  80743. };
  80744. }
  80745. declare module BABYLON {
  80746. /** @hidden */
  80747. export var bonesVertex: {
  80748. name: string;
  80749. shader: string;
  80750. };
  80751. }
  80752. declare module BABYLON {
  80753. /** @hidden */
  80754. export var shadowMapVertexShader: {
  80755. name: string;
  80756. shader: string;
  80757. };
  80758. }
  80759. declare module BABYLON {
  80760. /** @hidden */
  80761. export var depthBoxBlurPixelShader: {
  80762. name: string;
  80763. shader: string;
  80764. };
  80765. }
  80766. declare module BABYLON {
  80767. /**
  80768. * Defines the options associated with the creation of a custom shader for a shadow generator.
  80769. */
  80770. export interface ICustomShaderOptions {
  80771. /**
  80772. * Gets or sets the custom shader name to use
  80773. */
  80774. shaderName: string;
  80775. /**
  80776. * The list of attribute names used in the shader
  80777. */
  80778. attributes?: string[];
  80779. /**
  80780. * The list of unifrom names used in the shader
  80781. */
  80782. uniforms?: string[];
  80783. /**
  80784. * The list of sampler names used in the shader
  80785. */
  80786. samplers?: string[];
  80787. /**
  80788. * The list of defines used in the shader
  80789. */
  80790. defines?: string[];
  80791. }
  80792. /**
  80793. * Interface to implement to create a shadow generator compatible with BJS.
  80794. */
  80795. export interface IShadowGenerator {
  80796. /**
  80797. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80798. * @returns The render target texture if present otherwise, null
  80799. */
  80800. getShadowMap(): Nullable<RenderTargetTexture>;
  80801. /**
  80802. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80803. * @returns The render target texture if the shadow map is present otherwise, null
  80804. */
  80805. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80806. /**
  80807. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80808. * @param subMesh The submesh we want to render in the shadow map
  80809. * @param useInstances Defines wether will draw in the map using instances
  80810. * @returns true if ready otherwise, false
  80811. */
  80812. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80813. /**
  80814. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80815. * @param defines Defines of the material we want to update
  80816. * @param lightIndex Index of the light in the enabled light list of the material
  80817. */
  80818. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  80819. /**
  80820. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80821. * defined in the generator but impacting the effect).
  80822. * It implies the unifroms available on the materials are the standard BJS ones.
  80823. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80824. * @param effect The effect we are binfing the information for
  80825. */
  80826. bindShadowLight(lightIndex: string, effect: Effect): void;
  80827. /**
  80828. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80829. * (eq to shadow prjection matrix * light transform matrix)
  80830. * @returns The transform matrix used to create the shadow map
  80831. */
  80832. getTransformMatrix(): Matrix;
  80833. /**
  80834. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80835. * Cube and 2D textures for instance.
  80836. */
  80837. recreateShadowMap(): void;
  80838. /**
  80839. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80840. * @param onCompiled Callback triggered at the and of the effects compilation
  80841. * @param options Sets of optional options forcing the compilation with different modes
  80842. */
  80843. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80844. useInstances: boolean;
  80845. }>): void;
  80846. /**
  80847. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80848. * @param options Sets of optional options forcing the compilation with different modes
  80849. * @returns A promise that resolves when the compilation completes
  80850. */
  80851. forceCompilationAsync(options?: Partial<{
  80852. useInstances: boolean;
  80853. }>): Promise<void>;
  80854. /**
  80855. * Serializes the shadow generator setup to a json object.
  80856. * @returns The serialized JSON object
  80857. */
  80858. serialize(): any;
  80859. /**
  80860. * Disposes the Shadow map and related Textures and effects.
  80861. */
  80862. dispose(): void;
  80863. }
  80864. /**
  80865. * Default implementation IShadowGenerator.
  80866. * This is the main object responsible of generating shadows in the framework.
  80867. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80868. */
  80869. export class ShadowGenerator implements IShadowGenerator {
  80870. /**
  80871. * Shadow generator mode None: no filtering applied.
  80872. */
  80873. static readonly FILTER_NONE: number;
  80874. /**
  80875. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80876. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80877. */
  80878. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80879. /**
  80880. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80881. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80882. */
  80883. static readonly FILTER_POISSONSAMPLING: number;
  80884. /**
  80885. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80886. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80887. */
  80888. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80889. /**
  80890. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80891. * edge artifacts on steep falloff.
  80892. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80893. */
  80894. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80895. /**
  80896. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80897. * edge artifacts on steep falloff.
  80898. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80899. */
  80900. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80901. /**
  80902. * Shadow generator mode PCF: Percentage Closer Filtering
  80903. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80904. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80905. */
  80906. static readonly FILTER_PCF: number;
  80907. /**
  80908. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80909. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80910. * Contact Hardening
  80911. */
  80912. static readonly FILTER_PCSS: number;
  80913. /**
  80914. * Reserved for PCF and PCSS
  80915. * Highest Quality.
  80916. *
  80917. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80918. *
  80919. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80920. */
  80921. static readonly QUALITY_HIGH: number;
  80922. /**
  80923. * Reserved for PCF and PCSS
  80924. * Good tradeoff for quality/perf cross devices
  80925. *
  80926. * Execute PCF on a 3*3 kernel.
  80927. *
  80928. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80929. */
  80930. static readonly QUALITY_MEDIUM: number;
  80931. /**
  80932. * Reserved for PCF and PCSS
  80933. * The lowest quality but the fastest.
  80934. *
  80935. * Execute PCF on a 1*1 kernel.
  80936. *
  80937. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80938. */
  80939. static readonly QUALITY_LOW: number;
  80940. /** Gets or sets the custom shader name to use */
  80941. customShaderOptions: ICustomShaderOptions;
  80942. /**
  80943. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80944. */
  80945. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80946. /**
  80947. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80948. */
  80949. onAfterShadowMapRenderObservable: Observable<Effect>;
  80950. /**
  80951. * Observable triggered before a mesh is rendered in the shadow map.
  80952. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80953. */
  80954. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80955. /**
  80956. * Observable triggered after a mesh is rendered in the shadow map.
  80957. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80958. */
  80959. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80960. private _bias;
  80961. /**
  80962. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80963. */
  80964. get bias(): number;
  80965. /**
  80966. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80967. */
  80968. set bias(bias: number);
  80969. private _normalBias;
  80970. /**
  80971. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80972. */
  80973. get normalBias(): number;
  80974. /**
  80975. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80976. */
  80977. set normalBias(normalBias: number);
  80978. private _blurBoxOffset;
  80979. /**
  80980. * Gets the blur box offset: offset applied during the blur pass.
  80981. * Only useful if useKernelBlur = false
  80982. */
  80983. get blurBoxOffset(): number;
  80984. /**
  80985. * Sets the blur box offset: offset applied during the blur pass.
  80986. * Only useful if useKernelBlur = false
  80987. */
  80988. set blurBoxOffset(value: number);
  80989. private _blurScale;
  80990. /**
  80991. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80992. * 2 means half of the size.
  80993. */
  80994. get blurScale(): number;
  80995. /**
  80996. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  80997. * 2 means half of the size.
  80998. */
  80999. set blurScale(value: number);
  81000. private _blurKernel;
  81001. /**
  81002. * Gets the blur kernel: kernel size of the blur pass.
  81003. * Only useful if useKernelBlur = true
  81004. */
  81005. get blurKernel(): number;
  81006. /**
  81007. * Sets the blur kernel: kernel size of the blur pass.
  81008. * Only useful if useKernelBlur = true
  81009. */
  81010. set blurKernel(value: number);
  81011. private _useKernelBlur;
  81012. /**
  81013. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  81014. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  81015. */
  81016. get useKernelBlur(): boolean;
  81017. /**
  81018. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  81019. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  81020. */
  81021. set useKernelBlur(value: boolean);
  81022. private _depthScale;
  81023. /**
  81024. * Gets the depth scale used in ESM mode.
  81025. */
  81026. get depthScale(): number;
  81027. /**
  81028. * Sets the depth scale used in ESM mode.
  81029. * This can override the scale stored on the light.
  81030. */
  81031. set depthScale(value: number);
  81032. private _filter;
  81033. /**
  81034. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  81035. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  81036. */
  81037. get filter(): number;
  81038. /**
  81039. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  81040. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  81041. */
  81042. set filter(value: number);
  81043. /**
  81044. * Gets if the current filter is set to Poisson Sampling.
  81045. */
  81046. get usePoissonSampling(): boolean;
  81047. /**
  81048. * Sets the current filter to Poisson Sampling.
  81049. */
  81050. set usePoissonSampling(value: boolean);
  81051. /**
  81052. * Gets if the current filter is set to ESM.
  81053. */
  81054. get useExponentialShadowMap(): boolean;
  81055. /**
  81056. * Sets the current filter is to ESM.
  81057. */
  81058. set useExponentialShadowMap(value: boolean);
  81059. /**
  81060. * Gets if the current filter is set to filtered ESM.
  81061. */
  81062. get useBlurExponentialShadowMap(): boolean;
  81063. /**
  81064. * Gets if the current filter is set to filtered ESM.
  81065. */
  81066. set useBlurExponentialShadowMap(value: boolean);
  81067. /**
  81068. * Gets if the current filter is set to "close ESM" (using the inverse of the
  81069. * exponential to prevent steep falloff artifacts).
  81070. */
  81071. get useCloseExponentialShadowMap(): boolean;
  81072. /**
  81073. * Sets the current filter to "close ESM" (using the inverse of the
  81074. * exponential to prevent steep falloff artifacts).
  81075. */
  81076. set useCloseExponentialShadowMap(value: boolean);
  81077. /**
  81078. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  81079. * exponential to prevent steep falloff artifacts).
  81080. */
  81081. get useBlurCloseExponentialShadowMap(): boolean;
  81082. /**
  81083. * Sets the current filter to filtered "close ESM" (using the inverse of the
  81084. * exponential to prevent steep falloff artifacts).
  81085. */
  81086. set useBlurCloseExponentialShadowMap(value: boolean);
  81087. /**
  81088. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  81089. */
  81090. get usePercentageCloserFiltering(): boolean;
  81091. /**
  81092. * Sets the current filter to "PCF" (percentage closer filtering).
  81093. */
  81094. set usePercentageCloserFiltering(value: boolean);
  81095. private _filteringQuality;
  81096. /**
  81097. * Gets the PCF or PCSS Quality.
  81098. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  81099. */
  81100. get filteringQuality(): number;
  81101. /**
  81102. * Sets the PCF or PCSS Quality.
  81103. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  81104. */
  81105. set filteringQuality(filteringQuality: number);
  81106. /**
  81107. * Gets if the current filter is set to "PCSS" (contact hardening).
  81108. */
  81109. get useContactHardeningShadow(): boolean;
  81110. /**
  81111. * Sets the current filter to "PCSS" (contact hardening).
  81112. */
  81113. set useContactHardeningShadow(value: boolean);
  81114. private _contactHardeningLightSizeUVRatio;
  81115. /**
  81116. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  81117. * Using a ratio helps keeping shape stability independently of the map size.
  81118. *
  81119. * It does not account for the light projection as it was having too much
  81120. * instability during the light setup or during light position changes.
  81121. *
  81122. * Only valid if useContactHardeningShadow is true.
  81123. */
  81124. get contactHardeningLightSizeUVRatio(): number;
  81125. /**
  81126. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  81127. * Using a ratio helps keeping shape stability independently of the map size.
  81128. *
  81129. * It does not account for the light projection as it was having too much
  81130. * instability during the light setup or during light position changes.
  81131. *
  81132. * Only valid if useContactHardeningShadow is true.
  81133. */
  81134. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  81135. private _darkness;
  81136. /** Gets or sets the actual darkness of a shadow */
  81137. get darkness(): number;
  81138. set darkness(value: number);
  81139. /**
  81140. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  81141. * 0 means strongest and 1 would means no shadow.
  81142. * @returns the darkness.
  81143. */
  81144. getDarkness(): number;
  81145. /**
  81146. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  81147. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  81148. * @returns the shadow generator allowing fluent coding.
  81149. */
  81150. setDarkness(darkness: number): ShadowGenerator;
  81151. private _transparencyShadow;
  81152. /** Gets or sets the ability to have transparent shadow */
  81153. get transparencyShadow(): boolean;
  81154. set transparencyShadow(value: boolean);
  81155. /**
  81156. * Sets the ability to have transparent shadow (boolean).
  81157. * @param transparent True if transparent else False
  81158. * @returns the shadow generator allowing fluent coding
  81159. */
  81160. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  81161. private _shadowMap;
  81162. private _shadowMap2;
  81163. /**
  81164. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  81165. * @returns The render target texture if present otherwise, null
  81166. */
  81167. getShadowMap(): Nullable<RenderTargetTexture>;
  81168. /**
  81169. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  81170. * @returns The render target texture if the shadow map is present otherwise, null
  81171. */
  81172. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  81173. /**
  81174. * Gets the class name of that object
  81175. * @returns "ShadowGenerator"
  81176. */
  81177. getClassName(): string;
  81178. /**
  81179. * Helper function to add a mesh and its descendants to the list of shadow casters.
  81180. * @param mesh Mesh to add
  81181. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  81182. * @returns the Shadow Generator itself
  81183. */
  81184. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  81185. /**
  81186. * Helper function to remove a mesh and its descendants from the list of shadow casters
  81187. * @param mesh Mesh to remove
  81188. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  81189. * @returns the Shadow Generator itself
  81190. */
  81191. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  81192. /**
  81193. * Controls the extent to which the shadows fade out at the edge of the frustum
  81194. * Used only by directionals and spots
  81195. */
  81196. frustumEdgeFalloff: number;
  81197. private _light;
  81198. /**
  81199. * Returns the associated light object.
  81200. * @returns the light generating the shadow
  81201. */
  81202. getLight(): IShadowLight;
  81203. /**
  81204. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  81205. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  81206. * It might on the other hand introduce peter panning.
  81207. */
  81208. forceBackFacesOnly: boolean;
  81209. private _scene;
  81210. private _lightDirection;
  81211. private _effect;
  81212. private _viewMatrix;
  81213. private _projectionMatrix;
  81214. private _transformMatrix;
  81215. private _cachedPosition;
  81216. private _cachedDirection;
  81217. private _cachedDefines;
  81218. private _currentRenderID;
  81219. private _boxBlurPostprocess;
  81220. private _kernelBlurXPostprocess;
  81221. private _kernelBlurYPostprocess;
  81222. private _blurPostProcesses;
  81223. private _mapSize;
  81224. private _currentFaceIndex;
  81225. private _currentFaceIndexCache;
  81226. private _textureType;
  81227. private _defaultTextureMatrix;
  81228. private _storedUniqueId;
  81229. /** @hidden */
  81230. static _SceneComponentInitialization: (scene: Scene) => void;
  81231. /**
  81232. * Creates a ShadowGenerator object.
  81233. * A ShadowGenerator is the required tool to use the shadows.
  81234. * Each light casting shadows needs to use its own ShadowGenerator.
  81235. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  81236. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  81237. * @param light The light object generating the shadows.
  81238. * @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.
  81239. */
  81240. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  81241. private _initializeGenerator;
  81242. private _initializeShadowMap;
  81243. private _initializeBlurRTTAndPostProcesses;
  81244. private _renderForShadowMap;
  81245. private _renderSubMeshForShadowMap;
  81246. private _applyFilterValues;
  81247. /**
  81248. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81249. * @param onCompiled Callback triggered at the and of the effects compilation
  81250. * @param options Sets of optional options forcing the compilation with different modes
  81251. */
  81252. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  81253. useInstances: boolean;
  81254. }>): void;
  81255. /**
  81256. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81257. * @param options Sets of optional options forcing the compilation with different modes
  81258. * @returns A promise that resolves when the compilation completes
  81259. */
  81260. forceCompilationAsync(options?: Partial<{
  81261. useInstances: boolean;
  81262. }>): Promise<void>;
  81263. /**
  81264. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  81265. * @param subMesh The submesh we want to render in the shadow map
  81266. * @param useInstances Defines wether will draw in the map using instances
  81267. * @returns true if ready otherwise, false
  81268. */
  81269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  81270. /**
  81271. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  81272. * @param defines Defines of the material we want to update
  81273. * @param lightIndex Index of the light in the enabled light list of the material
  81274. */
  81275. prepareDefines(defines: any, lightIndex: number): void;
  81276. /**
  81277. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  81278. * defined in the generator but impacting the effect).
  81279. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  81280. * @param effect The effect we are binfing the information for
  81281. */
  81282. bindShadowLight(lightIndex: string, effect: Effect): void;
  81283. /**
  81284. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  81285. * (eq to shadow prjection matrix * light transform matrix)
  81286. * @returns The transform matrix used to create the shadow map
  81287. */
  81288. getTransformMatrix(): Matrix;
  81289. /**
  81290. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  81291. * Cube and 2D textures for instance.
  81292. */
  81293. recreateShadowMap(): void;
  81294. private _disposeBlurPostProcesses;
  81295. private _disposeRTTandPostProcesses;
  81296. /**
  81297. * Disposes the ShadowGenerator.
  81298. * Returns nothing.
  81299. */
  81300. dispose(): void;
  81301. /**
  81302. * Serializes the shadow generator setup to a json object.
  81303. * @returns The serialized JSON object
  81304. */
  81305. serialize(): any;
  81306. /**
  81307. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  81308. * @param parsedShadowGenerator The JSON object to parse
  81309. * @param scene The scene to create the shadow map for
  81310. * @returns The parsed shadow generator
  81311. */
  81312. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  81313. }
  81314. }
  81315. declare module BABYLON {
  81316. /**
  81317. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  81318. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  81319. * 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.
  81320. */
  81321. export abstract class Light extends Node {
  81322. /**
  81323. * Falloff Default: light is falling off following the material specification:
  81324. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  81325. */
  81326. static readonly FALLOFF_DEFAULT: number;
  81327. /**
  81328. * Falloff Physical: light is falling off following the inverse squared distance law.
  81329. */
  81330. static readonly FALLOFF_PHYSICAL: number;
  81331. /**
  81332. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  81333. * to enhance interoperability with other engines.
  81334. */
  81335. static readonly FALLOFF_GLTF: number;
  81336. /**
  81337. * Falloff Standard: light is falling off like in the standard material
  81338. * to enhance interoperability with other materials.
  81339. */
  81340. static readonly FALLOFF_STANDARD: number;
  81341. /**
  81342. * If every light affecting the material is in this lightmapMode,
  81343. * material.lightmapTexture adds or multiplies
  81344. * (depends on material.useLightmapAsShadowmap)
  81345. * after every other light calculations.
  81346. */
  81347. static readonly LIGHTMAP_DEFAULT: number;
  81348. /**
  81349. * material.lightmapTexture as only diffuse lighting from this light
  81350. * adds only specular lighting from this light
  81351. * adds dynamic shadows
  81352. */
  81353. static readonly LIGHTMAP_SPECULAR: number;
  81354. /**
  81355. * material.lightmapTexture as only lighting
  81356. * no light calculation from this light
  81357. * only adds dynamic shadows from this light
  81358. */
  81359. static readonly LIGHTMAP_SHADOWSONLY: number;
  81360. /**
  81361. * Each light type uses the default quantity according to its type:
  81362. * point/spot lights use luminous intensity
  81363. * directional lights use illuminance
  81364. */
  81365. static readonly INTENSITYMODE_AUTOMATIC: number;
  81366. /**
  81367. * lumen (lm)
  81368. */
  81369. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  81370. /**
  81371. * candela (lm/sr)
  81372. */
  81373. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  81374. /**
  81375. * lux (lm/m^2)
  81376. */
  81377. static readonly INTENSITYMODE_ILLUMINANCE: number;
  81378. /**
  81379. * nit (cd/m^2)
  81380. */
  81381. static readonly INTENSITYMODE_LUMINANCE: number;
  81382. /**
  81383. * Light type const id of the point light.
  81384. */
  81385. static readonly LIGHTTYPEID_POINTLIGHT: number;
  81386. /**
  81387. * Light type const id of the directional light.
  81388. */
  81389. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  81390. /**
  81391. * Light type const id of the spot light.
  81392. */
  81393. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  81394. /**
  81395. * Light type const id of the hemispheric light.
  81396. */
  81397. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  81398. /**
  81399. * Diffuse gives the basic color to an object.
  81400. */
  81401. diffuse: Color3;
  81402. /**
  81403. * Specular produces a highlight color on an object.
  81404. * Note: This is note affecting PBR materials.
  81405. */
  81406. specular: Color3;
  81407. /**
  81408. * Defines the falloff type for this light. This lets overrriding how punctual light are
  81409. * falling off base on range or angle.
  81410. * This can be set to any values in Light.FALLOFF_x.
  81411. *
  81412. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  81413. * other types of materials.
  81414. */
  81415. falloffType: number;
  81416. /**
  81417. * Strength of the light.
  81418. * Note: By default it is define in the framework own unit.
  81419. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  81420. */
  81421. intensity: number;
  81422. private _range;
  81423. protected _inverseSquaredRange: number;
  81424. /**
  81425. * Defines how far from the source the light is impacting in scene units.
  81426. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  81427. */
  81428. get range(): number;
  81429. /**
  81430. * Defines how far from the source the light is impacting in scene units.
  81431. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  81432. */
  81433. set range(value: number);
  81434. /**
  81435. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  81436. * of light.
  81437. */
  81438. private _photometricScale;
  81439. private _intensityMode;
  81440. /**
  81441. * Gets the photometric scale used to interpret the intensity.
  81442. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  81443. */
  81444. get intensityMode(): number;
  81445. /**
  81446. * Sets the photometric scale used to interpret the intensity.
  81447. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  81448. */
  81449. set intensityMode(value: number);
  81450. private _radius;
  81451. /**
  81452. * Gets the light radius used by PBR Materials to simulate soft area lights.
  81453. */
  81454. get radius(): number;
  81455. /**
  81456. * sets the light radius used by PBR Materials to simulate soft area lights.
  81457. */
  81458. set radius(value: number);
  81459. private _renderPriority;
  81460. /**
  81461. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  81462. * exceeding the number allowed of the materials.
  81463. */
  81464. renderPriority: number;
  81465. private _shadowEnabled;
  81466. /**
  81467. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  81468. * the current shadow generator.
  81469. */
  81470. get shadowEnabled(): boolean;
  81471. /**
  81472. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  81473. * the current shadow generator.
  81474. */
  81475. set shadowEnabled(value: boolean);
  81476. private _includedOnlyMeshes;
  81477. /**
  81478. * Gets the only meshes impacted by this light.
  81479. */
  81480. get includedOnlyMeshes(): AbstractMesh[];
  81481. /**
  81482. * Sets the only meshes impacted by this light.
  81483. */
  81484. set includedOnlyMeshes(value: AbstractMesh[]);
  81485. private _excludedMeshes;
  81486. /**
  81487. * Gets the meshes not impacted by this light.
  81488. */
  81489. get excludedMeshes(): AbstractMesh[];
  81490. /**
  81491. * Sets the meshes not impacted by this light.
  81492. */
  81493. set excludedMeshes(value: AbstractMesh[]);
  81494. private _excludeWithLayerMask;
  81495. /**
  81496. * Gets the layer id use to find what meshes are not impacted by the light.
  81497. * Inactive if 0
  81498. */
  81499. get excludeWithLayerMask(): number;
  81500. /**
  81501. * Sets the layer id use to find what meshes are not impacted by the light.
  81502. * Inactive if 0
  81503. */
  81504. set excludeWithLayerMask(value: number);
  81505. private _includeOnlyWithLayerMask;
  81506. /**
  81507. * Gets the layer id use to find what meshes are impacted by the light.
  81508. * Inactive if 0
  81509. */
  81510. get includeOnlyWithLayerMask(): number;
  81511. /**
  81512. * Sets the layer id use to find what meshes are impacted by the light.
  81513. * Inactive if 0
  81514. */
  81515. set includeOnlyWithLayerMask(value: number);
  81516. private _lightmapMode;
  81517. /**
  81518. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  81519. */
  81520. get lightmapMode(): number;
  81521. /**
  81522. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  81523. */
  81524. set lightmapMode(value: number);
  81525. /**
  81526. * Shadow generator associted to the light.
  81527. * @hidden Internal use only.
  81528. */
  81529. _shadowGenerator: Nullable<IShadowGenerator>;
  81530. /**
  81531. * @hidden Internal use only.
  81532. */
  81533. _excludedMeshesIds: string[];
  81534. /**
  81535. * @hidden Internal use only.
  81536. */
  81537. _includedOnlyMeshesIds: string[];
  81538. /**
  81539. * The current light unifom buffer.
  81540. * @hidden Internal use only.
  81541. */
  81542. _uniformBuffer: UniformBuffer;
  81543. /** @hidden */
  81544. _renderId: number;
  81545. /**
  81546. * Creates a Light object in the scene.
  81547. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81548. * @param name The firendly name of the light
  81549. * @param scene The scene the light belongs too
  81550. */
  81551. constructor(name: string, scene: Scene);
  81552. protected abstract _buildUniformLayout(): void;
  81553. /**
  81554. * Sets the passed Effect "effect" with the Light information.
  81555. * @param effect The effect to update
  81556. * @param lightIndex The index of the light in the effect to update
  81557. * @returns The light
  81558. */
  81559. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  81560. /**
  81561. * Sets the passed Effect "effect" with the Light textures.
  81562. * @param effect The effect to update
  81563. * @param lightIndex The index of the light in the effect to update
  81564. * @returns The light
  81565. */
  81566. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  81567. /**
  81568. * Binds the lights information from the scene to the effect for the given mesh.
  81569. * @param lightIndex Light index
  81570. * @param scene The scene where the light belongs to
  81571. * @param effect The effect we are binding the data to
  81572. * @param useSpecular Defines if specular is supported
  81573. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81574. */
  81575. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  81576. /**
  81577. * Sets the passed Effect "effect" with the Light information.
  81578. * @param effect The effect to update
  81579. * @param lightDataUniformName The uniform used to store light data (position or direction)
  81580. * @returns The light
  81581. */
  81582. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  81583. /**
  81584. * Returns the string "Light".
  81585. * @returns the class name
  81586. */
  81587. getClassName(): string;
  81588. /** @hidden */
  81589. readonly _isLight: boolean;
  81590. /**
  81591. * Converts the light information to a readable string for debug purpose.
  81592. * @param fullDetails Supports for multiple levels of logging within scene loading
  81593. * @returns the human readable light info
  81594. */
  81595. toString(fullDetails?: boolean): string;
  81596. /** @hidden */
  81597. protected _syncParentEnabledState(): void;
  81598. /**
  81599. * Set the enabled state of this node.
  81600. * @param value - the new enabled state
  81601. */
  81602. setEnabled(value: boolean): void;
  81603. /**
  81604. * Returns the Light associated shadow generator if any.
  81605. * @return the associated shadow generator.
  81606. */
  81607. getShadowGenerator(): Nullable<IShadowGenerator>;
  81608. /**
  81609. * Returns a Vector3, the absolute light position in the World.
  81610. * @returns the world space position of the light
  81611. */
  81612. getAbsolutePosition(): Vector3;
  81613. /**
  81614. * Specifies if the light will affect the passed mesh.
  81615. * @param mesh The mesh to test against the light
  81616. * @return true the mesh is affected otherwise, false.
  81617. */
  81618. canAffectMesh(mesh: AbstractMesh): boolean;
  81619. /**
  81620. * Sort function to order lights for rendering.
  81621. * @param a First Light object to compare to second.
  81622. * @param b Second Light object to compare first.
  81623. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  81624. */
  81625. static CompareLightsPriority(a: Light, b: Light): number;
  81626. /**
  81627. * Releases resources associated with this node.
  81628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81630. */
  81631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81632. /**
  81633. * Returns the light type ID (integer).
  81634. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81635. */
  81636. getTypeID(): number;
  81637. /**
  81638. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  81639. * @returns the scaled intensity in intensity mode unit
  81640. */
  81641. getScaledIntensity(): number;
  81642. /**
  81643. * Returns a new Light object, named "name", from the current one.
  81644. * @param name The name of the cloned light
  81645. * @returns the new created light
  81646. */
  81647. clone(name: string): Nullable<Light>;
  81648. /**
  81649. * Serializes the current light into a Serialization object.
  81650. * @returns the serialized object.
  81651. */
  81652. serialize(): any;
  81653. /**
  81654. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  81655. * This new light is named "name" and added to the passed scene.
  81656. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  81657. * @param name The friendly name of the light
  81658. * @param scene The scene the new light will belong to
  81659. * @returns the constructor function
  81660. */
  81661. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  81662. /**
  81663. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  81664. * @param parsedLight The JSON representation of the light
  81665. * @param scene The scene to create the parsed light in
  81666. * @returns the created light after parsing
  81667. */
  81668. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  81669. private _hookArrayForExcluded;
  81670. private _hookArrayForIncludedOnly;
  81671. private _resyncMeshes;
  81672. /**
  81673. * Forces the meshes to update their light related information in their rendering used effects
  81674. * @hidden Internal Use Only
  81675. */
  81676. _markMeshesAsLightDirty(): void;
  81677. /**
  81678. * Recomputes the cached photometric scale if needed.
  81679. */
  81680. private _computePhotometricScale;
  81681. /**
  81682. * Returns the Photometric Scale according to the light type and intensity mode.
  81683. */
  81684. private _getPhotometricScale;
  81685. /**
  81686. * Reorder the light in the scene according to their defined priority.
  81687. * @hidden Internal Use Only
  81688. */
  81689. _reorderLightsInScene(): void;
  81690. /**
  81691. * Prepares the list of defines specific to the light type.
  81692. * @param defines the list of defines
  81693. * @param lightIndex defines the index of the light for the effect
  81694. */
  81695. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81696. }
  81697. }
  81698. declare module BABYLON {
  81699. /**
  81700. * Interface used to define Action
  81701. */
  81702. export interface IAction {
  81703. /**
  81704. * Trigger for the action
  81705. */
  81706. trigger: number;
  81707. /** Options of the trigger */
  81708. triggerOptions: any;
  81709. /**
  81710. * Gets the trigger parameters
  81711. * @returns the trigger parameters
  81712. */
  81713. getTriggerParameter(): any;
  81714. /**
  81715. * Internal only - executes current action event
  81716. * @hidden
  81717. */
  81718. _executeCurrent(evt?: ActionEvent): void;
  81719. /**
  81720. * Serialize placeholder for child classes
  81721. * @param parent of child
  81722. * @returns the serialized object
  81723. */
  81724. serialize(parent: any): any;
  81725. /**
  81726. * Internal only
  81727. * @hidden
  81728. */
  81729. _prepare(): void;
  81730. /**
  81731. * Internal only - manager for action
  81732. * @hidden
  81733. */
  81734. _actionManager: AbstractActionManager;
  81735. /**
  81736. * Adds action to chain of actions, may be a DoNothingAction
  81737. * @param action defines the next action to execute
  81738. * @returns The action passed in
  81739. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81740. */
  81741. then(action: IAction): IAction;
  81742. }
  81743. /**
  81744. * The action to be carried out following a trigger
  81745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  81746. */
  81747. export class Action implements IAction {
  81748. /** the trigger, with or without parameters, for the action */
  81749. triggerOptions: any;
  81750. /**
  81751. * Trigger for the action
  81752. */
  81753. trigger: number;
  81754. /**
  81755. * Internal only - manager for action
  81756. * @hidden
  81757. */
  81758. _actionManager: ActionManager;
  81759. private _nextActiveAction;
  81760. private _child;
  81761. private _condition?;
  81762. private _triggerParameter;
  81763. /**
  81764. * An event triggered prior to action being executed.
  81765. */
  81766. onBeforeExecuteObservable: Observable<Action>;
  81767. /**
  81768. * Creates a new Action
  81769. * @param triggerOptions the trigger, with or without parameters, for the action
  81770. * @param condition an optional determinant of action
  81771. */
  81772. constructor(
  81773. /** the trigger, with or without parameters, for the action */
  81774. triggerOptions: any, condition?: Condition);
  81775. /**
  81776. * Internal only
  81777. * @hidden
  81778. */
  81779. _prepare(): void;
  81780. /**
  81781. * Gets the trigger parameters
  81782. * @returns the trigger parameters
  81783. */
  81784. getTriggerParameter(): any;
  81785. /**
  81786. * Internal only - executes current action event
  81787. * @hidden
  81788. */
  81789. _executeCurrent(evt?: ActionEvent): void;
  81790. /**
  81791. * Execute placeholder for child classes
  81792. * @param evt optional action event
  81793. */
  81794. execute(evt?: ActionEvent): void;
  81795. /**
  81796. * Skips to next active action
  81797. */
  81798. skipToNextActiveAction(): void;
  81799. /**
  81800. * Adds action to chain of actions, may be a DoNothingAction
  81801. * @param action defines the next action to execute
  81802. * @returns The action passed in
  81803. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81804. */
  81805. then(action: Action): Action;
  81806. /**
  81807. * Internal only
  81808. * @hidden
  81809. */
  81810. _getProperty(propertyPath: string): string;
  81811. /**
  81812. * Internal only
  81813. * @hidden
  81814. */
  81815. _getEffectiveTarget(target: any, propertyPath: string): any;
  81816. /**
  81817. * Serialize placeholder for child classes
  81818. * @param parent of child
  81819. * @returns the serialized object
  81820. */
  81821. serialize(parent: any): any;
  81822. /**
  81823. * Internal only called by serialize
  81824. * @hidden
  81825. */
  81826. protected _serialize(serializedAction: any, parent?: any): any;
  81827. /**
  81828. * Internal only
  81829. * @hidden
  81830. */
  81831. static _SerializeValueAsString: (value: any) => string;
  81832. /**
  81833. * Internal only
  81834. * @hidden
  81835. */
  81836. static _GetTargetProperty: (target: Node | Scene) => {
  81837. name: string;
  81838. targetType: string;
  81839. value: string;
  81840. };
  81841. }
  81842. }
  81843. declare module BABYLON {
  81844. /**
  81845. * A Condition applied to an Action
  81846. */
  81847. export class Condition {
  81848. /**
  81849. * Internal only - manager for action
  81850. * @hidden
  81851. */
  81852. _actionManager: ActionManager;
  81853. /**
  81854. * Internal only
  81855. * @hidden
  81856. */
  81857. _evaluationId: number;
  81858. /**
  81859. * Internal only
  81860. * @hidden
  81861. */
  81862. _currentResult: boolean;
  81863. /**
  81864. * Creates a new Condition
  81865. * @param actionManager the manager of the action the condition is applied to
  81866. */
  81867. constructor(actionManager: ActionManager);
  81868. /**
  81869. * Check if the current condition is valid
  81870. * @returns a boolean
  81871. */
  81872. isValid(): boolean;
  81873. /**
  81874. * Internal only
  81875. * @hidden
  81876. */
  81877. _getProperty(propertyPath: string): string;
  81878. /**
  81879. * Internal only
  81880. * @hidden
  81881. */
  81882. _getEffectiveTarget(target: any, propertyPath: string): any;
  81883. /**
  81884. * Serialize placeholder for child classes
  81885. * @returns the serialized object
  81886. */
  81887. serialize(): any;
  81888. /**
  81889. * Internal only
  81890. * @hidden
  81891. */
  81892. protected _serialize(serializedCondition: any): any;
  81893. }
  81894. /**
  81895. * Defines specific conditional operators as extensions of Condition
  81896. */
  81897. export class ValueCondition extends Condition {
  81898. /** path to specify the property of the target the conditional operator uses */
  81899. propertyPath: string;
  81900. /** the value compared by the conditional operator against the current value of the property */
  81901. value: any;
  81902. /** the conditional operator, default ValueCondition.IsEqual */
  81903. operator: number;
  81904. /**
  81905. * Internal only
  81906. * @hidden
  81907. */
  81908. private static _IsEqual;
  81909. /**
  81910. * Internal only
  81911. * @hidden
  81912. */
  81913. private static _IsDifferent;
  81914. /**
  81915. * Internal only
  81916. * @hidden
  81917. */
  81918. private static _IsGreater;
  81919. /**
  81920. * Internal only
  81921. * @hidden
  81922. */
  81923. private static _IsLesser;
  81924. /**
  81925. * returns the number for IsEqual
  81926. */
  81927. static get IsEqual(): number;
  81928. /**
  81929. * Returns the number for IsDifferent
  81930. */
  81931. static get IsDifferent(): number;
  81932. /**
  81933. * Returns the number for IsGreater
  81934. */
  81935. static get IsGreater(): number;
  81936. /**
  81937. * Returns the number for IsLesser
  81938. */
  81939. static get IsLesser(): number;
  81940. /**
  81941. * Internal only The action manager for the condition
  81942. * @hidden
  81943. */
  81944. _actionManager: ActionManager;
  81945. /**
  81946. * Internal only
  81947. * @hidden
  81948. */
  81949. private _target;
  81950. /**
  81951. * Internal only
  81952. * @hidden
  81953. */
  81954. private _effectiveTarget;
  81955. /**
  81956. * Internal only
  81957. * @hidden
  81958. */
  81959. private _property;
  81960. /**
  81961. * Creates a new ValueCondition
  81962. * @param actionManager manager for the action the condition applies to
  81963. * @param target for the action
  81964. * @param propertyPath path to specify the property of the target the conditional operator uses
  81965. * @param value the value compared by the conditional operator against the current value of the property
  81966. * @param operator the conditional operator, default ValueCondition.IsEqual
  81967. */
  81968. constructor(actionManager: ActionManager, target: any,
  81969. /** path to specify the property of the target the conditional operator uses */
  81970. propertyPath: string,
  81971. /** the value compared by the conditional operator against the current value of the property */
  81972. value: any,
  81973. /** the conditional operator, default ValueCondition.IsEqual */
  81974. operator?: number);
  81975. /**
  81976. * Compares the given value with the property value for the specified conditional operator
  81977. * @returns the result of the comparison
  81978. */
  81979. isValid(): boolean;
  81980. /**
  81981. * Serialize the ValueCondition into a JSON compatible object
  81982. * @returns serialization object
  81983. */
  81984. serialize(): any;
  81985. /**
  81986. * Gets the name of the conditional operator for the ValueCondition
  81987. * @param operator the conditional operator
  81988. * @returns the name
  81989. */
  81990. static GetOperatorName(operator: number): string;
  81991. }
  81992. /**
  81993. * Defines a predicate condition as an extension of Condition
  81994. */
  81995. export class PredicateCondition extends Condition {
  81996. /** defines the predicate function used to validate the condition */
  81997. predicate: () => boolean;
  81998. /**
  81999. * Internal only - manager for action
  82000. * @hidden
  82001. */
  82002. _actionManager: ActionManager;
  82003. /**
  82004. * Creates a new PredicateCondition
  82005. * @param actionManager manager for the action the condition applies to
  82006. * @param predicate defines the predicate function used to validate the condition
  82007. */
  82008. constructor(actionManager: ActionManager,
  82009. /** defines the predicate function used to validate the condition */
  82010. predicate: () => boolean);
  82011. /**
  82012. * @returns the validity of the predicate condition
  82013. */
  82014. isValid(): boolean;
  82015. }
  82016. /**
  82017. * Defines a state condition as an extension of Condition
  82018. */
  82019. export class StateCondition extends Condition {
  82020. /** Value to compare with target state */
  82021. value: string;
  82022. /**
  82023. * Internal only - manager for action
  82024. * @hidden
  82025. */
  82026. _actionManager: ActionManager;
  82027. /**
  82028. * Internal only
  82029. * @hidden
  82030. */
  82031. private _target;
  82032. /**
  82033. * Creates a new StateCondition
  82034. * @param actionManager manager for the action the condition applies to
  82035. * @param target of the condition
  82036. * @param value to compare with target state
  82037. */
  82038. constructor(actionManager: ActionManager, target: any,
  82039. /** Value to compare with target state */
  82040. value: string);
  82041. /**
  82042. * Gets a boolean indicating if the current condition is met
  82043. * @returns the validity of the state
  82044. */
  82045. isValid(): boolean;
  82046. /**
  82047. * Serialize the StateCondition into a JSON compatible object
  82048. * @returns serialization object
  82049. */
  82050. serialize(): any;
  82051. }
  82052. }
  82053. declare module BABYLON {
  82054. /**
  82055. * This defines an action responsible to toggle a boolean once triggered.
  82056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82057. */
  82058. export class SwitchBooleanAction extends Action {
  82059. /**
  82060. * The path to the boolean property in the target object
  82061. */
  82062. propertyPath: string;
  82063. private _target;
  82064. private _effectiveTarget;
  82065. private _property;
  82066. /**
  82067. * Instantiate the action
  82068. * @param triggerOptions defines the trigger options
  82069. * @param target defines the object containing the boolean
  82070. * @param propertyPath defines the path to the boolean property in the target object
  82071. * @param condition defines the trigger related conditions
  82072. */
  82073. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  82074. /** @hidden */
  82075. _prepare(): void;
  82076. /**
  82077. * Execute the action toggle the boolean value.
  82078. */
  82079. execute(): void;
  82080. /**
  82081. * Serializes the actions and its related information.
  82082. * @param parent defines the object to serialize in
  82083. * @returns the serialized object
  82084. */
  82085. serialize(parent: any): any;
  82086. }
  82087. /**
  82088. * This defines an action responsible to set a the state field of the target
  82089. * to a desired value once triggered.
  82090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82091. */
  82092. export class SetStateAction extends Action {
  82093. /**
  82094. * The value to store in the state field.
  82095. */
  82096. value: string;
  82097. private _target;
  82098. /**
  82099. * Instantiate the action
  82100. * @param triggerOptions defines the trigger options
  82101. * @param target defines the object containing the state property
  82102. * @param value defines the value to store in the state field
  82103. * @param condition defines the trigger related conditions
  82104. */
  82105. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  82106. /**
  82107. * Execute the action and store the value on the target state property.
  82108. */
  82109. execute(): void;
  82110. /**
  82111. * Serializes the actions and its related information.
  82112. * @param parent defines the object to serialize in
  82113. * @returns the serialized object
  82114. */
  82115. serialize(parent: any): any;
  82116. }
  82117. /**
  82118. * This defines an action responsible to set a property of the target
  82119. * to a desired value once triggered.
  82120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82121. */
  82122. export class SetValueAction extends Action {
  82123. /**
  82124. * The path of the property to set in the target.
  82125. */
  82126. propertyPath: string;
  82127. /**
  82128. * The value to set in the property
  82129. */
  82130. value: any;
  82131. private _target;
  82132. private _effectiveTarget;
  82133. private _property;
  82134. /**
  82135. * Instantiate the action
  82136. * @param triggerOptions defines the trigger options
  82137. * @param target defines the object containing the property
  82138. * @param propertyPath defines the path of the property to set in the target
  82139. * @param value defines the value to set in the property
  82140. * @param condition defines the trigger related conditions
  82141. */
  82142. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  82143. /** @hidden */
  82144. _prepare(): void;
  82145. /**
  82146. * Execute the action and set the targetted property to the desired value.
  82147. */
  82148. execute(): void;
  82149. /**
  82150. * Serializes the actions and its related information.
  82151. * @param parent defines the object to serialize in
  82152. * @returns the serialized object
  82153. */
  82154. serialize(parent: any): any;
  82155. }
  82156. /**
  82157. * This defines an action responsible to increment the target value
  82158. * to a desired value once triggered.
  82159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82160. */
  82161. export class IncrementValueAction extends Action {
  82162. /**
  82163. * The path of the property to increment in the target.
  82164. */
  82165. propertyPath: string;
  82166. /**
  82167. * The value we should increment the property by.
  82168. */
  82169. value: any;
  82170. private _target;
  82171. private _effectiveTarget;
  82172. private _property;
  82173. /**
  82174. * Instantiate the action
  82175. * @param triggerOptions defines the trigger options
  82176. * @param target defines the object containing the property
  82177. * @param propertyPath defines the path of the property to increment in the target
  82178. * @param value defines the value value we should increment the property by
  82179. * @param condition defines the trigger related conditions
  82180. */
  82181. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  82182. /** @hidden */
  82183. _prepare(): void;
  82184. /**
  82185. * Execute the action and increment the target of the value amount.
  82186. */
  82187. execute(): void;
  82188. /**
  82189. * Serializes the actions and its related information.
  82190. * @param parent defines the object to serialize in
  82191. * @returns the serialized object
  82192. */
  82193. serialize(parent: any): any;
  82194. }
  82195. /**
  82196. * This defines an action responsible to start an animation once triggered.
  82197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82198. */
  82199. export class PlayAnimationAction extends Action {
  82200. /**
  82201. * Where the animation should start (animation frame)
  82202. */
  82203. from: number;
  82204. /**
  82205. * Where the animation should stop (animation frame)
  82206. */
  82207. to: number;
  82208. /**
  82209. * Define if the animation should loop or stop after the first play.
  82210. */
  82211. loop?: boolean;
  82212. private _target;
  82213. /**
  82214. * Instantiate the action
  82215. * @param triggerOptions defines the trigger options
  82216. * @param target defines the target animation or animation name
  82217. * @param from defines from where the animation should start (animation frame)
  82218. * @param end defines where the animation should stop (animation frame)
  82219. * @param loop defines if the animation should loop or stop after the first play
  82220. * @param condition defines the trigger related conditions
  82221. */
  82222. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  82223. /** @hidden */
  82224. _prepare(): void;
  82225. /**
  82226. * Execute the action and play the animation.
  82227. */
  82228. execute(): void;
  82229. /**
  82230. * Serializes the actions and its related information.
  82231. * @param parent defines the object to serialize in
  82232. * @returns the serialized object
  82233. */
  82234. serialize(parent: any): any;
  82235. }
  82236. /**
  82237. * This defines an action responsible to stop an animation once triggered.
  82238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82239. */
  82240. export class StopAnimationAction extends Action {
  82241. private _target;
  82242. /**
  82243. * Instantiate the action
  82244. * @param triggerOptions defines the trigger options
  82245. * @param target defines the target animation or animation name
  82246. * @param condition defines the trigger related conditions
  82247. */
  82248. constructor(triggerOptions: any, target: any, condition?: Condition);
  82249. /** @hidden */
  82250. _prepare(): void;
  82251. /**
  82252. * Execute the action and stop the animation.
  82253. */
  82254. execute(): void;
  82255. /**
  82256. * Serializes the actions and its related information.
  82257. * @param parent defines the object to serialize in
  82258. * @returns the serialized object
  82259. */
  82260. serialize(parent: any): any;
  82261. }
  82262. /**
  82263. * This defines an action responsible that does nothing once triggered.
  82264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82265. */
  82266. export class DoNothingAction extends Action {
  82267. /**
  82268. * Instantiate the action
  82269. * @param triggerOptions defines the trigger options
  82270. * @param condition defines the trigger related conditions
  82271. */
  82272. constructor(triggerOptions?: any, condition?: Condition);
  82273. /**
  82274. * Execute the action and do nothing.
  82275. */
  82276. execute(): void;
  82277. /**
  82278. * Serializes the actions and its related information.
  82279. * @param parent defines the object to serialize in
  82280. * @returns the serialized object
  82281. */
  82282. serialize(parent: any): any;
  82283. }
  82284. /**
  82285. * This defines an action responsible to trigger several actions once triggered.
  82286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82287. */
  82288. export class CombineAction extends Action {
  82289. /**
  82290. * The list of aggregated animations to run.
  82291. */
  82292. children: Action[];
  82293. /**
  82294. * Instantiate the action
  82295. * @param triggerOptions defines the trigger options
  82296. * @param children defines the list of aggregated animations to run
  82297. * @param condition defines the trigger related conditions
  82298. */
  82299. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  82300. /** @hidden */
  82301. _prepare(): void;
  82302. /**
  82303. * Execute the action and executes all the aggregated actions.
  82304. */
  82305. execute(evt: ActionEvent): void;
  82306. /**
  82307. * Serializes the actions and its related information.
  82308. * @param parent defines the object to serialize in
  82309. * @returns the serialized object
  82310. */
  82311. serialize(parent: any): any;
  82312. }
  82313. /**
  82314. * This defines an action responsible to run code (external event) once triggered.
  82315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82316. */
  82317. export class ExecuteCodeAction extends Action {
  82318. /**
  82319. * The callback function to run.
  82320. */
  82321. func: (evt: ActionEvent) => void;
  82322. /**
  82323. * Instantiate the action
  82324. * @param triggerOptions defines the trigger options
  82325. * @param func defines the callback function to run
  82326. * @param condition defines the trigger related conditions
  82327. */
  82328. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  82329. /**
  82330. * Execute the action and run the attached code.
  82331. */
  82332. execute(evt: ActionEvent): void;
  82333. }
  82334. /**
  82335. * This defines an action responsible to set the parent property of the target once triggered.
  82336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82337. */
  82338. export class SetParentAction extends Action {
  82339. private _parent;
  82340. private _target;
  82341. /**
  82342. * Instantiate the action
  82343. * @param triggerOptions defines the trigger options
  82344. * @param target defines the target containing the parent property
  82345. * @param parent defines from where the animation should start (animation frame)
  82346. * @param condition defines the trigger related conditions
  82347. */
  82348. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  82349. /** @hidden */
  82350. _prepare(): void;
  82351. /**
  82352. * Execute the action and set the parent property.
  82353. */
  82354. execute(): void;
  82355. /**
  82356. * Serializes the actions and its related information.
  82357. * @param parent defines the object to serialize in
  82358. * @returns the serialized object
  82359. */
  82360. serialize(parent: any): any;
  82361. }
  82362. }
  82363. declare module BABYLON {
  82364. /**
  82365. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  82366. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  82367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82368. */
  82369. export class ActionManager extends AbstractActionManager {
  82370. /**
  82371. * Nothing
  82372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82373. */
  82374. static readonly NothingTrigger: number;
  82375. /**
  82376. * On pick
  82377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82378. */
  82379. static readonly OnPickTrigger: number;
  82380. /**
  82381. * On left pick
  82382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82383. */
  82384. static readonly OnLeftPickTrigger: number;
  82385. /**
  82386. * On right pick
  82387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82388. */
  82389. static readonly OnRightPickTrigger: number;
  82390. /**
  82391. * On center pick
  82392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82393. */
  82394. static readonly OnCenterPickTrigger: number;
  82395. /**
  82396. * On pick down
  82397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82398. */
  82399. static readonly OnPickDownTrigger: number;
  82400. /**
  82401. * On double pick
  82402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82403. */
  82404. static readonly OnDoublePickTrigger: number;
  82405. /**
  82406. * On pick up
  82407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82408. */
  82409. static readonly OnPickUpTrigger: number;
  82410. /**
  82411. * On pick out.
  82412. * This trigger will only be raised if you also declared a OnPickDown
  82413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82414. */
  82415. static readonly OnPickOutTrigger: number;
  82416. /**
  82417. * On long press
  82418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82419. */
  82420. static readonly OnLongPressTrigger: number;
  82421. /**
  82422. * On pointer over
  82423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82424. */
  82425. static readonly OnPointerOverTrigger: number;
  82426. /**
  82427. * On pointer out
  82428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82429. */
  82430. static readonly OnPointerOutTrigger: number;
  82431. /**
  82432. * On every frame
  82433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82434. */
  82435. static readonly OnEveryFrameTrigger: number;
  82436. /**
  82437. * On intersection enter
  82438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82439. */
  82440. static readonly OnIntersectionEnterTrigger: number;
  82441. /**
  82442. * On intersection exit
  82443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82444. */
  82445. static readonly OnIntersectionExitTrigger: number;
  82446. /**
  82447. * On key down
  82448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82449. */
  82450. static readonly OnKeyDownTrigger: number;
  82451. /**
  82452. * On key up
  82453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82454. */
  82455. static readonly OnKeyUpTrigger: number;
  82456. private _scene;
  82457. /**
  82458. * Creates a new action manager
  82459. * @param scene defines the hosting scene
  82460. */
  82461. constructor(scene: Scene);
  82462. /**
  82463. * Releases all associated resources
  82464. */
  82465. dispose(): void;
  82466. /**
  82467. * Gets hosting scene
  82468. * @returns the hosting scene
  82469. */
  82470. getScene(): Scene;
  82471. /**
  82472. * Does this action manager handles actions of any of the given triggers
  82473. * @param triggers defines the triggers to be tested
  82474. * @return a boolean indicating whether one (or more) of the triggers is handled
  82475. */
  82476. hasSpecificTriggers(triggers: number[]): boolean;
  82477. /**
  82478. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  82479. * speed.
  82480. * @param triggerA defines the trigger to be tested
  82481. * @param triggerB defines the trigger to be tested
  82482. * @return a boolean indicating whether one (or more) of the triggers is handled
  82483. */
  82484. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  82485. /**
  82486. * Does this action manager handles actions of a given trigger
  82487. * @param trigger defines the trigger to be tested
  82488. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  82489. * @return whether the trigger is handled
  82490. */
  82491. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  82492. /**
  82493. * Does this action manager has pointer triggers
  82494. */
  82495. get hasPointerTriggers(): boolean;
  82496. /**
  82497. * Does this action manager has pick triggers
  82498. */
  82499. get hasPickTriggers(): boolean;
  82500. /**
  82501. * Registers an action to this action manager
  82502. * @param action defines the action to be registered
  82503. * @return the action amended (prepared) after registration
  82504. */
  82505. registerAction(action: IAction): Nullable<IAction>;
  82506. /**
  82507. * Unregisters an action to this action manager
  82508. * @param action defines the action to be unregistered
  82509. * @return a boolean indicating whether the action has been unregistered
  82510. */
  82511. unregisterAction(action: IAction): Boolean;
  82512. /**
  82513. * Process a specific trigger
  82514. * @param trigger defines the trigger to process
  82515. * @param evt defines the event details to be processed
  82516. */
  82517. processTrigger(trigger: number, evt?: IActionEvent): void;
  82518. /** @hidden */
  82519. _getEffectiveTarget(target: any, propertyPath: string): any;
  82520. /** @hidden */
  82521. _getProperty(propertyPath: string): string;
  82522. /**
  82523. * Serialize this manager to a JSON object
  82524. * @param name defines the property name to store this manager
  82525. * @returns a JSON representation of this manager
  82526. */
  82527. serialize(name: string): any;
  82528. /**
  82529. * Creates a new ActionManager from a JSON data
  82530. * @param parsedActions defines the JSON data to read from
  82531. * @param object defines the hosting mesh
  82532. * @param scene defines the hosting scene
  82533. */
  82534. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  82535. /**
  82536. * Get a trigger name by index
  82537. * @param trigger defines the trigger index
  82538. * @returns a trigger name
  82539. */
  82540. static GetTriggerName(trigger: number): string;
  82541. }
  82542. }
  82543. declare module BABYLON {
  82544. /**
  82545. * Class representing a ray with position and direction
  82546. */
  82547. export class Ray {
  82548. /** origin point */
  82549. origin: Vector3;
  82550. /** direction */
  82551. direction: Vector3;
  82552. /** length of the ray */
  82553. length: number;
  82554. private static readonly TmpVector3;
  82555. private _tmpRay;
  82556. /**
  82557. * Creates a new ray
  82558. * @param origin origin point
  82559. * @param direction direction
  82560. * @param length length of the ray
  82561. */
  82562. constructor(
  82563. /** origin point */
  82564. origin: Vector3,
  82565. /** direction */
  82566. direction: Vector3,
  82567. /** length of the ray */
  82568. length?: number);
  82569. /**
  82570. * Checks if the ray intersects a box
  82571. * @param minimum bound of the box
  82572. * @param maximum bound of the box
  82573. * @param intersectionTreshold extra extend to be added to the box in all direction
  82574. * @returns if the box was hit
  82575. */
  82576. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82577. /**
  82578. * Checks if the ray intersects a box
  82579. * @param box the bounding box to check
  82580. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82581. * @returns if the box was hit
  82582. */
  82583. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82584. /**
  82585. * If the ray hits a sphere
  82586. * @param sphere the bounding sphere to check
  82587. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82588. * @returns true if it hits the sphere
  82589. */
  82590. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82591. /**
  82592. * If the ray hits a triange
  82593. * @param vertex0 triangle vertex
  82594. * @param vertex1 triangle vertex
  82595. * @param vertex2 triangle vertex
  82596. * @returns intersection information if hit
  82597. */
  82598. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82599. /**
  82600. * Checks if ray intersects a plane
  82601. * @param plane the plane to check
  82602. * @returns the distance away it was hit
  82603. */
  82604. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82605. /**
  82606. * Calculate the intercept of a ray on a given axis
  82607. * @param axis to check 'x' | 'y' | 'z'
  82608. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82609. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82610. */
  82611. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82612. /**
  82613. * Checks if ray intersects a mesh
  82614. * @param mesh the mesh to check
  82615. * @param fastCheck if only the bounding box should checked
  82616. * @returns picking info of the intersecton
  82617. */
  82618. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82619. /**
  82620. * Checks if ray intersects a mesh
  82621. * @param meshes the meshes to check
  82622. * @param fastCheck if only the bounding box should checked
  82623. * @param results array to store result in
  82624. * @returns Array of picking infos
  82625. */
  82626. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82627. private _comparePickingInfo;
  82628. private static smallnum;
  82629. private static rayl;
  82630. /**
  82631. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82632. * @param sega the first point of the segment to test the intersection against
  82633. * @param segb the second point of the segment to test the intersection against
  82634. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82635. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82636. */
  82637. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82638. /**
  82639. * Update the ray from viewport position
  82640. * @param x position
  82641. * @param y y position
  82642. * @param viewportWidth viewport width
  82643. * @param viewportHeight viewport height
  82644. * @param world world matrix
  82645. * @param view view matrix
  82646. * @param projection projection matrix
  82647. * @returns this ray updated
  82648. */
  82649. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82650. /**
  82651. * Creates a ray with origin and direction of 0,0,0
  82652. * @returns the new ray
  82653. */
  82654. static Zero(): Ray;
  82655. /**
  82656. * Creates a new ray from screen space and viewport
  82657. * @param x position
  82658. * @param y y position
  82659. * @param viewportWidth viewport width
  82660. * @param viewportHeight viewport height
  82661. * @param world world matrix
  82662. * @param view view matrix
  82663. * @param projection projection matrix
  82664. * @returns new ray
  82665. */
  82666. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82667. /**
  82668. * 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
  82669. * transformed to the given world matrix.
  82670. * @param origin The origin point
  82671. * @param end The end point
  82672. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82673. * @returns the new ray
  82674. */
  82675. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82676. /**
  82677. * Transforms a ray by a matrix
  82678. * @param ray ray to transform
  82679. * @param matrix matrix to apply
  82680. * @returns the resulting new ray
  82681. */
  82682. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82683. /**
  82684. * Transforms a ray by a matrix
  82685. * @param ray ray to transform
  82686. * @param matrix matrix to apply
  82687. * @param result ray to store result in
  82688. */
  82689. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82690. /**
  82691. * Unproject a ray from screen space to object space
  82692. * @param sourceX defines the screen space x coordinate to use
  82693. * @param sourceY defines the screen space y coordinate to use
  82694. * @param viewportWidth defines the current width of the viewport
  82695. * @param viewportHeight defines the current height of the viewport
  82696. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82697. * @param view defines the view matrix to use
  82698. * @param projection defines the projection matrix to use
  82699. */
  82700. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82701. }
  82702. /**
  82703. * Type used to define predicate used to select faces when a mesh intersection is detected
  82704. */
  82705. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82706. interface Scene {
  82707. /** @hidden */
  82708. _tempPickingRay: Nullable<Ray>;
  82709. /** @hidden */
  82710. _cachedRayForTransform: Ray;
  82711. /** @hidden */
  82712. _pickWithRayInverseMatrix: Matrix;
  82713. /** @hidden */
  82714. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82715. /** @hidden */
  82716. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82717. }
  82718. }
  82719. declare module BABYLON {
  82720. /**
  82721. * Groups all the scene component constants in one place to ease maintenance.
  82722. * @hidden
  82723. */
  82724. export class SceneComponentConstants {
  82725. static readonly NAME_EFFECTLAYER: string;
  82726. static readonly NAME_LAYER: string;
  82727. static readonly NAME_LENSFLARESYSTEM: string;
  82728. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82729. static readonly NAME_PARTICLESYSTEM: string;
  82730. static readonly NAME_GAMEPAD: string;
  82731. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82732. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82733. static readonly NAME_DEPTHRENDERER: string;
  82734. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82735. static readonly NAME_SPRITE: string;
  82736. static readonly NAME_OUTLINERENDERER: string;
  82737. static readonly NAME_PROCEDURALTEXTURE: string;
  82738. static readonly NAME_SHADOWGENERATOR: string;
  82739. static readonly NAME_OCTREE: string;
  82740. static readonly NAME_PHYSICSENGINE: string;
  82741. static readonly NAME_AUDIO: string;
  82742. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82743. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82744. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82745. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82746. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82747. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82748. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82749. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82750. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82751. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82752. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82753. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82754. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82755. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82756. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82757. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82758. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82759. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82760. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82761. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82762. static readonly STEP_AFTERRENDER_AUDIO: number;
  82763. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82764. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82765. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82766. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82767. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82768. static readonly STEP_POINTERMOVE_SPRITE: number;
  82769. static readonly STEP_POINTERDOWN_SPRITE: number;
  82770. static readonly STEP_POINTERUP_SPRITE: number;
  82771. }
  82772. /**
  82773. * This represents a scene component.
  82774. *
  82775. * This is used to decouple the dependency the scene is having on the different workloads like
  82776. * layers, post processes...
  82777. */
  82778. export interface ISceneComponent {
  82779. /**
  82780. * The name of the component. Each component must have a unique name.
  82781. */
  82782. name: string;
  82783. /**
  82784. * The scene the component belongs to.
  82785. */
  82786. scene: Scene;
  82787. /**
  82788. * Register the component to one instance of a scene.
  82789. */
  82790. register(): void;
  82791. /**
  82792. * Rebuilds the elements related to this component in case of
  82793. * context lost for instance.
  82794. */
  82795. rebuild(): void;
  82796. /**
  82797. * Disposes the component and the associated ressources.
  82798. */
  82799. dispose(): void;
  82800. }
  82801. /**
  82802. * This represents a SERIALIZABLE scene component.
  82803. *
  82804. * This extends Scene Component to add Serialization methods on top.
  82805. */
  82806. export interface ISceneSerializableComponent extends ISceneComponent {
  82807. /**
  82808. * Adds all the elements from the container to the scene
  82809. * @param container the container holding the elements
  82810. */
  82811. addFromContainer(container: AbstractScene): void;
  82812. /**
  82813. * Removes all the elements in the container from the scene
  82814. * @param container contains the elements to remove
  82815. * @param dispose if the removed element should be disposed (default: false)
  82816. */
  82817. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82818. /**
  82819. * Serializes the component data to the specified json object
  82820. * @param serializationObject The object to serialize to
  82821. */
  82822. serialize(serializationObject: any): void;
  82823. }
  82824. /**
  82825. * Strong typing of a Mesh related stage step action
  82826. */
  82827. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82828. /**
  82829. * Strong typing of a Evaluate Sub Mesh related stage step action
  82830. */
  82831. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82832. /**
  82833. * Strong typing of a Active Mesh related stage step action
  82834. */
  82835. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82836. /**
  82837. * Strong typing of a Camera related stage step action
  82838. */
  82839. export type CameraStageAction = (camera: Camera) => void;
  82840. /**
  82841. * Strong typing of a Camera Frame buffer related stage step action
  82842. */
  82843. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82844. /**
  82845. * Strong typing of a Render Target related stage step action
  82846. */
  82847. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82848. /**
  82849. * Strong typing of a RenderingGroup related stage step action
  82850. */
  82851. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82852. /**
  82853. * Strong typing of a Mesh Render related stage step action
  82854. */
  82855. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82856. /**
  82857. * Strong typing of a simple stage step action
  82858. */
  82859. export type SimpleStageAction = () => void;
  82860. /**
  82861. * Strong typing of a render target action.
  82862. */
  82863. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82864. /**
  82865. * Strong typing of a pointer move action.
  82866. */
  82867. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82868. /**
  82869. * Strong typing of a pointer up/down action.
  82870. */
  82871. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82872. /**
  82873. * Representation of a stage in the scene (Basically a list of ordered steps)
  82874. * @hidden
  82875. */
  82876. export class Stage<T extends Function> extends Array<{
  82877. index: number;
  82878. component: ISceneComponent;
  82879. action: T;
  82880. }> {
  82881. /**
  82882. * Hide ctor from the rest of the world.
  82883. * @param items The items to add.
  82884. */
  82885. private constructor();
  82886. /**
  82887. * Creates a new Stage.
  82888. * @returns A new instance of a Stage
  82889. */
  82890. static Create<T extends Function>(): Stage<T>;
  82891. /**
  82892. * Registers a step in an ordered way in the targeted stage.
  82893. * @param index Defines the position to register the step in
  82894. * @param component Defines the component attached to the step
  82895. * @param action Defines the action to launch during the step
  82896. */
  82897. registerStep(index: number, component: ISceneComponent, action: T): void;
  82898. /**
  82899. * Clears all the steps from the stage.
  82900. */
  82901. clear(): void;
  82902. }
  82903. }
  82904. declare module BABYLON {
  82905. interface Scene {
  82906. /** @hidden */
  82907. _pointerOverSprite: Nullable<Sprite>;
  82908. /** @hidden */
  82909. _pickedDownSprite: Nullable<Sprite>;
  82910. /** @hidden */
  82911. _tempSpritePickingRay: Nullable<Ray>;
  82912. /**
  82913. * All of the sprite managers added to this scene
  82914. * @see http://doc.babylonjs.com/babylon101/sprites
  82915. */
  82916. spriteManagers: Array<ISpriteManager>;
  82917. /**
  82918. * An event triggered when sprites rendering is about to start
  82919. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82920. */
  82921. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82922. /**
  82923. * An event triggered when sprites rendering is done
  82924. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82925. */
  82926. onAfterSpritesRenderingObservable: Observable<Scene>;
  82927. /** @hidden */
  82928. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82929. /** Launch a ray to try to pick a sprite in the scene
  82930. * @param x position on screen
  82931. * @param y position on screen
  82932. * @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
  82933. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82934. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82935. * @returns a PickingInfo
  82936. */
  82937. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82938. /** Use the given ray to pick a sprite in the scene
  82939. * @param ray The ray (in world space) to use to pick meshes
  82940. * @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
  82941. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82942. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82943. * @returns a PickingInfo
  82944. */
  82945. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82946. /** @hidden */
  82947. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82948. /** Launch a ray to try to pick sprites in the scene
  82949. * @param x position on screen
  82950. * @param y position on screen
  82951. * @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
  82952. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82953. * @returns a PickingInfo array
  82954. */
  82955. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82956. /** Use the given ray to pick sprites in the scene
  82957. * @param ray The ray (in world space) to use to pick meshes
  82958. * @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
  82959. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82960. * @returns a PickingInfo array
  82961. */
  82962. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82963. /**
  82964. * Force the sprite under the pointer
  82965. * @param sprite defines the sprite to use
  82966. */
  82967. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82968. /**
  82969. * Gets the sprite under the pointer
  82970. * @returns a Sprite or null if no sprite is under the pointer
  82971. */
  82972. getPointerOverSprite(): Nullable<Sprite>;
  82973. }
  82974. /**
  82975. * Defines the sprite scene component responsible to manage sprites
  82976. * in a given scene.
  82977. */
  82978. export class SpriteSceneComponent implements ISceneComponent {
  82979. /**
  82980. * The component name helpfull to identify the component in the list of scene components.
  82981. */
  82982. readonly name: string;
  82983. /**
  82984. * The scene the component belongs to.
  82985. */
  82986. scene: Scene;
  82987. /** @hidden */
  82988. private _spritePredicate;
  82989. /**
  82990. * Creates a new instance of the component for the given scene
  82991. * @param scene Defines the scene to register the component in
  82992. */
  82993. constructor(scene: Scene);
  82994. /**
  82995. * Registers the component in a given scene
  82996. */
  82997. register(): void;
  82998. /**
  82999. * Rebuilds the elements related to this component in case of
  83000. * context lost for instance.
  83001. */
  83002. rebuild(): void;
  83003. /**
  83004. * Disposes the component and the associated ressources.
  83005. */
  83006. dispose(): void;
  83007. private _pickSpriteButKeepRay;
  83008. private _pointerMove;
  83009. private _pointerDown;
  83010. private _pointerUp;
  83011. }
  83012. }
  83013. declare module BABYLON {
  83014. /** @hidden */
  83015. export var fogFragmentDeclaration: {
  83016. name: string;
  83017. shader: string;
  83018. };
  83019. }
  83020. declare module BABYLON {
  83021. /** @hidden */
  83022. export var fogFragment: {
  83023. name: string;
  83024. shader: string;
  83025. };
  83026. }
  83027. declare module BABYLON {
  83028. /** @hidden */
  83029. export var spritesPixelShader: {
  83030. name: string;
  83031. shader: string;
  83032. };
  83033. }
  83034. declare module BABYLON {
  83035. /** @hidden */
  83036. export var fogVertexDeclaration: {
  83037. name: string;
  83038. shader: string;
  83039. };
  83040. }
  83041. declare module BABYLON {
  83042. /** @hidden */
  83043. export var spritesVertexShader: {
  83044. name: string;
  83045. shader: string;
  83046. };
  83047. }
  83048. declare module BABYLON {
  83049. /**
  83050. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83051. */
  83052. export interface ISpriteManager extends IDisposable {
  83053. /**
  83054. * Restricts the camera to viewing objects with the same layerMask.
  83055. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83056. */
  83057. layerMask: number;
  83058. /**
  83059. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83060. */
  83061. isPickable: boolean;
  83062. /**
  83063. * Specifies the rendering group id for this mesh (0 by default)
  83064. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83065. */
  83066. renderingGroupId: number;
  83067. /**
  83068. * Defines the list of sprites managed by the manager.
  83069. */
  83070. sprites: Array<Sprite>;
  83071. /**
  83072. * Tests the intersection of a sprite with a specific ray.
  83073. * @param ray The ray we are sending to test the collision
  83074. * @param camera The camera space we are sending rays in
  83075. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83076. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83077. * @returns picking info or null.
  83078. */
  83079. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83080. /**
  83081. * Intersects the sprites with a ray
  83082. * @param ray defines the ray to intersect with
  83083. * @param camera defines the current active camera
  83084. * @param predicate defines a predicate used to select candidate sprites
  83085. * @returns null if no hit or a PickingInfo array
  83086. */
  83087. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83088. /**
  83089. * Renders the list of sprites on screen.
  83090. */
  83091. render(): void;
  83092. }
  83093. /**
  83094. * Class used to manage multiple sprites on the same spritesheet
  83095. * @see http://doc.babylonjs.com/babylon101/sprites
  83096. */
  83097. export class SpriteManager implements ISpriteManager {
  83098. /** defines the manager's name */
  83099. name: string;
  83100. /** Gets the list of sprites */
  83101. sprites: Sprite[];
  83102. /** Gets or sets the rendering group id (0 by default) */
  83103. renderingGroupId: number;
  83104. /** Gets or sets camera layer mask */
  83105. layerMask: number;
  83106. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83107. fogEnabled: boolean;
  83108. /** Gets or sets a boolean indicating if the sprites are pickable */
  83109. isPickable: boolean;
  83110. /** Defines the default width of a cell in the spritesheet */
  83111. cellWidth: number;
  83112. /** Defines the default height of a cell in the spritesheet */
  83113. cellHeight: number;
  83114. /** Associative array from JSON sprite data file */
  83115. private _cellData;
  83116. /** Array of sprite names from JSON sprite data file */
  83117. private _spriteMap;
  83118. /** True when packed cell data from JSON file is ready*/
  83119. private _packedAndReady;
  83120. /**
  83121. * An event triggered when the manager is disposed.
  83122. */
  83123. onDisposeObservable: Observable<SpriteManager>;
  83124. private _onDisposeObserver;
  83125. /**
  83126. * Callback called when the manager is disposed
  83127. */
  83128. set onDispose(callback: () => void);
  83129. private _capacity;
  83130. private _fromPacked;
  83131. private _spriteTexture;
  83132. private _epsilon;
  83133. private _scene;
  83134. private _vertexData;
  83135. private _buffer;
  83136. private _vertexBuffers;
  83137. private _indexBuffer;
  83138. private _effectBase;
  83139. private _effectFog;
  83140. /**
  83141. * Gets or sets the spritesheet texture
  83142. */
  83143. get texture(): Texture;
  83144. set texture(value: Texture);
  83145. /**
  83146. * Creates a new sprite manager
  83147. * @param name defines the manager's name
  83148. * @param imgUrl defines the sprite sheet url
  83149. * @param capacity defines the maximum allowed number of sprites
  83150. * @param cellSize defines the size of a sprite cell
  83151. * @param scene defines the hosting scene
  83152. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83153. * @param samplingMode defines the smapling mode to use with spritesheet
  83154. * @param fromPacked set to false; do not alter
  83155. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83156. */
  83157. constructor(
  83158. /** defines the manager's name */
  83159. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83160. private _makePacked;
  83161. private _appendSpriteVertex;
  83162. /**
  83163. * Intersects the sprites with a ray
  83164. * @param ray defines the ray to intersect with
  83165. * @param camera defines the current active camera
  83166. * @param predicate defines a predicate used to select candidate sprites
  83167. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83168. * @returns null if no hit or a PickingInfo
  83169. */
  83170. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83171. /**
  83172. * Intersects the sprites with a ray
  83173. * @param ray defines the ray to intersect with
  83174. * @param camera defines the current active camera
  83175. * @param predicate defines a predicate used to select candidate sprites
  83176. * @returns null if no hit or a PickingInfo array
  83177. */
  83178. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83179. /**
  83180. * Render all child sprites
  83181. */
  83182. render(): void;
  83183. /**
  83184. * Release associated resources
  83185. */
  83186. dispose(): void;
  83187. }
  83188. }
  83189. declare module BABYLON {
  83190. /**
  83191. * Class used to represent a sprite
  83192. * @see http://doc.babylonjs.com/babylon101/sprites
  83193. */
  83194. export class Sprite {
  83195. /** defines the name */
  83196. name: string;
  83197. /** Gets or sets the current world position */
  83198. position: Vector3;
  83199. /** Gets or sets the main color */
  83200. color: Color4;
  83201. /** Gets or sets the width */
  83202. width: number;
  83203. /** Gets or sets the height */
  83204. height: number;
  83205. /** Gets or sets rotation angle */
  83206. angle: number;
  83207. /** Gets or sets the cell index in the sprite sheet */
  83208. cellIndex: number;
  83209. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  83210. cellRef: string;
  83211. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  83212. invertU: number;
  83213. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  83214. invertV: number;
  83215. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  83216. disposeWhenFinishedAnimating: boolean;
  83217. /** Gets the list of attached animations */
  83218. animations: Animation[];
  83219. /** Gets or sets a boolean indicating if the sprite can be picked */
  83220. isPickable: boolean;
  83221. /**
  83222. * Gets or sets the associated action manager
  83223. */
  83224. actionManager: Nullable<ActionManager>;
  83225. private _animationStarted;
  83226. private _loopAnimation;
  83227. private _fromIndex;
  83228. private _toIndex;
  83229. private _delay;
  83230. private _direction;
  83231. private _manager;
  83232. private _time;
  83233. private _onAnimationEnd;
  83234. /**
  83235. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  83236. */
  83237. isVisible: boolean;
  83238. /**
  83239. * Gets or sets the sprite size
  83240. */
  83241. get size(): number;
  83242. set size(value: number);
  83243. /**
  83244. * Creates a new Sprite
  83245. * @param name defines the name
  83246. * @param manager defines the manager
  83247. */
  83248. constructor(
  83249. /** defines the name */
  83250. name: string, manager: ISpriteManager);
  83251. /**
  83252. * Starts an animation
  83253. * @param from defines the initial key
  83254. * @param to defines the end key
  83255. * @param loop defines if the animation must loop
  83256. * @param delay defines the start delay (in ms)
  83257. * @param onAnimationEnd defines a callback to call when animation ends
  83258. */
  83259. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  83260. /** Stops current animation (if any) */
  83261. stopAnimation(): void;
  83262. /** @hidden */
  83263. _animate(deltaTime: number): void;
  83264. /** Release associated resources */
  83265. dispose(): void;
  83266. }
  83267. }
  83268. declare module BABYLON {
  83269. /**
  83270. * Information about the result of picking within a scene
  83271. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  83272. */
  83273. export class PickingInfo {
  83274. /** @hidden */
  83275. _pickingUnavailable: boolean;
  83276. /**
  83277. * If the pick collided with an object
  83278. */
  83279. hit: boolean;
  83280. /**
  83281. * Distance away where the pick collided
  83282. */
  83283. distance: number;
  83284. /**
  83285. * The location of pick collision
  83286. */
  83287. pickedPoint: Nullable<Vector3>;
  83288. /**
  83289. * The mesh corresponding the the pick collision
  83290. */
  83291. pickedMesh: Nullable<AbstractMesh>;
  83292. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  83293. bu: number;
  83294. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  83295. bv: number;
  83296. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  83297. faceId: number;
  83298. /** Id of the the submesh that was picked */
  83299. subMeshId: number;
  83300. /** If a sprite was picked, this will be the sprite the pick collided with */
  83301. pickedSprite: Nullable<Sprite>;
  83302. /**
  83303. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  83304. */
  83305. originMesh: Nullable<AbstractMesh>;
  83306. /**
  83307. * The ray that was used to perform the picking.
  83308. */
  83309. ray: Nullable<Ray>;
  83310. /**
  83311. * Gets the normal correspodning to the face the pick collided with
  83312. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  83313. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  83314. * @returns The normal correspodning to the face the pick collided with
  83315. */
  83316. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  83317. /**
  83318. * Gets the texture coordinates of where the pick occured
  83319. * @returns the vector containing the coordnates of the texture
  83320. */
  83321. getTextureCoordinates(): Nullable<Vector2>;
  83322. }
  83323. }
  83324. declare module BABYLON {
  83325. /**
  83326. * Gather the list of pointer event types as constants.
  83327. */
  83328. export class PointerEventTypes {
  83329. /**
  83330. * 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.
  83331. */
  83332. static readonly POINTERDOWN: number;
  83333. /**
  83334. * The pointerup event is fired when a pointer is no longer active.
  83335. */
  83336. static readonly POINTERUP: number;
  83337. /**
  83338. * The pointermove event is fired when a pointer changes coordinates.
  83339. */
  83340. static readonly POINTERMOVE: number;
  83341. /**
  83342. * The pointerwheel event is fired when a mouse wheel has been rotated.
  83343. */
  83344. static readonly POINTERWHEEL: number;
  83345. /**
  83346. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  83347. */
  83348. static readonly POINTERPICK: number;
  83349. /**
  83350. * The pointertap event is fired when a the object has been touched and released without drag.
  83351. */
  83352. static readonly POINTERTAP: number;
  83353. /**
  83354. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  83355. */
  83356. static readonly POINTERDOUBLETAP: number;
  83357. }
  83358. /**
  83359. * Base class of pointer info types.
  83360. */
  83361. export class PointerInfoBase {
  83362. /**
  83363. * Defines the type of event (PointerEventTypes)
  83364. */
  83365. type: number;
  83366. /**
  83367. * Defines the related dom event
  83368. */
  83369. event: PointerEvent | MouseWheelEvent;
  83370. /**
  83371. * Instantiates the base class of pointers info.
  83372. * @param type Defines the type of event (PointerEventTypes)
  83373. * @param event Defines the related dom event
  83374. */
  83375. constructor(
  83376. /**
  83377. * Defines the type of event (PointerEventTypes)
  83378. */
  83379. type: number,
  83380. /**
  83381. * Defines the related dom event
  83382. */
  83383. event: PointerEvent | MouseWheelEvent);
  83384. }
  83385. /**
  83386. * This class is used to store pointer related info for the onPrePointerObservable event.
  83387. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  83388. */
  83389. export class PointerInfoPre extends PointerInfoBase {
  83390. /**
  83391. * Ray from a pointer if availible (eg. 6dof controller)
  83392. */
  83393. ray: Nullable<Ray>;
  83394. /**
  83395. * Defines the local position of the pointer on the canvas.
  83396. */
  83397. localPosition: Vector2;
  83398. /**
  83399. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  83400. */
  83401. skipOnPointerObservable: boolean;
  83402. /**
  83403. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  83404. * @param type Defines the type of event (PointerEventTypes)
  83405. * @param event Defines the related dom event
  83406. * @param localX Defines the local x coordinates of the pointer when the event occured
  83407. * @param localY Defines the local y coordinates of the pointer when the event occured
  83408. */
  83409. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  83410. }
  83411. /**
  83412. * This type contains all the data related to a pointer event in Babylon.js.
  83413. * 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.
  83414. */
  83415. export class PointerInfo extends PointerInfoBase {
  83416. /**
  83417. * Defines the picking info associated to the info (if any)\
  83418. */
  83419. pickInfo: Nullable<PickingInfo>;
  83420. /**
  83421. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  83422. * @param type Defines the type of event (PointerEventTypes)
  83423. * @param event Defines the related dom event
  83424. * @param pickInfo Defines the picking info associated to the info (if any)\
  83425. */
  83426. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  83427. /**
  83428. * Defines the picking info associated to the info (if any)\
  83429. */
  83430. pickInfo: Nullable<PickingInfo>);
  83431. }
  83432. /**
  83433. * Data relating to a touch event on the screen.
  83434. */
  83435. export interface PointerTouch {
  83436. /**
  83437. * X coordinate of touch.
  83438. */
  83439. x: number;
  83440. /**
  83441. * Y coordinate of touch.
  83442. */
  83443. y: number;
  83444. /**
  83445. * Id of touch. Unique for each finger.
  83446. */
  83447. pointerId: number;
  83448. /**
  83449. * Event type passed from DOM.
  83450. */
  83451. type: any;
  83452. }
  83453. }
  83454. declare module BABYLON {
  83455. /**
  83456. * Manage the mouse inputs to control the movement of a free camera.
  83457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83458. */
  83459. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  83460. /**
  83461. * Define if touch is enabled in the mouse input
  83462. */
  83463. touchEnabled: boolean;
  83464. /**
  83465. * Defines the camera the input is attached to.
  83466. */
  83467. camera: FreeCamera;
  83468. /**
  83469. * Defines the buttons associated with the input to handle camera move.
  83470. */
  83471. buttons: number[];
  83472. /**
  83473. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  83474. */
  83475. angularSensibility: number;
  83476. private _pointerInput;
  83477. private _onMouseMove;
  83478. private _observer;
  83479. private previousPosition;
  83480. /**
  83481. * Observable for when a pointer move event occurs containing the move offset
  83482. */
  83483. onPointerMovedObservable: Observable<{
  83484. offsetX: number;
  83485. offsetY: number;
  83486. }>;
  83487. /**
  83488. * @hidden
  83489. * If the camera should be rotated automatically based on pointer movement
  83490. */
  83491. _allowCameraRotation: boolean;
  83492. /**
  83493. * Manage the mouse inputs to control the movement of a free camera.
  83494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83495. * @param touchEnabled Defines if touch is enabled or not
  83496. */
  83497. constructor(
  83498. /**
  83499. * Define if touch is enabled in the mouse input
  83500. */
  83501. touchEnabled?: boolean);
  83502. /**
  83503. * Attach the input controls to a specific dom element to get the input from.
  83504. * @param element Defines the element the controls should be listened from
  83505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83506. */
  83507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83508. /**
  83509. * Called on JS contextmenu event.
  83510. * Override this method to provide functionality.
  83511. */
  83512. protected onContextMenu(evt: PointerEvent): void;
  83513. /**
  83514. * Detach the current controls from the specified dom element.
  83515. * @param element Defines the element to stop listening the inputs from
  83516. */
  83517. detachControl(element: Nullable<HTMLElement>): void;
  83518. /**
  83519. * Gets the class name of the current intput.
  83520. * @returns the class name
  83521. */
  83522. getClassName(): string;
  83523. /**
  83524. * Get the friendly name associated with the input class.
  83525. * @returns the input friendly name
  83526. */
  83527. getSimpleName(): string;
  83528. }
  83529. }
  83530. declare module BABYLON {
  83531. /**
  83532. * Manage the touch inputs to control the movement of a free camera.
  83533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83534. */
  83535. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  83536. /**
  83537. * Defines the camera the input is attached to.
  83538. */
  83539. camera: FreeCamera;
  83540. /**
  83541. * Defines the touch sensibility for rotation.
  83542. * The higher the faster.
  83543. */
  83544. touchAngularSensibility: number;
  83545. /**
  83546. * Defines the touch sensibility for move.
  83547. * The higher the faster.
  83548. */
  83549. touchMoveSensibility: number;
  83550. private _offsetX;
  83551. private _offsetY;
  83552. private _pointerPressed;
  83553. private _pointerInput;
  83554. private _observer;
  83555. private _onLostFocus;
  83556. /**
  83557. * Attach the input controls to a specific dom element to get the input from.
  83558. * @param element Defines the element the controls should be listened from
  83559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83560. */
  83561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83562. /**
  83563. * Detach the current controls from the specified dom element.
  83564. * @param element Defines the element to stop listening the inputs from
  83565. */
  83566. detachControl(element: Nullable<HTMLElement>): void;
  83567. /**
  83568. * Update the current camera state depending on the inputs that have been used this frame.
  83569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83570. */
  83571. checkInputs(): void;
  83572. /**
  83573. * Gets the class name of the current intput.
  83574. * @returns the class name
  83575. */
  83576. getClassName(): string;
  83577. /**
  83578. * Get the friendly name associated with the input class.
  83579. * @returns the input friendly name
  83580. */
  83581. getSimpleName(): string;
  83582. }
  83583. }
  83584. declare module BABYLON {
  83585. /**
  83586. * Default Inputs manager for the FreeCamera.
  83587. * It groups all the default supported inputs for ease of use.
  83588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83589. */
  83590. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  83591. /**
  83592. * @hidden
  83593. */
  83594. _mouseInput: Nullable<FreeCameraMouseInput>;
  83595. /**
  83596. * Instantiates a new FreeCameraInputsManager.
  83597. * @param camera Defines the camera the inputs belong to
  83598. */
  83599. constructor(camera: FreeCamera);
  83600. /**
  83601. * Add keyboard input support to the input manager.
  83602. * @returns the current input manager
  83603. */
  83604. addKeyboard(): FreeCameraInputsManager;
  83605. /**
  83606. * Add mouse input support to the input manager.
  83607. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  83608. * @returns the current input manager
  83609. */
  83610. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  83611. /**
  83612. * Removes the mouse input support from the manager
  83613. * @returns the current input manager
  83614. */
  83615. removeMouse(): FreeCameraInputsManager;
  83616. /**
  83617. * Add touch input support to the input manager.
  83618. * @returns the current input manager
  83619. */
  83620. addTouch(): FreeCameraInputsManager;
  83621. /**
  83622. * Remove all attached input methods from a camera
  83623. */
  83624. clear(): void;
  83625. }
  83626. }
  83627. declare module BABYLON {
  83628. /**
  83629. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  83630. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  83631. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  83632. */
  83633. export class FreeCamera extends TargetCamera {
  83634. /**
  83635. * Define the collision ellipsoid of the camera.
  83636. * This is helpful to simulate a camera body like the player body around the camera
  83637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  83638. */
  83639. ellipsoid: Vector3;
  83640. /**
  83641. * Define an offset for the position of the ellipsoid around the camera.
  83642. * This can be helpful to determine the center of the body near the gravity center of the body
  83643. * instead of its head.
  83644. */
  83645. ellipsoidOffset: Vector3;
  83646. /**
  83647. * Enable or disable collisions of the camera with the rest of the scene objects.
  83648. */
  83649. checkCollisions: boolean;
  83650. /**
  83651. * Enable or disable gravity on the camera.
  83652. */
  83653. applyGravity: boolean;
  83654. /**
  83655. * Define the input manager associated to the camera.
  83656. */
  83657. inputs: FreeCameraInputsManager;
  83658. /**
  83659. * Gets the input sensibility for a mouse input. (default is 2000.0)
  83660. * Higher values reduce sensitivity.
  83661. */
  83662. get angularSensibility(): number;
  83663. /**
  83664. * Sets the input sensibility for a mouse input. (default is 2000.0)
  83665. * Higher values reduce sensitivity.
  83666. */
  83667. set angularSensibility(value: number);
  83668. /**
  83669. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83670. */
  83671. get keysUp(): number[];
  83672. set keysUp(value: number[]);
  83673. /**
  83674. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83675. */
  83676. get keysDown(): number[];
  83677. set keysDown(value: number[]);
  83678. /**
  83679. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83680. */
  83681. get keysLeft(): number[];
  83682. set keysLeft(value: number[]);
  83683. /**
  83684. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83685. */
  83686. get keysRight(): number[];
  83687. set keysRight(value: number[]);
  83688. /**
  83689. * Event raised when the camera collide with a mesh in the scene.
  83690. */
  83691. onCollide: (collidedMesh: AbstractMesh) => void;
  83692. private _collider;
  83693. private _needMoveForGravity;
  83694. private _oldPosition;
  83695. private _diffPosition;
  83696. private _newPosition;
  83697. /** @hidden */
  83698. _localDirection: Vector3;
  83699. /** @hidden */
  83700. _transformedDirection: Vector3;
  83701. /**
  83702. * Instantiates a Free Camera.
  83703. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  83704. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  83705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  83706. * @param name Define the name of the camera in the scene
  83707. * @param position Define the start position of the camera in the scene
  83708. * @param scene Define the scene the camera belongs to
  83709. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  83710. */
  83711. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  83712. /**
  83713. * Attached controls to the current camera.
  83714. * @param element Defines the element the controls should be listened from
  83715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83716. */
  83717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83718. /**
  83719. * Detach the current controls from the camera.
  83720. * The camera will stop reacting to inputs.
  83721. * @param element Defines the element to stop listening the inputs from
  83722. */
  83723. detachControl(element: HTMLElement): void;
  83724. private _collisionMask;
  83725. /**
  83726. * Define a collision mask to limit the list of object the camera can collide with
  83727. */
  83728. get collisionMask(): number;
  83729. set collisionMask(mask: number);
  83730. /** @hidden */
  83731. _collideWithWorld(displacement: Vector3): void;
  83732. private _onCollisionPositionChange;
  83733. /** @hidden */
  83734. _checkInputs(): void;
  83735. /** @hidden */
  83736. _decideIfNeedsToMove(): boolean;
  83737. /** @hidden */
  83738. _updatePosition(): void;
  83739. /**
  83740. * Destroy the camera and release the current resources hold by it.
  83741. */
  83742. dispose(): void;
  83743. /**
  83744. * Gets the current object class name.
  83745. * @return the class name
  83746. */
  83747. getClassName(): string;
  83748. }
  83749. }
  83750. declare module BABYLON {
  83751. /**
  83752. * Represents a gamepad control stick position
  83753. */
  83754. export class StickValues {
  83755. /**
  83756. * The x component of the control stick
  83757. */
  83758. x: number;
  83759. /**
  83760. * The y component of the control stick
  83761. */
  83762. y: number;
  83763. /**
  83764. * Initializes the gamepad x and y control stick values
  83765. * @param x The x component of the gamepad control stick value
  83766. * @param y The y component of the gamepad control stick value
  83767. */
  83768. constructor(
  83769. /**
  83770. * The x component of the control stick
  83771. */
  83772. x: number,
  83773. /**
  83774. * The y component of the control stick
  83775. */
  83776. y: number);
  83777. }
  83778. /**
  83779. * An interface which manages callbacks for gamepad button changes
  83780. */
  83781. export interface GamepadButtonChanges {
  83782. /**
  83783. * Called when a gamepad has been changed
  83784. */
  83785. changed: boolean;
  83786. /**
  83787. * Called when a gamepad press event has been triggered
  83788. */
  83789. pressChanged: boolean;
  83790. /**
  83791. * Called when a touch event has been triggered
  83792. */
  83793. touchChanged: boolean;
  83794. /**
  83795. * Called when a value has changed
  83796. */
  83797. valueChanged: boolean;
  83798. }
  83799. /**
  83800. * Represents a gamepad
  83801. */
  83802. export class Gamepad {
  83803. /**
  83804. * The id of the gamepad
  83805. */
  83806. id: string;
  83807. /**
  83808. * The index of the gamepad
  83809. */
  83810. index: number;
  83811. /**
  83812. * The browser gamepad
  83813. */
  83814. browserGamepad: any;
  83815. /**
  83816. * Specifies what type of gamepad this represents
  83817. */
  83818. type: number;
  83819. private _leftStick;
  83820. private _rightStick;
  83821. /** @hidden */
  83822. _isConnected: boolean;
  83823. private _leftStickAxisX;
  83824. private _leftStickAxisY;
  83825. private _rightStickAxisX;
  83826. private _rightStickAxisY;
  83827. /**
  83828. * Triggered when the left control stick has been changed
  83829. */
  83830. private _onleftstickchanged;
  83831. /**
  83832. * Triggered when the right control stick has been changed
  83833. */
  83834. private _onrightstickchanged;
  83835. /**
  83836. * Represents a gamepad controller
  83837. */
  83838. static GAMEPAD: number;
  83839. /**
  83840. * Represents a generic controller
  83841. */
  83842. static GENERIC: number;
  83843. /**
  83844. * Represents an XBox controller
  83845. */
  83846. static XBOX: number;
  83847. /**
  83848. * Represents a pose-enabled controller
  83849. */
  83850. static POSE_ENABLED: number;
  83851. /**
  83852. * Represents an Dual Shock controller
  83853. */
  83854. static DUALSHOCK: number;
  83855. /**
  83856. * Specifies whether the left control stick should be Y-inverted
  83857. */
  83858. protected _invertLeftStickY: boolean;
  83859. /**
  83860. * Specifies if the gamepad has been connected
  83861. */
  83862. get isConnected(): boolean;
  83863. /**
  83864. * Initializes the gamepad
  83865. * @param id The id of the gamepad
  83866. * @param index The index of the gamepad
  83867. * @param browserGamepad The browser gamepad
  83868. * @param leftStickX The x component of the left joystick
  83869. * @param leftStickY The y component of the left joystick
  83870. * @param rightStickX The x component of the right joystick
  83871. * @param rightStickY The y component of the right joystick
  83872. */
  83873. constructor(
  83874. /**
  83875. * The id of the gamepad
  83876. */
  83877. id: string,
  83878. /**
  83879. * The index of the gamepad
  83880. */
  83881. index: number,
  83882. /**
  83883. * The browser gamepad
  83884. */
  83885. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83886. /**
  83887. * Callback triggered when the left joystick has changed
  83888. * @param callback
  83889. */
  83890. onleftstickchanged(callback: (values: StickValues) => void): void;
  83891. /**
  83892. * Callback triggered when the right joystick has changed
  83893. * @param callback
  83894. */
  83895. onrightstickchanged(callback: (values: StickValues) => void): void;
  83896. /**
  83897. * Gets the left joystick
  83898. */
  83899. get leftStick(): StickValues;
  83900. /**
  83901. * Sets the left joystick values
  83902. */
  83903. set leftStick(newValues: StickValues);
  83904. /**
  83905. * Gets the right joystick
  83906. */
  83907. get rightStick(): StickValues;
  83908. /**
  83909. * Sets the right joystick value
  83910. */
  83911. set rightStick(newValues: StickValues);
  83912. /**
  83913. * Updates the gamepad joystick positions
  83914. */
  83915. update(): void;
  83916. /**
  83917. * Disposes the gamepad
  83918. */
  83919. dispose(): void;
  83920. }
  83921. /**
  83922. * Represents a generic gamepad
  83923. */
  83924. export class GenericPad extends Gamepad {
  83925. private _buttons;
  83926. private _onbuttondown;
  83927. private _onbuttonup;
  83928. /**
  83929. * Observable triggered when a button has been pressed
  83930. */
  83931. onButtonDownObservable: Observable<number>;
  83932. /**
  83933. * Observable triggered when a button has been released
  83934. */
  83935. onButtonUpObservable: Observable<number>;
  83936. /**
  83937. * Callback triggered when a button has been pressed
  83938. * @param callback Called when a button has been pressed
  83939. */
  83940. onbuttondown(callback: (buttonPressed: number) => void): void;
  83941. /**
  83942. * Callback triggered when a button has been released
  83943. * @param callback Called when a button has been released
  83944. */
  83945. onbuttonup(callback: (buttonReleased: number) => void): void;
  83946. /**
  83947. * Initializes the generic gamepad
  83948. * @param id The id of the generic gamepad
  83949. * @param index The index of the generic gamepad
  83950. * @param browserGamepad The browser gamepad
  83951. */
  83952. constructor(id: string, index: number, browserGamepad: any);
  83953. private _setButtonValue;
  83954. /**
  83955. * Updates the generic gamepad
  83956. */
  83957. update(): void;
  83958. /**
  83959. * Disposes the generic gamepad
  83960. */
  83961. dispose(): void;
  83962. }
  83963. }
  83964. declare module BABYLON {
  83965. interface Engine {
  83966. /**
  83967. * Creates a raw texture
  83968. * @param data defines the data to store in the texture
  83969. * @param width defines the width of the texture
  83970. * @param height defines the height of the texture
  83971. * @param format defines the format of the data
  83972. * @param generateMipMaps defines if the engine should generate the mip levels
  83973. * @param invertY defines if data must be stored with Y axis inverted
  83974. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83975. * @param compression defines the compression used (null by default)
  83976. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83977. * @returns the raw texture inside an InternalTexture
  83978. */
  83979. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83980. /**
  83981. * Update a raw texture
  83982. * @param texture defines the texture to update
  83983. * @param data defines the data to store in the texture
  83984. * @param format defines the format of the data
  83985. * @param invertY defines if data must be stored with Y axis inverted
  83986. */
  83987. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83988. /**
  83989. * Update a raw texture
  83990. * @param texture defines the texture to update
  83991. * @param data defines the data to store in the texture
  83992. * @param format defines the format of the data
  83993. * @param invertY defines if data must be stored with Y axis inverted
  83994. * @param compression defines the compression used (null by default)
  83995. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83996. */
  83997. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83998. /**
  83999. * Creates a new raw cube texture
  84000. * @param data defines the array of data to use to create each face
  84001. * @param size defines the size of the textures
  84002. * @param format defines the format of the data
  84003. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84004. * @param generateMipMaps defines if the engine should generate the mip levels
  84005. * @param invertY defines if data must be stored with Y axis inverted
  84006. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84007. * @param compression defines the compression used (null by default)
  84008. * @returns the cube texture as an InternalTexture
  84009. */
  84010. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84011. /**
  84012. * Update a raw cube texture
  84013. * @param texture defines the texture to udpdate
  84014. * @param data defines the data to store
  84015. * @param format defines the data format
  84016. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84017. * @param invertY defines if data must be stored with Y axis inverted
  84018. */
  84019. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84020. /**
  84021. * Update a raw cube texture
  84022. * @param texture defines the texture to udpdate
  84023. * @param data defines the data to store
  84024. * @param format defines the data format
  84025. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84026. * @param invertY defines if data must be stored with Y axis inverted
  84027. * @param compression defines the compression used (null by default)
  84028. */
  84029. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84030. /**
  84031. * Update a raw cube texture
  84032. * @param texture defines the texture to udpdate
  84033. * @param data defines the data to store
  84034. * @param format defines the data format
  84035. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84036. * @param invertY defines if data must be stored with Y axis inverted
  84037. * @param compression defines the compression used (null by default)
  84038. * @param level defines which level of the texture to update
  84039. */
  84040. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84041. /**
  84042. * Creates a new raw cube texture from a specified url
  84043. * @param url defines the url where the data is located
  84044. * @param scene defines the current scene
  84045. * @param size defines the size of the textures
  84046. * @param format defines the format of the data
  84047. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84048. * @param noMipmap defines if the engine should avoid generating the mip levels
  84049. * @param callback defines a callback used to extract texture data from loaded data
  84050. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84051. * @param onLoad defines a callback called when texture is loaded
  84052. * @param onError defines a callback called if there is an error
  84053. * @returns the cube texture as an InternalTexture
  84054. */
  84055. 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;
  84056. /**
  84057. * Creates a new raw cube texture from a specified url
  84058. * @param url defines the url where the data is located
  84059. * @param scene defines the current scene
  84060. * @param size defines the size of the textures
  84061. * @param format defines the format of the data
  84062. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84063. * @param noMipmap defines if the engine should avoid generating the mip levels
  84064. * @param callback defines a callback used to extract texture data from loaded data
  84065. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84066. * @param onLoad defines a callback called when texture is loaded
  84067. * @param onError defines a callback called if there is an error
  84068. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84069. * @param invertY defines if data must be stored with Y axis inverted
  84070. * @returns the cube texture as an InternalTexture
  84071. */
  84072. 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;
  84073. /**
  84074. * Creates a new raw 3D texture
  84075. * @param data defines the data used to create the texture
  84076. * @param width defines the width of the texture
  84077. * @param height defines the height of the texture
  84078. * @param depth defines the depth of the texture
  84079. * @param format defines the format of the texture
  84080. * @param generateMipMaps defines if the engine must generate mip levels
  84081. * @param invertY defines if data must be stored with Y axis inverted
  84082. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84083. * @param compression defines the compressed used (can be null)
  84084. * @param textureType defines the compressed used (can be null)
  84085. * @returns a new raw 3D texture (stored in an InternalTexture)
  84086. */
  84087. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84088. /**
  84089. * Update a raw 3D texture
  84090. * @param texture defines the texture to update
  84091. * @param data defines the data to store
  84092. * @param format defines the data format
  84093. * @param invertY defines if data must be stored with Y axis inverted
  84094. */
  84095. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84096. /**
  84097. * Update a raw 3D texture
  84098. * @param texture defines the texture to update
  84099. * @param data defines the data to store
  84100. * @param format defines the data format
  84101. * @param invertY defines if data must be stored with Y axis inverted
  84102. * @param compression defines the used compression (can be null)
  84103. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84104. */
  84105. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84106. /**
  84107. * Creates a new raw 2D array texture
  84108. * @param data defines the data used to create the texture
  84109. * @param width defines the width of the texture
  84110. * @param height defines the height of the texture
  84111. * @param depth defines the number of layers of the texture
  84112. * @param format defines the format of the texture
  84113. * @param generateMipMaps defines if the engine must generate mip levels
  84114. * @param invertY defines if data must be stored with Y axis inverted
  84115. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84116. * @param compression defines the compressed used (can be null)
  84117. * @param textureType defines the compressed used (can be null)
  84118. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84119. */
  84120. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84121. /**
  84122. * Update a raw 2D array texture
  84123. * @param texture defines the texture to update
  84124. * @param data defines the data to store
  84125. * @param format defines the data format
  84126. * @param invertY defines if data must be stored with Y axis inverted
  84127. */
  84128. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84129. /**
  84130. * Update a raw 2D array texture
  84131. * @param texture defines the texture to update
  84132. * @param data defines the data to store
  84133. * @param format defines the data format
  84134. * @param invertY defines if data must be stored with Y axis inverted
  84135. * @param compression defines the used compression (can be null)
  84136. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84137. */
  84138. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84139. }
  84140. }
  84141. declare module BABYLON {
  84142. /**
  84143. * Raw texture can help creating a texture directly from an array of data.
  84144. * This can be super useful if you either get the data from an uncompressed source or
  84145. * if you wish to create your texture pixel by pixel.
  84146. */
  84147. export class RawTexture extends Texture {
  84148. /**
  84149. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84150. */
  84151. format: number;
  84152. private _engine;
  84153. /**
  84154. * Instantiates a new RawTexture.
  84155. * Raw texture can help creating a texture directly from an array of data.
  84156. * This can be super useful if you either get the data from an uncompressed source or
  84157. * if you wish to create your texture pixel by pixel.
  84158. * @param data define the array of data to use to create the texture
  84159. * @param width define the width of the texture
  84160. * @param height define the height of the texture
  84161. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84162. * @param scene define the scene the texture belongs to
  84163. * @param generateMipMaps define whether mip maps should be generated or not
  84164. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84165. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84166. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84167. */
  84168. constructor(data: ArrayBufferView, width: number, height: number,
  84169. /**
  84170. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84171. */
  84172. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84173. /**
  84174. * Updates the texture underlying data.
  84175. * @param data Define the new data of the texture
  84176. */
  84177. update(data: ArrayBufferView): void;
  84178. /**
  84179. * Creates a luminance texture from some data.
  84180. * @param data Define the texture data
  84181. * @param width Define the width of the texture
  84182. * @param height Define the height of the texture
  84183. * @param scene Define the scene the texture belongs to
  84184. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84185. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84186. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84187. * @returns the luminance texture
  84188. */
  84189. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84190. /**
  84191. * Creates a luminance alpha texture from some data.
  84192. * @param data Define the texture data
  84193. * @param width Define the width of the texture
  84194. * @param height Define the height of the texture
  84195. * @param scene Define the scene the texture belongs to
  84196. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84197. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84198. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84199. * @returns the luminance alpha texture
  84200. */
  84201. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84202. /**
  84203. * Creates an alpha texture from some data.
  84204. * @param data Define the texture data
  84205. * @param width Define the width of the texture
  84206. * @param height Define the height of the texture
  84207. * @param scene Define the scene the texture belongs to
  84208. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84209. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84210. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84211. * @returns the alpha texture
  84212. */
  84213. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84214. /**
  84215. * Creates a RGB texture from some data.
  84216. * @param data Define the texture data
  84217. * @param width Define the width of the texture
  84218. * @param height Define the height of the texture
  84219. * @param scene Define the scene the texture belongs to
  84220. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84221. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84222. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84223. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84224. * @returns the RGB alpha texture
  84225. */
  84226. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84227. /**
  84228. * Creates a RGBA texture from some data.
  84229. * @param data Define the texture data
  84230. * @param width Define the width of the texture
  84231. * @param height Define the height of the texture
  84232. * @param scene Define the scene the texture belongs to
  84233. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84234. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84235. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84236. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84237. * @returns the RGBA texture
  84238. */
  84239. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84240. /**
  84241. * Creates a R texture from some data.
  84242. * @param data Define the texture data
  84243. * @param width Define the width of the texture
  84244. * @param height Define the height of the texture
  84245. * @param scene Define the scene the texture belongs to
  84246. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84247. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84248. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84249. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84250. * @returns the R texture
  84251. */
  84252. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84253. }
  84254. }
  84255. declare module BABYLON {
  84256. /**
  84257. * Interface for the size containing width and height
  84258. */
  84259. export interface ISize {
  84260. /**
  84261. * Width
  84262. */
  84263. width: number;
  84264. /**
  84265. * Heighht
  84266. */
  84267. height: number;
  84268. }
  84269. /**
  84270. * Size containing widht and height
  84271. */
  84272. export class Size implements ISize {
  84273. /**
  84274. * Width
  84275. */
  84276. width: number;
  84277. /**
  84278. * Height
  84279. */
  84280. height: number;
  84281. /**
  84282. * Creates a Size object from the given width and height (floats).
  84283. * @param width width of the new size
  84284. * @param height height of the new size
  84285. */
  84286. constructor(width: number, height: number);
  84287. /**
  84288. * Returns a string with the Size width and height
  84289. * @returns a string with the Size width and height
  84290. */
  84291. toString(): string;
  84292. /**
  84293. * "Size"
  84294. * @returns the string "Size"
  84295. */
  84296. getClassName(): string;
  84297. /**
  84298. * Returns the Size hash code.
  84299. * @returns a hash code for a unique width and height
  84300. */
  84301. getHashCode(): number;
  84302. /**
  84303. * Updates the current size from the given one.
  84304. * @param src the given size
  84305. */
  84306. copyFrom(src: Size): void;
  84307. /**
  84308. * Updates in place the current Size from the given floats.
  84309. * @param width width of the new size
  84310. * @param height height of the new size
  84311. * @returns the updated Size.
  84312. */
  84313. copyFromFloats(width: number, height: number): Size;
  84314. /**
  84315. * Updates in place the current Size from the given floats.
  84316. * @param width width to set
  84317. * @param height height to set
  84318. * @returns the updated Size.
  84319. */
  84320. set(width: number, height: number): Size;
  84321. /**
  84322. * Multiplies the width and height by numbers
  84323. * @param w factor to multiple the width by
  84324. * @param h factor to multiple the height by
  84325. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84326. */
  84327. multiplyByFloats(w: number, h: number): Size;
  84328. /**
  84329. * Clones the size
  84330. * @returns a new Size copied from the given one.
  84331. */
  84332. clone(): Size;
  84333. /**
  84334. * True if the current Size and the given one width and height are strictly equal.
  84335. * @param other the other size to compare against
  84336. * @returns True if the current Size and the given one width and height are strictly equal.
  84337. */
  84338. equals(other: Size): boolean;
  84339. /**
  84340. * The surface of the Size : width * height (float).
  84341. */
  84342. get surface(): number;
  84343. /**
  84344. * Create a new size of zero
  84345. * @returns a new Size set to (0.0, 0.0)
  84346. */
  84347. static Zero(): Size;
  84348. /**
  84349. * Sums the width and height of two sizes
  84350. * @param otherSize size to add to this size
  84351. * @returns a new Size set as the addition result of the current Size and the given one.
  84352. */
  84353. add(otherSize: Size): Size;
  84354. /**
  84355. * Subtracts the width and height of two
  84356. * @param otherSize size to subtract to this size
  84357. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84358. */
  84359. subtract(otherSize: Size): Size;
  84360. /**
  84361. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84362. * @param start starting size to lerp between
  84363. * @param end end size to lerp between
  84364. * @param amount amount to lerp between the start and end values
  84365. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84366. */
  84367. static Lerp(start: Size, end: Size, amount: number): Size;
  84368. }
  84369. }
  84370. declare module BABYLON {
  84371. /**
  84372. * Defines a runtime animation
  84373. */
  84374. export class RuntimeAnimation {
  84375. private _events;
  84376. /**
  84377. * The current frame of the runtime animation
  84378. */
  84379. private _currentFrame;
  84380. /**
  84381. * The animation used by the runtime animation
  84382. */
  84383. private _animation;
  84384. /**
  84385. * The target of the runtime animation
  84386. */
  84387. private _target;
  84388. /**
  84389. * The initiating animatable
  84390. */
  84391. private _host;
  84392. /**
  84393. * The original value of the runtime animation
  84394. */
  84395. private _originalValue;
  84396. /**
  84397. * The original blend value of the runtime animation
  84398. */
  84399. private _originalBlendValue;
  84400. /**
  84401. * The offsets cache of the runtime animation
  84402. */
  84403. private _offsetsCache;
  84404. /**
  84405. * The high limits cache of the runtime animation
  84406. */
  84407. private _highLimitsCache;
  84408. /**
  84409. * Specifies if the runtime animation has been stopped
  84410. */
  84411. private _stopped;
  84412. /**
  84413. * The blending factor of the runtime animation
  84414. */
  84415. private _blendingFactor;
  84416. /**
  84417. * The BabylonJS scene
  84418. */
  84419. private _scene;
  84420. /**
  84421. * The current value of the runtime animation
  84422. */
  84423. private _currentValue;
  84424. /** @hidden */
  84425. _animationState: _IAnimationState;
  84426. /**
  84427. * The active target of the runtime animation
  84428. */
  84429. private _activeTargets;
  84430. private _currentActiveTarget;
  84431. private _directTarget;
  84432. /**
  84433. * The target path of the runtime animation
  84434. */
  84435. private _targetPath;
  84436. /**
  84437. * The weight of the runtime animation
  84438. */
  84439. private _weight;
  84440. /**
  84441. * The ratio offset of the runtime animation
  84442. */
  84443. private _ratioOffset;
  84444. /**
  84445. * The previous delay of the runtime animation
  84446. */
  84447. private _previousDelay;
  84448. /**
  84449. * The previous ratio of the runtime animation
  84450. */
  84451. private _previousRatio;
  84452. private _enableBlending;
  84453. private _keys;
  84454. private _minFrame;
  84455. private _maxFrame;
  84456. private _minValue;
  84457. private _maxValue;
  84458. private _targetIsArray;
  84459. /**
  84460. * Gets the current frame of the runtime animation
  84461. */
  84462. get currentFrame(): number;
  84463. /**
  84464. * Gets the weight of the runtime animation
  84465. */
  84466. get weight(): number;
  84467. /**
  84468. * Gets the current value of the runtime animation
  84469. */
  84470. get currentValue(): any;
  84471. /**
  84472. * Gets the target path of the runtime animation
  84473. */
  84474. get targetPath(): string;
  84475. /**
  84476. * Gets the actual target of the runtime animation
  84477. */
  84478. get target(): any;
  84479. /** @hidden */
  84480. _onLoop: () => void;
  84481. /**
  84482. * Create a new RuntimeAnimation object
  84483. * @param target defines the target of the animation
  84484. * @param animation defines the source animation object
  84485. * @param scene defines the hosting scene
  84486. * @param host defines the initiating Animatable
  84487. */
  84488. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  84489. private _preparePath;
  84490. /**
  84491. * Gets the animation from the runtime animation
  84492. */
  84493. get animation(): Animation;
  84494. /**
  84495. * Resets the runtime animation to the beginning
  84496. * @param restoreOriginal defines whether to restore the target property to the original value
  84497. */
  84498. reset(restoreOriginal?: boolean): void;
  84499. /**
  84500. * Specifies if the runtime animation is stopped
  84501. * @returns Boolean specifying if the runtime animation is stopped
  84502. */
  84503. isStopped(): boolean;
  84504. /**
  84505. * Disposes of the runtime animation
  84506. */
  84507. dispose(): void;
  84508. /**
  84509. * Apply the interpolated value to the target
  84510. * @param currentValue defines the value computed by the animation
  84511. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  84512. */
  84513. setValue(currentValue: any, weight: number): void;
  84514. private _getOriginalValues;
  84515. private _setValue;
  84516. /**
  84517. * Gets the loop pmode of the runtime animation
  84518. * @returns Loop Mode
  84519. */
  84520. private _getCorrectLoopMode;
  84521. /**
  84522. * Move the current animation to a given frame
  84523. * @param frame defines the frame to move to
  84524. */
  84525. goToFrame(frame: number): void;
  84526. /**
  84527. * @hidden Internal use only
  84528. */
  84529. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  84530. /**
  84531. * Execute the current animation
  84532. * @param delay defines the delay to add to the current frame
  84533. * @param from defines the lower bound of the animation range
  84534. * @param to defines the upper bound of the animation range
  84535. * @param loop defines if the current animation must loop
  84536. * @param speedRatio defines the current speed ratio
  84537. * @param weight defines the weight of the animation (default is -1 so no weight)
  84538. * @param onLoop optional callback called when animation loops
  84539. * @returns a boolean indicating if the animation is running
  84540. */
  84541. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  84542. }
  84543. }
  84544. declare module BABYLON {
  84545. /**
  84546. * Class used to store an actual running animation
  84547. */
  84548. export class Animatable {
  84549. /** defines the target object */
  84550. target: any;
  84551. /** defines the starting frame number (default is 0) */
  84552. fromFrame: number;
  84553. /** defines the ending frame number (default is 100) */
  84554. toFrame: number;
  84555. /** defines if the animation must loop (default is false) */
  84556. loopAnimation: boolean;
  84557. /** defines a callback to call when animation ends if it is not looping */
  84558. onAnimationEnd?: (() => void) | null | undefined;
  84559. /** defines a callback to call when animation loops */
  84560. onAnimationLoop?: (() => void) | null | undefined;
  84561. private _localDelayOffset;
  84562. private _pausedDelay;
  84563. private _runtimeAnimations;
  84564. private _paused;
  84565. private _scene;
  84566. private _speedRatio;
  84567. private _weight;
  84568. private _syncRoot;
  84569. /**
  84570. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  84571. * This will only apply for non looping animation (default is true)
  84572. */
  84573. disposeOnEnd: boolean;
  84574. /**
  84575. * Gets a boolean indicating if the animation has started
  84576. */
  84577. animationStarted: boolean;
  84578. /**
  84579. * Observer raised when the animation ends
  84580. */
  84581. onAnimationEndObservable: Observable<Animatable>;
  84582. /**
  84583. * Observer raised when the animation loops
  84584. */
  84585. onAnimationLoopObservable: Observable<Animatable>;
  84586. /**
  84587. * Gets the root Animatable used to synchronize and normalize animations
  84588. */
  84589. get syncRoot(): Nullable<Animatable>;
  84590. /**
  84591. * Gets the current frame of the first RuntimeAnimation
  84592. * Used to synchronize Animatables
  84593. */
  84594. get masterFrame(): number;
  84595. /**
  84596. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  84597. */
  84598. get weight(): number;
  84599. set weight(value: number);
  84600. /**
  84601. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  84602. */
  84603. get speedRatio(): number;
  84604. set speedRatio(value: number);
  84605. /**
  84606. * Creates a new Animatable
  84607. * @param scene defines the hosting scene
  84608. * @param target defines the target object
  84609. * @param fromFrame defines the starting frame number (default is 0)
  84610. * @param toFrame defines the ending frame number (default is 100)
  84611. * @param loopAnimation defines if the animation must loop (default is false)
  84612. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  84613. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  84614. * @param animations defines a group of animation to add to the new Animatable
  84615. * @param onAnimationLoop defines a callback to call when animation loops
  84616. */
  84617. constructor(scene: Scene,
  84618. /** defines the target object */
  84619. target: any,
  84620. /** defines the starting frame number (default is 0) */
  84621. fromFrame?: number,
  84622. /** defines the ending frame number (default is 100) */
  84623. toFrame?: number,
  84624. /** defines if the animation must loop (default is false) */
  84625. loopAnimation?: boolean, speedRatio?: number,
  84626. /** defines a callback to call when animation ends if it is not looping */
  84627. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  84628. /** defines a callback to call when animation loops */
  84629. onAnimationLoop?: (() => void) | null | undefined);
  84630. /**
  84631. * Synchronize and normalize current Animatable with a source Animatable
  84632. * This is useful when using animation weights and when animations are not of the same length
  84633. * @param root defines the root Animatable to synchronize with
  84634. * @returns the current Animatable
  84635. */
  84636. syncWith(root: Animatable): Animatable;
  84637. /**
  84638. * Gets the list of runtime animations
  84639. * @returns an array of RuntimeAnimation
  84640. */
  84641. getAnimations(): RuntimeAnimation[];
  84642. /**
  84643. * Adds more animations to the current animatable
  84644. * @param target defines the target of the animations
  84645. * @param animations defines the new animations to add
  84646. */
  84647. appendAnimations(target: any, animations: Animation[]): void;
  84648. /**
  84649. * Gets the source animation for a specific property
  84650. * @param property defines the propertyu to look for
  84651. * @returns null or the source animation for the given property
  84652. */
  84653. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  84654. /**
  84655. * Gets the runtime animation for a specific property
  84656. * @param property defines the propertyu to look for
  84657. * @returns null or the runtime animation for the given property
  84658. */
  84659. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  84660. /**
  84661. * Resets the animatable to its original state
  84662. */
  84663. reset(): void;
  84664. /**
  84665. * Allows the animatable to blend with current running animations
  84666. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84667. * @param blendingSpeed defines the blending speed to use
  84668. */
  84669. enableBlending(blendingSpeed: number): void;
  84670. /**
  84671. * Disable animation blending
  84672. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84673. */
  84674. disableBlending(): void;
  84675. /**
  84676. * Jump directly to a given frame
  84677. * @param frame defines the frame to jump to
  84678. */
  84679. goToFrame(frame: number): void;
  84680. /**
  84681. * Pause the animation
  84682. */
  84683. pause(): void;
  84684. /**
  84685. * Restart the animation
  84686. */
  84687. restart(): void;
  84688. private _raiseOnAnimationEnd;
  84689. /**
  84690. * Stop and delete the current animation
  84691. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  84692. * @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)
  84693. */
  84694. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  84695. /**
  84696. * Wait asynchronously for the animation to end
  84697. * @returns a promise which will be fullfilled when the animation ends
  84698. */
  84699. waitAsync(): Promise<Animatable>;
  84700. /** @hidden */
  84701. _animate(delay: number): boolean;
  84702. }
  84703. interface Scene {
  84704. /** @hidden */
  84705. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  84706. /** @hidden */
  84707. _processLateAnimationBindingsForMatrices(holder: {
  84708. totalWeight: number;
  84709. animations: RuntimeAnimation[];
  84710. originalValue: Matrix;
  84711. }): any;
  84712. /** @hidden */
  84713. _processLateAnimationBindingsForQuaternions(holder: {
  84714. totalWeight: number;
  84715. animations: RuntimeAnimation[];
  84716. originalValue: Quaternion;
  84717. }, refQuaternion: Quaternion): Quaternion;
  84718. /** @hidden */
  84719. _processLateAnimationBindings(): void;
  84720. /**
  84721. * Will start the animation sequence of a given target
  84722. * @param target defines the target
  84723. * @param from defines from which frame should animation start
  84724. * @param to defines until which frame should animation run.
  84725. * @param weight defines the weight to apply to the animation (1.0 by default)
  84726. * @param loop defines if the animation loops
  84727. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84728. * @param onAnimationEnd defines the function to be executed when the animation ends
  84729. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84730. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84731. * @param onAnimationLoop defines the callback to call when an animation loops
  84732. * @returns the animatable object created for this animation
  84733. */
  84734. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84735. /**
  84736. * Will start the animation sequence of a given target
  84737. * @param target defines the target
  84738. * @param from defines from which frame should animation start
  84739. * @param to defines until which frame should animation run.
  84740. * @param loop defines if the animation loops
  84741. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84742. * @param onAnimationEnd defines the function to be executed when the animation ends
  84743. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84744. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84745. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  84746. * @param onAnimationLoop defines the callback to call when an animation loops
  84747. * @returns the animatable object created for this animation
  84748. */
  84749. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84750. /**
  84751. * Will start the animation sequence of a given target and its hierarchy
  84752. * @param target defines the target
  84753. * @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.
  84754. * @param from defines from which frame should animation start
  84755. * @param to defines until which frame should animation run.
  84756. * @param loop defines if the animation loops
  84757. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84758. * @param onAnimationEnd defines the function to be executed when the animation ends
  84759. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84760. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84761. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84762. * @param onAnimationLoop defines the callback to call when an animation loops
  84763. * @returns the list of created animatables
  84764. */
  84765. 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[];
  84766. /**
  84767. * Begin a new animation on a given node
  84768. * @param target defines the target where the animation will take place
  84769. * @param animations defines the list of animations to start
  84770. * @param from defines the initial value
  84771. * @param to defines the final value
  84772. * @param loop defines if you want animation to loop (off by default)
  84773. * @param speedRatio defines the speed ratio to apply to all animations
  84774. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84775. * @param onAnimationLoop defines the callback to call when an animation loops
  84776. * @returns the list of created animatables
  84777. */
  84778. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  84779. /**
  84780. * Begin a new animation on a given node and its hierarchy
  84781. * @param target defines the root node where the animation will take place
  84782. * @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.
  84783. * @param animations defines the list of animations to start
  84784. * @param from defines the initial value
  84785. * @param to defines the final value
  84786. * @param loop defines if you want animation to loop (off by default)
  84787. * @param speedRatio defines the speed ratio to apply to all animations
  84788. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84789. * @param onAnimationLoop defines the callback to call when an animation loops
  84790. * @returns the list of animatables created for all nodes
  84791. */
  84792. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  84793. /**
  84794. * Gets the animatable associated with a specific target
  84795. * @param target defines the target of the animatable
  84796. * @returns the required animatable if found
  84797. */
  84798. getAnimatableByTarget(target: any): Nullable<Animatable>;
  84799. /**
  84800. * Gets all animatables associated with a given target
  84801. * @param target defines the target to look animatables for
  84802. * @returns an array of Animatables
  84803. */
  84804. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  84805. /**
  84806. * Stops and removes all animations that have been applied to the scene
  84807. */
  84808. stopAllAnimations(): void;
  84809. /**
  84810. * Gets the current delta time used by animation engine
  84811. */
  84812. deltaTime: number;
  84813. }
  84814. interface Bone {
  84815. /**
  84816. * Copy an animation range from another bone
  84817. * @param source defines the source bone
  84818. * @param rangeName defines the range name to copy
  84819. * @param frameOffset defines the frame offset
  84820. * @param rescaleAsRequired defines if rescaling must be applied if required
  84821. * @param skelDimensionsRatio defines the scaling ratio
  84822. * @returns true if operation was successful
  84823. */
  84824. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  84825. }
  84826. }
  84827. declare module BABYLON {
  84828. /**
  84829. * Class used to override all child animations of a given target
  84830. */
  84831. export class AnimationPropertiesOverride {
  84832. /**
  84833. * Gets or sets a value indicating if animation blending must be used
  84834. */
  84835. enableBlending: boolean;
  84836. /**
  84837. * Gets or sets the blending speed to use when enableBlending is true
  84838. */
  84839. blendingSpeed: number;
  84840. /**
  84841. * Gets or sets the default loop mode to use
  84842. */
  84843. loopMode: number;
  84844. }
  84845. }
  84846. declare module BABYLON {
  84847. /**
  84848. * Class used to handle skinning animations
  84849. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84850. */
  84851. export class Skeleton implements IAnimatable {
  84852. /** defines the skeleton name */
  84853. name: string;
  84854. /** defines the skeleton Id */
  84855. id: string;
  84856. /**
  84857. * Defines the list of child bones
  84858. */
  84859. bones: Bone[];
  84860. /**
  84861. * Defines an estimate of the dimension of the skeleton at rest
  84862. */
  84863. dimensionsAtRest: Vector3;
  84864. /**
  84865. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84866. */
  84867. needInitialSkinMatrix: boolean;
  84868. /**
  84869. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84870. */
  84871. overrideMesh: Nullable<AbstractMesh>;
  84872. /**
  84873. * Gets the list of animations attached to this skeleton
  84874. */
  84875. animations: Array<Animation>;
  84876. private _scene;
  84877. private _isDirty;
  84878. private _transformMatrices;
  84879. private _transformMatrixTexture;
  84880. private _meshesWithPoseMatrix;
  84881. private _animatables;
  84882. private _identity;
  84883. private _synchronizedWithMesh;
  84884. private _ranges;
  84885. private _lastAbsoluteTransformsUpdateId;
  84886. private _canUseTextureForBones;
  84887. private _uniqueId;
  84888. /** @hidden */
  84889. _numBonesWithLinkedTransformNode: number;
  84890. /** @hidden */
  84891. _hasWaitingData: Nullable<boolean>;
  84892. /**
  84893. * Specifies if the skeleton should be serialized
  84894. */
  84895. doNotSerialize: boolean;
  84896. private _useTextureToStoreBoneMatrices;
  84897. /**
  84898. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84899. * Please note that this option is not available if the hardware does not support it
  84900. */
  84901. get useTextureToStoreBoneMatrices(): boolean;
  84902. set useTextureToStoreBoneMatrices(value: boolean);
  84903. private _animationPropertiesOverride;
  84904. /**
  84905. * Gets or sets the animation properties override
  84906. */
  84907. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84908. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84909. /**
  84910. * List of inspectable custom properties (used by the Inspector)
  84911. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84912. */
  84913. inspectableCustomProperties: IInspectable[];
  84914. /**
  84915. * An observable triggered before computing the skeleton's matrices
  84916. */
  84917. onBeforeComputeObservable: Observable<Skeleton>;
  84918. /**
  84919. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84920. */
  84921. get isUsingTextureForMatrices(): boolean;
  84922. /**
  84923. * Gets the unique ID of this skeleton
  84924. */
  84925. get uniqueId(): number;
  84926. /**
  84927. * Creates a new skeleton
  84928. * @param name defines the skeleton name
  84929. * @param id defines the skeleton Id
  84930. * @param scene defines the hosting scene
  84931. */
  84932. constructor(
  84933. /** defines the skeleton name */
  84934. name: string,
  84935. /** defines the skeleton Id */
  84936. id: string, scene: Scene);
  84937. /**
  84938. * Gets the current object class name.
  84939. * @return the class name
  84940. */
  84941. getClassName(): string;
  84942. /**
  84943. * Returns an array containing the root bones
  84944. * @returns an array containing the root bones
  84945. */
  84946. getChildren(): Array<Bone>;
  84947. /**
  84948. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84949. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84950. * @returns a Float32Array containing matrices data
  84951. */
  84952. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84953. /**
  84954. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84955. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84956. * @returns a raw texture containing the data
  84957. */
  84958. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84959. /**
  84960. * Gets the current hosting scene
  84961. * @returns a scene object
  84962. */
  84963. getScene(): Scene;
  84964. /**
  84965. * Gets a string representing the current skeleton data
  84966. * @param fullDetails defines a boolean indicating if we want a verbose version
  84967. * @returns a string representing the current skeleton data
  84968. */
  84969. toString(fullDetails?: boolean): string;
  84970. /**
  84971. * Get bone's index searching by name
  84972. * @param name defines bone's name to search for
  84973. * @return the indice of the bone. Returns -1 if not found
  84974. */
  84975. getBoneIndexByName(name: string): number;
  84976. /**
  84977. * Creater a new animation range
  84978. * @param name defines the name of the range
  84979. * @param from defines the start key
  84980. * @param to defines the end key
  84981. */
  84982. createAnimationRange(name: string, from: number, to: number): void;
  84983. /**
  84984. * Delete a specific animation range
  84985. * @param name defines the name of the range
  84986. * @param deleteFrames defines if frames must be removed as well
  84987. */
  84988. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84989. /**
  84990. * Gets a specific animation range
  84991. * @param name defines the name of the range to look for
  84992. * @returns the requested animation range or null if not found
  84993. */
  84994. getAnimationRange(name: string): Nullable<AnimationRange>;
  84995. /**
  84996. * Gets the list of all animation ranges defined on this skeleton
  84997. * @returns an array
  84998. */
  84999. getAnimationRanges(): Nullable<AnimationRange>[];
  85000. /**
  85001. * Copy animation range from a source skeleton.
  85002. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  85003. * @param source defines the source skeleton
  85004. * @param name defines the name of the range to copy
  85005. * @param rescaleAsRequired defines if rescaling must be applied if required
  85006. * @returns true if operation was successful
  85007. */
  85008. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  85009. /**
  85010. * Forces the skeleton to go to rest pose
  85011. */
  85012. returnToRest(): void;
  85013. private _getHighestAnimationFrame;
  85014. /**
  85015. * Begin a specific animation range
  85016. * @param name defines the name of the range to start
  85017. * @param loop defines if looping must be turned on (false by default)
  85018. * @param speedRatio defines the speed ratio to apply (1 by default)
  85019. * @param onAnimationEnd defines a callback which will be called when animation will end
  85020. * @returns a new animatable
  85021. */
  85022. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85023. /** @hidden */
  85024. _markAsDirty(): void;
  85025. /** @hidden */
  85026. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  85027. /** @hidden */
  85028. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  85029. private _computeTransformMatrices;
  85030. /**
  85031. * Build all resources required to render a skeleton
  85032. */
  85033. prepare(): void;
  85034. /**
  85035. * Gets the list of animatables currently running for this skeleton
  85036. * @returns an array of animatables
  85037. */
  85038. getAnimatables(): IAnimatable[];
  85039. /**
  85040. * Clone the current skeleton
  85041. * @param name defines the name of the new skeleton
  85042. * @param id defines the id of the new skeleton
  85043. * @returns the new skeleton
  85044. */
  85045. clone(name: string, id?: string): Skeleton;
  85046. /**
  85047. * Enable animation blending for this skeleton
  85048. * @param blendingSpeed defines the blending speed to apply
  85049. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85050. */
  85051. enableBlending(blendingSpeed?: number): void;
  85052. /**
  85053. * Releases all resources associated with the current skeleton
  85054. */
  85055. dispose(): void;
  85056. /**
  85057. * Serialize the skeleton in a JSON object
  85058. * @returns a JSON object
  85059. */
  85060. serialize(): any;
  85061. /**
  85062. * Creates a new skeleton from serialized data
  85063. * @param parsedSkeleton defines the serialized data
  85064. * @param scene defines the hosting scene
  85065. * @returns a new skeleton
  85066. */
  85067. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  85068. /**
  85069. * Compute all node absolute transforms
  85070. * @param forceUpdate defines if computation must be done even if cache is up to date
  85071. */
  85072. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  85073. /**
  85074. * Gets the root pose matrix
  85075. * @returns a matrix
  85076. */
  85077. getPoseMatrix(): Nullable<Matrix>;
  85078. /**
  85079. * Sorts bones per internal index
  85080. */
  85081. sortBones(): void;
  85082. private _sortBones;
  85083. }
  85084. }
  85085. declare module BABYLON {
  85086. /**
  85087. * Class used to store bone information
  85088. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  85089. */
  85090. export class Bone extends Node {
  85091. /**
  85092. * defines the bone name
  85093. */
  85094. name: string;
  85095. private static _tmpVecs;
  85096. private static _tmpQuat;
  85097. private static _tmpMats;
  85098. /**
  85099. * Gets the list of child bones
  85100. */
  85101. children: Bone[];
  85102. /** Gets the animations associated with this bone */
  85103. animations: Animation[];
  85104. /**
  85105. * Gets or sets bone length
  85106. */
  85107. length: number;
  85108. /**
  85109. * @hidden Internal only
  85110. * Set this value to map this bone to a different index in the transform matrices
  85111. * Set this value to -1 to exclude the bone from the transform matrices
  85112. */
  85113. _index: Nullable<number>;
  85114. private _skeleton;
  85115. private _localMatrix;
  85116. private _restPose;
  85117. private _baseMatrix;
  85118. private _absoluteTransform;
  85119. private _invertedAbsoluteTransform;
  85120. private _parent;
  85121. private _scalingDeterminant;
  85122. private _worldTransform;
  85123. private _localScaling;
  85124. private _localRotation;
  85125. private _localPosition;
  85126. private _needToDecompose;
  85127. private _needToCompose;
  85128. /** @hidden */
  85129. _linkedTransformNode: Nullable<TransformNode>;
  85130. /** @hidden */
  85131. _waitingTransformNodeId: Nullable<string>;
  85132. /** @hidden */
  85133. get _matrix(): Matrix;
  85134. /** @hidden */
  85135. set _matrix(value: Matrix);
  85136. /**
  85137. * Create a new bone
  85138. * @param name defines the bone name
  85139. * @param skeleton defines the parent skeleton
  85140. * @param parentBone defines the parent (can be null if the bone is the root)
  85141. * @param localMatrix defines the local matrix
  85142. * @param restPose defines the rest pose matrix
  85143. * @param baseMatrix defines the base matrix
  85144. * @param index defines index of the bone in the hiearchy
  85145. */
  85146. constructor(
  85147. /**
  85148. * defines the bone name
  85149. */
  85150. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  85151. /**
  85152. * Gets the current object class name.
  85153. * @return the class name
  85154. */
  85155. getClassName(): string;
  85156. /**
  85157. * Gets the parent skeleton
  85158. * @returns a skeleton
  85159. */
  85160. getSkeleton(): Skeleton;
  85161. /**
  85162. * Gets parent bone
  85163. * @returns a bone or null if the bone is the root of the bone hierarchy
  85164. */
  85165. getParent(): Nullable<Bone>;
  85166. /**
  85167. * Returns an array containing the root bones
  85168. * @returns an array containing the root bones
  85169. */
  85170. getChildren(): Array<Bone>;
  85171. /**
  85172. * Gets the node index in matrix array generated for rendering
  85173. * @returns the node index
  85174. */
  85175. getIndex(): number;
  85176. /**
  85177. * Sets the parent bone
  85178. * @param parent defines the parent (can be null if the bone is the root)
  85179. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  85180. */
  85181. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  85182. /**
  85183. * Gets the local matrix
  85184. * @returns a matrix
  85185. */
  85186. getLocalMatrix(): Matrix;
  85187. /**
  85188. * Gets the base matrix (initial matrix which remains unchanged)
  85189. * @returns a matrix
  85190. */
  85191. getBaseMatrix(): Matrix;
  85192. /**
  85193. * Gets the rest pose matrix
  85194. * @returns a matrix
  85195. */
  85196. getRestPose(): Matrix;
  85197. /**
  85198. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  85199. */
  85200. getWorldMatrix(): Matrix;
  85201. /**
  85202. * Sets the local matrix to rest pose matrix
  85203. */
  85204. returnToRest(): void;
  85205. /**
  85206. * Gets the inverse of the absolute transform matrix.
  85207. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  85208. * @returns a matrix
  85209. */
  85210. getInvertedAbsoluteTransform(): Matrix;
  85211. /**
  85212. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  85213. * @returns a matrix
  85214. */
  85215. getAbsoluteTransform(): Matrix;
  85216. /**
  85217. * Links with the given transform node.
  85218. * The local matrix of this bone is copied from the transform node every frame.
  85219. * @param transformNode defines the transform node to link to
  85220. */
  85221. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  85222. /**
  85223. * Gets the node used to drive the bone's transformation
  85224. * @returns a transform node or null
  85225. */
  85226. getTransformNode(): Nullable<TransformNode>;
  85227. /** Gets or sets current position (in local space) */
  85228. get position(): Vector3;
  85229. set position(newPosition: Vector3);
  85230. /** Gets or sets current rotation (in local space) */
  85231. get rotation(): Vector3;
  85232. set rotation(newRotation: Vector3);
  85233. /** Gets or sets current rotation quaternion (in local space) */
  85234. get rotationQuaternion(): Quaternion;
  85235. set rotationQuaternion(newRotation: Quaternion);
  85236. /** Gets or sets current scaling (in local space) */
  85237. get scaling(): Vector3;
  85238. set scaling(newScaling: Vector3);
  85239. /**
  85240. * Gets the animation properties override
  85241. */
  85242. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  85243. private _decompose;
  85244. private _compose;
  85245. /**
  85246. * Update the base and local matrices
  85247. * @param matrix defines the new base or local matrix
  85248. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  85249. * @param updateLocalMatrix defines if the local matrix should be updated
  85250. */
  85251. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  85252. /** @hidden */
  85253. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  85254. /**
  85255. * Flag the bone as dirty (Forcing it to update everything)
  85256. */
  85257. markAsDirty(): void;
  85258. /** @hidden */
  85259. _markAsDirtyAndCompose(): void;
  85260. private _markAsDirtyAndDecompose;
  85261. /**
  85262. * Translate the bone in local or world space
  85263. * @param vec The amount to translate the bone
  85264. * @param space The space that the translation is in
  85265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85266. */
  85267. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  85268. /**
  85269. * Set the postion of the bone in local or world space
  85270. * @param position The position to set the bone
  85271. * @param space The space that the position is in
  85272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85273. */
  85274. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  85275. /**
  85276. * Set the absolute position of the bone (world space)
  85277. * @param position The position to set the bone
  85278. * @param mesh The mesh that this bone is attached to
  85279. */
  85280. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  85281. /**
  85282. * Scale the bone on the x, y and z axes (in local space)
  85283. * @param x The amount to scale the bone on the x axis
  85284. * @param y The amount to scale the bone on the y axis
  85285. * @param z The amount to scale the bone on the z axis
  85286. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  85287. */
  85288. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  85289. /**
  85290. * Set the bone scaling in local space
  85291. * @param scale defines the scaling vector
  85292. */
  85293. setScale(scale: Vector3): void;
  85294. /**
  85295. * Gets the current scaling in local space
  85296. * @returns the current scaling vector
  85297. */
  85298. getScale(): Vector3;
  85299. /**
  85300. * Gets the current scaling in local space and stores it in a target vector
  85301. * @param result defines the target vector
  85302. */
  85303. getScaleToRef(result: Vector3): void;
  85304. /**
  85305. * Set the yaw, pitch, and roll of the bone in local or world space
  85306. * @param yaw The rotation of the bone on the y axis
  85307. * @param pitch The rotation of the bone on the x axis
  85308. * @param roll The rotation of the bone on the z axis
  85309. * @param space The space that the axes of rotation are in
  85310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85311. */
  85312. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  85313. /**
  85314. * Add a rotation to the bone on an axis in local or world space
  85315. * @param axis The axis to rotate the bone on
  85316. * @param amount The amount to rotate the bone
  85317. * @param space The space that the axis is in
  85318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85319. */
  85320. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  85321. /**
  85322. * Set the rotation of the bone to a particular axis angle in local or world space
  85323. * @param axis The axis to rotate the bone on
  85324. * @param angle The angle that the bone should be rotated to
  85325. * @param space The space that the axis is in
  85326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85327. */
  85328. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  85329. /**
  85330. * Set the euler rotation of the bone in local of world space
  85331. * @param rotation The euler rotation that the bone should be set to
  85332. * @param space The space that the rotation is in
  85333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85334. */
  85335. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  85336. /**
  85337. * Set the quaternion rotation of the bone in local of world space
  85338. * @param quat The quaternion rotation that the bone should be set to
  85339. * @param space The space that the rotation is in
  85340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85341. */
  85342. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  85343. /**
  85344. * Set the rotation matrix of the bone in local of world space
  85345. * @param rotMat The rotation matrix that the bone should be set to
  85346. * @param space The space that the rotation is in
  85347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85348. */
  85349. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  85350. private _rotateWithMatrix;
  85351. private _getNegativeRotationToRef;
  85352. /**
  85353. * Get the position of the bone in local or world space
  85354. * @param space The space that the returned position is in
  85355. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85356. * @returns The position of the bone
  85357. */
  85358. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  85359. /**
  85360. * Copy the position of the bone to a vector3 in local or world space
  85361. * @param space The space that the returned position is in
  85362. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85363. * @param result The vector3 to copy the position to
  85364. */
  85365. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  85366. /**
  85367. * Get the absolute position of the bone (world space)
  85368. * @param mesh The mesh that this bone is attached to
  85369. * @returns The absolute position of the bone
  85370. */
  85371. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  85372. /**
  85373. * Copy the absolute position of the bone (world space) to the result param
  85374. * @param mesh The mesh that this bone is attached to
  85375. * @param result The vector3 to copy the absolute position to
  85376. */
  85377. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  85378. /**
  85379. * Compute the absolute transforms of this bone and its children
  85380. */
  85381. computeAbsoluteTransforms(): void;
  85382. /**
  85383. * Get the world direction from an axis that is in the local space of the bone
  85384. * @param localAxis The local direction that is used to compute the world direction
  85385. * @param mesh The mesh that this bone is attached to
  85386. * @returns The world direction
  85387. */
  85388. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  85389. /**
  85390. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  85391. * @param localAxis The local direction that is used to compute the world direction
  85392. * @param mesh The mesh that this bone is attached to
  85393. * @param result The vector3 that the world direction will be copied to
  85394. */
  85395. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85396. /**
  85397. * Get the euler rotation of the bone in local or world space
  85398. * @param space The space that the rotation should be in
  85399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85400. * @returns The euler rotation
  85401. */
  85402. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  85403. /**
  85404. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  85405. * @param space The space that the rotation should be in
  85406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85407. * @param result The vector3 that the rotation should be copied to
  85408. */
  85409. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85410. /**
  85411. * Get the quaternion rotation of the bone in either local or world space
  85412. * @param space The space that the rotation should be in
  85413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85414. * @returns The quaternion rotation
  85415. */
  85416. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  85417. /**
  85418. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  85419. * @param space The space that the rotation should be in
  85420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85421. * @param result The quaternion that the rotation should be copied to
  85422. */
  85423. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  85424. /**
  85425. * Get the rotation matrix of the bone in local or world space
  85426. * @param space The space that the rotation should be in
  85427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85428. * @returns The rotation matrix
  85429. */
  85430. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  85431. /**
  85432. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  85433. * @param space The space that the rotation should be in
  85434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85435. * @param result The quaternion that the rotation should be copied to
  85436. */
  85437. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  85438. /**
  85439. * Get the world position of a point that is in the local space of the bone
  85440. * @param position The local position
  85441. * @param mesh The mesh that this bone is attached to
  85442. * @returns The world position
  85443. */
  85444. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  85445. /**
  85446. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  85447. * @param position The local position
  85448. * @param mesh The mesh that this bone is attached to
  85449. * @param result The vector3 that the world position should be copied to
  85450. */
  85451. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85452. /**
  85453. * Get the local position of a point that is in world space
  85454. * @param position The world position
  85455. * @param mesh The mesh that this bone is attached to
  85456. * @returns The local position
  85457. */
  85458. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  85459. /**
  85460. * Get the local position of a point that is in world space and copy it to the result param
  85461. * @param position The world position
  85462. * @param mesh The mesh that this bone is attached to
  85463. * @param result The vector3 that the local position should be copied to
  85464. */
  85465. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85466. }
  85467. }
  85468. declare module BABYLON {
  85469. /**
  85470. * 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.
  85471. * @see https://doc.babylonjs.com/how_to/transformnode
  85472. */
  85473. export class TransformNode extends Node {
  85474. /**
  85475. * Object will not rotate to face the camera
  85476. */
  85477. static BILLBOARDMODE_NONE: number;
  85478. /**
  85479. * Object will rotate to face the camera but only on the x axis
  85480. */
  85481. static BILLBOARDMODE_X: number;
  85482. /**
  85483. * Object will rotate to face the camera but only on the y axis
  85484. */
  85485. static BILLBOARDMODE_Y: number;
  85486. /**
  85487. * Object will rotate to face the camera but only on the z axis
  85488. */
  85489. static BILLBOARDMODE_Z: number;
  85490. /**
  85491. * Object will rotate to face the camera
  85492. */
  85493. static BILLBOARDMODE_ALL: number;
  85494. /**
  85495. * Object will rotate to face the camera's position instead of orientation
  85496. */
  85497. static BILLBOARDMODE_USE_POSITION: number;
  85498. private _forward;
  85499. private _forwardInverted;
  85500. private _up;
  85501. private _right;
  85502. private _rightInverted;
  85503. private _position;
  85504. private _rotation;
  85505. private _rotationQuaternion;
  85506. protected _scaling: Vector3;
  85507. protected _isDirty: boolean;
  85508. private _transformToBoneReferal;
  85509. private _isAbsoluteSynced;
  85510. private _billboardMode;
  85511. /**
  85512. * Gets or sets the billboard mode. Default is 0.
  85513. *
  85514. * | Value | Type | Description |
  85515. * | --- | --- | --- |
  85516. * | 0 | BILLBOARDMODE_NONE | |
  85517. * | 1 | BILLBOARDMODE_X | |
  85518. * | 2 | BILLBOARDMODE_Y | |
  85519. * | 4 | BILLBOARDMODE_Z | |
  85520. * | 7 | BILLBOARDMODE_ALL | |
  85521. *
  85522. */
  85523. get billboardMode(): number;
  85524. set billboardMode(value: number);
  85525. private _preserveParentRotationForBillboard;
  85526. /**
  85527. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  85528. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  85529. */
  85530. get preserveParentRotationForBillboard(): boolean;
  85531. set preserveParentRotationForBillboard(value: boolean);
  85532. /**
  85533. * 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
  85534. */
  85535. scalingDeterminant: number;
  85536. private _infiniteDistance;
  85537. /**
  85538. * Gets or sets the distance of the object to max, often used by skybox
  85539. */
  85540. get infiniteDistance(): boolean;
  85541. set infiniteDistance(value: boolean);
  85542. /**
  85543. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  85544. * By default the system will update normals to compensate
  85545. */
  85546. ignoreNonUniformScaling: boolean;
  85547. /**
  85548. * 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
  85549. */
  85550. reIntegrateRotationIntoRotationQuaternion: boolean;
  85551. /** @hidden */
  85552. _poseMatrix: Nullable<Matrix>;
  85553. /** @hidden */
  85554. _localMatrix: Matrix;
  85555. private _usePivotMatrix;
  85556. private _absolutePosition;
  85557. private _absoluteScaling;
  85558. private _absoluteRotationQuaternion;
  85559. private _pivotMatrix;
  85560. private _pivotMatrixInverse;
  85561. protected _postMultiplyPivotMatrix: boolean;
  85562. protected _isWorldMatrixFrozen: boolean;
  85563. /** @hidden */
  85564. _indexInSceneTransformNodesArray: number;
  85565. /**
  85566. * An event triggered after the world matrix is updated
  85567. */
  85568. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  85569. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  85570. /**
  85571. * Gets a string identifying the name of the class
  85572. * @returns "TransformNode" string
  85573. */
  85574. getClassName(): string;
  85575. /**
  85576. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  85577. */
  85578. get position(): Vector3;
  85579. set position(newPosition: Vector3);
  85580. /**
  85581. * 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)).
  85582. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  85583. */
  85584. get rotation(): Vector3;
  85585. set rotation(newRotation: Vector3);
  85586. /**
  85587. * 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)).
  85588. */
  85589. get scaling(): Vector3;
  85590. set scaling(newScaling: Vector3);
  85591. /**
  85592. * 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).
  85593. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  85594. */
  85595. get rotationQuaternion(): Nullable<Quaternion>;
  85596. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  85597. /**
  85598. * The forward direction of that transform in world space.
  85599. */
  85600. get forward(): Vector3;
  85601. /**
  85602. * The up direction of that transform in world space.
  85603. */
  85604. get up(): Vector3;
  85605. /**
  85606. * The right direction of that transform in world space.
  85607. */
  85608. get right(): Vector3;
  85609. /**
  85610. * Copies the parameter passed Matrix into the mesh Pose matrix.
  85611. * @param matrix the matrix to copy the pose from
  85612. * @returns this TransformNode.
  85613. */
  85614. updatePoseMatrix(matrix: Matrix): TransformNode;
  85615. /**
  85616. * Returns the mesh Pose matrix.
  85617. * @returns the pose matrix
  85618. */
  85619. getPoseMatrix(): Matrix;
  85620. /** @hidden */
  85621. _isSynchronized(): boolean;
  85622. /** @hidden */
  85623. _initCache(): void;
  85624. /**
  85625. * Flag the transform node as dirty (Forcing it to update everything)
  85626. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  85627. * @returns this transform node
  85628. */
  85629. markAsDirty(property: string): TransformNode;
  85630. /**
  85631. * Returns the current mesh absolute position.
  85632. * Returns a Vector3.
  85633. */
  85634. get absolutePosition(): Vector3;
  85635. /**
  85636. * Returns the current mesh absolute scaling.
  85637. * Returns a Vector3.
  85638. */
  85639. get absoluteScaling(): Vector3;
  85640. /**
  85641. * Returns the current mesh absolute rotation.
  85642. * Returns a Quaternion.
  85643. */
  85644. get absoluteRotationQuaternion(): Quaternion;
  85645. /**
  85646. * Sets a new matrix to apply before all other transformation
  85647. * @param matrix defines the transform matrix
  85648. * @returns the current TransformNode
  85649. */
  85650. setPreTransformMatrix(matrix: Matrix): TransformNode;
  85651. /**
  85652. * Sets a new pivot matrix to the current node
  85653. * @param matrix defines the new pivot matrix to use
  85654. * @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
  85655. * @returns the current TransformNode
  85656. */
  85657. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  85658. /**
  85659. * Returns the mesh pivot matrix.
  85660. * Default : Identity.
  85661. * @returns the matrix
  85662. */
  85663. getPivotMatrix(): Matrix;
  85664. /**
  85665. * Instantiate (when possible) or clone that node with its hierarchy
  85666. * @param newParent defines the new parent to use for the instance (or clone)
  85667. * @param options defines options to configure how copy is done
  85668. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  85669. * @returns an instance (or a clone) of the current node with its hiearchy
  85670. */
  85671. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  85672. doNotInstantiate: boolean;
  85673. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  85674. /**
  85675. * Prevents the World matrix to be computed any longer
  85676. * @param newWorldMatrix defines an optional matrix to use as world matrix
  85677. * @returns the TransformNode.
  85678. */
  85679. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  85680. /**
  85681. * Allows back the World matrix computation.
  85682. * @returns the TransformNode.
  85683. */
  85684. unfreezeWorldMatrix(): this;
  85685. /**
  85686. * True if the World matrix has been frozen.
  85687. */
  85688. get isWorldMatrixFrozen(): boolean;
  85689. /**
  85690. * Retuns the mesh absolute position in the World.
  85691. * @returns a Vector3.
  85692. */
  85693. getAbsolutePosition(): Vector3;
  85694. /**
  85695. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  85696. * @param absolutePosition the absolute position to set
  85697. * @returns the TransformNode.
  85698. */
  85699. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  85700. /**
  85701. * Sets the mesh position in its local space.
  85702. * @param vector3 the position to set in localspace
  85703. * @returns the TransformNode.
  85704. */
  85705. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  85706. /**
  85707. * Returns the mesh position in the local space from the current World matrix values.
  85708. * @returns a new Vector3.
  85709. */
  85710. getPositionExpressedInLocalSpace(): Vector3;
  85711. /**
  85712. * Translates the mesh along the passed Vector3 in its local space.
  85713. * @param vector3 the distance to translate in localspace
  85714. * @returns the TransformNode.
  85715. */
  85716. locallyTranslate(vector3: Vector3): TransformNode;
  85717. private static _lookAtVectorCache;
  85718. /**
  85719. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  85720. * @param targetPoint the position (must be in same space as current mesh) to look at
  85721. * @param yawCor optional yaw (y-axis) correction in radians
  85722. * @param pitchCor optional pitch (x-axis) correction in radians
  85723. * @param rollCor optional roll (z-axis) correction in radians
  85724. * @param space the choosen space of the target
  85725. * @returns the TransformNode.
  85726. */
  85727. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  85728. /**
  85729. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85730. * This Vector3 is expressed in the World space.
  85731. * @param localAxis axis to rotate
  85732. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85733. */
  85734. getDirection(localAxis: Vector3): Vector3;
  85735. /**
  85736. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  85737. * localAxis is expressed in the mesh local space.
  85738. * result is computed in the Wordl space from the mesh World matrix.
  85739. * @param localAxis axis to rotate
  85740. * @param result the resulting transformnode
  85741. * @returns this TransformNode.
  85742. */
  85743. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  85744. /**
  85745. * Sets this transform node rotation to the given local axis.
  85746. * @param localAxis the axis in local space
  85747. * @param yawCor optional yaw (y-axis) correction in radians
  85748. * @param pitchCor optional pitch (x-axis) correction in radians
  85749. * @param rollCor optional roll (z-axis) correction in radians
  85750. * @returns this TransformNode
  85751. */
  85752. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  85753. /**
  85754. * Sets a new pivot point to the current node
  85755. * @param point defines the new pivot point to use
  85756. * @param space defines if the point is in world or local space (local by default)
  85757. * @returns the current TransformNode
  85758. */
  85759. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  85760. /**
  85761. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  85762. * @returns the pivot point
  85763. */
  85764. getPivotPoint(): Vector3;
  85765. /**
  85766. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  85767. * @param result the vector3 to store the result
  85768. * @returns this TransformNode.
  85769. */
  85770. getPivotPointToRef(result: Vector3): TransformNode;
  85771. /**
  85772. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  85773. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  85774. */
  85775. getAbsolutePivotPoint(): Vector3;
  85776. /**
  85777. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  85778. * @param result vector3 to store the result
  85779. * @returns this TransformNode.
  85780. */
  85781. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  85782. /**
  85783. * Defines the passed node as the parent of the current node.
  85784. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  85785. * @see https://doc.babylonjs.com/how_to/parenting
  85786. * @param node the node ot set as the parent
  85787. * @returns this TransformNode.
  85788. */
  85789. setParent(node: Nullable<Node>): TransformNode;
  85790. private _nonUniformScaling;
  85791. /**
  85792. * True if the scaling property of this object is non uniform eg. (1,2,1)
  85793. */
  85794. get nonUniformScaling(): boolean;
  85795. /** @hidden */
  85796. _updateNonUniformScalingState(value: boolean): boolean;
  85797. /**
  85798. * Attach the current TransformNode to another TransformNode associated with a bone
  85799. * @param bone Bone affecting the TransformNode
  85800. * @param affectedTransformNode TransformNode associated with the bone
  85801. * @returns this object
  85802. */
  85803. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  85804. /**
  85805. * Detach the transform node if its associated with a bone
  85806. * @returns this object
  85807. */
  85808. detachFromBone(): TransformNode;
  85809. private static _rotationAxisCache;
  85810. /**
  85811. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  85812. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85813. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85814. * The passed axis is also normalized.
  85815. * @param axis the axis to rotate around
  85816. * @param amount the amount to rotate in radians
  85817. * @param space Space to rotate in (Default: local)
  85818. * @returns the TransformNode.
  85819. */
  85820. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  85821. /**
  85822. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  85823. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85824. * The passed axis is also normalized. .
  85825. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  85826. * @param point the point to rotate around
  85827. * @param axis the axis to rotate around
  85828. * @param amount the amount to rotate in radians
  85829. * @returns the TransformNode
  85830. */
  85831. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  85832. /**
  85833. * Translates the mesh along the axis vector for the passed distance in the given space.
  85834. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85835. * @param axis the axis to translate in
  85836. * @param distance the distance to translate
  85837. * @param space Space to rotate in (Default: local)
  85838. * @returns the TransformNode.
  85839. */
  85840. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85841. /**
  85842. * Adds a rotation step to the mesh current rotation.
  85843. * x, y, z are Euler angles expressed in radians.
  85844. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85845. * This means this rotation is made in the mesh local space only.
  85846. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85847. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85848. * ```javascript
  85849. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85850. * ```
  85851. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85852. * 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.
  85853. * @param x Rotation to add
  85854. * @param y Rotation to add
  85855. * @param z Rotation to add
  85856. * @returns the TransformNode.
  85857. */
  85858. addRotation(x: number, y: number, z: number): TransformNode;
  85859. /**
  85860. * @hidden
  85861. */
  85862. protected _getEffectiveParent(): Nullable<Node>;
  85863. /**
  85864. * Computes the world matrix of the node
  85865. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85866. * @returns the world matrix
  85867. */
  85868. computeWorldMatrix(force?: boolean): Matrix;
  85869. protected _afterComputeWorldMatrix(): void;
  85870. /**
  85871. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85872. * @param func callback function to add
  85873. *
  85874. * @returns the TransformNode.
  85875. */
  85876. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85877. /**
  85878. * Removes a registered callback function.
  85879. * @param func callback function to remove
  85880. * @returns the TransformNode.
  85881. */
  85882. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85883. /**
  85884. * Gets the position of the current mesh in camera space
  85885. * @param camera defines the camera to use
  85886. * @returns a position
  85887. */
  85888. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85889. /**
  85890. * Returns the distance from the mesh to the active camera
  85891. * @param camera defines the camera to use
  85892. * @returns the distance
  85893. */
  85894. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85895. /**
  85896. * Clone the current transform node
  85897. * @param name Name of the new clone
  85898. * @param newParent New parent for the clone
  85899. * @param doNotCloneChildren Do not clone children hierarchy
  85900. * @returns the new transform node
  85901. */
  85902. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85903. /**
  85904. * Serializes the objects information.
  85905. * @param currentSerializationObject defines the object to serialize in
  85906. * @returns the serialized object
  85907. */
  85908. serialize(currentSerializationObject?: any): any;
  85909. /**
  85910. * Returns a new TransformNode object parsed from the source provided.
  85911. * @param parsedTransformNode is the source.
  85912. * @param scene the scne the object belongs to
  85913. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85914. * @returns a new TransformNode object parsed from the source provided.
  85915. */
  85916. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85917. /**
  85918. * Get all child-transformNodes of this node
  85919. * @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
  85920. * @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
  85921. * @returns an array of TransformNode
  85922. */
  85923. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85924. /**
  85925. * Releases resources associated with this transform node.
  85926. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85927. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85928. */
  85929. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85930. /**
  85931. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85932. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85933. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85934. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85935. * @returns the current mesh
  85936. */
  85937. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85938. private _syncAbsoluteScalingAndRotation;
  85939. }
  85940. }
  85941. declare module BABYLON {
  85942. /**
  85943. * Defines the types of pose enabled controllers that are supported
  85944. */
  85945. export enum PoseEnabledControllerType {
  85946. /**
  85947. * HTC Vive
  85948. */
  85949. VIVE = 0,
  85950. /**
  85951. * Oculus Rift
  85952. */
  85953. OCULUS = 1,
  85954. /**
  85955. * Windows mixed reality
  85956. */
  85957. WINDOWS = 2,
  85958. /**
  85959. * Samsung gear VR
  85960. */
  85961. GEAR_VR = 3,
  85962. /**
  85963. * Google Daydream
  85964. */
  85965. DAYDREAM = 4,
  85966. /**
  85967. * Generic
  85968. */
  85969. GENERIC = 5
  85970. }
  85971. /**
  85972. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85973. */
  85974. export interface MutableGamepadButton {
  85975. /**
  85976. * Value of the button/trigger
  85977. */
  85978. value: number;
  85979. /**
  85980. * If the button/trigger is currently touched
  85981. */
  85982. touched: boolean;
  85983. /**
  85984. * If the button/trigger is currently pressed
  85985. */
  85986. pressed: boolean;
  85987. }
  85988. /**
  85989. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85990. * @hidden
  85991. */
  85992. export interface ExtendedGamepadButton extends GamepadButton {
  85993. /**
  85994. * If the button/trigger is currently pressed
  85995. */
  85996. readonly pressed: boolean;
  85997. /**
  85998. * If the button/trigger is currently touched
  85999. */
  86000. readonly touched: boolean;
  86001. /**
  86002. * Value of the button/trigger
  86003. */
  86004. readonly value: number;
  86005. }
  86006. /** @hidden */
  86007. export interface _GamePadFactory {
  86008. /**
  86009. * Returns wether or not the current gamepad can be created for this type of controller.
  86010. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  86011. * @returns true if it can be created, otherwise false
  86012. */
  86013. canCreate(gamepadInfo: any): boolean;
  86014. /**
  86015. * Creates a new instance of the Gamepad.
  86016. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  86017. * @returns the new gamepad instance
  86018. */
  86019. create(gamepadInfo: any): Gamepad;
  86020. }
  86021. /**
  86022. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  86023. */
  86024. export class PoseEnabledControllerHelper {
  86025. /** @hidden */
  86026. static _ControllerFactories: _GamePadFactory[];
  86027. /** @hidden */
  86028. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  86029. /**
  86030. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  86031. * @param vrGamepad the gamepad to initialized
  86032. * @returns a vr controller of the type the gamepad identified as
  86033. */
  86034. static InitiateController(vrGamepad: any): Gamepad;
  86035. }
  86036. /**
  86037. * Defines the PoseEnabledController object that contains state of a vr capable controller
  86038. */
  86039. export class PoseEnabledController extends Gamepad implements PoseControlled {
  86040. /**
  86041. * If the controller is used in a webXR session
  86042. */
  86043. isXR: boolean;
  86044. private _deviceRoomPosition;
  86045. private _deviceRoomRotationQuaternion;
  86046. /**
  86047. * The device position in babylon space
  86048. */
  86049. devicePosition: Vector3;
  86050. /**
  86051. * The device rotation in babylon space
  86052. */
  86053. deviceRotationQuaternion: Quaternion;
  86054. /**
  86055. * The scale factor of the device in babylon space
  86056. */
  86057. deviceScaleFactor: number;
  86058. /**
  86059. * (Likely devicePosition should be used instead) The device position in its room space
  86060. */
  86061. position: Vector3;
  86062. /**
  86063. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  86064. */
  86065. rotationQuaternion: Quaternion;
  86066. /**
  86067. * The type of controller (Eg. Windows mixed reality)
  86068. */
  86069. controllerType: PoseEnabledControllerType;
  86070. protected _calculatedPosition: Vector3;
  86071. private _calculatedRotation;
  86072. /**
  86073. * The raw pose from the device
  86074. */
  86075. rawPose: DevicePose;
  86076. private _trackPosition;
  86077. private _maxRotationDistFromHeadset;
  86078. private _draggedRoomRotation;
  86079. /**
  86080. * @hidden
  86081. */
  86082. _disableTrackPosition(fixedPosition: Vector3): void;
  86083. /**
  86084. * Internal, the mesh attached to the controller
  86085. * @hidden
  86086. */
  86087. _mesh: Nullable<AbstractMesh>;
  86088. private _poseControlledCamera;
  86089. private _leftHandSystemQuaternion;
  86090. /**
  86091. * Internal, matrix used to convert room space to babylon space
  86092. * @hidden
  86093. */
  86094. _deviceToWorld: Matrix;
  86095. /**
  86096. * Node to be used when casting a ray from the controller
  86097. * @hidden
  86098. */
  86099. _pointingPoseNode: Nullable<TransformNode>;
  86100. /**
  86101. * Name of the child mesh that can be used to cast a ray from the controller
  86102. */
  86103. static readonly POINTING_POSE: string;
  86104. /**
  86105. * Creates a new PoseEnabledController from a gamepad
  86106. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  86107. */
  86108. constructor(browserGamepad: any);
  86109. private _workingMatrix;
  86110. /**
  86111. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  86112. */
  86113. update(): void;
  86114. /**
  86115. * Updates only the pose device and mesh without doing any button event checking
  86116. */
  86117. protected _updatePoseAndMesh(): void;
  86118. /**
  86119. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  86120. * @param poseData raw pose fromthe device
  86121. */
  86122. updateFromDevice(poseData: DevicePose): void;
  86123. /**
  86124. * @hidden
  86125. */
  86126. _meshAttachedObservable: Observable<AbstractMesh>;
  86127. /**
  86128. * Attaches a mesh to the controller
  86129. * @param mesh the mesh to be attached
  86130. */
  86131. attachToMesh(mesh: AbstractMesh): void;
  86132. /**
  86133. * Attaches the controllers mesh to a camera
  86134. * @param camera the camera the mesh should be attached to
  86135. */
  86136. attachToPoseControlledCamera(camera: TargetCamera): void;
  86137. /**
  86138. * Disposes of the controller
  86139. */
  86140. dispose(): void;
  86141. /**
  86142. * The mesh that is attached to the controller
  86143. */
  86144. get mesh(): Nullable<AbstractMesh>;
  86145. /**
  86146. * Gets the ray of the controller in the direction the controller is pointing
  86147. * @param length the length the resulting ray should be
  86148. * @returns a ray in the direction the controller is pointing
  86149. */
  86150. getForwardRay(length?: number): Ray;
  86151. }
  86152. }
  86153. declare module BABYLON {
  86154. /**
  86155. * Defines the WebVRController object that represents controllers tracked in 3D space
  86156. */
  86157. export abstract class WebVRController extends PoseEnabledController {
  86158. /**
  86159. * Internal, the default controller model for the controller
  86160. */
  86161. protected _defaultModel: Nullable<AbstractMesh>;
  86162. /**
  86163. * Fired when the trigger state has changed
  86164. */
  86165. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  86166. /**
  86167. * Fired when the main button state has changed
  86168. */
  86169. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  86170. /**
  86171. * Fired when the secondary button state has changed
  86172. */
  86173. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  86174. /**
  86175. * Fired when the pad state has changed
  86176. */
  86177. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  86178. /**
  86179. * Fired when controllers stick values have changed
  86180. */
  86181. onPadValuesChangedObservable: Observable<StickValues>;
  86182. /**
  86183. * Array of button availible on the controller
  86184. */
  86185. protected _buttons: Array<MutableGamepadButton>;
  86186. private _onButtonStateChange;
  86187. /**
  86188. * Fired when a controller button's state has changed
  86189. * @param callback the callback containing the button that was modified
  86190. */
  86191. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  86192. /**
  86193. * X and Y axis corresponding to the controllers joystick
  86194. */
  86195. pad: StickValues;
  86196. /**
  86197. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  86198. */
  86199. hand: string;
  86200. /**
  86201. * The default controller model for the controller
  86202. */
  86203. get defaultModel(): Nullable<AbstractMesh>;
  86204. /**
  86205. * Creates a new WebVRController from a gamepad
  86206. * @param vrGamepad the gamepad that the WebVRController should be created from
  86207. */
  86208. constructor(vrGamepad: any);
  86209. /**
  86210. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  86211. */
  86212. update(): void;
  86213. /**
  86214. * Function to be called when a button is modified
  86215. */
  86216. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  86217. /**
  86218. * Loads a mesh and attaches it to the controller
  86219. * @param scene the scene the mesh should be added to
  86220. * @param meshLoaded callback for when the mesh has been loaded
  86221. */
  86222. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  86223. private _setButtonValue;
  86224. private _changes;
  86225. private _checkChanges;
  86226. /**
  86227. * Disposes of th webVRCOntroller
  86228. */
  86229. dispose(): void;
  86230. }
  86231. }
  86232. declare module BABYLON {
  86233. /**
  86234. * The HemisphericLight simulates the ambient environment light,
  86235. * so the passed direction is the light reflection direction, not the incoming direction.
  86236. */
  86237. export class HemisphericLight extends Light {
  86238. /**
  86239. * The groundColor is the light in the opposite direction to the one specified during creation.
  86240. * 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.
  86241. */
  86242. groundColor: Color3;
  86243. /**
  86244. * The light reflection direction, not the incoming direction.
  86245. */
  86246. direction: Vector3;
  86247. /**
  86248. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  86249. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  86250. * The HemisphericLight can't cast shadows.
  86251. * Documentation : https://doc.babylonjs.com/babylon101/lights
  86252. * @param name The friendly name of the light
  86253. * @param direction The direction of the light reflection
  86254. * @param scene The scene the light belongs to
  86255. */
  86256. constructor(name: string, direction: Vector3, scene: Scene);
  86257. protected _buildUniformLayout(): void;
  86258. /**
  86259. * Returns the string "HemisphericLight".
  86260. * @return The class name
  86261. */
  86262. getClassName(): string;
  86263. /**
  86264. * Sets the HemisphericLight direction towards the passed target (Vector3).
  86265. * Returns the updated direction.
  86266. * @param target The target the direction should point to
  86267. * @return The computed direction
  86268. */
  86269. setDirectionToTarget(target: Vector3): Vector3;
  86270. /**
  86271. * Returns the shadow generator associated to the light.
  86272. * @returns Always null for hemispheric lights because it does not support shadows.
  86273. */
  86274. getShadowGenerator(): Nullable<IShadowGenerator>;
  86275. /**
  86276. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  86277. * @param effect The effect to update
  86278. * @param lightIndex The index of the light in the effect to update
  86279. * @returns The hemispheric light
  86280. */
  86281. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  86282. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  86283. /**
  86284. * Computes the world matrix of the node
  86285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86286. * @param useWasUpdatedFlag defines a reserved property
  86287. * @returns the world matrix
  86288. */
  86289. computeWorldMatrix(): Matrix;
  86290. /**
  86291. * Returns the integer 3.
  86292. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  86293. */
  86294. getTypeID(): number;
  86295. /**
  86296. * Prepares the list of defines specific to the light type.
  86297. * @param defines the list of defines
  86298. * @param lightIndex defines the index of the light for the effect
  86299. */
  86300. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  86301. }
  86302. }
  86303. declare module BABYLON {
  86304. /** @hidden */
  86305. export var vrMultiviewToSingleviewPixelShader: {
  86306. name: string;
  86307. shader: string;
  86308. };
  86309. }
  86310. declare module BABYLON {
  86311. /**
  86312. * Renders to multiple views with a single draw call
  86313. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  86314. */
  86315. export class MultiviewRenderTarget extends RenderTargetTexture {
  86316. /**
  86317. * Creates a multiview render target
  86318. * @param scene scene used with the render target
  86319. * @param size the size of the render target (used for each view)
  86320. */
  86321. constructor(scene: Scene, size?: number | {
  86322. width: number;
  86323. height: number;
  86324. } | {
  86325. ratio: number;
  86326. });
  86327. /**
  86328. * @hidden
  86329. * @param faceIndex the face index, if its a cube texture
  86330. */
  86331. _bindFrameBuffer(faceIndex?: number): void;
  86332. /**
  86333. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86334. * @returns the view count
  86335. */
  86336. getViewCount(): number;
  86337. }
  86338. }
  86339. declare module BABYLON {
  86340. /**
  86341. * Represents a camera frustum
  86342. */
  86343. export class Frustum {
  86344. /**
  86345. * Gets the planes representing the frustum
  86346. * @param transform matrix to be applied to the returned planes
  86347. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86348. */
  86349. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86350. /**
  86351. * Gets the near frustum plane transformed by the transform matrix
  86352. * @param transform transformation matrix to be applied to the resulting frustum plane
  86353. * @param frustumPlane the resuling frustum plane
  86354. */
  86355. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86356. /**
  86357. * Gets the far frustum plane transformed by the transform matrix
  86358. * @param transform transformation matrix to be applied to the resulting frustum plane
  86359. * @param frustumPlane the resuling frustum plane
  86360. */
  86361. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86362. /**
  86363. * Gets the left frustum plane transformed by the transform matrix
  86364. * @param transform transformation matrix to be applied to the resulting frustum plane
  86365. * @param frustumPlane the resuling frustum plane
  86366. */
  86367. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86368. /**
  86369. * Gets the right frustum plane transformed by the transform matrix
  86370. * @param transform transformation matrix to be applied to the resulting frustum plane
  86371. * @param frustumPlane the resuling frustum plane
  86372. */
  86373. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86374. /**
  86375. * Gets the top frustum plane transformed by the transform matrix
  86376. * @param transform transformation matrix to be applied to the resulting frustum plane
  86377. * @param frustumPlane the resuling frustum plane
  86378. */
  86379. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86380. /**
  86381. * Gets the bottom frustum plane transformed by the transform matrix
  86382. * @param transform transformation matrix to be applied to the resulting frustum plane
  86383. * @param frustumPlane the resuling frustum plane
  86384. */
  86385. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86386. /**
  86387. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86388. * @param transform transformation matrix to be applied to the resulting frustum planes
  86389. * @param frustumPlanes the resuling frustum planes
  86390. */
  86391. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86392. }
  86393. }
  86394. declare module BABYLON {
  86395. interface Engine {
  86396. /**
  86397. * Creates a new multiview render target
  86398. * @param width defines the width of the texture
  86399. * @param height defines the height of the texture
  86400. * @returns the created multiview texture
  86401. */
  86402. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  86403. /**
  86404. * Binds a multiview framebuffer to be drawn to
  86405. * @param multiviewTexture texture to bind
  86406. */
  86407. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  86408. }
  86409. interface Camera {
  86410. /**
  86411. * @hidden
  86412. * 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)
  86413. */
  86414. _useMultiviewToSingleView: boolean;
  86415. /**
  86416. * @hidden
  86417. * 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)
  86418. */
  86419. _multiviewTexture: Nullable<RenderTargetTexture>;
  86420. /**
  86421. * @hidden
  86422. * ensures the multiview texture of the camera exists and has the specified width/height
  86423. * @param width height to set on the multiview texture
  86424. * @param height width to set on the multiview texture
  86425. */
  86426. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  86427. }
  86428. interface Scene {
  86429. /** @hidden */
  86430. _transformMatrixR: Matrix;
  86431. /** @hidden */
  86432. _multiviewSceneUbo: Nullable<UniformBuffer>;
  86433. /** @hidden */
  86434. _createMultiviewUbo(): void;
  86435. /** @hidden */
  86436. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  86437. /** @hidden */
  86438. _renderMultiviewToSingleView(camera: Camera): void;
  86439. }
  86440. }
  86441. declare module BABYLON {
  86442. /**
  86443. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  86444. * This will not be used for webXR as it supports displaying texture arrays directly
  86445. */
  86446. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  86447. /**
  86448. * Initializes a VRMultiviewToSingleview
  86449. * @param name name of the post process
  86450. * @param camera camera to be applied to
  86451. * @param scaleFactor scaling factor to the size of the output texture
  86452. */
  86453. constructor(name: string, camera: Camera, scaleFactor: number);
  86454. }
  86455. }
  86456. declare module BABYLON {
  86457. /**
  86458. * Interface used to define additional presentation attributes
  86459. */
  86460. export interface IVRPresentationAttributes {
  86461. /**
  86462. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  86463. */
  86464. highRefreshRate: boolean;
  86465. /**
  86466. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  86467. */
  86468. foveationLevel: number;
  86469. }
  86470. interface Engine {
  86471. /** @hidden */
  86472. _vrDisplay: any;
  86473. /** @hidden */
  86474. _vrSupported: boolean;
  86475. /** @hidden */
  86476. _oldSize: Size;
  86477. /** @hidden */
  86478. _oldHardwareScaleFactor: number;
  86479. /** @hidden */
  86480. _vrExclusivePointerMode: boolean;
  86481. /** @hidden */
  86482. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  86483. /** @hidden */
  86484. _onVRDisplayPointerRestricted: () => void;
  86485. /** @hidden */
  86486. _onVRDisplayPointerUnrestricted: () => void;
  86487. /** @hidden */
  86488. _onVrDisplayConnect: Nullable<(display: any) => void>;
  86489. /** @hidden */
  86490. _onVrDisplayDisconnect: Nullable<() => void>;
  86491. /** @hidden */
  86492. _onVrDisplayPresentChange: Nullable<() => void>;
  86493. /**
  86494. * Observable signaled when VR display mode changes
  86495. */
  86496. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86497. /**
  86498. * Observable signaled when VR request present is complete
  86499. */
  86500. onVRRequestPresentComplete: Observable<boolean>;
  86501. /**
  86502. * Observable signaled when VR request present starts
  86503. */
  86504. onVRRequestPresentStart: Observable<Engine>;
  86505. /**
  86506. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86507. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86508. */
  86509. isInVRExclusivePointerMode: boolean;
  86510. /**
  86511. * Gets a boolean indicating if a webVR device was detected
  86512. * @returns true if a webVR device was detected
  86513. */
  86514. isVRDevicePresent(): boolean;
  86515. /**
  86516. * Gets the current webVR device
  86517. * @returns the current webVR device (or null)
  86518. */
  86519. getVRDevice(): any;
  86520. /**
  86521. * Initializes a webVR display and starts listening to display change events
  86522. * The onVRDisplayChangedObservable will be notified upon these changes
  86523. * @returns A promise containing a VRDisplay and if vr is supported
  86524. */
  86525. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86526. /** @hidden */
  86527. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  86528. /**
  86529. * Gets or sets the presentation attributes used to configure VR rendering
  86530. */
  86531. vrPresentationAttributes?: IVRPresentationAttributes;
  86532. /**
  86533. * Call this function to switch to webVR mode
  86534. * Will do nothing if webVR is not supported or if there is no webVR device
  86535. * @param options the webvr options provided to the camera. mainly used for multiview
  86536. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86537. */
  86538. enableVR(options: WebVROptions): void;
  86539. /** @hidden */
  86540. _onVRFullScreenTriggered(): void;
  86541. }
  86542. }
  86543. declare module BABYLON {
  86544. /**
  86545. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  86546. * IMPORTANT!! The data is right-hand data.
  86547. * @export
  86548. * @interface DevicePose
  86549. */
  86550. export interface DevicePose {
  86551. /**
  86552. * The position of the device, values in array are [x,y,z].
  86553. */
  86554. readonly position: Nullable<Float32Array>;
  86555. /**
  86556. * The linearVelocity of the device, values in array are [x,y,z].
  86557. */
  86558. readonly linearVelocity: Nullable<Float32Array>;
  86559. /**
  86560. * The linearAcceleration of the device, values in array are [x,y,z].
  86561. */
  86562. readonly linearAcceleration: Nullable<Float32Array>;
  86563. /**
  86564. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  86565. */
  86566. readonly orientation: Nullable<Float32Array>;
  86567. /**
  86568. * The angularVelocity of the device, values in array are [x,y,z].
  86569. */
  86570. readonly angularVelocity: Nullable<Float32Array>;
  86571. /**
  86572. * The angularAcceleration of the device, values in array are [x,y,z].
  86573. */
  86574. readonly angularAcceleration: Nullable<Float32Array>;
  86575. }
  86576. /**
  86577. * Interface representing a pose controlled object in Babylon.
  86578. * A pose controlled object has both regular pose values as well as pose values
  86579. * from an external device such as a VR head mounted display
  86580. */
  86581. export interface PoseControlled {
  86582. /**
  86583. * The position of the object in babylon space.
  86584. */
  86585. position: Vector3;
  86586. /**
  86587. * The rotation quaternion of the object in babylon space.
  86588. */
  86589. rotationQuaternion: Quaternion;
  86590. /**
  86591. * The position of the device in babylon space.
  86592. */
  86593. devicePosition?: Vector3;
  86594. /**
  86595. * The rotation quaternion of the device in babylon space.
  86596. */
  86597. deviceRotationQuaternion: Quaternion;
  86598. /**
  86599. * The raw pose coming from the device.
  86600. */
  86601. rawPose: Nullable<DevicePose>;
  86602. /**
  86603. * The scale of the device to be used when translating from device space to babylon space.
  86604. */
  86605. deviceScaleFactor: number;
  86606. /**
  86607. * Updates the poseControlled values based on the input device pose.
  86608. * @param poseData the pose data to update the object with
  86609. */
  86610. updateFromDevice(poseData: DevicePose): void;
  86611. }
  86612. /**
  86613. * Set of options to customize the webVRCamera
  86614. */
  86615. export interface WebVROptions {
  86616. /**
  86617. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  86618. */
  86619. trackPosition?: boolean;
  86620. /**
  86621. * Sets the scale of the vrDevice in babylon space. (default: 1)
  86622. */
  86623. positionScale?: number;
  86624. /**
  86625. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  86626. */
  86627. displayName?: string;
  86628. /**
  86629. * Should the native controller meshes be initialized. (default: true)
  86630. */
  86631. controllerMeshes?: boolean;
  86632. /**
  86633. * Creating a default HemiLight only on controllers. (default: true)
  86634. */
  86635. defaultLightingOnControllers?: boolean;
  86636. /**
  86637. * If you don't want to use the default VR button of the helper. (default: false)
  86638. */
  86639. useCustomVRButton?: boolean;
  86640. /**
  86641. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  86642. */
  86643. customVRButton?: HTMLButtonElement;
  86644. /**
  86645. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  86646. */
  86647. rayLength?: number;
  86648. /**
  86649. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  86650. */
  86651. defaultHeight?: number;
  86652. /**
  86653. * If multiview should be used if availible (default: false)
  86654. */
  86655. useMultiview?: boolean;
  86656. }
  86657. /**
  86658. * This represents a WebVR camera.
  86659. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  86660. * @example http://doc.babylonjs.com/how_to/webvr_camera
  86661. */
  86662. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  86663. private webVROptions;
  86664. /**
  86665. * @hidden
  86666. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  86667. */
  86668. _vrDevice: any;
  86669. /**
  86670. * The rawPose of the vrDevice.
  86671. */
  86672. rawPose: Nullable<DevicePose>;
  86673. private _onVREnabled;
  86674. private _specsVersion;
  86675. private _attached;
  86676. private _frameData;
  86677. protected _descendants: Array<Node>;
  86678. private _deviceRoomPosition;
  86679. /** @hidden */
  86680. _deviceRoomRotationQuaternion: Quaternion;
  86681. private _standingMatrix;
  86682. /**
  86683. * Represents device position in babylon space.
  86684. */
  86685. devicePosition: Vector3;
  86686. /**
  86687. * Represents device rotation in babylon space.
  86688. */
  86689. deviceRotationQuaternion: Quaternion;
  86690. /**
  86691. * The scale of the device to be used when translating from device space to babylon space.
  86692. */
  86693. deviceScaleFactor: number;
  86694. private _deviceToWorld;
  86695. private _worldToDevice;
  86696. /**
  86697. * References to the webVR controllers for the vrDevice.
  86698. */
  86699. controllers: Array<WebVRController>;
  86700. /**
  86701. * Emits an event when a controller is attached.
  86702. */
  86703. onControllersAttachedObservable: Observable<WebVRController[]>;
  86704. /**
  86705. * Emits an event when a controller's mesh has been loaded;
  86706. */
  86707. onControllerMeshLoadedObservable: Observable<WebVRController>;
  86708. /**
  86709. * Emits an event when the HMD's pose has been updated.
  86710. */
  86711. onPoseUpdatedFromDeviceObservable: Observable<any>;
  86712. private _poseSet;
  86713. /**
  86714. * If the rig cameras be used as parent instead of this camera.
  86715. */
  86716. rigParenting: boolean;
  86717. private _lightOnControllers;
  86718. private _defaultHeight?;
  86719. /**
  86720. * Instantiates a WebVRFreeCamera.
  86721. * @param name The name of the WebVRFreeCamera
  86722. * @param position The starting anchor position for the camera
  86723. * @param scene The scene the camera belongs to
  86724. * @param webVROptions a set of customizable options for the webVRCamera
  86725. */
  86726. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  86727. /**
  86728. * Gets the device distance from the ground in meters.
  86729. * @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.
  86730. */
  86731. deviceDistanceToRoomGround(): number;
  86732. /**
  86733. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  86734. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  86735. */
  86736. useStandingMatrix(callback?: (bool: boolean) => void): void;
  86737. /**
  86738. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  86739. * @returns A promise with a boolean set to if the standing matrix is supported.
  86740. */
  86741. useStandingMatrixAsync(): Promise<boolean>;
  86742. /**
  86743. * Disposes the camera
  86744. */
  86745. dispose(): void;
  86746. /**
  86747. * Gets a vrController by name.
  86748. * @param name The name of the controller to retreive
  86749. * @returns the controller matching the name specified or null if not found
  86750. */
  86751. getControllerByName(name: string): Nullable<WebVRController>;
  86752. private _leftController;
  86753. /**
  86754. * The controller corresponding to the users left hand.
  86755. */
  86756. get leftController(): Nullable<WebVRController>;
  86757. private _rightController;
  86758. /**
  86759. * The controller corresponding to the users right hand.
  86760. */
  86761. get rightController(): Nullable<WebVRController>;
  86762. /**
  86763. * Casts a ray forward from the vrCamera's gaze.
  86764. * @param length Length of the ray (default: 100)
  86765. * @returns the ray corresponding to the gaze
  86766. */
  86767. getForwardRay(length?: number): Ray;
  86768. /**
  86769. * @hidden
  86770. * Updates the camera based on device's frame data
  86771. */
  86772. _checkInputs(): void;
  86773. /**
  86774. * Updates the poseControlled values based on the input device pose.
  86775. * @param poseData Pose coming from the device
  86776. */
  86777. updateFromDevice(poseData: DevicePose): void;
  86778. private _htmlElementAttached;
  86779. private _detachIfAttached;
  86780. /**
  86781. * WebVR's attach control will start broadcasting frames to the device.
  86782. * Note that in certain browsers (chrome for example) this function must be called
  86783. * within a user-interaction callback. Example:
  86784. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  86785. *
  86786. * @param element html element to attach the vrDevice to
  86787. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  86788. */
  86789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86790. /**
  86791. * Detaches the camera from the html element and disables VR
  86792. *
  86793. * @param element html element to detach from
  86794. */
  86795. detachControl(element: HTMLElement): void;
  86796. /**
  86797. * @returns the name of this class
  86798. */
  86799. getClassName(): string;
  86800. /**
  86801. * Calls resetPose on the vrDisplay
  86802. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  86803. */
  86804. resetToCurrentRotation(): void;
  86805. /**
  86806. * @hidden
  86807. * Updates the rig cameras (left and right eye)
  86808. */
  86809. _updateRigCameras(): void;
  86810. private _workingVector;
  86811. private _oneVector;
  86812. private _workingMatrix;
  86813. private updateCacheCalled;
  86814. private _correctPositionIfNotTrackPosition;
  86815. /**
  86816. * @hidden
  86817. * Updates the cached values of the camera
  86818. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  86819. */
  86820. _updateCache(ignoreParentClass?: boolean): void;
  86821. /**
  86822. * @hidden
  86823. * Get current device position in babylon world
  86824. */
  86825. _computeDevicePosition(): void;
  86826. /**
  86827. * Updates the current device position and rotation in the babylon world
  86828. */
  86829. update(): void;
  86830. /**
  86831. * @hidden
  86832. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  86833. * @returns an identity matrix
  86834. */
  86835. _getViewMatrix(): Matrix;
  86836. private _tmpMatrix;
  86837. /**
  86838. * This function is called by the two RIG cameras.
  86839. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  86840. * @hidden
  86841. */
  86842. _getWebVRViewMatrix(): Matrix;
  86843. /** @hidden */
  86844. _getWebVRProjectionMatrix(): Matrix;
  86845. private _onGamepadConnectedObserver;
  86846. private _onGamepadDisconnectedObserver;
  86847. private _updateCacheWhenTrackingDisabledObserver;
  86848. /**
  86849. * Initializes the controllers and their meshes
  86850. */
  86851. initControllers(): void;
  86852. }
  86853. }
  86854. declare module BABYLON {
  86855. /**
  86856. * Size options for a post process
  86857. */
  86858. export type PostProcessOptions = {
  86859. width: number;
  86860. height: number;
  86861. };
  86862. /**
  86863. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86864. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86865. */
  86866. export class PostProcess {
  86867. /** Name of the PostProcess. */
  86868. name: string;
  86869. /**
  86870. * Gets or sets the unique id of the post process
  86871. */
  86872. uniqueId: number;
  86873. /**
  86874. * Width of the texture to apply the post process on
  86875. */
  86876. width: number;
  86877. /**
  86878. * Height of the texture to apply the post process on
  86879. */
  86880. height: number;
  86881. /**
  86882. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86883. * @hidden
  86884. */
  86885. _outputTexture: Nullable<InternalTexture>;
  86886. /**
  86887. * Sampling mode used by the shader
  86888. * See https://doc.babylonjs.com/classes/3.1/texture
  86889. */
  86890. renderTargetSamplingMode: number;
  86891. /**
  86892. * Clear color to use when screen clearing
  86893. */
  86894. clearColor: Color4;
  86895. /**
  86896. * If the buffer needs to be cleared before applying the post process. (default: true)
  86897. * Should be set to false if shader will overwrite all previous pixels.
  86898. */
  86899. autoClear: boolean;
  86900. /**
  86901. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86902. */
  86903. alphaMode: number;
  86904. /**
  86905. * Sets the setAlphaBlendConstants of the babylon engine
  86906. */
  86907. alphaConstants: Color4;
  86908. /**
  86909. * Animations to be used for the post processing
  86910. */
  86911. animations: Animation[];
  86912. /**
  86913. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86914. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86915. */
  86916. enablePixelPerfectMode: boolean;
  86917. /**
  86918. * Force the postprocess to be applied without taking in account viewport
  86919. */
  86920. forceFullscreenViewport: boolean;
  86921. /**
  86922. * List of inspectable custom properties (used by the Inspector)
  86923. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86924. */
  86925. inspectableCustomProperties: IInspectable[];
  86926. /**
  86927. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86928. *
  86929. * | Value | Type | Description |
  86930. * | ----- | ----------------------------------- | ----------- |
  86931. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86932. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86933. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86934. *
  86935. */
  86936. scaleMode: number;
  86937. /**
  86938. * Force textures to be a power of two (default: false)
  86939. */
  86940. alwaysForcePOT: boolean;
  86941. private _samples;
  86942. /**
  86943. * Number of sample textures (default: 1)
  86944. */
  86945. get samples(): number;
  86946. set samples(n: number);
  86947. /**
  86948. * Modify the scale of the post process to be the same as the viewport (default: false)
  86949. */
  86950. adaptScaleToCurrentViewport: boolean;
  86951. private _camera;
  86952. private _scene;
  86953. private _engine;
  86954. private _options;
  86955. private _reusable;
  86956. private _textureType;
  86957. /**
  86958. * Smart array of input and output textures for the post process.
  86959. * @hidden
  86960. */
  86961. _textures: SmartArray<InternalTexture>;
  86962. /**
  86963. * The index in _textures that corresponds to the output texture.
  86964. * @hidden
  86965. */
  86966. _currentRenderTextureInd: number;
  86967. private _effect;
  86968. private _samplers;
  86969. private _fragmentUrl;
  86970. private _vertexUrl;
  86971. private _parameters;
  86972. private _scaleRatio;
  86973. protected _indexParameters: any;
  86974. private _shareOutputWithPostProcess;
  86975. private _texelSize;
  86976. private _forcedOutputTexture;
  86977. /**
  86978. * Returns the fragment url or shader name used in the post process.
  86979. * @returns the fragment url or name in the shader store.
  86980. */
  86981. getEffectName(): string;
  86982. /**
  86983. * An event triggered when the postprocess is activated.
  86984. */
  86985. onActivateObservable: Observable<Camera>;
  86986. private _onActivateObserver;
  86987. /**
  86988. * A function that is added to the onActivateObservable
  86989. */
  86990. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86991. /**
  86992. * An event triggered when the postprocess changes its size.
  86993. */
  86994. onSizeChangedObservable: Observable<PostProcess>;
  86995. private _onSizeChangedObserver;
  86996. /**
  86997. * A function that is added to the onSizeChangedObservable
  86998. */
  86999. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  87000. /**
  87001. * An event triggered when the postprocess applies its effect.
  87002. */
  87003. onApplyObservable: Observable<Effect>;
  87004. private _onApplyObserver;
  87005. /**
  87006. * A function that is added to the onApplyObservable
  87007. */
  87008. set onApply(callback: (effect: Effect) => void);
  87009. /**
  87010. * An event triggered before rendering the postprocess
  87011. */
  87012. onBeforeRenderObservable: Observable<Effect>;
  87013. private _onBeforeRenderObserver;
  87014. /**
  87015. * A function that is added to the onBeforeRenderObservable
  87016. */
  87017. set onBeforeRender(callback: (effect: Effect) => void);
  87018. /**
  87019. * An event triggered after rendering the postprocess
  87020. */
  87021. onAfterRenderObservable: Observable<Effect>;
  87022. private _onAfterRenderObserver;
  87023. /**
  87024. * A function that is added to the onAfterRenderObservable
  87025. */
  87026. set onAfterRender(callback: (efect: Effect) => void);
  87027. /**
  87028. * 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
  87029. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  87030. */
  87031. get inputTexture(): InternalTexture;
  87032. set inputTexture(value: InternalTexture);
  87033. /**
  87034. * Gets the camera which post process is applied to.
  87035. * @returns The camera the post process is applied to.
  87036. */
  87037. getCamera(): Camera;
  87038. /**
  87039. * Gets the texel size of the postprocess.
  87040. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  87041. */
  87042. get texelSize(): Vector2;
  87043. /**
  87044. * Creates a new instance PostProcess
  87045. * @param name The name of the PostProcess.
  87046. * @param fragmentUrl The url of the fragment shader to be used.
  87047. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  87048. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  87049. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  87050. * @param camera The camera to apply the render pass to.
  87051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  87052. * @param engine The engine which the post process will be applied. (default: current engine)
  87053. * @param reusable If the post process can be reused on the same frame. (default: false)
  87054. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  87055. * @param textureType Type of textures used when performing the post process. (default: 0)
  87056. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  87057. * @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
  87058. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  87059. */
  87060. constructor(
  87061. /** Name of the PostProcess. */
  87062. 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);
  87063. /**
  87064. * Gets a string idenfifying the name of the class
  87065. * @returns "PostProcess" string
  87066. */
  87067. getClassName(): string;
  87068. /**
  87069. * Gets the engine which this post process belongs to.
  87070. * @returns The engine the post process was enabled with.
  87071. */
  87072. getEngine(): Engine;
  87073. /**
  87074. * The effect that is created when initializing the post process.
  87075. * @returns The created effect corresponding the the postprocess.
  87076. */
  87077. getEffect(): Effect;
  87078. /**
  87079. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  87080. * @param postProcess The post process to share the output with.
  87081. * @returns This post process.
  87082. */
  87083. shareOutputWith(postProcess: PostProcess): PostProcess;
  87084. /**
  87085. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  87086. * This should be called if the post process that shares output with this post process is disabled/disposed.
  87087. */
  87088. useOwnOutput(): void;
  87089. /**
  87090. * Updates the effect with the current post process compile time values and recompiles the shader.
  87091. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  87092. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  87093. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  87094. * @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
  87095. * @param onCompiled Called when the shader has been compiled.
  87096. * @param onError Called if there is an error when compiling a shader.
  87097. */
  87098. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  87099. /**
  87100. * The post process is reusable if it can be used multiple times within one frame.
  87101. * @returns If the post process is reusable
  87102. */
  87103. isReusable(): boolean;
  87104. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  87105. markTextureDirty(): void;
  87106. /**
  87107. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  87108. * 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.
  87109. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  87110. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  87111. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  87112. * @returns The target texture that was bound to be written to.
  87113. */
  87114. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  87115. /**
  87116. * If the post process is supported.
  87117. */
  87118. get isSupported(): boolean;
  87119. /**
  87120. * The aspect ratio of the output texture.
  87121. */
  87122. get aspectRatio(): number;
  87123. /**
  87124. * Get a value indicating if the post-process is ready to be used
  87125. * @returns true if the post-process is ready (shader is compiled)
  87126. */
  87127. isReady(): boolean;
  87128. /**
  87129. * Binds all textures and uniforms to the shader, this will be run on every pass.
  87130. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  87131. */
  87132. apply(): Nullable<Effect>;
  87133. private _disposeTextures;
  87134. /**
  87135. * Disposes the post process.
  87136. * @param camera The camera to dispose the post process on.
  87137. */
  87138. dispose(camera?: Camera): void;
  87139. }
  87140. }
  87141. declare module BABYLON {
  87142. /** @hidden */
  87143. export var kernelBlurVaryingDeclaration: {
  87144. name: string;
  87145. shader: string;
  87146. };
  87147. }
  87148. declare module BABYLON {
  87149. /** @hidden */
  87150. export var kernelBlurFragment: {
  87151. name: string;
  87152. shader: string;
  87153. };
  87154. }
  87155. declare module BABYLON {
  87156. /** @hidden */
  87157. export var kernelBlurFragment2: {
  87158. name: string;
  87159. shader: string;
  87160. };
  87161. }
  87162. declare module BABYLON {
  87163. /** @hidden */
  87164. export var kernelBlurPixelShader: {
  87165. name: string;
  87166. shader: string;
  87167. };
  87168. }
  87169. declare module BABYLON {
  87170. /** @hidden */
  87171. export var kernelBlurVertex: {
  87172. name: string;
  87173. shader: string;
  87174. };
  87175. }
  87176. declare module BABYLON {
  87177. /** @hidden */
  87178. export var kernelBlurVertexShader: {
  87179. name: string;
  87180. shader: string;
  87181. };
  87182. }
  87183. declare module BABYLON {
  87184. /**
  87185. * The Blur Post Process which blurs an image based on a kernel and direction.
  87186. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  87187. */
  87188. export class BlurPostProcess extends PostProcess {
  87189. /** The direction in which to blur the image. */
  87190. direction: Vector2;
  87191. private blockCompilation;
  87192. protected _kernel: number;
  87193. protected _idealKernel: number;
  87194. protected _packedFloat: boolean;
  87195. private _staticDefines;
  87196. /**
  87197. * Sets the length in pixels of the blur sample region
  87198. */
  87199. set kernel(v: number);
  87200. /**
  87201. * Gets the length in pixels of the blur sample region
  87202. */
  87203. get kernel(): number;
  87204. /**
  87205. * Sets wether or not the blur needs to unpack/repack floats
  87206. */
  87207. set packedFloat(v: boolean);
  87208. /**
  87209. * Gets wether or not the blur is unpacking/repacking floats
  87210. */
  87211. get packedFloat(): boolean;
  87212. /**
  87213. * Creates a new instance BlurPostProcess
  87214. * @param name The name of the effect.
  87215. * @param direction The direction in which to blur the image.
  87216. * @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.
  87217. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  87218. * @param camera The camera to apply the render pass to.
  87219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  87220. * @param engine The engine which the post process will be applied. (default: current engine)
  87221. * @param reusable If the post process can be reused on the same frame. (default: false)
  87222. * @param textureType Type of textures used when performing the post process. (default: 0)
  87223. * @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)
  87224. */
  87225. constructor(name: string,
  87226. /** The direction in which to blur the image. */
  87227. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  87228. /**
  87229. * Updates the effect with the current post process compile time values and recompiles the shader.
  87230. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  87231. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  87232. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  87233. * @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
  87234. * @param onCompiled Called when the shader has been compiled.
  87235. * @param onError Called if there is an error when compiling a shader.
  87236. */
  87237. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  87238. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  87239. /**
  87240. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  87241. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  87242. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  87243. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  87244. * The gaps between physical kernels are compensated for in the weighting of the samples
  87245. * @param idealKernel Ideal blur kernel.
  87246. * @return Nearest best kernel.
  87247. */
  87248. protected _nearestBestKernel(idealKernel: number): number;
  87249. /**
  87250. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  87251. * @param x The point on the Gaussian distribution to sample.
  87252. * @return the value of the Gaussian function at x.
  87253. */
  87254. protected _gaussianWeight(x: number): number;
  87255. /**
  87256. * Generates a string that can be used as a floating point number in GLSL.
  87257. * @param x Value to print.
  87258. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  87259. * @return GLSL float string.
  87260. */
  87261. protected _glslFloat(x: number, decimalFigures?: number): string;
  87262. }
  87263. }
  87264. declare module BABYLON {
  87265. /**
  87266. * Mirror texture can be used to simulate the view from a mirror in a scene.
  87267. * It will dynamically be rendered every frame to adapt to the camera point of view.
  87268. * You can then easily use it as a reflectionTexture on a flat surface.
  87269. * In case the surface is not a plane, please consider relying on reflection probes.
  87270. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  87271. */
  87272. export class MirrorTexture extends RenderTargetTexture {
  87273. private scene;
  87274. /**
  87275. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  87276. * 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.
  87277. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  87278. */
  87279. mirrorPlane: Plane;
  87280. /**
  87281. * Define the blur ratio used to blur the reflection if needed.
  87282. */
  87283. set blurRatio(value: number);
  87284. get blurRatio(): number;
  87285. /**
  87286. * Define the adaptive blur kernel used to blur the reflection if needed.
  87287. * This will autocompute the closest best match for the `blurKernel`
  87288. */
  87289. set adaptiveBlurKernel(value: number);
  87290. /**
  87291. * Define the blur kernel used to blur the reflection if needed.
  87292. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  87293. */
  87294. set blurKernel(value: number);
  87295. /**
  87296. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  87297. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  87298. */
  87299. set blurKernelX(value: number);
  87300. get blurKernelX(): number;
  87301. /**
  87302. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  87303. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  87304. */
  87305. set blurKernelY(value: number);
  87306. get blurKernelY(): number;
  87307. private _autoComputeBlurKernel;
  87308. protected _onRatioRescale(): void;
  87309. private _updateGammaSpace;
  87310. private _imageProcessingConfigChangeObserver;
  87311. private _transformMatrix;
  87312. private _mirrorMatrix;
  87313. private _savedViewMatrix;
  87314. private _blurX;
  87315. private _blurY;
  87316. private _adaptiveBlurKernel;
  87317. private _blurKernelX;
  87318. private _blurKernelY;
  87319. private _blurRatio;
  87320. /**
  87321. * Instantiates a Mirror Texture.
  87322. * Mirror texture can be used to simulate the view from a mirror in a scene.
  87323. * It will dynamically be rendered every frame to adapt to the camera point of view.
  87324. * You can then easily use it as a reflectionTexture on a flat surface.
  87325. * In case the surface is not a plane, please consider relying on reflection probes.
  87326. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  87327. * @param name
  87328. * @param size
  87329. * @param scene
  87330. * @param generateMipMaps
  87331. * @param type
  87332. * @param samplingMode
  87333. * @param generateDepthBuffer
  87334. */
  87335. constructor(name: string, size: number | {
  87336. width: number;
  87337. height: number;
  87338. } | {
  87339. ratio: number;
  87340. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  87341. private _preparePostProcesses;
  87342. /**
  87343. * Clone the mirror texture.
  87344. * @returns the cloned texture
  87345. */
  87346. clone(): MirrorTexture;
  87347. /**
  87348. * Serialize the texture to a JSON representation you could use in Parse later on
  87349. * @returns the serialized JSON representation
  87350. */
  87351. serialize(): any;
  87352. /**
  87353. * Dispose the texture and release its associated resources.
  87354. */
  87355. dispose(): void;
  87356. }
  87357. }
  87358. declare module BABYLON {
  87359. /**
  87360. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  87361. * @see http://doc.babylonjs.com/babylon101/materials#texture
  87362. */
  87363. export class Texture extends BaseTexture {
  87364. /**
  87365. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  87366. */
  87367. static SerializeBuffers: boolean;
  87368. /** @hidden */
  87369. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  87370. /** @hidden */
  87371. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  87372. /** @hidden */
  87373. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  87374. /** nearest is mag = nearest and min = nearest and mip = linear */
  87375. static readonly NEAREST_SAMPLINGMODE: number;
  87376. /** nearest is mag = nearest and min = nearest and mip = linear */
  87377. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  87378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87379. static readonly BILINEAR_SAMPLINGMODE: number;
  87380. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87381. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  87382. /** Trilinear is mag = linear and min = linear and mip = linear */
  87383. static readonly TRILINEAR_SAMPLINGMODE: number;
  87384. /** Trilinear is mag = linear and min = linear and mip = linear */
  87385. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  87386. /** mag = nearest and min = nearest and mip = nearest */
  87387. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  87388. /** mag = nearest and min = linear and mip = nearest */
  87389. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  87390. /** mag = nearest and min = linear and mip = linear */
  87391. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  87392. /** mag = nearest and min = linear and mip = none */
  87393. static readonly NEAREST_LINEAR: number;
  87394. /** mag = nearest and min = nearest and mip = none */
  87395. static readonly NEAREST_NEAREST: number;
  87396. /** mag = linear and min = nearest and mip = nearest */
  87397. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  87398. /** mag = linear and min = nearest and mip = linear */
  87399. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  87400. /** mag = linear and min = linear and mip = none */
  87401. static readonly LINEAR_LINEAR: number;
  87402. /** mag = linear and min = nearest and mip = none */
  87403. static readonly LINEAR_NEAREST: number;
  87404. /** Explicit coordinates mode */
  87405. static readonly EXPLICIT_MODE: number;
  87406. /** Spherical coordinates mode */
  87407. static readonly SPHERICAL_MODE: number;
  87408. /** Planar coordinates mode */
  87409. static readonly PLANAR_MODE: number;
  87410. /** Cubic coordinates mode */
  87411. static readonly CUBIC_MODE: number;
  87412. /** Projection coordinates mode */
  87413. static readonly PROJECTION_MODE: number;
  87414. /** Inverse Cubic coordinates mode */
  87415. static readonly SKYBOX_MODE: number;
  87416. /** Inverse Cubic coordinates mode */
  87417. static readonly INVCUBIC_MODE: number;
  87418. /** Equirectangular coordinates mode */
  87419. static readonly EQUIRECTANGULAR_MODE: number;
  87420. /** Equirectangular Fixed coordinates mode */
  87421. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  87422. /** Equirectangular Fixed Mirrored coordinates mode */
  87423. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87424. /** Texture is not repeating outside of 0..1 UVs */
  87425. static readonly CLAMP_ADDRESSMODE: number;
  87426. /** Texture is repeating outside of 0..1 UVs */
  87427. static readonly WRAP_ADDRESSMODE: number;
  87428. /** Texture is repeating and mirrored */
  87429. static readonly MIRROR_ADDRESSMODE: number;
  87430. /**
  87431. * 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
  87432. */
  87433. static UseSerializedUrlIfAny: boolean;
  87434. /**
  87435. * Define the url of the texture.
  87436. */
  87437. url: Nullable<string>;
  87438. /**
  87439. * Define an offset on the texture to offset the u coordinates of the UVs
  87440. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  87441. */
  87442. uOffset: number;
  87443. /**
  87444. * Define an offset on the texture to offset the v coordinates of the UVs
  87445. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  87446. */
  87447. vOffset: number;
  87448. /**
  87449. * Define an offset on the texture to scale the u coordinates of the UVs
  87450. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  87451. */
  87452. uScale: number;
  87453. /**
  87454. * Define an offset on the texture to scale the v coordinates of the UVs
  87455. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  87456. */
  87457. vScale: number;
  87458. /**
  87459. * Define an offset on the texture to rotate around the u coordinates of the UVs
  87460. * @see http://doc.babylonjs.com/how_to/more_materials
  87461. */
  87462. uAng: number;
  87463. /**
  87464. * Define an offset on the texture to rotate around the v coordinates of the UVs
  87465. * @see http://doc.babylonjs.com/how_to/more_materials
  87466. */
  87467. vAng: number;
  87468. /**
  87469. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  87470. * @see http://doc.babylonjs.com/how_to/more_materials
  87471. */
  87472. wAng: number;
  87473. /**
  87474. * Defines the center of rotation (U)
  87475. */
  87476. uRotationCenter: number;
  87477. /**
  87478. * Defines the center of rotation (V)
  87479. */
  87480. vRotationCenter: number;
  87481. /**
  87482. * Defines the center of rotation (W)
  87483. */
  87484. wRotationCenter: number;
  87485. /**
  87486. * Are mip maps generated for this texture or not.
  87487. */
  87488. get noMipmap(): boolean;
  87489. /**
  87490. * List of inspectable custom properties (used by the Inspector)
  87491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87492. */
  87493. inspectableCustomProperties: Nullable<IInspectable[]>;
  87494. private _noMipmap;
  87495. /** @hidden */
  87496. _invertY: boolean;
  87497. private _rowGenerationMatrix;
  87498. private _cachedTextureMatrix;
  87499. private _projectionModeMatrix;
  87500. private _t0;
  87501. private _t1;
  87502. private _t2;
  87503. private _cachedUOffset;
  87504. private _cachedVOffset;
  87505. private _cachedUScale;
  87506. private _cachedVScale;
  87507. private _cachedUAng;
  87508. private _cachedVAng;
  87509. private _cachedWAng;
  87510. private _cachedProjectionMatrixId;
  87511. private _cachedCoordinatesMode;
  87512. /** @hidden */
  87513. protected _initialSamplingMode: number;
  87514. /** @hidden */
  87515. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  87516. private _deleteBuffer;
  87517. protected _format: Nullable<number>;
  87518. private _delayedOnLoad;
  87519. private _delayedOnError;
  87520. private _mimeType?;
  87521. /**
  87522. * Observable triggered once the texture has been loaded.
  87523. */
  87524. onLoadObservable: Observable<Texture>;
  87525. protected _isBlocking: boolean;
  87526. /**
  87527. * Is the texture preventing material to render while loading.
  87528. * If false, a default texture will be used instead of the loading one during the preparation step.
  87529. */
  87530. set isBlocking(value: boolean);
  87531. get isBlocking(): boolean;
  87532. /**
  87533. * Get the current sampling mode associated with the texture.
  87534. */
  87535. get samplingMode(): number;
  87536. /**
  87537. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  87538. */
  87539. get invertY(): boolean;
  87540. /**
  87541. * Instantiates a new texture.
  87542. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  87543. * @see http://doc.babylonjs.com/babylon101/materials#texture
  87544. * @param url defines the url of the picture to load as a texture
  87545. * @param scene defines the scene or engine the texture will belong to
  87546. * @param noMipmap defines if the texture will require mip maps or not
  87547. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  87548. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  87549. * @param onLoad defines a callback triggered when the texture has been loaded
  87550. * @param onError defines a callback triggered when an error occurred during the loading session
  87551. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  87552. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  87553. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  87554. * @param mimeType defines an optional mime type information
  87555. */
  87556. 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);
  87557. /**
  87558. * Update the url (and optional buffer) of this texture if url was null during construction.
  87559. * @param url the url of the texture
  87560. * @param buffer the buffer of the texture (defaults to null)
  87561. * @param onLoad callback called when the texture is loaded (defaults to null)
  87562. */
  87563. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  87564. /**
  87565. * Finish the loading sequence of a texture flagged as delayed load.
  87566. * @hidden
  87567. */
  87568. delayLoad(): void;
  87569. private _prepareRowForTextureGeneration;
  87570. /**
  87571. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  87572. * @returns the transform matrix of the texture.
  87573. */
  87574. getTextureMatrix(uBase?: number): Matrix;
  87575. /**
  87576. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  87577. * @returns The reflection texture transform
  87578. */
  87579. getReflectionTextureMatrix(): Matrix;
  87580. /**
  87581. * Clones the texture.
  87582. * @returns the cloned texture
  87583. */
  87584. clone(): Texture;
  87585. /**
  87586. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87587. * @returns The JSON representation of the texture
  87588. */
  87589. serialize(): any;
  87590. /**
  87591. * Get the current class name of the texture useful for serialization or dynamic coding.
  87592. * @returns "Texture"
  87593. */
  87594. getClassName(): string;
  87595. /**
  87596. * Dispose the texture and release its associated resources.
  87597. */
  87598. dispose(): void;
  87599. /**
  87600. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  87601. * @param parsedTexture Define the JSON representation of the texture
  87602. * @param scene Define the scene the parsed texture should be instantiated in
  87603. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  87604. * @returns The parsed texture if successful
  87605. */
  87606. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  87607. /**
  87608. * Creates a texture from its base 64 representation.
  87609. * @param data Define the base64 payload without the data: prefix
  87610. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  87611. * @param scene Define the scene the texture should belong to
  87612. * @param noMipmap Forces the texture to not create mip map information if true
  87613. * @param invertY define if the texture needs to be inverted on the y axis during loading
  87614. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  87615. * @param onLoad define a callback triggered when the texture has been loaded
  87616. * @param onError define a callback triggered when an error occurred during the loading session
  87617. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  87618. * @returns the created texture
  87619. */
  87620. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  87621. /**
  87622. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  87623. * @param data Define the base64 payload without the data: prefix
  87624. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  87625. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  87626. * @param scene Define the scene the texture should belong to
  87627. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  87628. * @param noMipmap Forces the texture to not create mip map information if true
  87629. * @param invertY define if the texture needs to be inverted on the y axis during loading
  87630. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  87631. * @param onLoad define a callback triggered when the texture has been loaded
  87632. * @param onError define a callback triggered when an error occurred during the loading session
  87633. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  87634. * @returns the created texture
  87635. */
  87636. 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;
  87637. }
  87638. }
  87639. declare module BABYLON {
  87640. /**
  87641. * PostProcessManager is used to manage one or more post processes or post process pipelines
  87642. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  87643. */
  87644. export class PostProcessManager {
  87645. private _scene;
  87646. private _indexBuffer;
  87647. private _vertexBuffers;
  87648. /**
  87649. * Creates a new instance PostProcess
  87650. * @param scene The scene that the post process is associated with.
  87651. */
  87652. constructor(scene: Scene);
  87653. private _prepareBuffers;
  87654. private _buildIndexBuffer;
  87655. /**
  87656. * Rebuilds the vertex buffers of the manager.
  87657. * @hidden
  87658. */
  87659. _rebuild(): void;
  87660. /**
  87661. * Prepares a frame to be run through a post process.
  87662. * @param sourceTexture The input texture to the post procesess. (default: null)
  87663. * @param postProcesses An array of post processes to be run. (default: null)
  87664. * @returns True if the post processes were able to be run.
  87665. * @hidden
  87666. */
  87667. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  87668. /**
  87669. * Manually render a set of post processes to a texture.
  87670. * @param postProcesses An array of post processes to be run.
  87671. * @param targetTexture The target texture to render to.
  87672. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  87673. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  87674. * @param lodLevel defines which lod of the texture to render to
  87675. */
  87676. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  87677. /**
  87678. * Finalize the result of the output of the postprocesses.
  87679. * @param doNotPresent If true the result will not be displayed to the screen.
  87680. * @param targetTexture The target texture to render to.
  87681. * @param faceIndex The index of the face to bind the target texture to.
  87682. * @param postProcesses The array of post processes to render.
  87683. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  87684. * @hidden
  87685. */
  87686. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  87687. /**
  87688. * Disposes of the post process manager.
  87689. */
  87690. dispose(): void;
  87691. }
  87692. }
  87693. declare module BABYLON {
  87694. /** Interface used by value gradients (color, factor, ...) */
  87695. export interface IValueGradient {
  87696. /**
  87697. * Gets or sets the gradient value (between 0 and 1)
  87698. */
  87699. gradient: number;
  87700. }
  87701. /** Class used to store color4 gradient */
  87702. export class ColorGradient implements IValueGradient {
  87703. /**
  87704. * Gets or sets the gradient value (between 0 and 1)
  87705. */
  87706. gradient: number;
  87707. /**
  87708. * Gets or sets first associated color
  87709. */
  87710. color1: Color4;
  87711. /**
  87712. * Gets or sets second associated color
  87713. */
  87714. color2?: Color4;
  87715. /**
  87716. * Will get a color picked randomly between color1 and color2.
  87717. * If color2 is undefined then color1 will be used
  87718. * @param result defines the target Color4 to store the result in
  87719. */
  87720. getColorToRef(result: Color4): void;
  87721. }
  87722. /** Class used to store color 3 gradient */
  87723. export class Color3Gradient implements IValueGradient {
  87724. /**
  87725. * Gets or sets the gradient value (between 0 and 1)
  87726. */
  87727. gradient: number;
  87728. /**
  87729. * Gets or sets the associated color
  87730. */
  87731. color: Color3;
  87732. }
  87733. /** Class used to store factor gradient */
  87734. export class FactorGradient implements IValueGradient {
  87735. /**
  87736. * Gets or sets the gradient value (between 0 and 1)
  87737. */
  87738. gradient: number;
  87739. /**
  87740. * Gets or sets first associated factor
  87741. */
  87742. factor1: number;
  87743. /**
  87744. * Gets or sets second associated factor
  87745. */
  87746. factor2?: number;
  87747. /**
  87748. * Will get a number picked randomly between factor1 and factor2.
  87749. * If factor2 is undefined then factor1 will be used
  87750. * @returns the picked number
  87751. */
  87752. getFactor(): number;
  87753. }
  87754. /**
  87755. * Helper used to simplify some generic gradient tasks
  87756. */
  87757. export class GradientHelper {
  87758. /**
  87759. * Gets the current gradient from an array of IValueGradient
  87760. * @param ratio defines the current ratio to get
  87761. * @param gradients defines the array of IValueGradient
  87762. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87763. */
  87764. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87765. }
  87766. }
  87767. declare module BABYLON {
  87768. interface ThinEngine {
  87769. /**
  87770. * Creates a dynamic texture
  87771. * @param width defines the width of the texture
  87772. * @param height defines the height of the texture
  87773. * @param generateMipMaps defines if the engine should generate the mip levels
  87774. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87775. * @returns the dynamic texture inside an InternalTexture
  87776. */
  87777. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87778. /**
  87779. * Update the content of a dynamic texture
  87780. * @param texture defines the texture to update
  87781. * @param canvas defines the canvas containing the source
  87782. * @param invertY defines if data must be stored with Y axis inverted
  87783. * @param premulAlpha defines if alpha is stored as premultiplied
  87784. * @param format defines the format of the data
  87785. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87786. */
  87787. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87788. }
  87789. }
  87790. declare module BABYLON {
  87791. /**
  87792. * Helper class used to generate a canvas to manipulate images
  87793. */
  87794. export class CanvasGenerator {
  87795. /**
  87796. * Create a new canvas (or offscreen canvas depending on the context)
  87797. * @param width defines the expected width
  87798. * @param height defines the expected height
  87799. * @return a new canvas or offscreen canvas
  87800. */
  87801. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  87802. }
  87803. }
  87804. declare module BABYLON {
  87805. /**
  87806. * A class extending Texture allowing drawing on a texture
  87807. * @see http://doc.babylonjs.com/how_to/dynamictexture
  87808. */
  87809. export class DynamicTexture extends Texture {
  87810. private _generateMipMaps;
  87811. private _canvas;
  87812. private _context;
  87813. private _engine;
  87814. /**
  87815. * Creates a DynamicTexture
  87816. * @param name defines the name of the texture
  87817. * @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
  87818. * @param scene defines the scene where you want the texture
  87819. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  87820. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  87821. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  87822. */
  87823. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  87824. /**
  87825. * Get the current class name of the texture useful for serialization or dynamic coding.
  87826. * @returns "DynamicTexture"
  87827. */
  87828. getClassName(): string;
  87829. /**
  87830. * Gets the current state of canRescale
  87831. */
  87832. get canRescale(): boolean;
  87833. private _recreate;
  87834. /**
  87835. * Scales the texture
  87836. * @param ratio the scale factor to apply to both width and height
  87837. */
  87838. scale(ratio: number): void;
  87839. /**
  87840. * Resizes the texture
  87841. * @param width the new width
  87842. * @param height the new height
  87843. */
  87844. scaleTo(width: number, height: number): void;
  87845. /**
  87846. * Gets the context of the canvas used by the texture
  87847. * @returns the canvas context of the dynamic texture
  87848. */
  87849. getContext(): CanvasRenderingContext2D;
  87850. /**
  87851. * Clears the texture
  87852. */
  87853. clear(): void;
  87854. /**
  87855. * Updates the texture
  87856. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87857. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87858. */
  87859. update(invertY?: boolean, premulAlpha?: boolean): void;
  87860. /**
  87861. * Draws text onto the texture
  87862. * @param text defines the text to be drawn
  87863. * @param x defines the placement of the text from the left
  87864. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87865. * @param font defines the font to be used with font-style, font-size, font-name
  87866. * @param color defines the color used for the text
  87867. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87868. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87869. * @param update defines whether texture is immediately update (default is true)
  87870. */
  87871. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87872. /**
  87873. * Clones the texture
  87874. * @returns the clone of the texture.
  87875. */
  87876. clone(): DynamicTexture;
  87877. /**
  87878. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87879. * @returns a serialized dynamic texture object
  87880. */
  87881. serialize(): any;
  87882. /** @hidden */
  87883. _rebuild(): void;
  87884. }
  87885. }
  87886. declare module BABYLON {
  87887. interface AbstractScene {
  87888. /**
  87889. * The list of procedural textures added to the scene
  87890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87891. */
  87892. proceduralTextures: Array<ProceduralTexture>;
  87893. }
  87894. /**
  87895. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87896. * in a given scene.
  87897. */
  87898. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87899. /**
  87900. * The component name helpfull to identify the component in the list of scene components.
  87901. */
  87902. readonly name: string;
  87903. /**
  87904. * The scene the component belongs to.
  87905. */
  87906. scene: Scene;
  87907. /**
  87908. * Creates a new instance of the component for the given scene
  87909. * @param scene Defines the scene to register the component in
  87910. */
  87911. constructor(scene: Scene);
  87912. /**
  87913. * Registers the component in a given scene
  87914. */
  87915. register(): void;
  87916. /**
  87917. * Rebuilds the elements related to this component in case of
  87918. * context lost for instance.
  87919. */
  87920. rebuild(): void;
  87921. /**
  87922. * Disposes the component and the associated ressources.
  87923. */
  87924. dispose(): void;
  87925. private _beforeClear;
  87926. }
  87927. }
  87928. declare module BABYLON {
  87929. interface ThinEngine {
  87930. /**
  87931. * Creates a new render target cube texture
  87932. * @param size defines the size of the texture
  87933. * @param options defines the options used to create the texture
  87934. * @returns a new render target cube texture stored in an InternalTexture
  87935. */
  87936. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87937. }
  87938. }
  87939. declare module BABYLON {
  87940. /** @hidden */
  87941. export var proceduralVertexShader: {
  87942. name: string;
  87943. shader: string;
  87944. };
  87945. }
  87946. declare module BABYLON {
  87947. /**
  87948. * 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.
  87949. * This is the base class of any Procedural texture and contains most of the shareable code.
  87950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87951. */
  87952. export class ProceduralTexture extends Texture {
  87953. isCube: boolean;
  87954. /**
  87955. * Define if the texture is enabled or not (disabled texture will not render)
  87956. */
  87957. isEnabled: boolean;
  87958. /**
  87959. * Define if the texture must be cleared before rendering (default is true)
  87960. */
  87961. autoClear: boolean;
  87962. /**
  87963. * Callback called when the texture is generated
  87964. */
  87965. onGenerated: () => void;
  87966. /**
  87967. * Event raised when the texture is generated
  87968. */
  87969. onGeneratedObservable: Observable<ProceduralTexture>;
  87970. /** @hidden */
  87971. _generateMipMaps: boolean;
  87972. /** @hidden **/
  87973. _effect: Effect;
  87974. /** @hidden */
  87975. _textures: {
  87976. [key: string]: Texture;
  87977. };
  87978. private _size;
  87979. private _currentRefreshId;
  87980. private _frameId;
  87981. private _refreshRate;
  87982. private _vertexBuffers;
  87983. private _indexBuffer;
  87984. private _uniforms;
  87985. private _samplers;
  87986. private _fragment;
  87987. private _floats;
  87988. private _ints;
  87989. private _floatsArrays;
  87990. private _colors3;
  87991. private _colors4;
  87992. private _vectors2;
  87993. private _vectors3;
  87994. private _matrices;
  87995. private _fallbackTexture;
  87996. private _fallbackTextureUsed;
  87997. private _engine;
  87998. private _cachedDefines;
  87999. private _contentUpdateId;
  88000. private _contentData;
  88001. /**
  88002. * Instantiates a new procedural texture.
  88003. * 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.
  88004. * This is the base class of any Procedural texture and contains most of the shareable code.
  88005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88006. * @param name Define the name of the texture
  88007. * @param size Define the size of the texture to create
  88008. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  88009. * @param scene Define the scene the texture belongs to
  88010. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  88011. * @param generateMipMaps Define if the texture should creates mip maps or not
  88012. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  88013. */
  88014. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  88015. /**
  88016. * The effect that is created when initializing the post process.
  88017. * @returns The created effect corresponding the the postprocess.
  88018. */
  88019. getEffect(): Effect;
  88020. /**
  88021. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  88022. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  88023. */
  88024. getContent(): Nullable<ArrayBufferView>;
  88025. private _createIndexBuffer;
  88026. /** @hidden */
  88027. _rebuild(): void;
  88028. /**
  88029. * Resets the texture in order to recreate its associated resources.
  88030. * This can be called in case of context loss
  88031. */
  88032. reset(): void;
  88033. protected _getDefines(): string;
  88034. /**
  88035. * Is the texture ready to be used ? (rendered at least once)
  88036. * @returns true if ready, otherwise, false.
  88037. */
  88038. isReady(): boolean;
  88039. /**
  88040. * Resets the refresh counter of the texture and start bak from scratch.
  88041. * Could be useful to regenerate the texture if it is setup to render only once.
  88042. */
  88043. resetRefreshCounter(): void;
  88044. /**
  88045. * Set the fragment shader to use in order to render the texture.
  88046. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  88047. */
  88048. setFragment(fragment: any): void;
  88049. /**
  88050. * Define the refresh rate of the texture or the rendering frequency.
  88051. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88052. */
  88053. get refreshRate(): number;
  88054. set refreshRate(value: number);
  88055. /** @hidden */
  88056. _shouldRender(): boolean;
  88057. /**
  88058. * Get the size the texture is rendering at.
  88059. * @returns the size (texture is always squared)
  88060. */
  88061. getRenderSize(): number;
  88062. /**
  88063. * Resize the texture to new value.
  88064. * @param size Define the new size the texture should have
  88065. * @param generateMipMaps Define whether the new texture should create mip maps
  88066. */
  88067. resize(size: number, generateMipMaps: boolean): void;
  88068. private _checkUniform;
  88069. /**
  88070. * Set a texture in the shader program used to render.
  88071. * @param name Define the name of the uniform samplers as defined in the shader
  88072. * @param texture Define the texture to bind to this sampler
  88073. * @return the texture itself allowing "fluent" like uniform updates
  88074. */
  88075. setTexture(name: string, texture: Texture): ProceduralTexture;
  88076. /**
  88077. * Set a float in the shader.
  88078. * @param name Define the name of the uniform as defined in the shader
  88079. * @param value Define the value to give to the uniform
  88080. * @return the texture itself allowing "fluent" like uniform updates
  88081. */
  88082. setFloat(name: string, value: number): ProceduralTexture;
  88083. /**
  88084. * Set a int in the shader.
  88085. * @param name Define the name of the uniform as defined in the shader
  88086. * @param value Define the value to give to the uniform
  88087. * @return the texture itself allowing "fluent" like uniform updates
  88088. */
  88089. setInt(name: string, value: number): ProceduralTexture;
  88090. /**
  88091. * Set an array of floats in the shader.
  88092. * @param name Define the name of the uniform as defined in the shader
  88093. * @param value Define the value to give to the uniform
  88094. * @return the texture itself allowing "fluent" like uniform updates
  88095. */
  88096. setFloats(name: string, value: number[]): ProceduralTexture;
  88097. /**
  88098. * Set a vec3 in the shader from a Color3.
  88099. * @param name Define the name of the uniform as defined in the shader
  88100. * @param value Define the value to give to the uniform
  88101. * @return the texture itself allowing "fluent" like uniform updates
  88102. */
  88103. setColor3(name: string, value: Color3): ProceduralTexture;
  88104. /**
  88105. * Set a vec4 in the shader from a Color4.
  88106. * @param name Define the name of the uniform as defined in the shader
  88107. * @param value Define the value to give to the uniform
  88108. * @return the texture itself allowing "fluent" like uniform updates
  88109. */
  88110. setColor4(name: string, value: Color4): ProceduralTexture;
  88111. /**
  88112. * Set a vec2 in the shader from a Vector2.
  88113. * @param name Define the name of the uniform as defined in the shader
  88114. * @param value Define the value to give to the uniform
  88115. * @return the texture itself allowing "fluent" like uniform updates
  88116. */
  88117. setVector2(name: string, value: Vector2): ProceduralTexture;
  88118. /**
  88119. * Set a vec3 in the shader from a Vector3.
  88120. * @param name Define the name of the uniform as defined in the shader
  88121. * @param value Define the value to give to the uniform
  88122. * @return the texture itself allowing "fluent" like uniform updates
  88123. */
  88124. setVector3(name: string, value: Vector3): ProceduralTexture;
  88125. /**
  88126. * Set a mat4 in the shader from a MAtrix.
  88127. * @param name Define the name of the uniform as defined in the shader
  88128. * @param value Define the value to give to the uniform
  88129. * @return the texture itself allowing "fluent" like uniform updates
  88130. */
  88131. setMatrix(name: string, value: Matrix): ProceduralTexture;
  88132. /**
  88133. * Render the texture to its associated render target.
  88134. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  88135. */
  88136. render(useCameraPostProcess?: boolean): void;
  88137. /**
  88138. * Clone the texture.
  88139. * @returns the cloned texture
  88140. */
  88141. clone(): ProceduralTexture;
  88142. /**
  88143. * Dispose the texture and release its asoociated resources.
  88144. */
  88145. dispose(): void;
  88146. }
  88147. }
  88148. declare module BABYLON {
  88149. /**
  88150. * This represents the base class for particle system in Babylon.
  88151. * 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.
  88152. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88153. * @example https://doc.babylonjs.com/babylon101/particles
  88154. */
  88155. export class BaseParticleSystem {
  88156. /**
  88157. * Source color is added to the destination color without alpha affecting the result
  88158. */
  88159. static BLENDMODE_ONEONE: number;
  88160. /**
  88161. * Blend current color and particle color using particle’s alpha
  88162. */
  88163. static BLENDMODE_STANDARD: number;
  88164. /**
  88165. * Add current color and particle color multiplied by particle’s alpha
  88166. */
  88167. static BLENDMODE_ADD: number;
  88168. /**
  88169. * Multiply current color with particle color
  88170. */
  88171. static BLENDMODE_MULTIPLY: number;
  88172. /**
  88173. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  88174. */
  88175. static BLENDMODE_MULTIPLYADD: number;
  88176. /**
  88177. * List of animations used by the particle system.
  88178. */
  88179. animations: Animation[];
  88180. /**
  88181. * The id of the Particle system.
  88182. */
  88183. id: string;
  88184. /**
  88185. * The friendly name of the Particle system.
  88186. */
  88187. name: string;
  88188. /**
  88189. * The rendering group used by the Particle system to chose when to render.
  88190. */
  88191. renderingGroupId: number;
  88192. /**
  88193. * The emitter represents the Mesh or position we are attaching the particle system to.
  88194. */
  88195. emitter: Nullable<AbstractMesh | Vector3>;
  88196. /**
  88197. * The maximum number of particles to emit per frame
  88198. */
  88199. emitRate: number;
  88200. /**
  88201. * If you want to launch only a few particles at once, that can be done, as well.
  88202. */
  88203. manualEmitCount: number;
  88204. /**
  88205. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  88206. */
  88207. updateSpeed: number;
  88208. /**
  88209. * The amount of time the particle system is running (depends of the overall update speed).
  88210. */
  88211. targetStopDuration: number;
  88212. /**
  88213. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  88214. */
  88215. disposeOnStop: boolean;
  88216. /**
  88217. * Minimum power of emitting particles.
  88218. */
  88219. minEmitPower: number;
  88220. /**
  88221. * Maximum power of emitting particles.
  88222. */
  88223. maxEmitPower: number;
  88224. /**
  88225. * Minimum life time of emitting particles.
  88226. */
  88227. minLifeTime: number;
  88228. /**
  88229. * Maximum life time of emitting particles.
  88230. */
  88231. maxLifeTime: number;
  88232. /**
  88233. * Minimum Size of emitting particles.
  88234. */
  88235. minSize: number;
  88236. /**
  88237. * Maximum Size of emitting particles.
  88238. */
  88239. maxSize: number;
  88240. /**
  88241. * Minimum scale of emitting particles on X axis.
  88242. */
  88243. minScaleX: number;
  88244. /**
  88245. * Maximum scale of emitting particles on X axis.
  88246. */
  88247. maxScaleX: number;
  88248. /**
  88249. * Minimum scale of emitting particles on Y axis.
  88250. */
  88251. minScaleY: number;
  88252. /**
  88253. * Maximum scale of emitting particles on Y axis.
  88254. */
  88255. maxScaleY: number;
  88256. /**
  88257. * Gets or sets the minimal initial rotation in radians.
  88258. */
  88259. minInitialRotation: number;
  88260. /**
  88261. * Gets or sets the maximal initial rotation in radians.
  88262. */
  88263. maxInitialRotation: number;
  88264. /**
  88265. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  88266. */
  88267. minAngularSpeed: number;
  88268. /**
  88269. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  88270. */
  88271. maxAngularSpeed: number;
  88272. /**
  88273. * The texture used to render each particle. (this can be a spritesheet)
  88274. */
  88275. particleTexture: Nullable<Texture>;
  88276. /**
  88277. * The layer mask we are rendering the particles through.
  88278. */
  88279. layerMask: number;
  88280. /**
  88281. * This can help using your own shader to render the particle system.
  88282. * The according effect will be created
  88283. */
  88284. customShader: any;
  88285. /**
  88286. * By default particle system starts as soon as they are created. This prevents the
  88287. * automatic start to happen and let you decide when to start emitting particles.
  88288. */
  88289. preventAutoStart: boolean;
  88290. private _noiseTexture;
  88291. /**
  88292. * Gets or sets a texture used to add random noise to particle positions
  88293. */
  88294. get noiseTexture(): Nullable<ProceduralTexture>;
  88295. set noiseTexture(value: Nullable<ProceduralTexture>);
  88296. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  88297. noiseStrength: Vector3;
  88298. /**
  88299. * Callback triggered when the particle animation is ending.
  88300. */
  88301. onAnimationEnd: Nullable<() => void>;
  88302. /**
  88303. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  88304. */
  88305. blendMode: number;
  88306. /**
  88307. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  88308. * to override the particles.
  88309. */
  88310. forceDepthWrite: boolean;
  88311. /** 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 */
  88312. preWarmCycles: number;
  88313. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  88314. preWarmStepOffset: number;
  88315. /**
  88316. * 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)
  88317. */
  88318. spriteCellChangeSpeed: number;
  88319. /**
  88320. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  88321. */
  88322. startSpriteCellID: number;
  88323. /**
  88324. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  88325. */
  88326. endSpriteCellID: number;
  88327. /**
  88328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  88329. */
  88330. spriteCellWidth: number;
  88331. /**
  88332. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  88333. */
  88334. spriteCellHeight: number;
  88335. /**
  88336. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  88337. */
  88338. spriteRandomStartCell: boolean;
  88339. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  88340. translationPivot: Vector2;
  88341. /** @hidden */
  88342. protected _isAnimationSheetEnabled: boolean;
  88343. /**
  88344. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  88345. */
  88346. beginAnimationOnStart: boolean;
  88347. /**
  88348. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  88349. */
  88350. beginAnimationFrom: number;
  88351. /**
  88352. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  88353. */
  88354. beginAnimationTo: number;
  88355. /**
  88356. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  88357. */
  88358. beginAnimationLoop: boolean;
  88359. /**
  88360. * Gets or sets a world offset applied to all particles
  88361. */
  88362. worldOffset: Vector3;
  88363. /**
  88364. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  88365. */
  88366. get isAnimationSheetEnabled(): boolean;
  88367. set isAnimationSheetEnabled(value: boolean);
  88368. /**
  88369. * Get hosting scene
  88370. * @returns the scene
  88371. */
  88372. getScene(): Scene;
  88373. /**
  88374. * You can use gravity if you want to give an orientation to your particles.
  88375. */
  88376. gravity: Vector3;
  88377. protected _colorGradients: Nullable<Array<ColorGradient>>;
  88378. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  88379. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  88380. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  88381. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  88382. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  88383. protected _dragGradients: Nullable<Array<FactorGradient>>;
  88384. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  88385. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  88386. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  88387. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  88388. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  88389. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  88390. /**
  88391. * Defines the delay in milliseconds before starting the system (0 by default)
  88392. */
  88393. startDelay: number;
  88394. /**
  88395. * Gets the current list of drag gradients.
  88396. * You must use addDragGradient and removeDragGradient to udpate this list
  88397. * @returns the list of drag gradients
  88398. */
  88399. getDragGradients(): Nullable<Array<FactorGradient>>;
  88400. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  88401. limitVelocityDamping: number;
  88402. /**
  88403. * Gets the current list of limit velocity gradients.
  88404. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  88405. * @returns the list of limit velocity gradients
  88406. */
  88407. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  88408. /**
  88409. * Gets the current list of color gradients.
  88410. * You must use addColorGradient and removeColorGradient to udpate this list
  88411. * @returns the list of color gradients
  88412. */
  88413. getColorGradients(): Nullable<Array<ColorGradient>>;
  88414. /**
  88415. * Gets the current list of size gradients.
  88416. * You must use addSizeGradient and removeSizeGradient to udpate this list
  88417. * @returns the list of size gradients
  88418. */
  88419. getSizeGradients(): Nullable<Array<FactorGradient>>;
  88420. /**
  88421. * Gets the current list of color remap gradients.
  88422. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  88423. * @returns the list of color remap gradients
  88424. */
  88425. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  88426. /**
  88427. * Gets the current list of alpha remap gradients.
  88428. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  88429. * @returns the list of alpha remap gradients
  88430. */
  88431. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  88432. /**
  88433. * Gets the current list of life time gradients.
  88434. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  88435. * @returns the list of life time gradients
  88436. */
  88437. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  88438. /**
  88439. * Gets the current list of angular speed gradients.
  88440. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  88441. * @returns the list of angular speed gradients
  88442. */
  88443. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  88444. /**
  88445. * Gets the current list of velocity gradients.
  88446. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  88447. * @returns the list of velocity gradients
  88448. */
  88449. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  88450. /**
  88451. * Gets the current list of start size gradients.
  88452. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  88453. * @returns the list of start size gradients
  88454. */
  88455. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  88456. /**
  88457. * Gets the current list of emit rate gradients.
  88458. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  88459. * @returns the list of emit rate gradients
  88460. */
  88461. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  88462. /**
  88463. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88464. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88465. */
  88466. get direction1(): Vector3;
  88467. set direction1(value: Vector3);
  88468. /**
  88469. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88470. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88471. */
  88472. get direction2(): Vector3;
  88473. set direction2(value: Vector3);
  88474. /**
  88475. * 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.
  88476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88477. */
  88478. get minEmitBox(): Vector3;
  88479. set minEmitBox(value: Vector3);
  88480. /**
  88481. * 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.
  88482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88483. */
  88484. get maxEmitBox(): Vector3;
  88485. set maxEmitBox(value: Vector3);
  88486. /**
  88487. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  88488. */
  88489. color1: Color4;
  88490. /**
  88491. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  88492. */
  88493. color2: Color4;
  88494. /**
  88495. * Color the particle will have at the end of its lifetime
  88496. */
  88497. colorDead: Color4;
  88498. /**
  88499. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  88500. */
  88501. textureMask: Color4;
  88502. /**
  88503. * The particle emitter type defines the emitter used by the particle system.
  88504. * It can be for example box, sphere, or cone...
  88505. */
  88506. particleEmitterType: IParticleEmitterType;
  88507. /** @hidden */
  88508. _isSubEmitter: boolean;
  88509. /**
  88510. * Gets or sets the billboard mode to use when isBillboardBased = true.
  88511. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  88512. */
  88513. billboardMode: number;
  88514. protected _isBillboardBased: boolean;
  88515. /**
  88516. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  88517. */
  88518. get isBillboardBased(): boolean;
  88519. set isBillboardBased(value: boolean);
  88520. /**
  88521. * The scene the particle system belongs to.
  88522. */
  88523. protected _scene: Scene;
  88524. /**
  88525. * Local cache of defines for image processing.
  88526. */
  88527. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  88528. /**
  88529. * Default configuration related to image processing available in the standard Material.
  88530. */
  88531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88532. /**
  88533. * Gets the image processing configuration used either in this material.
  88534. */
  88535. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  88536. /**
  88537. * Sets the Default image processing configuration used either in the this material.
  88538. *
  88539. * If sets to null, the scene one is in use.
  88540. */
  88541. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  88542. /**
  88543. * Attaches a new image processing configuration to the Standard Material.
  88544. * @param configuration
  88545. */
  88546. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  88547. /** @hidden */
  88548. protected _reset(): void;
  88549. /** @hidden */
  88550. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  88551. /**
  88552. * Instantiates a particle system.
  88553. * 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.
  88554. * @param name The name of the particle system
  88555. */
  88556. constructor(name: string);
  88557. /**
  88558. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  88559. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88560. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88561. * @returns the emitter
  88562. */
  88563. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  88564. /**
  88565. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  88566. * @param radius The radius of the hemisphere to emit from
  88567. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88568. * @returns the emitter
  88569. */
  88570. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  88571. /**
  88572. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  88573. * @param radius The radius of the sphere to emit from
  88574. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88575. * @returns the emitter
  88576. */
  88577. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  88578. /**
  88579. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  88580. * @param radius The radius of the sphere to emit from
  88581. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  88582. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  88583. * @returns the emitter
  88584. */
  88585. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  88586. /**
  88587. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  88588. * @param radius The radius of the emission cylinder
  88589. * @param height The height of the emission cylinder
  88590. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  88591. * @param directionRandomizer How much to randomize the particle direction [0-1]
  88592. * @returns the emitter
  88593. */
  88594. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  88595. /**
  88596. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  88597. * @param radius The radius of the cylinder to emit from
  88598. * @param height The height of the emission cylinder
  88599. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  88601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  88602. * @returns the emitter
  88603. */
  88604. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  88605. /**
  88606. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  88607. * @param radius The radius of the cone to emit from
  88608. * @param angle The base angle of the cone
  88609. * @returns the emitter
  88610. */
  88611. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  88612. /**
  88613. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  88614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88616. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88617. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88618. * @returns the emitter
  88619. */
  88620. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  88621. }
  88622. }
  88623. declare module BABYLON {
  88624. /**
  88625. * Type of sub emitter
  88626. */
  88627. export enum SubEmitterType {
  88628. /**
  88629. * Attached to the particle over it's lifetime
  88630. */
  88631. ATTACHED = 0,
  88632. /**
  88633. * Created when the particle dies
  88634. */
  88635. END = 1
  88636. }
  88637. /**
  88638. * Sub emitter class used to emit particles from an existing particle
  88639. */
  88640. export class SubEmitter {
  88641. /**
  88642. * the particle system to be used by the sub emitter
  88643. */
  88644. particleSystem: ParticleSystem;
  88645. /**
  88646. * Type of the submitter (Default: END)
  88647. */
  88648. type: SubEmitterType;
  88649. /**
  88650. * 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)
  88651. * Note: This only is supported when using an emitter of type Mesh
  88652. */
  88653. inheritDirection: boolean;
  88654. /**
  88655. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  88656. */
  88657. inheritedVelocityAmount: number;
  88658. /**
  88659. * Creates a sub emitter
  88660. * @param particleSystem the particle system to be used by the sub emitter
  88661. */
  88662. constructor(
  88663. /**
  88664. * the particle system to be used by the sub emitter
  88665. */
  88666. particleSystem: ParticleSystem);
  88667. /**
  88668. * Clones the sub emitter
  88669. * @returns the cloned sub emitter
  88670. */
  88671. clone(): SubEmitter;
  88672. /**
  88673. * Serialize current object to a JSON object
  88674. * @returns the serialized object
  88675. */
  88676. serialize(): any;
  88677. /** @hidden */
  88678. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  88679. /**
  88680. * Creates a new SubEmitter from a serialized JSON version
  88681. * @param serializationObject defines the JSON object to read from
  88682. * @param scene defines the hosting scene
  88683. * @param rootUrl defines the rootUrl for data loading
  88684. * @returns a new SubEmitter
  88685. */
  88686. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  88687. /** Release associated resources */
  88688. dispose(): void;
  88689. }
  88690. }
  88691. declare module BABYLON {
  88692. /** @hidden */
  88693. export var clipPlaneFragmentDeclaration: {
  88694. name: string;
  88695. shader: string;
  88696. };
  88697. }
  88698. declare module BABYLON {
  88699. /** @hidden */
  88700. export var imageProcessingDeclaration: {
  88701. name: string;
  88702. shader: string;
  88703. };
  88704. }
  88705. declare module BABYLON {
  88706. /** @hidden */
  88707. export var imageProcessingFunctions: {
  88708. name: string;
  88709. shader: string;
  88710. };
  88711. }
  88712. declare module BABYLON {
  88713. /** @hidden */
  88714. export var clipPlaneFragment: {
  88715. name: string;
  88716. shader: string;
  88717. };
  88718. }
  88719. declare module BABYLON {
  88720. /** @hidden */
  88721. export var particlesPixelShader: {
  88722. name: string;
  88723. shader: string;
  88724. };
  88725. }
  88726. declare module BABYLON {
  88727. /** @hidden */
  88728. export var clipPlaneVertexDeclaration: {
  88729. name: string;
  88730. shader: string;
  88731. };
  88732. }
  88733. declare module BABYLON {
  88734. /** @hidden */
  88735. export var clipPlaneVertex: {
  88736. name: string;
  88737. shader: string;
  88738. };
  88739. }
  88740. declare module BABYLON {
  88741. /** @hidden */
  88742. export var particlesVertexShader: {
  88743. name: string;
  88744. shader: string;
  88745. };
  88746. }
  88747. declare module BABYLON {
  88748. /**
  88749. * This represents a particle system in Babylon.
  88750. * 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.
  88751. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88752. * @example https://doc.babylonjs.com/babylon101/particles
  88753. */
  88754. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  88755. /**
  88756. * Billboard mode will only apply to Y axis
  88757. */
  88758. static readonly BILLBOARDMODE_Y: number;
  88759. /**
  88760. * Billboard mode will apply to all axes
  88761. */
  88762. static readonly BILLBOARDMODE_ALL: number;
  88763. /**
  88764. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  88765. */
  88766. static readonly BILLBOARDMODE_STRETCHED: number;
  88767. /**
  88768. * This function can be defined to provide custom update for active particles.
  88769. * This function will be called instead of regular update (age, position, color, etc.).
  88770. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  88771. */
  88772. updateFunction: (particles: Particle[]) => void;
  88773. private _emitterWorldMatrix;
  88774. /**
  88775. * This function can be defined to specify initial direction for every new particle.
  88776. * It by default use the emitterType defined function
  88777. */
  88778. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  88779. /**
  88780. * This function can be defined to specify initial position for every new particle.
  88781. * It by default use the emitterType defined function
  88782. */
  88783. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  88784. /**
  88785. * @hidden
  88786. */
  88787. _inheritedVelocityOffset: Vector3;
  88788. /**
  88789. * An event triggered when the system is disposed
  88790. */
  88791. onDisposeObservable: Observable<ParticleSystem>;
  88792. private _onDisposeObserver;
  88793. /**
  88794. * Sets a callback that will be triggered when the system is disposed
  88795. */
  88796. set onDispose(callback: () => void);
  88797. private _particles;
  88798. private _epsilon;
  88799. private _capacity;
  88800. private _stockParticles;
  88801. private _newPartsExcess;
  88802. private _vertexData;
  88803. private _vertexBuffer;
  88804. private _vertexBuffers;
  88805. private _spriteBuffer;
  88806. private _indexBuffer;
  88807. private _effect;
  88808. private _customEffect;
  88809. private _cachedDefines;
  88810. private _scaledColorStep;
  88811. private _colorDiff;
  88812. private _scaledDirection;
  88813. private _scaledGravity;
  88814. private _currentRenderId;
  88815. private _alive;
  88816. private _useInstancing;
  88817. private _started;
  88818. private _stopped;
  88819. private _actualFrame;
  88820. private _scaledUpdateSpeed;
  88821. private _vertexBufferSize;
  88822. /** @hidden */
  88823. _currentEmitRateGradient: Nullable<FactorGradient>;
  88824. /** @hidden */
  88825. _currentEmitRate1: number;
  88826. /** @hidden */
  88827. _currentEmitRate2: number;
  88828. /** @hidden */
  88829. _currentStartSizeGradient: Nullable<FactorGradient>;
  88830. /** @hidden */
  88831. _currentStartSize1: number;
  88832. /** @hidden */
  88833. _currentStartSize2: number;
  88834. private readonly _rawTextureWidth;
  88835. private _rampGradientsTexture;
  88836. private _useRampGradients;
  88837. /** Gets or sets a boolean indicating that ramp gradients must be used
  88838. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88839. */
  88840. get useRampGradients(): boolean;
  88841. set useRampGradients(value: boolean);
  88842. /**
  88843. * 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.
  88844. * 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: [])
  88845. */
  88846. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88847. private _subEmitters;
  88848. /**
  88849. * @hidden
  88850. * If the particle systems emitter should be disposed when the particle system is disposed
  88851. */
  88852. _disposeEmitterOnDispose: boolean;
  88853. /**
  88854. * The current active Sub-systems, this property is used by the root particle system only.
  88855. */
  88856. activeSubSystems: Array<ParticleSystem>;
  88857. private _rootParticleSystem;
  88858. /**
  88859. * Gets the current list of active particles
  88860. */
  88861. get particles(): Particle[];
  88862. /**
  88863. * Returns the string "ParticleSystem"
  88864. * @returns a string containing the class name
  88865. */
  88866. getClassName(): string;
  88867. /**
  88868. * Instantiates a particle system.
  88869. * 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.
  88870. * @param name The name of the particle system
  88871. * @param capacity The max number of particles alive at the same time
  88872. * @param scene The scene the particle system belongs to
  88873. * @param customEffect a custom effect used to change the way particles are rendered by default
  88874. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88875. * @param epsilon Offset used to render the particles
  88876. */
  88877. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88878. private _addFactorGradient;
  88879. private _removeFactorGradient;
  88880. /**
  88881. * Adds a new life time gradient
  88882. * @param gradient defines the gradient to use (between 0 and 1)
  88883. * @param factor defines the life time factor to affect to the specified gradient
  88884. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88885. * @returns the current particle system
  88886. */
  88887. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88888. /**
  88889. * Remove a specific life time gradient
  88890. * @param gradient defines the gradient to remove
  88891. * @returns the current particle system
  88892. */
  88893. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88894. /**
  88895. * Adds a new size gradient
  88896. * @param gradient defines the gradient to use (between 0 and 1)
  88897. * @param factor defines the size factor to affect to the specified gradient
  88898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88899. * @returns the current particle system
  88900. */
  88901. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88902. /**
  88903. * Remove a specific size gradient
  88904. * @param gradient defines the gradient to remove
  88905. * @returns the current particle system
  88906. */
  88907. removeSizeGradient(gradient: number): IParticleSystem;
  88908. /**
  88909. * Adds a new color remap gradient
  88910. * @param gradient defines the gradient to use (between 0 and 1)
  88911. * @param min defines the color remap minimal range
  88912. * @param max defines the color remap maximal range
  88913. * @returns the current particle system
  88914. */
  88915. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88916. /**
  88917. * Remove a specific color remap gradient
  88918. * @param gradient defines the gradient to remove
  88919. * @returns the current particle system
  88920. */
  88921. removeColorRemapGradient(gradient: number): IParticleSystem;
  88922. /**
  88923. * Adds a new alpha remap gradient
  88924. * @param gradient defines the gradient to use (between 0 and 1)
  88925. * @param min defines the alpha remap minimal range
  88926. * @param max defines the alpha remap maximal range
  88927. * @returns the current particle system
  88928. */
  88929. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88930. /**
  88931. * Remove a specific alpha remap gradient
  88932. * @param gradient defines the gradient to remove
  88933. * @returns the current particle system
  88934. */
  88935. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88936. /**
  88937. * Adds a new angular speed gradient
  88938. * @param gradient defines the gradient to use (between 0 and 1)
  88939. * @param factor defines the angular speed to affect to the specified gradient
  88940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88941. * @returns the current particle system
  88942. */
  88943. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88944. /**
  88945. * Remove a specific angular speed gradient
  88946. * @param gradient defines the gradient to remove
  88947. * @returns the current particle system
  88948. */
  88949. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88950. /**
  88951. * Adds a new velocity gradient
  88952. * @param gradient defines the gradient to use (between 0 and 1)
  88953. * @param factor defines the velocity to affect to the specified gradient
  88954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88955. * @returns the current particle system
  88956. */
  88957. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88958. /**
  88959. * Remove a specific velocity gradient
  88960. * @param gradient defines the gradient to remove
  88961. * @returns the current particle system
  88962. */
  88963. removeVelocityGradient(gradient: number): IParticleSystem;
  88964. /**
  88965. * Adds a new limit velocity gradient
  88966. * @param gradient defines the gradient to use (between 0 and 1)
  88967. * @param factor defines the limit velocity value to affect to the specified gradient
  88968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88969. * @returns the current particle system
  88970. */
  88971. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88972. /**
  88973. * Remove a specific limit velocity gradient
  88974. * @param gradient defines the gradient to remove
  88975. * @returns the current particle system
  88976. */
  88977. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88978. /**
  88979. * Adds a new drag gradient
  88980. * @param gradient defines the gradient to use (between 0 and 1)
  88981. * @param factor defines the drag value to affect to the specified gradient
  88982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88983. * @returns the current particle system
  88984. */
  88985. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88986. /**
  88987. * Remove a specific drag gradient
  88988. * @param gradient defines the gradient to remove
  88989. * @returns the current particle system
  88990. */
  88991. removeDragGradient(gradient: number): IParticleSystem;
  88992. /**
  88993. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88994. * @param gradient defines the gradient to use (between 0 and 1)
  88995. * @param factor defines the emit rate value to affect to the specified gradient
  88996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88997. * @returns the current particle system
  88998. */
  88999. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89000. /**
  89001. * Remove a specific emit rate gradient
  89002. * @param gradient defines the gradient to remove
  89003. * @returns the current particle system
  89004. */
  89005. removeEmitRateGradient(gradient: number): IParticleSystem;
  89006. /**
  89007. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89008. * @param gradient defines the gradient to use (between 0 and 1)
  89009. * @param factor defines the start size value to affect to the specified gradient
  89010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89011. * @returns the current particle system
  89012. */
  89013. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89014. /**
  89015. * Remove a specific start size gradient
  89016. * @param gradient defines the gradient to remove
  89017. * @returns the current particle system
  89018. */
  89019. removeStartSizeGradient(gradient: number): IParticleSystem;
  89020. private _createRampGradientTexture;
  89021. /**
  89022. * Gets the current list of ramp gradients.
  89023. * You must use addRampGradient and removeRampGradient to udpate this list
  89024. * @returns the list of ramp gradients
  89025. */
  89026. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89027. /**
  89028. * Adds a new ramp gradient used to remap particle colors
  89029. * @param gradient defines the gradient to use (between 0 and 1)
  89030. * @param color defines the color to affect to the specified gradient
  89031. * @returns the current particle system
  89032. */
  89033. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  89034. /**
  89035. * Remove a specific ramp gradient
  89036. * @param gradient defines the gradient to remove
  89037. * @returns the current particle system
  89038. */
  89039. removeRampGradient(gradient: number): ParticleSystem;
  89040. /**
  89041. * Adds a new color gradient
  89042. * @param gradient defines the gradient to use (between 0 and 1)
  89043. * @param color1 defines the color to affect to the specified gradient
  89044. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89045. * @returns this particle system
  89046. */
  89047. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89048. /**
  89049. * Remove a specific color gradient
  89050. * @param gradient defines the gradient to remove
  89051. * @returns this particle system
  89052. */
  89053. removeColorGradient(gradient: number): IParticleSystem;
  89054. private _fetchR;
  89055. protected _reset(): void;
  89056. private _resetEffect;
  89057. private _createVertexBuffers;
  89058. private _createIndexBuffer;
  89059. /**
  89060. * Gets the maximum number of particles active at the same time.
  89061. * @returns The max number of active particles.
  89062. */
  89063. getCapacity(): number;
  89064. /**
  89065. * Gets whether there are still active particles in the system.
  89066. * @returns True if it is alive, otherwise false.
  89067. */
  89068. isAlive(): boolean;
  89069. /**
  89070. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89071. * @returns True if it has been started, otherwise false.
  89072. */
  89073. isStarted(): boolean;
  89074. private _prepareSubEmitterInternalArray;
  89075. /**
  89076. * Starts the particle system and begins to emit
  89077. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  89078. */
  89079. start(delay?: number): void;
  89080. /**
  89081. * Stops the particle system.
  89082. * @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.
  89083. */
  89084. stop(stopSubEmitters?: boolean): void;
  89085. /**
  89086. * Remove all active particles
  89087. */
  89088. reset(): void;
  89089. /**
  89090. * @hidden (for internal use only)
  89091. */
  89092. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  89093. /**
  89094. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  89095. * Its lifetime will start back at 0.
  89096. */
  89097. recycleParticle: (particle: Particle) => void;
  89098. private _stopSubEmitters;
  89099. private _createParticle;
  89100. private _removeFromRoot;
  89101. private _emitFromParticle;
  89102. private _update;
  89103. /** @hidden */
  89104. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  89105. /** @hidden */
  89106. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  89107. /** @hidden */
  89108. private _getEffect;
  89109. /**
  89110. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  89111. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  89112. */
  89113. animate(preWarmOnly?: boolean): void;
  89114. private _appendParticleVertices;
  89115. /**
  89116. * Rebuilds the particle system.
  89117. */
  89118. rebuild(): void;
  89119. /**
  89120. * Is this system ready to be used/rendered
  89121. * @return true if the system is ready
  89122. */
  89123. isReady(): boolean;
  89124. private _render;
  89125. /**
  89126. * Renders the particle system in its current state.
  89127. * @returns the current number of particles
  89128. */
  89129. render(): number;
  89130. /**
  89131. * Disposes the particle system and free the associated resources
  89132. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89133. */
  89134. dispose(disposeTexture?: boolean): void;
  89135. /**
  89136. * Clones the particle system.
  89137. * @param name The name of the cloned object
  89138. * @param newEmitter The new emitter to use
  89139. * @returns the cloned particle system
  89140. */
  89141. clone(name: string, newEmitter: any): ParticleSystem;
  89142. /**
  89143. * Serializes the particle system to a JSON object.
  89144. * @returns the JSON object
  89145. */
  89146. serialize(): any;
  89147. /** @hidden */
  89148. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  89149. /** @hidden */
  89150. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  89151. /**
  89152. * Parses a JSON object to create a particle system.
  89153. * @param parsedParticleSystem The JSON object to parse
  89154. * @param scene The scene to create the particle system in
  89155. * @param rootUrl The root url to use to load external dependencies like texture
  89156. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  89157. * @returns the Parsed particle system
  89158. */
  89159. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  89160. }
  89161. }
  89162. declare module BABYLON {
  89163. /**
  89164. * A particle represents one of the element emitted by a particle system.
  89165. * This is mainly define by its coordinates, direction, velocity and age.
  89166. */
  89167. export class Particle {
  89168. /**
  89169. * The particle system the particle belongs to.
  89170. */
  89171. particleSystem: ParticleSystem;
  89172. private static _Count;
  89173. /**
  89174. * Unique ID of the particle
  89175. */
  89176. id: number;
  89177. /**
  89178. * The world position of the particle in the scene.
  89179. */
  89180. position: Vector3;
  89181. /**
  89182. * The world direction of the particle in the scene.
  89183. */
  89184. direction: Vector3;
  89185. /**
  89186. * The color of the particle.
  89187. */
  89188. color: Color4;
  89189. /**
  89190. * The color change of the particle per step.
  89191. */
  89192. colorStep: Color4;
  89193. /**
  89194. * Defines how long will the life of the particle be.
  89195. */
  89196. lifeTime: number;
  89197. /**
  89198. * The current age of the particle.
  89199. */
  89200. age: number;
  89201. /**
  89202. * The current size of the particle.
  89203. */
  89204. size: number;
  89205. /**
  89206. * The current scale of the particle.
  89207. */
  89208. scale: Vector2;
  89209. /**
  89210. * The current angle of the particle.
  89211. */
  89212. angle: number;
  89213. /**
  89214. * Defines how fast is the angle changing.
  89215. */
  89216. angularSpeed: number;
  89217. /**
  89218. * Defines the cell index used by the particle to be rendered from a sprite.
  89219. */
  89220. cellIndex: number;
  89221. /**
  89222. * The information required to support color remapping
  89223. */
  89224. remapData: Vector4;
  89225. /** @hidden */
  89226. _randomCellOffset?: number;
  89227. /** @hidden */
  89228. _initialDirection: Nullable<Vector3>;
  89229. /** @hidden */
  89230. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  89231. /** @hidden */
  89232. _initialStartSpriteCellID: number;
  89233. /** @hidden */
  89234. _initialEndSpriteCellID: number;
  89235. /** @hidden */
  89236. _currentColorGradient: Nullable<ColorGradient>;
  89237. /** @hidden */
  89238. _currentColor1: Color4;
  89239. /** @hidden */
  89240. _currentColor2: Color4;
  89241. /** @hidden */
  89242. _currentSizeGradient: Nullable<FactorGradient>;
  89243. /** @hidden */
  89244. _currentSize1: number;
  89245. /** @hidden */
  89246. _currentSize2: number;
  89247. /** @hidden */
  89248. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  89249. /** @hidden */
  89250. _currentAngularSpeed1: number;
  89251. /** @hidden */
  89252. _currentAngularSpeed2: number;
  89253. /** @hidden */
  89254. _currentVelocityGradient: Nullable<FactorGradient>;
  89255. /** @hidden */
  89256. _currentVelocity1: number;
  89257. /** @hidden */
  89258. _currentVelocity2: number;
  89259. /** @hidden */
  89260. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  89261. /** @hidden */
  89262. _currentLimitVelocity1: number;
  89263. /** @hidden */
  89264. _currentLimitVelocity2: number;
  89265. /** @hidden */
  89266. _currentDragGradient: Nullable<FactorGradient>;
  89267. /** @hidden */
  89268. _currentDrag1: number;
  89269. /** @hidden */
  89270. _currentDrag2: number;
  89271. /** @hidden */
  89272. _randomNoiseCoordinates1: Vector3;
  89273. /** @hidden */
  89274. _randomNoiseCoordinates2: Vector3;
  89275. /**
  89276. * Creates a new instance Particle
  89277. * @param particleSystem the particle system the particle belongs to
  89278. */
  89279. constructor(
  89280. /**
  89281. * The particle system the particle belongs to.
  89282. */
  89283. particleSystem: ParticleSystem);
  89284. private updateCellInfoFromSystem;
  89285. /**
  89286. * Defines how the sprite cell index is updated for the particle
  89287. */
  89288. updateCellIndex(): void;
  89289. /** @hidden */
  89290. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  89291. /** @hidden */
  89292. _inheritParticleInfoToSubEmitters(): void;
  89293. /** @hidden */
  89294. _reset(): void;
  89295. /**
  89296. * Copy the properties of particle to another one.
  89297. * @param other the particle to copy the information to.
  89298. */
  89299. copyTo(other: Particle): void;
  89300. }
  89301. }
  89302. declare module BABYLON {
  89303. /**
  89304. * Particle emitter represents a volume emitting particles.
  89305. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  89306. */
  89307. export interface IParticleEmitterType {
  89308. /**
  89309. * Called by the particle System when the direction is computed for the created particle.
  89310. * @param worldMatrix is the world matrix of the particle system
  89311. * @param directionToUpdate is the direction vector to update with the result
  89312. * @param particle is the particle we are computed the direction for
  89313. */
  89314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89315. /**
  89316. * Called by the particle System when the position is computed for the created particle.
  89317. * @param worldMatrix is the world matrix of the particle system
  89318. * @param positionToUpdate is the position vector to update with the result
  89319. * @param particle is the particle we are computed the position for
  89320. */
  89321. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89322. /**
  89323. * Clones the current emitter and returns a copy of it
  89324. * @returns the new emitter
  89325. */
  89326. clone(): IParticleEmitterType;
  89327. /**
  89328. * Called by the GPUParticleSystem to setup the update shader
  89329. * @param effect defines the update shader
  89330. */
  89331. applyToShader(effect: Effect): void;
  89332. /**
  89333. * Returns a string to use to update the GPU particles update shader
  89334. * @returns the effect defines string
  89335. */
  89336. getEffectDefines(): string;
  89337. /**
  89338. * Returns a string representing the class name
  89339. * @returns a string containing the class name
  89340. */
  89341. getClassName(): string;
  89342. /**
  89343. * Serializes the particle system to a JSON object.
  89344. * @returns the JSON object
  89345. */
  89346. serialize(): any;
  89347. /**
  89348. * Parse properties from a JSON object
  89349. * @param serializationObject defines the JSON object
  89350. */
  89351. parse(serializationObject: any): void;
  89352. }
  89353. }
  89354. declare module BABYLON {
  89355. /**
  89356. * Particle emitter emitting particles from the inside of a box.
  89357. * It emits the particles randomly between 2 given directions.
  89358. */
  89359. export class BoxParticleEmitter implements IParticleEmitterType {
  89360. /**
  89361. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89362. */
  89363. direction1: Vector3;
  89364. /**
  89365. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89366. */
  89367. direction2: Vector3;
  89368. /**
  89369. * 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.
  89370. */
  89371. minEmitBox: Vector3;
  89372. /**
  89373. * 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.
  89374. */
  89375. maxEmitBox: Vector3;
  89376. /**
  89377. * Creates a new instance BoxParticleEmitter
  89378. */
  89379. constructor();
  89380. /**
  89381. * Called by the particle System when the direction is computed for the created particle.
  89382. * @param worldMatrix is the world matrix of the particle system
  89383. * @param directionToUpdate is the direction vector to update with the result
  89384. * @param particle is the particle we are computed the direction for
  89385. */
  89386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89387. /**
  89388. * Called by the particle System when the position is computed for the created particle.
  89389. * @param worldMatrix is the world matrix of the particle system
  89390. * @param positionToUpdate is the position vector to update with the result
  89391. * @param particle is the particle we are computed the position for
  89392. */
  89393. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89394. /**
  89395. * Clones the current emitter and returns a copy of it
  89396. * @returns the new emitter
  89397. */
  89398. clone(): BoxParticleEmitter;
  89399. /**
  89400. * Called by the GPUParticleSystem to setup the update shader
  89401. * @param effect defines the update shader
  89402. */
  89403. applyToShader(effect: Effect): void;
  89404. /**
  89405. * Returns a string to use to update the GPU particles update shader
  89406. * @returns a string containng the defines string
  89407. */
  89408. getEffectDefines(): string;
  89409. /**
  89410. * Returns the string "BoxParticleEmitter"
  89411. * @returns a string containing the class name
  89412. */
  89413. getClassName(): string;
  89414. /**
  89415. * Serializes the particle system to a JSON object.
  89416. * @returns the JSON object
  89417. */
  89418. serialize(): any;
  89419. /**
  89420. * Parse properties from a JSON object
  89421. * @param serializationObject defines the JSON object
  89422. */
  89423. parse(serializationObject: any): void;
  89424. }
  89425. }
  89426. declare module BABYLON {
  89427. /**
  89428. * Particle emitter emitting particles from the inside of a cone.
  89429. * It emits the particles alongside the cone volume from the base to the particle.
  89430. * The emission direction might be randomized.
  89431. */
  89432. export class ConeParticleEmitter implements IParticleEmitterType {
  89433. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  89434. directionRandomizer: number;
  89435. private _radius;
  89436. private _angle;
  89437. private _height;
  89438. /**
  89439. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  89440. */
  89441. radiusRange: number;
  89442. /**
  89443. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  89444. */
  89445. heightRange: number;
  89446. /**
  89447. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  89448. */
  89449. emitFromSpawnPointOnly: boolean;
  89450. /**
  89451. * Gets or sets the radius of the emission cone
  89452. */
  89453. get radius(): number;
  89454. set radius(value: number);
  89455. /**
  89456. * Gets or sets the angle of the emission cone
  89457. */
  89458. get angle(): number;
  89459. set angle(value: number);
  89460. private _buildHeight;
  89461. /**
  89462. * Creates a new instance ConeParticleEmitter
  89463. * @param radius the radius of the emission cone (1 by default)
  89464. * @param angle the cone base angle (PI by default)
  89465. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  89466. */
  89467. constructor(radius?: number, angle?: number,
  89468. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  89469. directionRandomizer?: number);
  89470. /**
  89471. * Called by the particle System when the direction is computed for the created particle.
  89472. * @param worldMatrix is the world matrix of the particle system
  89473. * @param directionToUpdate is the direction vector to update with the result
  89474. * @param particle is the particle we are computed the direction for
  89475. */
  89476. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89477. /**
  89478. * Called by the particle System when the position is computed for the created particle.
  89479. * @param worldMatrix is the world matrix of the particle system
  89480. * @param positionToUpdate is the position vector to update with the result
  89481. * @param particle is the particle we are computed the position for
  89482. */
  89483. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89484. /**
  89485. * Clones the current emitter and returns a copy of it
  89486. * @returns the new emitter
  89487. */
  89488. clone(): ConeParticleEmitter;
  89489. /**
  89490. * Called by the GPUParticleSystem to setup the update shader
  89491. * @param effect defines the update shader
  89492. */
  89493. applyToShader(effect: Effect): void;
  89494. /**
  89495. * Returns a string to use to update the GPU particles update shader
  89496. * @returns a string containng the defines string
  89497. */
  89498. getEffectDefines(): string;
  89499. /**
  89500. * Returns the string "ConeParticleEmitter"
  89501. * @returns a string containing the class name
  89502. */
  89503. getClassName(): string;
  89504. /**
  89505. * Serializes the particle system to a JSON object.
  89506. * @returns the JSON object
  89507. */
  89508. serialize(): any;
  89509. /**
  89510. * Parse properties from a JSON object
  89511. * @param serializationObject defines the JSON object
  89512. */
  89513. parse(serializationObject: any): void;
  89514. }
  89515. }
  89516. declare module BABYLON {
  89517. /**
  89518. * Particle emitter emitting particles from the inside of a cylinder.
  89519. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  89520. */
  89521. export class CylinderParticleEmitter implements IParticleEmitterType {
  89522. /**
  89523. * The radius of the emission cylinder.
  89524. */
  89525. radius: number;
  89526. /**
  89527. * The height of the emission cylinder.
  89528. */
  89529. height: number;
  89530. /**
  89531. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89532. */
  89533. radiusRange: number;
  89534. /**
  89535. * How much to randomize the particle direction [0-1].
  89536. */
  89537. directionRandomizer: number;
  89538. /**
  89539. * Creates a new instance CylinderParticleEmitter
  89540. * @param radius the radius of the emission cylinder (1 by default)
  89541. * @param height the height of the emission cylinder (1 by default)
  89542. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89543. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89544. */
  89545. constructor(
  89546. /**
  89547. * The radius of the emission cylinder.
  89548. */
  89549. radius?: number,
  89550. /**
  89551. * The height of the emission cylinder.
  89552. */
  89553. height?: number,
  89554. /**
  89555. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89556. */
  89557. radiusRange?: number,
  89558. /**
  89559. * How much to randomize the particle direction [0-1].
  89560. */
  89561. directionRandomizer?: number);
  89562. /**
  89563. * Called by the particle System when the direction is computed for the created particle.
  89564. * @param worldMatrix is the world matrix of the particle system
  89565. * @param directionToUpdate is the direction vector to update with the result
  89566. * @param particle is the particle we are computed the direction for
  89567. */
  89568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89569. /**
  89570. * Called by the particle System when the position is computed for the created particle.
  89571. * @param worldMatrix is the world matrix of the particle system
  89572. * @param positionToUpdate is the position vector to update with the result
  89573. * @param particle is the particle we are computed the position for
  89574. */
  89575. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89576. /**
  89577. * Clones the current emitter and returns a copy of it
  89578. * @returns the new emitter
  89579. */
  89580. clone(): CylinderParticleEmitter;
  89581. /**
  89582. * Called by the GPUParticleSystem to setup the update shader
  89583. * @param effect defines the update shader
  89584. */
  89585. applyToShader(effect: Effect): void;
  89586. /**
  89587. * Returns a string to use to update the GPU particles update shader
  89588. * @returns a string containng the defines string
  89589. */
  89590. getEffectDefines(): string;
  89591. /**
  89592. * Returns the string "CylinderParticleEmitter"
  89593. * @returns a string containing the class name
  89594. */
  89595. getClassName(): string;
  89596. /**
  89597. * Serializes the particle system to a JSON object.
  89598. * @returns the JSON object
  89599. */
  89600. serialize(): any;
  89601. /**
  89602. * Parse properties from a JSON object
  89603. * @param serializationObject defines the JSON object
  89604. */
  89605. parse(serializationObject: any): void;
  89606. }
  89607. /**
  89608. * Particle emitter emitting particles from the inside of a cylinder.
  89609. * It emits the particles randomly between two vectors.
  89610. */
  89611. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  89612. /**
  89613. * The min limit of the emission direction.
  89614. */
  89615. direction1: Vector3;
  89616. /**
  89617. * The max limit of the emission direction.
  89618. */
  89619. direction2: Vector3;
  89620. /**
  89621. * Creates a new instance CylinderDirectedParticleEmitter
  89622. * @param radius the radius of the emission cylinder (1 by default)
  89623. * @param height the height of the emission cylinder (1 by default)
  89624. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89625. * @param direction1 the min limit of the emission direction (up vector by default)
  89626. * @param direction2 the max limit of the emission direction (up vector by default)
  89627. */
  89628. constructor(radius?: number, height?: number, radiusRange?: number,
  89629. /**
  89630. * The min limit of the emission direction.
  89631. */
  89632. direction1?: Vector3,
  89633. /**
  89634. * The max limit of the emission direction.
  89635. */
  89636. direction2?: Vector3);
  89637. /**
  89638. * Called by the particle System when the direction is computed for the created particle.
  89639. * @param worldMatrix is the world matrix of the particle system
  89640. * @param directionToUpdate is the direction vector to update with the result
  89641. * @param particle is the particle we are computed the direction for
  89642. */
  89643. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89644. /**
  89645. * Clones the current emitter and returns a copy of it
  89646. * @returns the new emitter
  89647. */
  89648. clone(): CylinderDirectedParticleEmitter;
  89649. /**
  89650. * Called by the GPUParticleSystem to setup the update shader
  89651. * @param effect defines the update shader
  89652. */
  89653. applyToShader(effect: Effect): void;
  89654. /**
  89655. * Returns a string to use to update the GPU particles update shader
  89656. * @returns a string containng the defines string
  89657. */
  89658. getEffectDefines(): string;
  89659. /**
  89660. * Returns the string "CylinderDirectedParticleEmitter"
  89661. * @returns a string containing the class name
  89662. */
  89663. getClassName(): string;
  89664. /**
  89665. * Serializes the particle system to a JSON object.
  89666. * @returns the JSON object
  89667. */
  89668. serialize(): any;
  89669. /**
  89670. * Parse properties from a JSON object
  89671. * @param serializationObject defines the JSON object
  89672. */
  89673. parse(serializationObject: any): void;
  89674. }
  89675. }
  89676. declare module BABYLON {
  89677. /**
  89678. * Particle emitter emitting particles from the inside of a hemisphere.
  89679. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  89680. */
  89681. export class HemisphericParticleEmitter implements IParticleEmitterType {
  89682. /**
  89683. * The radius of the emission hemisphere.
  89684. */
  89685. radius: number;
  89686. /**
  89687. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89688. */
  89689. radiusRange: number;
  89690. /**
  89691. * How much to randomize the particle direction [0-1].
  89692. */
  89693. directionRandomizer: number;
  89694. /**
  89695. * Creates a new instance HemisphericParticleEmitter
  89696. * @param radius the radius of the emission hemisphere (1 by default)
  89697. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89698. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89699. */
  89700. constructor(
  89701. /**
  89702. * The radius of the emission hemisphere.
  89703. */
  89704. radius?: number,
  89705. /**
  89706. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89707. */
  89708. radiusRange?: number,
  89709. /**
  89710. * How much to randomize the particle direction [0-1].
  89711. */
  89712. directionRandomizer?: number);
  89713. /**
  89714. * Called by the particle System when the direction is computed for the created particle.
  89715. * @param worldMatrix is the world matrix of the particle system
  89716. * @param directionToUpdate is the direction vector to update with the result
  89717. * @param particle is the particle we are computed the direction for
  89718. */
  89719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89720. /**
  89721. * Called by the particle System when the position is computed for the created particle.
  89722. * @param worldMatrix is the world matrix of the particle system
  89723. * @param positionToUpdate is the position vector to update with the result
  89724. * @param particle is the particle we are computed the position for
  89725. */
  89726. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89727. /**
  89728. * Clones the current emitter and returns a copy of it
  89729. * @returns the new emitter
  89730. */
  89731. clone(): HemisphericParticleEmitter;
  89732. /**
  89733. * Called by the GPUParticleSystem to setup the update shader
  89734. * @param effect defines the update shader
  89735. */
  89736. applyToShader(effect: Effect): void;
  89737. /**
  89738. * Returns a string to use to update the GPU particles update shader
  89739. * @returns a string containng the defines string
  89740. */
  89741. getEffectDefines(): string;
  89742. /**
  89743. * Returns the string "HemisphericParticleEmitter"
  89744. * @returns a string containing the class name
  89745. */
  89746. getClassName(): string;
  89747. /**
  89748. * Serializes the particle system to a JSON object.
  89749. * @returns the JSON object
  89750. */
  89751. serialize(): any;
  89752. /**
  89753. * Parse properties from a JSON object
  89754. * @param serializationObject defines the JSON object
  89755. */
  89756. parse(serializationObject: any): void;
  89757. }
  89758. }
  89759. declare module BABYLON {
  89760. /**
  89761. * Particle emitter emitting particles from a point.
  89762. * It emits the particles randomly between 2 given directions.
  89763. */
  89764. export class PointParticleEmitter implements IParticleEmitterType {
  89765. /**
  89766. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89767. */
  89768. direction1: Vector3;
  89769. /**
  89770. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89771. */
  89772. direction2: Vector3;
  89773. /**
  89774. * Creates a new instance PointParticleEmitter
  89775. */
  89776. constructor();
  89777. /**
  89778. * Called by the particle System when the direction is computed for the created particle.
  89779. * @param worldMatrix is the world matrix of the particle system
  89780. * @param directionToUpdate is the direction vector to update with the result
  89781. * @param particle is the particle we are computed the direction for
  89782. */
  89783. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89784. /**
  89785. * Called by the particle System when the position is computed for the created particle.
  89786. * @param worldMatrix is the world matrix of the particle system
  89787. * @param positionToUpdate is the position vector to update with the result
  89788. * @param particle is the particle we are computed the position for
  89789. */
  89790. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89791. /**
  89792. * Clones the current emitter and returns a copy of it
  89793. * @returns the new emitter
  89794. */
  89795. clone(): PointParticleEmitter;
  89796. /**
  89797. * Called by the GPUParticleSystem to setup the update shader
  89798. * @param effect defines the update shader
  89799. */
  89800. applyToShader(effect: Effect): void;
  89801. /**
  89802. * Returns a string to use to update the GPU particles update shader
  89803. * @returns a string containng the defines string
  89804. */
  89805. getEffectDefines(): string;
  89806. /**
  89807. * Returns the string "PointParticleEmitter"
  89808. * @returns a string containing the class name
  89809. */
  89810. getClassName(): string;
  89811. /**
  89812. * Serializes the particle system to a JSON object.
  89813. * @returns the JSON object
  89814. */
  89815. serialize(): any;
  89816. /**
  89817. * Parse properties from a JSON object
  89818. * @param serializationObject defines the JSON object
  89819. */
  89820. parse(serializationObject: any): void;
  89821. }
  89822. }
  89823. declare module BABYLON {
  89824. /**
  89825. * Particle emitter emitting particles from the inside of a sphere.
  89826. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  89827. */
  89828. export class SphereParticleEmitter implements IParticleEmitterType {
  89829. /**
  89830. * The radius of the emission sphere.
  89831. */
  89832. radius: number;
  89833. /**
  89834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89835. */
  89836. radiusRange: number;
  89837. /**
  89838. * How much to randomize the particle direction [0-1].
  89839. */
  89840. directionRandomizer: number;
  89841. /**
  89842. * Creates a new instance SphereParticleEmitter
  89843. * @param radius the radius of the emission sphere (1 by default)
  89844. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89845. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89846. */
  89847. constructor(
  89848. /**
  89849. * The radius of the emission sphere.
  89850. */
  89851. radius?: number,
  89852. /**
  89853. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89854. */
  89855. radiusRange?: number,
  89856. /**
  89857. * How much to randomize the particle direction [0-1].
  89858. */
  89859. directionRandomizer?: number);
  89860. /**
  89861. * Called by the particle System when the direction is computed for the created particle.
  89862. * @param worldMatrix is the world matrix of the particle system
  89863. * @param directionToUpdate is the direction vector to update with the result
  89864. * @param particle is the particle we are computed the direction for
  89865. */
  89866. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89867. /**
  89868. * Called by the particle System when the position is computed for the created particle.
  89869. * @param worldMatrix is the world matrix of the particle system
  89870. * @param positionToUpdate is the position vector to update with the result
  89871. * @param particle is the particle we are computed the position for
  89872. */
  89873. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89874. /**
  89875. * Clones the current emitter and returns a copy of it
  89876. * @returns the new emitter
  89877. */
  89878. clone(): SphereParticleEmitter;
  89879. /**
  89880. * Called by the GPUParticleSystem to setup the update shader
  89881. * @param effect defines the update shader
  89882. */
  89883. applyToShader(effect: Effect): void;
  89884. /**
  89885. * Returns a string to use to update the GPU particles update shader
  89886. * @returns a string containng the defines string
  89887. */
  89888. getEffectDefines(): string;
  89889. /**
  89890. * Returns the string "SphereParticleEmitter"
  89891. * @returns a string containing the class name
  89892. */
  89893. getClassName(): string;
  89894. /**
  89895. * Serializes the particle system to a JSON object.
  89896. * @returns the JSON object
  89897. */
  89898. serialize(): any;
  89899. /**
  89900. * Parse properties from a JSON object
  89901. * @param serializationObject defines the JSON object
  89902. */
  89903. parse(serializationObject: any): void;
  89904. }
  89905. /**
  89906. * Particle emitter emitting particles from the inside of a sphere.
  89907. * It emits the particles randomly between two vectors.
  89908. */
  89909. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89910. /**
  89911. * The min limit of the emission direction.
  89912. */
  89913. direction1: Vector3;
  89914. /**
  89915. * The max limit of the emission direction.
  89916. */
  89917. direction2: Vector3;
  89918. /**
  89919. * Creates a new instance SphereDirectedParticleEmitter
  89920. * @param radius the radius of the emission sphere (1 by default)
  89921. * @param direction1 the min limit of the emission direction (up vector by default)
  89922. * @param direction2 the max limit of the emission direction (up vector by default)
  89923. */
  89924. constructor(radius?: number,
  89925. /**
  89926. * The min limit of the emission direction.
  89927. */
  89928. direction1?: Vector3,
  89929. /**
  89930. * The max limit of the emission direction.
  89931. */
  89932. direction2?: Vector3);
  89933. /**
  89934. * Called by the particle System when the direction is computed for the created particle.
  89935. * @param worldMatrix is the world matrix of the particle system
  89936. * @param directionToUpdate is the direction vector to update with the result
  89937. * @param particle is the particle we are computed the direction for
  89938. */
  89939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89940. /**
  89941. * Clones the current emitter and returns a copy of it
  89942. * @returns the new emitter
  89943. */
  89944. clone(): SphereDirectedParticleEmitter;
  89945. /**
  89946. * Called by the GPUParticleSystem to setup the update shader
  89947. * @param effect defines the update shader
  89948. */
  89949. applyToShader(effect: Effect): void;
  89950. /**
  89951. * Returns a string to use to update the GPU particles update shader
  89952. * @returns a string containng the defines string
  89953. */
  89954. getEffectDefines(): string;
  89955. /**
  89956. * Returns the string "SphereDirectedParticleEmitter"
  89957. * @returns a string containing the class name
  89958. */
  89959. getClassName(): string;
  89960. /**
  89961. * Serializes the particle system to a JSON object.
  89962. * @returns the JSON object
  89963. */
  89964. serialize(): any;
  89965. /**
  89966. * Parse properties from a JSON object
  89967. * @param serializationObject defines the JSON object
  89968. */
  89969. parse(serializationObject: any): void;
  89970. }
  89971. }
  89972. declare module BABYLON {
  89973. /**
  89974. * Interface representing a particle system in Babylon.js.
  89975. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89976. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89977. */
  89978. export interface IParticleSystem {
  89979. /**
  89980. * List of animations used by the particle system.
  89981. */
  89982. animations: Animation[];
  89983. /**
  89984. * The id of the Particle system.
  89985. */
  89986. id: string;
  89987. /**
  89988. * The name of the Particle system.
  89989. */
  89990. name: string;
  89991. /**
  89992. * The emitter represents the Mesh or position we are attaching the particle system to.
  89993. */
  89994. emitter: Nullable<AbstractMesh | Vector3>;
  89995. /**
  89996. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89997. */
  89998. isBillboardBased: boolean;
  89999. /**
  90000. * The rendering group used by the Particle system to chose when to render.
  90001. */
  90002. renderingGroupId: number;
  90003. /**
  90004. * The layer mask we are rendering the particles through.
  90005. */
  90006. layerMask: number;
  90007. /**
  90008. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90009. */
  90010. updateSpeed: number;
  90011. /**
  90012. * The amount of time the particle system is running (depends of the overall update speed).
  90013. */
  90014. targetStopDuration: number;
  90015. /**
  90016. * The texture used to render each particle. (this can be a spritesheet)
  90017. */
  90018. particleTexture: Nullable<Texture>;
  90019. /**
  90020. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  90021. */
  90022. blendMode: number;
  90023. /**
  90024. * Minimum life time of emitting particles.
  90025. */
  90026. minLifeTime: number;
  90027. /**
  90028. * Maximum life time of emitting particles.
  90029. */
  90030. maxLifeTime: number;
  90031. /**
  90032. * Minimum Size of emitting particles.
  90033. */
  90034. minSize: number;
  90035. /**
  90036. * Maximum Size of emitting particles.
  90037. */
  90038. maxSize: number;
  90039. /**
  90040. * Minimum scale of emitting particles on X axis.
  90041. */
  90042. minScaleX: number;
  90043. /**
  90044. * Maximum scale of emitting particles on X axis.
  90045. */
  90046. maxScaleX: number;
  90047. /**
  90048. * Minimum scale of emitting particles on Y axis.
  90049. */
  90050. minScaleY: number;
  90051. /**
  90052. * Maximum scale of emitting particles on Y axis.
  90053. */
  90054. maxScaleY: number;
  90055. /**
  90056. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90057. */
  90058. color1: Color4;
  90059. /**
  90060. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90061. */
  90062. color2: Color4;
  90063. /**
  90064. * Color the particle will have at the end of its lifetime.
  90065. */
  90066. colorDead: Color4;
  90067. /**
  90068. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  90069. */
  90070. emitRate: number;
  90071. /**
  90072. * You can use gravity if you want to give an orientation to your particles.
  90073. */
  90074. gravity: Vector3;
  90075. /**
  90076. * Minimum power of emitting particles.
  90077. */
  90078. minEmitPower: number;
  90079. /**
  90080. * Maximum power of emitting particles.
  90081. */
  90082. maxEmitPower: number;
  90083. /**
  90084. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90085. */
  90086. minAngularSpeed: number;
  90087. /**
  90088. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90089. */
  90090. maxAngularSpeed: number;
  90091. /**
  90092. * Gets or sets the minimal initial rotation in radians.
  90093. */
  90094. minInitialRotation: number;
  90095. /**
  90096. * Gets or sets the maximal initial rotation in radians.
  90097. */
  90098. maxInitialRotation: number;
  90099. /**
  90100. * The particle emitter type defines the emitter used by the particle system.
  90101. * It can be for example box, sphere, or cone...
  90102. */
  90103. particleEmitterType: Nullable<IParticleEmitterType>;
  90104. /**
  90105. * Defines the delay in milliseconds before starting the system (0 by default)
  90106. */
  90107. startDelay: number;
  90108. /**
  90109. * 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
  90110. */
  90111. preWarmCycles: number;
  90112. /**
  90113. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  90114. */
  90115. preWarmStepOffset: number;
  90116. /**
  90117. * 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)
  90118. */
  90119. spriteCellChangeSpeed: number;
  90120. /**
  90121. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90122. */
  90123. startSpriteCellID: number;
  90124. /**
  90125. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90126. */
  90127. endSpriteCellID: number;
  90128. /**
  90129. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90130. */
  90131. spriteCellWidth: number;
  90132. /**
  90133. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90134. */
  90135. spriteCellHeight: number;
  90136. /**
  90137. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90138. */
  90139. spriteRandomStartCell: boolean;
  90140. /**
  90141. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  90142. */
  90143. isAnimationSheetEnabled: boolean;
  90144. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90145. translationPivot: Vector2;
  90146. /**
  90147. * Gets or sets a texture used to add random noise to particle positions
  90148. */
  90149. noiseTexture: Nullable<BaseTexture>;
  90150. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90151. noiseStrength: Vector3;
  90152. /**
  90153. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90154. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90155. */
  90156. billboardMode: number;
  90157. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90158. limitVelocityDamping: number;
  90159. /**
  90160. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90161. */
  90162. beginAnimationOnStart: boolean;
  90163. /**
  90164. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90165. */
  90166. beginAnimationFrom: number;
  90167. /**
  90168. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90169. */
  90170. beginAnimationTo: number;
  90171. /**
  90172. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90173. */
  90174. beginAnimationLoop: boolean;
  90175. /**
  90176. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90177. */
  90178. disposeOnStop: boolean;
  90179. /**
  90180. * Gets the maximum number of particles active at the same time.
  90181. * @returns The max number of active particles.
  90182. */
  90183. getCapacity(): number;
  90184. /**
  90185. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90186. * @returns True if it has been started, otherwise false.
  90187. */
  90188. isStarted(): boolean;
  90189. /**
  90190. * Animates the particle system for this frame.
  90191. */
  90192. animate(): void;
  90193. /**
  90194. * Renders the particle system in its current state.
  90195. * @returns the current number of particles
  90196. */
  90197. render(): number;
  90198. /**
  90199. * Dispose the particle system and frees its associated resources.
  90200. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90201. */
  90202. dispose(disposeTexture?: boolean): void;
  90203. /**
  90204. * Clones the particle system.
  90205. * @param name The name of the cloned object
  90206. * @param newEmitter The new emitter to use
  90207. * @returns the cloned particle system
  90208. */
  90209. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  90210. /**
  90211. * Serializes the particle system to a JSON object.
  90212. * @returns the JSON object
  90213. */
  90214. serialize(): any;
  90215. /**
  90216. * Rebuild the particle system
  90217. */
  90218. rebuild(): void;
  90219. /**
  90220. * Starts the particle system and begins to emit
  90221. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  90222. */
  90223. start(delay?: number): void;
  90224. /**
  90225. * Stops the particle system.
  90226. */
  90227. stop(): void;
  90228. /**
  90229. * Remove all active particles
  90230. */
  90231. reset(): void;
  90232. /**
  90233. * Is this system ready to be used/rendered
  90234. * @return true if the system is ready
  90235. */
  90236. isReady(): boolean;
  90237. /**
  90238. * Adds a new color gradient
  90239. * @param gradient defines the gradient to use (between 0 and 1)
  90240. * @param color1 defines the color to affect to the specified gradient
  90241. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90242. * @returns the current particle system
  90243. */
  90244. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90245. /**
  90246. * Remove a specific color gradient
  90247. * @param gradient defines the gradient to remove
  90248. * @returns the current particle system
  90249. */
  90250. removeColorGradient(gradient: number): IParticleSystem;
  90251. /**
  90252. * Adds a new size gradient
  90253. * @param gradient defines the gradient to use (between 0 and 1)
  90254. * @param factor defines the size factor to affect to the specified gradient
  90255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90256. * @returns the current particle system
  90257. */
  90258. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90259. /**
  90260. * Remove a specific size gradient
  90261. * @param gradient defines the gradient to remove
  90262. * @returns the current particle system
  90263. */
  90264. removeSizeGradient(gradient: number): IParticleSystem;
  90265. /**
  90266. * Gets the current list of color gradients.
  90267. * You must use addColorGradient and removeColorGradient to udpate this list
  90268. * @returns the list of color gradients
  90269. */
  90270. getColorGradients(): Nullable<Array<ColorGradient>>;
  90271. /**
  90272. * Gets the current list of size gradients.
  90273. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90274. * @returns the list of size gradients
  90275. */
  90276. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90277. /**
  90278. * Gets the current list of angular speed gradients.
  90279. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90280. * @returns the list of angular speed gradients
  90281. */
  90282. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90283. /**
  90284. * Adds a new angular speed gradient
  90285. * @param gradient defines the gradient to use (between 0 and 1)
  90286. * @param factor defines the angular speed to affect to the specified gradient
  90287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90288. * @returns the current particle system
  90289. */
  90290. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90291. /**
  90292. * Remove a specific angular speed gradient
  90293. * @param gradient defines the gradient to remove
  90294. * @returns the current particle system
  90295. */
  90296. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90297. /**
  90298. * Gets the current list of velocity gradients.
  90299. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90300. * @returns the list of velocity gradients
  90301. */
  90302. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90303. /**
  90304. * Adds a new velocity gradient
  90305. * @param gradient defines the gradient to use (between 0 and 1)
  90306. * @param factor defines the velocity to affect to the specified gradient
  90307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90308. * @returns the current particle system
  90309. */
  90310. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90311. /**
  90312. * Remove a specific velocity gradient
  90313. * @param gradient defines the gradient to remove
  90314. * @returns the current particle system
  90315. */
  90316. removeVelocityGradient(gradient: number): IParticleSystem;
  90317. /**
  90318. * Gets the current list of limit velocity gradients.
  90319. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90320. * @returns the list of limit velocity gradients
  90321. */
  90322. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90323. /**
  90324. * Adds a new limit velocity gradient
  90325. * @param gradient defines the gradient to use (between 0 and 1)
  90326. * @param factor defines the limit velocity to affect to the specified gradient
  90327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90328. * @returns the current particle system
  90329. */
  90330. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90331. /**
  90332. * Remove a specific limit velocity gradient
  90333. * @param gradient defines the gradient to remove
  90334. * @returns the current particle system
  90335. */
  90336. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90337. /**
  90338. * Adds a new drag gradient
  90339. * @param gradient defines the gradient to use (between 0 and 1)
  90340. * @param factor defines the drag to affect to the specified gradient
  90341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90342. * @returns the current particle system
  90343. */
  90344. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90345. /**
  90346. * Remove a specific drag gradient
  90347. * @param gradient defines the gradient to remove
  90348. * @returns the current particle system
  90349. */
  90350. removeDragGradient(gradient: number): IParticleSystem;
  90351. /**
  90352. * Gets the current list of drag gradients.
  90353. * You must use addDragGradient and removeDragGradient to udpate this list
  90354. * @returns the list of drag gradients
  90355. */
  90356. getDragGradients(): Nullable<Array<FactorGradient>>;
  90357. /**
  90358. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90359. * @param gradient defines the gradient to use (between 0 and 1)
  90360. * @param factor defines the emit rate to affect to the specified gradient
  90361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90362. * @returns the current particle system
  90363. */
  90364. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90365. /**
  90366. * Remove a specific emit rate gradient
  90367. * @param gradient defines the gradient to remove
  90368. * @returns the current particle system
  90369. */
  90370. removeEmitRateGradient(gradient: number): IParticleSystem;
  90371. /**
  90372. * Gets the current list of emit rate gradients.
  90373. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90374. * @returns the list of emit rate gradients
  90375. */
  90376. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90377. /**
  90378. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90379. * @param gradient defines the gradient to use (between 0 and 1)
  90380. * @param factor defines the start size to affect to the specified gradient
  90381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90382. * @returns the current particle system
  90383. */
  90384. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90385. /**
  90386. * Remove a specific start size gradient
  90387. * @param gradient defines the gradient to remove
  90388. * @returns the current particle system
  90389. */
  90390. removeStartSizeGradient(gradient: number): IParticleSystem;
  90391. /**
  90392. * Gets the current list of start size gradients.
  90393. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90394. * @returns the list of start size gradients
  90395. */
  90396. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90397. /**
  90398. * Adds a new life time gradient
  90399. * @param gradient defines the gradient to use (between 0 and 1)
  90400. * @param factor defines the life time factor to affect to the specified gradient
  90401. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90402. * @returns the current particle system
  90403. */
  90404. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90405. /**
  90406. * Remove a specific life time gradient
  90407. * @param gradient defines the gradient to remove
  90408. * @returns the current particle system
  90409. */
  90410. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90411. /**
  90412. * Gets the current list of life time gradients.
  90413. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90414. * @returns the list of life time gradients
  90415. */
  90416. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90417. /**
  90418. * Gets the current list of color gradients.
  90419. * You must use addColorGradient and removeColorGradient to udpate this list
  90420. * @returns the list of color gradients
  90421. */
  90422. getColorGradients(): Nullable<Array<ColorGradient>>;
  90423. /**
  90424. * Adds a new ramp gradient used to remap particle colors
  90425. * @param gradient defines the gradient to use (between 0 and 1)
  90426. * @param color defines the color to affect to the specified gradient
  90427. * @returns the current particle system
  90428. */
  90429. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  90430. /**
  90431. * Gets the current list of ramp gradients.
  90432. * You must use addRampGradient and removeRampGradient to udpate this list
  90433. * @returns the list of ramp gradients
  90434. */
  90435. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90436. /** Gets or sets a boolean indicating that ramp gradients must be used
  90437. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90438. */
  90439. useRampGradients: boolean;
  90440. /**
  90441. * Adds a new color remap gradient
  90442. * @param gradient defines the gradient to use (between 0 and 1)
  90443. * @param min defines the color remap minimal range
  90444. * @param max defines the color remap maximal range
  90445. * @returns the current particle system
  90446. */
  90447. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90448. /**
  90449. * Gets the current list of color remap gradients.
  90450. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90451. * @returns the list of color remap gradients
  90452. */
  90453. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90454. /**
  90455. * Adds a new alpha remap gradient
  90456. * @param gradient defines the gradient to use (between 0 and 1)
  90457. * @param min defines the alpha remap minimal range
  90458. * @param max defines the alpha remap maximal range
  90459. * @returns the current particle system
  90460. */
  90461. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90462. /**
  90463. * Gets the current list of alpha remap gradients.
  90464. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90465. * @returns the list of alpha remap gradients
  90466. */
  90467. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90468. /**
  90469. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90470. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90471. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90472. * @returns the emitter
  90473. */
  90474. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90475. /**
  90476. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90477. * @param radius The radius of the hemisphere to emit from
  90478. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90479. * @returns the emitter
  90480. */
  90481. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  90482. /**
  90483. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90484. * @param radius The radius of the sphere to emit from
  90485. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90486. * @returns the emitter
  90487. */
  90488. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  90489. /**
  90490. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90491. * @param radius The radius of the sphere to emit from
  90492. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90493. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90494. * @returns the emitter
  90495. */
  90496. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  90497. /**
  90498. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90499. * @param radius The radius of the emission cylinder
  90500. * @param height The height of the emission cylinder
  90501. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90502. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90503. * @returns the emitter
  90504. */
  90505. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  90506. /**
  90507. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90508. * @param radius The radius of the cylinder to emit from
  90509. * @param height The height of the emission cylinder
  90510. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90511. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90512. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90513. * @returns the emitter
  90514. */
  90515. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  90516. /**
  90517. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90518. * @param radius The radius of the cone to emit from
  90519. * @param angle The base angle of the cone
  90520. * @returns the emitter
  90521. */
  90522. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  90523. /**
  90524. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90525. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90526. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90527. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90528. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90529. * @returns the emitter
  90530. */
  90531. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90532. /**
  90533. * Get hosting scene
  90534. * @returns the scene
  90535. */
  90536. getScene(): Scene;
  90537. }
  90538. }
  90539. declare module BABYLON {
  90540. /**
  90541. * Creates an instance based on a source mesh.
  90542. */
  90543. export class InstancedMesh extends AbstractMesh {
  90544. private _sourceMesh;
  90545. private _currentLOD;
  90546. /** @hidden */
  90547. _indexInSourceMeshInstanceArray: number;
  90548. constructor(name: string, source: Mesh);
  90549. /**
  90550. * Returns the string "InstancedMesh".
  90551. */
  90552. getClassName(): string;
  90553. /** Gets the list of lights affecting that mesh */
  90554. get lightSources(): Light[];
  90555. _resyncLightSources(): void;
  90556. _resyncLightSource(light: Light): void;
  90557. _removeLightSource(light: Light, dispose: boolean): void;
  90558. /**
  90559. * If the source mesh receives shadows
  90560. */
  90561. get receiveShadows(): boolean;
  90562. /**
  90563. * The material of the source mesh
  90564. */
  90565. get material(): Nullable<Material>;
  90566. /**
  90567. * Visibility of the source mesh
  90568. */
  90569. get visibility(): number;
  90570. /**
  90571. * Skeleton of the source mesh
  90572. */
  90573. get skeleton(): Nullable<Skeleton>;
  90574. /**
  90575. * Rendering ground id of the source mesh
  90576. */
  90577. get renderingGroupId(): number;
  90578. set renderingGroupId(value: number);
  90579. /**
  90580. * Returns the total number of vertices (integer).
  90581. */
  90582. getTotalVertices(): number;
  90583. /**
  90584. * Returns a positive integer : the total number of indices in this mesh geometry.
  90585. * @returns the numner of indices or zero if the mesh has no geometry.
  90586. */
  90587. getTotalIndices(): number;
  90588. /**
  90589. * The source mesh of the instance
  90590. */
  90591. get sourceMesh(): Mesh;
  90592. /**
  90593. * Is this node ready to be used/rendered
  90594. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90595. * @return {boolean} is it ready
  90596. */
  90597. isReady(completeCheck?: boolean): boolean;
  90598. /**
  90599. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90600. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  90601. * @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.
  90602. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  90603. */
  90604. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  90605. /**
  90606. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90607. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90608. * The `data` are either a numeric array either a Float32Array.
  90609. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  90610. * 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).
  90611. * Note that a new underlying VertexBuffer object is created each call.
  90612. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90613. *
  90614. * Possible `kind` values :
  90615. * - VertexBuffer.PositionKind
  90616. * - VertexBuffer.UVKind
  90617. * - VertexBuffer.UV2Kind
  90618. * - VertexBuffer.UV3Kind
  90619. * - VertexBuffer.UV4Kind
  90620. * - VertexBuffer.UV5Kind
  90621. * - VertexBuffer.UV6Kind
  90622. * - VertexBuffer.ColorKind
  90623. * - VertexBuffer.MatricesIndicesKind
  90624. * - VertexBuffer.MatricesIndicesExtraKind
  90625. * - VertexBuffer.MatricesWeightsKind
  90626. * - VertexBuffer.MatricesWeightsExtraKind
  90627. *
  90628. * Returns the Mesh.
  90629. */
  90630. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90631. /**
  90632. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90633. * If the mesh has no geometry, it is simply returned as it is.
  90634. * The `data` are either a numeric array either a Float32Array.
  90635. * No new underlying VertexBuffer object is created.
  90636. * 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.
  90637. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  90638. *
  90639. * Possible `kind` values :
  90640. * - VertexBuffer.PositionKind
  90641. * - VertexBuffer.UVKind
  90642. * - VertexBuffer.UV2Kind
  90643. * - VertexBuffer.UV3Kind
  90644. * - VertexBuffer.UV4Kind
  90645. * - VertexBuffer.UV5Kind
  90646. * - VertexBuffer.UV6Kind
  90647. * - VertexBuffer.ColorKind
  90648. * - VertexBuffer.MatricesIndicesKind
  90649. * - VertexBuffer.MatricesIndicesExtraKind
  90650. * - VertexBuffer.MatricesWeightsKind
  90651. * - VertexBuffer.MatricesWeightsExtraKind
  90652. *
  90653. * Returns the Mesh.
  90654. */
  90655. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  90656. /**
  90657. * Sets the mesh indices.
  90658. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  90659. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90660. * This method creates a new index buffer each call.
  90661. * Returns the Mesh.
  90662. */
  90663. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  90664. /**
  90665. * Boolean : True if the mesh owns the requested kind of data.
  90666. */
  90667. isVerticesDataPresent(kind: string): boolean;
  90668. /**
  90669. * Returns an array of indices (IndicesArray).
  90670. */
  90671. getIndices(): Nullable<IndicesArray>;
  90672. get _positions(): Nullable<Vector3[]>;
  90673. /**
  90674. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90675. * This means the mesh underlying bounding box and sphere are recomputed.
  90676. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90677. * @returns the current mesh
  90678. */
  90679. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  90680. /** @hidden */
  90681. _preActivate(): InstancedMesh;
  90682. /** @hidden */
  90683. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90684. /** @hidden */
  90685. _postActivate(): void;
  90686. getWorldMatrix(): Matrix;
  90687. get isAnInstance(): boolean;
  90688. /**
  90689. * Returns the current associated LOD AbstractMesh.
  90690. */
  90691. getLOD(camera: Camera): AbstractMesh;
  90692. /** @hidden */
  90693. _syncSubMeshes(): InstancedMesh;
  90694. /** @hidden */
  90695. _generatePointsArray(): boolean;
  90696. /**
  90697. * Creates a new InstancedMesh from the current mesh.
  90698. * - name (string) : the cloned mesh name
  90699. * - newParent (optional Node) : the optional Node to parent the clone to.
  90700. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  90701. *
  90702. * Returns the clone.
  90703. */
  90704. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90705. /**
  90706. * Disposes the InstancedMesh.
  90707. * Returns nothing.
  90708. */
  90709. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90710. }
  90711. interface Mesh {
  90712. /**
  90713. * Register a custom buffer that will be instanced
  90714. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90715. * @param kind defines the buffer kind
  90716. * @param stride defines the stride in floats
  90717. */
  90718. registerInstancedBuffer(kind: string, stride: number): void;
  90719. /** @hidden */
  90720. _userInstancedBuffersStorage: {
  90721. data: {
  90722. [key: string]: Float32Array;
  90723. };
  90724. sizes: {
  90725. [key: string]: number;
  90726. };
  90727. vertexBuffers: {
  90728. [key: string]: Nullable<VertexBuffer>;
  90729. };
  90730. strides: {
  90731. [key: string]: number;
  90732. };
  90733. };
  90734. }
  90735. interface AbstractMesh {
  90736. /**
  90737. * Object used to store instanced buffers defined by user
  90738. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90739. */
  90740. instancedBuffers: {
  90741. [key: string]: any;
  90742. };
  90743. }
  90744. }
  90745. declare module BABYLON {
  90746. /**
  90747. * Defines the options associated with the creation of a shader material.
  90748. */
  90749. export interface IShaderMaterialOptions {
  90750. /**
  90751. * Does the material work in alpha blend mode
  90752. */
  90753. needAlphaBlending: boolean;
  90754. /**
  90755. * Does the material work in alpha test mode
  90756. */
  90757. needAlphaTesting: boolean;
  90758. /**
  90759. * The list of attribute names used in the shader
  90760. */
  90761. attributes: string[];
  90762. /**
  90763. * The list of unifrom names used in the shader
  90764. */
  90765. uniforms: string[];
  90766. /**
  90767. * The list of UBO names used in the shader
  90768. */
  90769. uniformBuffers: string[];
  90770. /**
  90771. * The list of sampler names used in the shader
  90772. */
  90773. samplers: string[];
  90774. /**
  90775. * The list of defines used in the shader
  90776. */
  90777. defines: string[];
  90778. }
  90779. /**
  90780. * 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.
  90781. *
  90782. * This returned material effects how the mesh will look based on the code in the shaders.
  90783. *
  90784. * @see http://doc.babylonjs.com/how_to/shader_material
  90785. */
  90786. export class ShaderMaterial extends Material {
  90787. private _shaderPath;
  90788. private _options;
  90789. private _textures;
  90790. private _textureArrays;
  90791. private _floats;
  90792. private _ints;
  90793. private _floatsArrays;
  90794. private _colors3;
  90795. private _colors3Arrays;
  90796. private _colors4;
  90797. private _colors4Arrays;
  90798. private _vectors2;
  90799. private _vectors3;
  90800. private _vectors4;
  90801. private _matrices;
  90802. private _matrixArrays;
  90803. private _matrices3x3;
  90804. private _matrices2x2;
  90805. private _vectors2Arrays;
  90806. private _vectors3Arrays;
  90807. private _vectors4Arrays;
  90808. private _cachedWorldViewMatrix;
  90809. private _cachedWorldViewProjectionMatrix;
  90810. private _renderId;
  90811. private _multiview;
  90812. /**
  90813. * Instantiate a new shader material.
  90814. * 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.
  90815. * This returned material effects how the mesh will look based on the code in the shaders.
  90816. * @see http://doc.babylonjs.com/how_to/shader_material
  90817. * @param name Define the name of the material in the scene
  90818. * @param scene Define the scene the material belongs to
  90819. * @param shaderPath Defines the route to the shader code in one of three ways:
  90820. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90821. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90822. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90823. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90824. * @param options Define the options used to create the shader
  90825. */
  90826. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90827. /**
  90828. * Gets the shader path used to define the shader code
  90829. * It can be modified to trigger a new compilation
  90830. */
  90831. get shaderPath(): any;
  90832. /**
  90833. * Sets the shader path used to define the shader code
  90834. * It can be modified to trigger a new compilation
  90835. */
  90836. set shaderPath(shaderPath: any);
  90837. /**
  90838. * Gets the options used to compile the shader.
  90839. * They can be modified to trigger a new compilation
  90840. */
  90841. get options(): IShaderMaterialOptions;
  90842. /**
  90843. * Gets the current class name of the material e.g. "ShaderMaterial"
  90844. * Mainly use in serialization.
  90845. * @returns the class name
  90846. */
  90847. getClassName(): string;
  90848. /**
  90849. * Specifies if the material will require alpha blending
  90850. * @returns a boolean specifying if alpha blending is needed
  90851. */
  90852. needAlphaBlending(): boolean;
  90853. /**
  90854. * Specifies if this material should be rendered in alpha test mode
  90855. * @returns a boolean specifying if an alpha test is needed.
  90856. */
  90857. needAlphaTesting(): boolean;
  90858. private _checkUniform;
  90859. /**
  90860. * Set a texture in the shader.
  90861. * @param name Define the name of the uniform samplers as defined in the shader
  90862. * @param texture Define the texture to bind to this sampler
  90863. * @return the material itself allowing "fluent" like uniform updates
  90864. */
  90865. setTexture(name: string, texture: Texture): ShaderMaterial;
  90866. /**
  90867. * Set a texture array in the shader.
  90868. * @param name Define the name of the uniform sampler array as defined in the shader
  90869. * @param textures Define the list of textures to bind to this sampler
  90870. * @return the material itself allowing "fluent" like uniform updates
  90871. */
  90872. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90873. /**
  90874. * Set a float in the shader.
  90875. * @param name Define the name of the uniform as defined in the shader
  90876. * @param value Define the value to give to the uniform
  90877. * @return the material itself allowing "fluent" like uniform updates
  90878. */
  90879. setFloat(name: string, value: number): ShaderMaterial;
  90880. /**
  90881. * Set a int in the shader.
  90882. * @param name Define the name of the uniform as defined in the shader
  90883. * @param value Define the value to give to the uniform
  90884. * @return the material itself allowing "fluent" like uniform updates
  90885. */
  90886. setInt(name: string, value: number): ShaderMaterial;
  90887. /**
  90888. * Set an array of floats in the shader.
  90889. * @param name Define the name of the uniform as defined in the shader
  90890. * @param value Define the value to give to the uniform
  90891. * @return the material itself allowing "fluent" like uniform updates
  90892. */
  90893. setFloats(name: string, value: number[]): ShaderMaterial;
  90894. /**
  90895. * Set a vec3 in the shader from a Color3.
  90896. * @param name Define the name of the uniform as defined in the shader
  90897. * @param value Define the value to give to the uniform
  90898. * @return the material itself allowing "fluent" like uniform updates
  90899. */
  90900. setColor3(name: string, value: Color3): ShaderMaterial;
  90901. /**
  90902. * Set a vec3 array in the shader from a Color3 array.
  90903. * @param name Define the name of the uniform as defined in the shader
  90904. * @param value Define the value to give to the uniform
  90905. * @return the material itself allowing "fluent" like uniform updates
  90906. */
  90907. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90908. /**
  90909. * Set a vec4 in the shader from a Color4.
  90910. * @param name Define the name of the uniform as defined in the shader
  90911. * @param value Define the value to give to the uniform
  90912. * @return the material itself allowing "fluent" like uniform updates
  90913. */
  90914. setColor4(name: string, value: Color4): ShaderMaterial;
  90915. /**
  90916. * Set a vec4 array in the shader from a Color4 array.
  90917. * @param name Define the name of the uniform as defined in the shader
  90918. * @param value Define the value to give to the uniform
  90919. * @return the material itself allowing "fluent" like uniform updates
  90920. */
  90921. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90922. /**
  90923. * Set a vec2 in the shader from a Vector2.
  90924. * @param name Define the name of the uniform as defined in the shader
  90925. * @param value Define the value to give to the uniform
  90926. * @return the material itself allowing "fluent" like uniform updates
  90927. */
  90928. setVector2(name: string, value: Vector2): ShaderMaterial;
  90929. /**
  90930. * Set a vec3 in the shader from a Vector3.
  90931. * @param name Define the name of the uniform as defined in the shader
  90932. * @param value Define the value to give to the uniform
  90933. * @return the material itself allowing "fluent" like uniform updates
  90934. */
  90935. setVector3(name: string, value: Vector3): ShaderMaterial;
  90936. /**
  90937. * Set a vec4 in the shader from a Vector4.
  90938. * @param name Define the name of the uniform as defined in the shader
  90939. * @param value Define the value to give to the uniform
  90940. * @return the material itself allowing "fluent" like uniform updates
  90941. */
  90942. setVector4(name: string, value: Vector4): ShaderMaterial;
  90943. /**
  90944. * Set a mat4 in the shader from a Matrix.
  90945. * @param name Define the name of the uniform as defined in the shader
  90946. * @param value Define the value to give to the uniform
  90947. * @return the material itself allowing "fluent" like uniform updates
  90948. */
  90949. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90950. /**
  90951. * Set a float32Array in the shader from a matrix array.
  90952. * @param name Define the name of the uniform as defined in the shader
  90953. * @param value Define the value to give to the uniform
  90954. * @return the material itself allowing "fluent" like uniform updates
  90955. */
  90956. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90957. /**
  90958. * Set a mat3 in the shader from a Float32Array.
  90959. * @param name Define the name of the uniform as defined in the shader
  90960. * @param value Define the value to give to the uniform
  90961. * @return the material itself allowing "fluent" like uniform updates
  90962. */
  90963. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90964. /**
  90965. * Set a mat2 in the shader from a Float32Array.
  90966. * @param name Define the name of the uniform as defined in the shader
  90967. * @param value Define the value to give to the uniform
  90968. * @return the material itself allowing "fluent" like uniform updates
  90969. */
  90970. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90971. /**
  90972. * Set a vec2 array in the shader from a number array.
  90973. * @param name Define the name of the uniform as defined in the shader
  90974. * @param value Define the value to give to the uniform
  90975. * @return the material itself allowing "fluent" like uniform updates
  90976. */
  90977. setArray2(name: string, value: number[]): ShaderMaterial;
  90978. /**
  90979. * Set a vec3 array in the shader from a number array.
  90980. * @param name Define the name of the uniform as defined in the shader
  90981. * @param value Define the value to give to the uniform
  90982. * @return the material itself allowing "fluent" like uniform updates
  90983. */
  90984. setArray3(name: string, value: number[]): ShaderMaterial;
  90985. /**
  90986. * Set a vec4 array in the shader from a number array.
  90987. * @param name Define the name of the uniform as defined in the shader
  90988. * @param value Define the value to give to the uniform
  90989. * @return the material itself allowing "fluent" like uniform updates
  90990. */
  90991. setArray4(name: string, value: number[]): ShaderMaterial;
  90992. private _checkCache;
  90993. /**
  90994. * Specifies that the submesh is ready to be used
  90995. * @param mesh defines the mesh to check
  90996. * @param subMesh defines which submesh to check
  90997. * @param useInstances specifies that instances should be used
  90998. * @returns a boolean indicating that the submesh is ready or not
  90999. */
  91000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91001. /**
  91002. * Checks if the material is ready to render the requested mesh
  91003. * @param mesh Define the mesh to render
  91004. * @param useInstances Define whether or not the material is used with instances
  91005. * @returns true if ready, otherwise false
  91006. */
  91007. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91008. /**
  91009. * Binds the world matrix to the material
  91010. * @param world defines the world transformation matrix
  91011. */
  91012. bindOnlyWorldMatrix(world: Matrix): void;
  91013. /**
  91014. * Binds the material to the mesh
  91015. * @param world defines the world transformation matrix
  91016. * @param mesh defines the mesh to bind the material to
  91017. */
  91018. bind(world: Matrix, mesh?: Mesh): void;
  91019. /**
  91020. * Gets the active textures from the material
  91021. * @returns an array of textures
  91022. */
  91023. getActiveTextures(): BaseTexture[];
  91024. /**
  91025. * Specifies if the material uses a texture
  91026. * @param texture defines the texture to check against the material
  91027. * @returns a boolean specifying if the material uses the texture
  91028. */
  91029. hasTexture(texture: BaseTexture): boolean;
  91030. /**
  91031. * Makes a duplicate of the material, and gives it a new name
  91032. * @param name defines the new name for the duplicated material
  91033. * @returns the cloned material
  91034. */
  91035. clone(name: string): ShaderMaterial;
  91036. /**
  91037. * Disposes the material
  91038. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91039. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91040. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91041. */
  91042. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91043. /**
  91044. * Serializes this material in a JSON representation
  91045. * @returns the serialized material object
  91046. */
  91047. serialize(): any;
  91048. /**
  91049. * Creates a shader material from parsed shader material data
  91050. * @param source defines the JSON represnetation of the material
  91051. * @param scene defines the hosting scene
  91052. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91053. * @returns a new material
  91054. */
  91055. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91056. }
  91057. }
  91058. declare module BABYLON {
  91059. /** @hidden */
  91060. export var colorPixelShader: {
  91061. name: string;
  91062. shader: string;
  91063. };
  91064. }
  91065. declare module BABYLON {
  91066. /** @hidden */
  91067. export var colorVertexShader: {
  91068. name: string;
  91069. shader: string;
  91070. };
  91071. }
  91072. declare module BABYLON {
  91073. /**
  91074. * Line mesh
  91075. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91076. */
  91077. export class LinesMesh extends Mesh {
  91078. /**
  91079. * If vertex color should be applied to the mesh
  91080. */
  91081. readonly useVertexColor?: boolean | undefined;
  91082. /**
  91083. * If vertex alpha should be applied to the mesh
  91084. */
  91085. readonly useVertexAlpha?: boolean | undefined;
  91086. /**
  91087. * Color of the line (Default: White)
  91088. */
  91089. color: Color3;
  91090. /**
  91091. * Alpha of the line (Default: 1)
  91092. */
  91093. alpha: number;
  91094. /**
  91095. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91096. * This margin is expressed in world space coordinates, so its value may vary.
  91097. * Default value is 0.1
  91098. */
  91099. intersectionThreshold: number;
  91100. private _colorShader;
  91101. private color4;
  91102. /**
  91103. * Creates a new LinesMesh
  91104. * @param name defines the name
  91105. * @param scene defines the hosting scene
  91106. * @param parent defines the parent mesh if any
  91107. * @param source defines the optional source LinesMesh used to clone data from
  91108. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91109. * When false, achieved by calling a clone(), also passing False.
  91110. * This will make creation of children, recursive.
  91111. * @param useVertexColor defines if this LinesMesh supports vertex color
  91112. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91113. */
  91114. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91115. /**
  91116. * If vertex color should be applied to the mesh
  91117. */
  91118. useVertexColor?: boolean | undefined,
  91119. /**
  91120. * If vertex alpha should be applied to the mesh
  91121. */
  91122. useVertexAlpha?: boolean | undefined);
  91123. private _addClipPlaneDefine;
  91124. private _removeClipPlaneDefine;
  91125. isReady(): boolean;
  91126. /**
  91127. * Returns the string "LineMesh"
  91128. */
  91129. getClassName(): string;
  91130. /**
  91131. * @hidden
  91132. */
  91133. get material(): Material;
  91134. /**
  91135. * @hidden
  91136. */
  91137. set material(value: Material);
  91138. /**
  91139. * @hidden
  91140. */
  91141. get checkCollisions(): boolean;
  91142. /** @hidden */
  91143. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91144. /** @hidden */
  91145. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91146. /**
  91147. * Disposes of the line mesh
  91148. * @param doNotRecurse If children should be disposed
  91149. */
  91150. dispose(doNotRecurse?: boolean): void;
  91151. /**
  91152. * Returns a new LineMesh object cloned from the current one.
  91153. */
  91154. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91155. /**
  91156. * Creates a new InstancedLinesMesh object from the mesh model.
  91157. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91158. * @param name defines the name of the new instance
  91159. * @returns a new InstancedLinesMesh
  91160. */
  91161. createInstance(name: string): InstancedLinesMesh;
  91162. }
  91163. /**
  91164. * Creates an instance based on a source LinesMesh
  91165. */
  91166. export class InstancedLinesMesh extends InstancedMesh {
  91167. /**
  91168. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91169. * This margin is expressed in world space coordinates, so its value may vary.
  91170. * Initilized with the intersectionThreshold value of the source LinesMesh
  91171. */
  91172. intersectionThreshold: number;
  91173. constructor(name: string, source: LinesMesh);
  91174. /**
  91175. * Returns the string "InstancedLinesMesh".
  91176. */
  91177. getClassName(): string;
  91178. }
  91179. }
  91180. declare module BABYLON {
  91181. /** @hidden */
  91182. export var linePixelShader: {
  91183. name: string;
  91184. shader: string;
  91185. };
  91186. }
  91187. declare module BABYLON {
  91188. /** @hidden */
  91189. export var lineVertexShader: {
  91190. name: string;
  91191. shader: string;
  91192. };
  91193. }
  91194. declare module BABYLON {
  91195. interface AbstractMesh {
  91196. /**
  91197. * Gets the edgesRenderer associated with the mesh
  91198. */
  91199. edgesRenderer: Nullable<EdgesRenderer>;
  91200. }
  91201. interface LinesMesh {
  91202. /**
  91203. * Enables the edge rendering mode on the mesh.
  91204. * This mode makes the mesh edges visible
  91205. * @param epsilon defines the maximal distance between two angles to detect a face
  91206. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91207. * @returns the currentAbstractMesh
  91208. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91209. */
  91210. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91211. }
  91212. interface InstancedLinesMesh {
  91213. /**
  91214. * Enables the edge rendering mode on the mesh.
  91215. * This mode makes the mesh edges visible
  91216. * @param epsilon defines the maximal distance between two angles to detect a face
  91217. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91218. * @returns the current InstancedLinesMesh
  91219. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91220. */
  91221. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  91222. }
  91223. /**
  91224. * Defines the minimum contract an Edges renderer should follow.
  91225. */
  91226. export interface IEdgesRenderer extends IDisposable {
  91227. /**
  91228. * Gets or sets a boolean indicating if the edgesRenderer is active
  91229. */
  91230. isEnabled: boolean;
  91231. /**
  91232. * Renders the edges of the attached mesh,
  91233. */
  91234. render(): void;
  91235. /**
  91236. * Checks wether or not the edges renderer is ready to render.
  91237. * @return true if ready, otherwise false.
  91238. */
  91239. isReady(): boolean;
  91240. }
  91241. /**
  91242. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  91243. */
  91244. export class EdgesRenderer implements IEdgesRenderer {
  91245. /**
  91246. * Define the size of the edges with an orthographic camera
  91247. */
  91248. edgesWidthScalerForOrthographic: number;
  91249. /**
  91250. * Define the size of the edges with a perspective camera
  91251. */
  91252. edgesWidthScalerForPerspective: number;
  91253. protected _source: AbstractMesh;
  91254. protected _linesPositions: number[];
  91255. protected _linesNormals: number[];
  91256. protected _linesIndices: number[];
  91257. protected _epsilon: number;
  91258. protected _indicesCount: number;
  91259. protected _lineShader: ShaderMaterial;
  91260. protected _ib: DataBuffer;
  91261. protected _buffers: {
  91262. [key: string]: Nullable<VertexBuffer>;
  91263. };
  91264. protected _checkVerticesInsteadOfIndices: boolean;
  91265. private _meshRebuildObserver;
  91266. private _meshDisposeObserver;
  91267. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  91268. isEnabled: boolean;
  91269. /**
  91270. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  91271. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  91272. * @param source Mesh used to create edges
  91273. * @param epsilon sum of angles in adjacency to check for edge
  91274. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  91275. * @param generateEdgesLines - should generate Lines or only prepare resources.
  91276. */
  91277. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  91278. protected _prepareRessources(): void;
  91279. /** @hidden */
  91280. _rebuild(): void;
  91281. /**
  91282. * Releases the required resources for the edges renderer
  91283. */
  91284. dispose(): void;
  91285. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  91286. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  91287. /**
  91288. * Checks if the pair of p0 and p1 is en edge
  91289. * @param faceIndex
  91290. * @param edge
  91291. * @param faceNormals
  91292. * @param p0
  91293. * @param p1
  91294. * @private
  91295. */
  91296. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  91297. /**
  91298. * push line into the position, normal and index buffer
  91299. * @protected
  91300. */
  91301. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  91302. /**
  91303. * Generates lines edges from adjacencjes
  91304. * @private
  91305. */
  91306. _generateEdgesLines(): void;
  91307. /**
  91308. * Checks wether or not the edges renderer is ready to render.
  91309. * @return true if ready, otherwise false.
  91310. */
  91311. isReady(): boolean;
  91312. /**
  91313. * Renders the edges of the attached mesh,
  91314. */
  91315. render(): void;
  91316. }
  91317. /**
  91318. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  91319. */
  91320. export class LineEdgesRenderer extends EdgesRenderer {
  91321. /**
  91322. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  91323. * @param source LineMesh used to generate edges
  91324. * @param epsilon not important (specified angle for edge detection)
  91325. * @param checkVerticesInsteadOfIndices not important for LineMesh
  91326. */
  91327. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  91328. /**
  91329. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  91330. */
  91331. _generateEdgesLines(): void;
  91332. }
  91333. }
  91334. declare module BABYLON {
  91335. /**
  91336. * This represents the object necessary to create a rendering group.
  91337. * This is exclusively used and created by the rendering manager.
  91338. * To modify the behavior, you use the available helpers in your scene or meshes.
  91339. * @hidden
  91340. */
  91341. export class RenderingGroup {
  91342. index: number;
  91343. private static _zeroVector;
  91344. private _scene;
  91345. private _opaqueSubMeshes;
  91346. private _transparentSubMeshes;
  91347. private _alphaTestSubMeshes;
  91348. private _depthOnlySubMeshes;
  91349. private _particleSystems;
  91350. private _spriteManagers;
  91351. private _opaqueSortCompareFn;
  91352. private _alphaTestSortCompareFn;
  91353. private _transparentSortCompareFn;
  91354. private _renderOpaque;
  91355. private _renderAlphaTest;
  91356. private _renderTransparent;
  91357. /** @hidden */
  91358. _edgesRenderers: SmartArray<IEdgesRenderer>;
  91359. onBeforeTransparentRendering: () => void;
  91360. /**
  91361. * Set the opaque sort comparison function.
  91362. * If null the sub meshes will be render in the order they were created
  91363. */
  91364. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91365. /**
  91366. * Set the alpha test sort comparison function.
  91367. * If null the sub meshes will be render in the order they were created
  91368. */
  91369. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91370. /**
  91371. * Set the transparent sort comparison function.
  91372. * If null the sub meshes will be render in the order they were created
  91373. */
  91374. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91375. /**
  91376. * Creates a new rendering group.
  91377. * @param index The rendering group index
  91378. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  91379. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  91380. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  91381. */
  91382. 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>);
  91383. /**
  91384. * Render all the sub meshes contained in the group.
  91385. * @param customRenderFunction Used to override the default render behaviour of the group.
  91386. * @returns true if rendered some submeshes.
  91387. */
  91388. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  91389. /**
  91390. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  91391. * @param subMeshes The submeshes to render
  91392. */
  91393. private renderOpaqueSorted;
  91394. /**
  91395. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  91396. * @param subMeshes The submeshes to render
  91397. */
  91398. private renderAlphaTestSorted;
  91399. /**
  91400. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  91401. * @param subMeshes The submeshes to render
  91402. */
  91403. private renderTransparentSorted;
  91404. /**
  91405. * Renders the submeshes in a specified order.
  91406. * @param subMeshes The submeshes to sort before render
  91407. * @param sortCompareFn The comparison function use to sort
  91408. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  91409. * @param transparent Specifies to activate blending if true
  91410. */
  91411. private static renderSorted;
  91412. /**
  91413. * Renders the submeshes in the order they were dispatched (no sort applied).
  91414. * @param subMeshes The submeshes to render
  91415. */
  91416. private static renderUnsorted;
  91417. /**
  91418. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91419. * are rendered back to front if in the same alpha index.
  91420. *
  91421. * @param a The first submesh
  91422. * @param b The second submesh
  91423. * @returns The result of the comparison
  91424. */
  91425. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  91426. /**
  91427. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91428. * are rendered back to front.
  91429. *
  91430. * @param a The first submesh
  91431. * @param b The second submesh
  91432. * @returns The result of the comparison
  91433. */
  91434. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  91435. /**
  91436. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91437. * are rendered front to back (prevent overdraw).
  91438. *
  91439. * @param a The first submesh
  91440. * @param b The second submesh
  91441. * @returns The result of the comparison
  91442. */
  91443. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  91444. /**
  91445. * Resets the different lists of submeshes to prepare a new frame.
  91446. */
  91447. prepare(): void;
  91448. dispose(): void;
  91449. /**
  91450. * Inserts the submesh in its correct queue depending on its material.
  91451. * @param subMesh The submesh to dispatch
  91452. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91453. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91454. */
  91455. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91456. dispatchSprites(spriteManager: ISpriteManager): void;
  91457. dispatchParticles(particleSystem: IParticleSystem): void;
  91458. private _renderParticles;
  91459. private _renderSprites;
  91460. }
  91461. }
  91462. declare module BABYLON {
  91463. /**
  91464. * Interface describing the different options available in the rendering manager
  91465. * regarding Auto Clear between groups.
  91466. */
  91467. export interface IRenderingManagerAutoClearSetup {
  91468. /**
  91469. * Defines whether or not autoclear is enable.
  91470. */
  91471. autoClear: boolean;
  91472. /**
  91473. * Defines whether or not to autoclear the depth buffer.
  91474. */
  91475. depth: boolean;
  91476. /**
  91477. * Defines whether or not to autoclear the stencil buffer.
  91478. */
  91479. stencil: boolean;
  91480. }
  91481. /**
  91482. * This class is used by the onRenderingGroupObservable
  91483. */
  91484. export class RenderingGroupInfo {
  91485. /**
  91486. * The Scene that being rendered
  91487. */
  91488. scene: Scene;
  91489. /**
  91490. * The camera currently used for the rendering pass
  91491. */
  91492. camera: Nullable<Camera>;
  91493. /**
  91494. * The ID of the renderingGroup being processed
  91495. */
  91496. renderingGroupId: number;
  91497. }
  91498. /**
  91499. * This is the manager responsible of all the rendering for meshes sprites and particles.
  91500. * It is enable to manage the different groups as well as the different necessary sort functions.
  91501. * This should not be used directly aside of the few static configurations
  91502. */
  91503. export class RenderingManager {
  91504. /**
  91505. * The max id used for rendering groups (not included)
  91506. */
  91507. static MAX_RENDERINGGROUPS: number;
  91508. /**
  91509. * The min id used for rendering groups (included)
  91510. */
  91511. static MIN_RENDERINGGROUPS: number;
  91512. /**
  91513. * Used to globally prevent autoclearing scenes.
  91514. */
  91515. static AUTOCLEAR: boolean;
  91516. /**
  91517. * @hidden
  91518. */
  91519. _useSceneAutoClearSetup: boolean;
  91520. private _scene;
  91521. private _renderingGroups;
  91522. private _depthStencilBufferAlreadyCleaned;
  91523. private _autoClearDepthStencil;
  91524. private _customOpaqueSortCompareFn;
  91525. private _customAlphaTestSortCompareFn;
  91526. private _customTransparentSortCompareFn;
  91527. private _renderingGroupInfo;
  91528. /**
  91529. * Instantiates a new rendering group for a particular scene
  91530. * @param scene Defines the scene the groups belongs to
  91531. */
  91532. constructor(scene: Scene);
  91533. private _clearDepthStencilBuffer;
  91534. /**
  91535. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  91536. * @hidden
  91537. */
  91538. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  91539. /**
  91540. * Resets the different information of the group to prepare a new frame
  91541. * @hidden
  91542. */
  91543. reset(): void;
  91544. /**
  91545. * Dispose and release the group and its associated resources.
  91546. * @hidden
  91547. */
  91548. dispose(): void;
  91549. /**
  91550. * Clear the info related to rendering groups preventing retention points during dispose.
  91551. */
  91552. freeRenderingGroups(): void;
  91553. private _prepareRenderingGroup;
  91554. /**
  91555. * Add a sprite manager to the rendering manager in order to render it this frame.
  91556. * @param spriteManager Define the sprite manager to render
  91557. */
  91558. dispatchSprites(spriteManager: ISpriteManager): void;
  91559. /**
  91560. * Add a particle system to the rendering manager in order to render it this frame.
  91561. * @param particleSystem Define the particle system to render
  91562. */
  91563. dispatchParticles(particleSystem: IParticleSystem): void;
  91564. /**
  91565. * Add a submesh to the manager in order to render it this frame
  91566. * @param subMesh The submesh to dispatch
  91567. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91568. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91569. */
  91570. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91571. /**
  91572. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91573. * This allowed control for front to back rendering or reversly depending of the special needs.
  91574. *
  91575. * @param renderingGroupId The rendering group id corresponding to its index
  91576. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91577. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91578. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91579. */
  91580. 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;
  91581. /**
  91582. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91583. *
  91584. * @param renderingGroupId The rendering group id corresponding to its index
  91585. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91586. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91587. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91588. */
  91589. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91590. /**
  91591. * Gets the current auto clear configuration for one rendering group of the rendering
  91592. * manager.
  91593. * @param index the rendering group index to get the information for
  91594. * @returns The auto clear setup for the requested rendering group
  91595. */
  91596. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91597. }
  91598. }
  91599. declare module BABYLON {
  91600. /**
  91601. * This Helps creating a texture that will be created from a camera in your scene.
  91602. * It is basically a dynamic texture that could be used to create special effects for instance.
  91603. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  91604. */
  91605. export class RenderTargetTexture extends Texture {
  91606. isCube: boolean;
  91607. /**
  91608. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  91609. */
  91610. static readonly REFRESHRATE_RENDER_ONCE: number;
  91611. /**
  91612. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  91613. */
  91614. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  91615. /**
  91616. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  91617. * the central point of your effect and can save a lot of performances.
  91618. */
  91619. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  91620. /**
  91621. * Use this predicate to dynamically define the list of mesh you want to render.
  91622. * If set, the renderList property will be overwritten.
  91623. */
  91624. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  91625. private _renderList;
  91626. /**
  91627. * Use this list to define the list of mesh you want to render.
  91628. */
  91629. get renderList(): Nullable<Array<AbstractMesh>>;
  91630. set renderList(value: Nullable<Array<AbstractMesh>>);
  91631. private _hookArray;
  91632. /**
  91633. * Define if particles should be rendered in your texture.
  91634. */
  91635. renderParticles: boolean;
  91636. /**
  91637. * Define if sprites should be rendered in your texture.
  91638. */
  91639. renderSprites: boolean;
  91640. /**
  91641. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  91642. */
  91643. coordinatesMode: number;
  91644. /**
  91645. * Define the camera used to render the texture.
  91646. */
  91647. activeCamera: Nullable<Camera>;
  91648. /**
  91649. * Override the render function of the texture with your own one.
  91650. */
  91651. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  91652. /**
  91653. * Define if camera post processes should be use while rendering the texture.
  91654. */
  91655. useCameraPostProcesses: boolean;
  91656. /**
  91657. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  91658. */
  91659. ignoreCameraViewport: boolean;
  91660. private _postProcessManager;
  91661. private _postProcesses;
  91662. private _resizeObserver;
  91663. /**
  91664. * An event triggered when the texture is unbind.
  91665. */
  91666. onBeforeBindObservable: Observable<RenderTargetTexture>;
  91667. /**
  91668. * An event triggered when the texture is unbind.
  91669. */
  91670. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  91671. private _onAfterUnbindObserver;
  91672. /**
  91673. * Set a after unbind callback in the texture.
  91674. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  91675. */
  91676. set onAfterUnbind(callback: () => void);
  91677. /**
  91678. * An event triggered before rendering the texture
  91679. */
  91680. onBeforeRenderObservable: Observable<number>;
  91681. private _onBeforeRenderObserver;
  91682. /**
  91683. * Set a before render callback in the texture.
  91684. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  91685. */
  91686. set onBeforeRender(callback: (faceIndex: number) => void);
  91687. /**
  91688. * An event triggered after rendering the texture
  91689. */
  91690. onAfterRenderObservable: Observable<number>;
  91691. private _onAfterRenderObserver;
  91692. /**
  91693. * Set a after render callback in the texture.
  91694. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  91695. */
  91696. set onAfterRender(callback: (faceIndex: number) => void);
  91697. /**
  91698. * An event triggered after the texture clear
  91699. */
  91700. onClearObservable: Observable<Engine>;
  91701. private _onClearObserver;
  91702. /**
  91703. * Set a clear callback in the texture.
  91704. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  91705. */
  91706. set onClear(callback: (Engine: Engine) => void);
  91707. /**
  91708. * An event triggered when the texture is resized.
  91709. */
  91710. onResizeObservable: Observable<RenderTargetTexture>;
  91711. /**
  91712. * Define the clear color of the Render Target if it should be different from the scene.
  91713. */
  91714. clearColor: Color4;
  91715. protected _size: number | {
  91716. width: number;
  91717. height: number;
  91718. };
  91719. protected _initialSizeParameter: number | {
  91720. width: number;
  91721. height: number;
  91722. } | {
  91723. ratio: number;
  91724. };
  91725. protected _sizeRatio: Nullable<number>;
  91726. /** @hidden */
  91727. _generateMipMaps: boolean;
  91728. protected _renderingManager: RenderingManager;
  91729. /** @hidden */
  91730. _waitingRenderList: string[];
  91731. protected _doNotChangeAspectRatio: boolean;
  91732. protected _currentRefreshId: number;
  91733. protected _refreshRate: number;
  91734. protected _textureMatrix: Matrix;
  91735. protected _samples: number;
  91736. protected _renderTargetOptions: RenderTargetCreationOptions;
  91737. /**
  91738. * Gets render target creation options that were used.
  91739. */
  91740. get renderTargetOptions(): RenderTargetCreationOptions;
  91741. protected _engine: Engine;
  91742. protected _onRatioRescale(): void;
  91743. /**
  91744. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  91745. * It must define where the camera used to render the texture is set
  91746. */
  91747. boundingBoxPosition: Vector3;
  91748. private _boundingBoxSize;
  91749. /**
  91750. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  91751. * When defined, the cubemap will switch to local mode
  91752. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  91753. * @example https://www.babylonjs-playground.com/#RNASML
  91754. */
  91755. set boundingBoxSize(value: Vector3);
  91756. get boundingBoxSize(): Vector3;
  91757. /**
  91758. * In case the RTT has been created with a depth texture, get the associated
  91759. * depth texture.
  91760. * Otherwise, return null.
  91761. */
  91762. depthStencilTexture: Nullable<InternalTexture>;
  91763. /**
  91764. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  91765. * or used a shadow, depth texture...
  91766. * @param name The friendly name of the texture
  91767. * @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)
  91768. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  91769. * @param generateMipMaps True if mip maps need to be generated after render.
  91770. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  91771. * @param type The type of the buffer in the RTT (int, half float, float...)
  91772. * @param isCube True if a cube texture needs to be created
  91773. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  91774. * @param generateDepthBuffer True to generate a depth buffer
  91775. * @param generateStencilBuffer True to generate a stencil buffer
  91776. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  91777. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  91778. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91779. */
  91780. constructor(name: string, size: number | {
  91781. width: number;
  91782. height: number;
  91783. } | {
  91784. ratio: number;
  91785. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  91786. /**
  91787. * Creates a depth stencil texture.
  91788. * This is only available in WebGL 2 or with the depth texture extension available.
  91789. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  91790. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  91791. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  91792. */
  91793. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  91794. private _processSizeParameter;
  91795. /**
  91796. * Define the number of samples to use in case of MSAA.
  91797. * It defaults to one meaning no MSAA has been enabled.
  91798. */
  91799. get samples(): number;
  91800. set samples(value: number);
  91801. /**
  91802. * Resets the refresh counter of the texture and start bak from scratch.
  91803. * Could be useful to regenerate the texture if it is setup to render only once.
  91804. */
  91805. resetRefreshCounter(): void;
  91806. /**
  91807. * Define the refresh rate of the texture or the rendering frequency.
  91808. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91809. */
  91810. get refreshRate(): number;
  91811. set refreshRate(value: number);
  91812. /**
  91813. * Adds a post process to the render target rendering passes.
  91814. * @param postProcess define the post process to add
  91815. */
  91816. addPostProcess(postProcess: PostProcess): void;
  91817. /**
  91818. * Clear all the post processes attached to the render target
  91819. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  91820. */
  91821. clearPostProcesses(dispose?: boolean): void;
  91822. /**
  91823. * Remove one of the post process from the list of attached post processes to the texture
  91824. * @param postProcess define the post process to remove from the list
  91825. */
  91826. removePostProcess(postProcess: PostProcess): void;
  91827. /** @hidden */
  91828. _shouldRender(): boolean;
  91829. /**
  91830. * Gets the actual render size of the texture.
  91831. * @returns the width of the render size
  91832. */
  91833. getRenderSize(): number;
  91834. /**
  91835. * Gets the actual render width of the texture.
  91836. * @returns the width of the render size
  91837. */
  91838. getRenderWidth(): number;
  91839. /**
  91840. * Gets the actual render height of the texture.
  91841. * @returns the height of the render size
  91842. */
  91843. getRenderHeight(): number;
  91844. /**
  91845. * Get if the texture can be rescaled or not.
  91846. */
  91847. get canRescale(): boolean;
  91848. /**
  91849. * Resize the texture using a ratio.
  91850. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91851. */
  91852. scale(ratio: number): void;
  91853. /**
  91854. * Get the texture reflection matrix used to rotate/transform the reflection.
  91855. * @returns the reflection matrix
  91856. */
  91857. getReflectionTextureMatrix(): Matrix;
  91858. /**
  91859. * Resize the texture to a new desired size.
  91860. * Be carrefull as it will recreate all the data in the new texture.
  91861. * @param size Define the new size. It can be:
  91862. * - a number for squared texture,
  91863. * - an object containing { width: number, height: number }
  91864. * - or an object containing a ratio { ratio: number }
  91865. */
  91866. resize(size: number | {
  91867. width: number;
  91868. height: number;
  91869. } | {
  91870. ratio: number;
  91871. }): void;
  91872. /**
  91873. * Renders all the objects from the render list into the texture.
  91874. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91875. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91876. */
  91877. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91878. private _bestReflectionRenderTargetDimension;
  91879. /**
  91880. * @hidden
  91881. * @param faceIndex face index to bind to if this is a cubetexture
  91882. */
  91883. _bindFrameBuffer(faceIndex?: number): void;
  91884. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91885. private renderToTarget;
  91886. /**
  91887. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91888. * This allowed control for front to back rendering or reversly depending of the special needs.
  91889. *
  91890. * @param renderingGroupId The rendering group id corresponding to its index
  91891. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91892. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91893. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91894. */
  91895. 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;
  91896. /**
  91897. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91898. *
  91899. * @param renderingGroupId The rendering group id corresponding to its index
  91900. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91901. */
  91902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91903. /**
  91904. * Clones the texture.
  91905. * @returns the cloned texture
  91906. */
  91907. clone(): RenderTargetTexture;
  91908. /**
  91909. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91910. * @returns The JSON representation of the texture
  91911. */
  91912. serialize(): any;
  91913. /**
  91914. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91915. */
  91916. disposeFramebufferObjects(): void;
  91917. /**
  91918. * Dispose the texture and release its associated resources.
  91919. */
  91920. dispose(): void;
  91921. /** @hidden */
  91922. _rebuild(): void;
  91923. /**
  91924. * Clear the info related to rendering groups preventing retention point in material dispose.
  91925. */
  91926. freeRenderingGroups(): void;
  91927. /**
  91928. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91929. * @returns the view count
  91930. */
  91931. getViewCount(): number;
  91932. }
  91933. }
  91934. declare module BABYLON {
  91935. /**
  91936. * Options for compiling materials.
  91937. */
  91938. export interface IMaterialCompilationOptions {
  91939. /**
  91940. * Defines whether clip planes are enabled.
  91941. */
  91942. clipPlane: boolean;
  91943. /**
  91944. * Defines whether instances are enabled.
  91945. */
  91946. useInstances: boolean;
  91947. }
  91948. /**
  91949. * Base class for the main features of a material in Babylon.js
  91950. */
  91951. export class Material implements IAnimatable {
  91952. /**
  91953. * Returns the triangle fill mode
  91954. */
  91955. static readonly TriangleFillMode: number;
  91956. /**
  91957. * Returns the wireframe mode
  91958. */
  91959. static readonly WireFrameFillMode: number;
  91960. /**
  91961. * Returns the point fill mode
  91962. */
  91963. static readonly PointFillMode: number;
  91964. /**
  91965. * Returns the point list draw mode
  91966. */
  91967. static readonly PointListDrawMode: number;
  91968. /**
  91969. * Returns the line list draw mode
  91970. */
  91971. static readonly LineListDrawMode: number;
  91972. /**
  91973. * Returns the line loop draw mode
  91974. */
  91975. static readonly LineLoopDrawMode: number;
  91976. /**
  91977. * Returns the line strip draw mode
  91978. */
  91979. static readonly LineStripDrawMode: number;
  91980. /**
  91981. * Returns the triangle strip draw mode
  91982. */
  91983. static readonly TriangleStripDrawMode: number;
  91984. /**
  91985. * Returns the triangle fan draw mode
  91986. */
  91987. static readonly TriangleFanDrawMode: number;
  91988. /**
  91989. * Stores the clock-wise side orientation
  91990. */
  91991. static readonly ClockWiseSideOrientation: number;
  91992. /**
  91993. * Stores the counter clock-wise side orientation
  91994. */
  91995. static readonly CounterClockWiseSideOrientation: number;
  91996. /**
  91997. * The dirty texture flag value
  91998. */
  91999. static readonly TextureDirtyFlag: number;
  92000. /**
  92001. * The dirty light flag value
  92002. */
  92003. static readonly LightDirtyFlag: number;
  92004. /**
  92005. * The dirty fresnel flag value
  92006. */
  92007. static readonly FresnelDirtyFlag: number;
  92008. /**
  92009. * The dirty attribute flag value
  92010. */
  92011. static readonly AttributesDirtyFlag: number;
  92012. /**
  92013. * The dirty misc flag value
  92014. */
  92015. static readonly MiscDirtyFlag: number;
  92016. /**
  92017. * The all dirty flag value
  92018. */
  92019. static readonly AllDirtyFlag: number;
  92020. /**
  92021. * The ID of the material
  92022. */
  92023. id: string;
  92024. /**
  92025. * Gets or sets the unique id of the material
  92026. */
  92027. uniqueId: number;
  92028. /**
  92029. * The name of the material
  92030. */
  92031. name: string;
  92032. /**
  92033. * Gets or sets user defined metadata
  92034. */
  92035. metadata: any;
  92036. /**
  92037. * For internal use only. Please do not use.
  92038. */
  92039. reservedDataStore: any;
  92040. /**
  92041. * Specifies if the ready state should be checked on each call
  92042. */
  92043. checkReadyOnEveryCall: boolean;
  92044. /**
  92045. * Specifies if the ready state should be checked once
  92046. */
  92047. checkReadyOnlyOnce: boolean;
  92048. /**
  92049. * The state of the material
  92050. */
  92051. state: string;
  92052. /**
  92053. * The alpha value of the material
  92054. */
  92055. protected _alpha: number;
  92056. /**
  92057. * List of inspectable custom properties (used by the Inspector)
  92058. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92059. */
  92060. inspectableCustomProperties: IInspectable[];
  92061. /**
  92062. * Sets the alpha value of the material
  92063. */
  92064. set alpha(value: number);
  92065. /**
  92066. * Gets the alpha value of the material
  92067. */
  92068. get alpha(): number;
  92069. /**
  92070. * Specifies if back face culling is enabled
  92071. */
  92072. protected _backFaceCulling: boolean;
  92073. /**
  92074. * Sets the back-face culling state
  92075. */
  92076. set backFaceCulling(value: boolean);
  92077. /**
  92078. * Gets the back-face culling state
  92079. */
  92080. get backFaceCulling(): boolean;
  92081. /**
  92082. * Stores the value for side orientation
  92083. */
  92084. sideOrientation: number;
  92085. /**
  92086. * Callback triggered when the material is compiled
  92087. */
  92088. onCompiled: Nullable<(effect: Effect) => void>;
  92089. /**
  92090. * Callback triggered when an error occurs
  92091. */
  92092. onError: Nullable<(effect: Effect, errors: string) => void>;
  92093. /**
  92094. * Callback triggered to get the render target textures
  92095. */
  92096. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  92097. /**
  92098. * Gets a boolean indicating that current material needs to register RTT
  92099. */
  92100. get hasRenderTargetTextures(): boolean;
  92101. /**
  92102. * Specifies if the material should be serialized
  92103. */
  92104. doNotSerialize: boolean;
  92105. /**
  92106. * @hidden
  92107. */
  92108. _storeEffectOnSubMeshes: boolean;
  92109. /**
  92110. * Stores the animations for the material
  92111. */
  92112. animations: Nullable<Array<Animation>>;
  92113. /**
  92114. * An event triggered when the material is disposed
  92115. */
  92116. onDisposeObservable: Observable<Material>;
  92117. /**
  92118. * An observer which watches for dispose events
  92119. */
  92120. private _onDisposeObserver;
  92121. private _onUnBindObservable;
  92122. /**
  92123. * Called during a dispose event
  92124. */
  92125. set onDispose(callback: () => void);
  92126. private _onBindObservable;
  92127. /**
  92128. * An event triggered when the material is bound
  92129. */
  92130. get onBindObservable(): Observable<AbstractMesh>;
  92131. /**
  92132. * An observer which watches for bind events
  92133. */
  92134. private _onBindObserver;
  92135. /**
  92136. * Called during a bind event
  92137. */
  92138. set onBind(callback: (Mesh: AbstractMesh) => void);
  92139. /**
  92140. * An event triggered when the material is unbound
  92141. */
  92142. get onUnBindObservable(): Observable<Material>;
  92143. /**
  92144. * Stores the value of the alpha mode
  92145. */
  92146. private _alphaMode;
  92147. /**
  92148. * Sets the value of the alpha mode.
  92149. *
  92150. * | Value | Type | Description |
  92151. * | --- | --- | --- |
  92152. * | 0 | ALPHA_DISABLE | |
  92153. * | 1 | ALPHA_ADD | |
  92154. * | 2 | ALPHA_COMBINE | |
  92155. * | 3 | ALPHA_SUBTRACT | |
  92156. * | 4 | ALPHA_MULTIPLY | |
  92157. * | 5 | ALPHA_MAXIMIZED | |
  92158. * | 6 | ALPHA_ONEONE | |
  92159. * | 7 | ALPHA_PREMULTIPLIED | |
  92160. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  92161. * | 9 | ALPHA_INTERPOLATE | |
  92162. * | 10 | ALPHA_SCREENMODE | |
  92163. *
  92164. */
  92165. set alphaMode(value: number);
  92166. /**
  92167. * Gets the value of the alpha mode
  92168. */
  92169. get alphaMode(): number;
  92170. /**
  92171. * Stores the state of the need depth pre-pass value
  92172. */
  92173. private _needDepthPrePass;
  92174. /**
  92175. * Sets the need depth pre-pass value
  92176. */
  92177. set needDepthPrePass(value: boolean);
  92178. /**
  92179. * Gets the depth pre-pass value
  92180. */
  92181. get needDepthPrePass(): boolean;
  92182. /**
  92183. * Specifies if depth writing should be disabled
  92184. */
  92185. disableDepthWrite: boolean;
  92186. /**
  92187. * Specifies if depth writing should be forced
  92188. */
  92189. forceDepthWrite: boolean;
  92190. /**
  92191. * Specifies the depth function that should be used. 0 means the default engine function
  92192. */
  92193. depthFunction: number;
  92194. /**
  92195. * Specifies if there should be a separate pass for culling
  92196. */
  92197. separateCullingPass: boolean;
  92198. /**
  92199. * Stores the state specifing if fog should be enabled
  92200. */
  92201. private _fogEnabled;
  92202. /**
  92203. * Sets the state for enabling fog
  92204. */
  92205. set fogEnabled(value: boolean);
  92206. /**
  92207. * Gets the value of the fog enabled state
  92208. */
  92209. get fogEnabled(): boolean;
  92210. /**
  92211. * Stores the size of points
  92212. */
  92213. pointSize: number;
  92214. /**
  92215. * Stores the z offset value
  92216. */
  92217. zOffset: number;
  92218. /**
  92219. * Gets a value specifying if wireframe mode is enabled
  92220. */
  92221. get wireframe(): boolean;
  92222. /**
  92223. * Sets the state of wireframe mode
  92224. */
  92225. set wireframe(value: boolean);
  92226. /**
  92227. * Gets the value specifying if point clouds are enabled
  92228. */
  92229. get pointsCloud(): boolean;
  92230. /**
  92231. * Sets the state of point cloud mode
  92232. */
  92233. set pointsCloud(value: boolean);
  92234. /**
  92235. * Gets the material fill mode
  92236. */
  92237. get fillMode(): number;
  92238. /**
  92239. * Sets the material fill mode
  92240. */
  92241. set fillMode(value: number);
  92242. /**
  92243. * @hidden
  92244. * Stores the effects for the material
  92245. */
  92246. _effect: Nullable<Effect>;
  92247. /**
  92248. * Specifies if uniform buffers should be used
  92249. */
  92250. private _useUBO;
  92251. /**
  92252. * Stores a reference to the scene
  92253. */
  92254. private _scene;
  92255. /**
  92256. * Stores the fill mode state
  92257. */
  92258. private _fillMode;
  92259. /**
  92260. * Specifies if the depth write state should be cached
  92261. */
  92262. private _cachedDepthWriteState;
  92263. /**
  92264. * Specifies if the depth function state should be cached
  92265. */
  92266. private _cachedDepthFunctionState;
  92267. /**
  92268. * Stores the uniform buffer
  92269. */
  92270. protected _uniformBuffer: UniformBuffer;
  92271. /** @hidden */
  92272. _indexInSceneMaterialArray: number;
  92273. /** @hidden */
  92274. meshMap: Nullable<{
  92275. [id: string]: AbstractMesh | undefined;
  92276. }>;
  92277. /**
  92278. * Creates a material instance
  92279. * @param name defines the name of the material
  92280. * @param scene defines the scene to reference
  92281. * @param doNotAdd specifies if the material should be added to the scene
  92282. */
  92283. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  92284. /**
  92285. * Returns a string representation of the current material
  92286. * @param fullDetails defines a boolean indicating which levels of logging is desired
  92287. * @returns a string with material information
  92288. */
  92289. toString(fullDetails?: boolean): string;
  92290. /**
  92291. * Gets the class name of the material
  92292. * @returns a string with the class name of the material
  92293. */
  92294. getClassName(): string;
  92295. /**
  92296. * Specifies if updates for the material been locked
  92297. */
  92298. get isFrozen(): boolean;
  92299. /**
  92300. * Locks updates for the material
  92301. */
  92302. freeze(): void;
  92303. /**
  92304. * Unlocks updates for the material
  92305. */
  92306. unfreeze(): void;
  92307. /**
  92308. * Specifies if the material is ready to be used
  92309. * @param mesh defines the mesh to check
  92310. * @param useInstances specifies if instances should be used
  92311. * @returns a boolean indicating if the material is ready to be used
  92312. */
  92313. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  92314. /**
  92315. * Specifies that the submesh is ready to be used
  92316. * @param mesh defines the mesh to check
  92317. * @param subMesh defines which submesh to check
  92318. * @param useInstances specifies that instances should be used
  92319. * @returns a boolean indicating that the submesh is ready or not
  92320. */
  92321. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92322. /**
  92323. * Returns the material effect
  92324. * @returns the effect associated with the material
  92325. */
  92326. getEffect(): Nullable<Effect>;
  92327. /**
  92328. * Returns the current scene
  92329. * @returns a Scene
  92330. */
  92331. getScene(): Scene;
  92332. /**
  92333. * Specifies if the material will require alpha blending
  92334. * @returns a boolean specifying if alpha blending is needed
  92335. */
  92336. needAlphaBlending(): boolean;
  92337. /**
  92338. * Specifies if the mesh will require alpha blending
  92339. * @param mesh defines the mesh to check
  92340. * @returns a boolean specifying if alpha blending is needed for the mesh
  92341. */
  92342. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  92343. /**
  92344. * Specifies if this material should be rendered in alpha test mode
  92345. * @returns a boolean specifying if an alpha test is needed.
  92346. */
  92347. needAlphaTesting(): boolean;
  92348. /**
  92349. * Gets the texture used for the alpha test
  92350. * @returns the texture to use for alpha testing
  92351. */
  92352. getAlphaTestTexture(): Nullable<BaseTexture>;
  92353. /**
  92354. * Marks the material to indicate that it needs to be re-calculated
  92355. */
  92356. markDirty(): void;
  92357. /** @hidden */
  92358. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  92359. /**
  92360. * Binds the material to the mesh
  92361. * @param world defines the world transformation matrix
  92362. * @param mesh defines the mesh to bind the material to
  92363. */
  92364. bind(world: Matrix, mesh?: Mesh): void;
  92365. /**
  92366. * Binds the submesh to the material
  92367. * @param world defines the world transformation matrix
  92368. * @param mesh defines the mesh containing the submesh
  92369. * @param subMesh defines the submesh to bind the material to
  92370. */
  92371. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  92372. /**
  92373. * Binds the world matrix to the material
  92374. * @param world defines the world transformation matrix
  92375. */
  92376. bindOnlyWorldMatrix(world: Matrix): void;
  92377. /**
  92378. * Binds the scene's uniform buffer to the effect.
  92379. * @param effect defines the effect to bind to the scene uniform buffer
  92380. * @param sceneUbo defines the uniform buffer storing scene data
  92381. */
  92382. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  92383. /**
  92384. * Binds the view matrix to the effect
  92385. * @param effect defines the effect to bind the view matrix to
  92386. */
  92387. bindView(effect: Effect): void;
  92388. /**
  92389. * Binds the view projection matrix to the effect
  92390. * @param effect defines the effect to bind the view projection matrix to
  92391. */
  92392. bindViewProjection(effect: Effect): void;
  92393. /**
  92394. * Specifies if material alpha testing should be turned on for the mesh
  92395. * @param mesh defines the mesh to check
  92396. */
  92397. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  92398. /**
  92399. * Processes to execute after binding the material to a mesh
  92400. * @param mesh defines the rendered mesh
  92401. */
  92402. protected _afterBind(mesh?: Mesh): void;
  92403. /**
  92404. * Unbinds the material from the mesh
  92405. */
  92406. unbind(): void;
  92407. /**
  92408. * Gets the active textures from the material
  92409. * @returns an array of textures
  92410. */
  92411. getActiveTextures(): BaseTexture[];
  92412. /**
  92413. * Specifies if the material uses a texture
  92414. * @param texture defines the texture to check against the material
  92415. * @returns a boolean specifying if the material uses the texture
  92416. */
  92417. hasTexture(texture: BaseTexture): boolean;
  92418. /**
  92419. * Makes a duplicate of the material, and gives it a new name
  92420. * @param name defines the new name for the duplicated material
  92421. * @returns the cloned material
  92422. */
  92423. clone(name: string): Nullable<Material>;
  92424. /**
  92425. * Gets the meshes bound to the material
  92426. * @returns an array of meshes bound to the material
  92427. */
  92428. getBindedMeshes(): AbstractMesh[];
  92429. /**
  92430. * Force shader compilation
  92431. * @param mesh defines the mesh associated with this material
  92432. * @param onCompiled defines a function to execute once the material is compiled
  92433. * @param options defines the options to configure the compilation
  92434. * @param onError defines a function to execute if the material fails compiling
  92435. */
  92436. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  92437. /**
  92438. * Force shader compilation
  92439. * @param mesh defines the mesh that will use this material
  92440. * @param options defines additional options for compiling the shaders
  92441. * @returns a promise that resolves when the compilation completes
  92442. */
  92443. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  92444. private static readonly _AllDirtyCallBack;
  92445. private static readonly _ImageProcessingDirtyCallBack;
  92446. private static readonly _TextureDirtyCallBack;
  92447. private static readonly _FresnelDirtyCallBack;
  92448. private static readonly _MiscDirtyCallBack;
  92449. private static readonly _LightsDirtyCallBack;
  92450. private static readonly _AttributeDirtyCallBack;
  92451. private static _FresnelAndMiscDirtyCallBack;
  92452. private static _TextureAndMiscDirtyCallBack;
  92453. private static readonly _DirtyCallbackArray;
  92454. private static readonly _RunDirtyCallBacks;
  92455. /**
  92456. * Marks a define in the material to indicate that it needs to be re-computed
  92457. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  92458. */
  92459. markAsDirty(flag: number): void;
  92460. /**
  92461. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  92462. * @param func defines a function which checks material defines against the submeshes
  92463. */
  92464. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  92465. /**
  92466. * Indicates that we need to re-calculated for all submeshes
  92467. */
  92468. protected _markAllSubMeshesAsAllDirty(): void;
  92469. /**
  92470. * Indicates that image processing needs to be re-calculated for all submeshes
  92471. */
  92472. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  92473. /**
  92474. * Indicates that textures need to be re-calculated for all submeshes
  92475. */
  92476. protected _markAllSubMeshesAsTexturesDirty(): void;
  92477. /**
  92478. * Indicates that fresnel needs to be re-calculated for all submeshes
  92479. */
  92480. protected _markAllSubMeshesAsFresnelDirty(): void;
  92481. /**
  92482. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  92483. */
  92484. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  92485. /**
  92486. * Indicates that lights need to be re-calculated for all submeshes
  92487. */
  92488. protected _markAllSubMeshesAsLightsDirty(): void;
  92489. /**
  92490. * Indicates that attributes need to be re-calculated for all submeshes
  92491. */
  92492. protected _markAllSubMeshesAsAttributesDirty(): void;
  92493. /**
  92494. * Indicates that misc needs to be re-calculated for all submeshes
  92495. */
  92496. protected _markAllSubMeshesAsMiscDirty(): void;
  92497. /**
  92498. * Indicates that textures and misc need to be re-calculated for all submeshes
  92499. */
  92500. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  92501. /**
  92502. * Disposes the material
  92503. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92504. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  92505. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  92506. */
  92507. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  92508. /** @hidden */
  92509. private releaseVertexArrayObject;
  92510. /**
  92511. * Serializes this material
  92512. * @returns the serialized material object
  92513. */
  92514. serialize(): any;
  92515. /**
  92516. * Creates a material from parsed material data
  92517. * @param parsedMaterial defines parsed material data
  92518. * @param scene defines the hosting scene
  92519. * @param rootUrl defines the root URL to use to load textures
  92520. * @returns a new material
  92521. */
  92522. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  92523. }
  92524. }
  92525. declare module BABYLON {
  92526. /**
  92527. * A multi-material is used to apply different materials to different parts of the same object without the need of
  92528. * separate meshes. This can be use to improve performances.
  92529. * @see http://doc.babylonjs.com/how_to/multi_materials
  92530. */
  92531. export class MultiMaterial extends Material {
  92532. private _subMaterials;
  92533. /**
  92534. * Gets or Sets the list of Materials used within the multi material.
  92535. * They need to be ordered according to the submeshes order in the associated mesh
  92536. */
  92537. get subMaterials(): Nullable<Material>[];
  92538. set subMaterials(value: Nullable<Material>[]);
  92539. /**
  92540. * Function used to align with Node.getChildren()
  92541. * @returns the list of Materials used within the multi material
  92542. */
  92543. getChildren(): Nullable<Material>[];
  92544. /**
  92545. * Instantiates a new Multi Material
  92546. * A multi-material is used to apply different materials to different parts of the same object without the need of
  92547. * separate meshes. This can be use to improve performances.
  92548. * @see http://doc.babylonjs.com/how_to/multi_materials
  92549. * @param name Define the name in the scene
  92550. * @param scene Define the scene the material belongs to
  92551. */
  92552. constructor(name: string, scene: Scene);
  92553. private _hookArray;
  92554. /**
  92555. * Get one of the submaterial by its index in the submaterials array
  92556. * @param index The index to look the sub material at
  92557. * @returns The Material if the index has been defined
  92558. */
  92559. getSubMaterial(index: number): Nullable<Material>;
  92560. /**
  92561. * Get the list of active textures for the whole sub materials list.
  92562. * @returns All the textures that will be used during the rendering
  92563. */
  92564. getActiveTextures(): BaseTexture[];
  92565. /**
  92566. * Gets the current class name of the material e.g. "MultiMaterial"
  92567. * Mainly use in serialization.
  92568. * @returns the class name
  92569. */
  92570. getClassName(): string;
  92571. /**
  92572. * Checks if the material is ready to render the requested sub mesh
  92573. * @param mesh Define the mesh the submesh belongs to
  92574. * @param subMesh Define the sub mesh to look readyness for
  92575. * @param useInstances Define whether or not the material is used with instances
  92576. * @returns true if ready, otherwise false
  92577. */
  92578. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92579. /**
  92580. * Clones the current material and its related sub materials
  92581. * @param name Define the name of the newly cloned material
  92582. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  92583. * @returns the cloned material
  92584. */
  92585. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  92586. /**
  92587. * Serializes the materials into a JSON representation.
  92588. * @returns the JSON representation
  92589. */
  92590. serialize(): any;
  92591. /**
  92592. * Dispose the material and release its associated resources
  92593. * @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)
  92594. * @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)
  92595. * @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)
  92596. */
  92597. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  92598. /**
  92599. * Creates a MultiMaterial from parsed MultiMaterial data.
  92600. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  92601. * @param scene defines the hosting scene
  92602. * @returns a new MultiMaterial
  92603. */
  92604. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  92605. }
  92606. }
  92607. declare module BABYLON {
  92608. /**
  92609. * Base class for submeshes
  92610. */
  92611. export class BaseSubMesh {
  92612. /** @hidden */
  92613. _materialDefines: Nullable<MaterialDefines>;
  92614. /** @hidden */
  92615. _materialEffect: Nullable<Effect>;
  92616. /**
  92617. * Gets material defines used by the effect associated to the sub mesh
  92618. */
  92619. get materialDefines(): Nullable<MaterialDefines>;
  92620. /**
  92621. * Sets material defines used by the effect associated to the sub mesh
  92622. */
  92623. set materialDefines(defines: Nullable<MaterialDefines>);
  92624. /**
  92625. * Gets associated effect
  92626. */
  92627. get effect(): Nullable<Effect>;
  92628. /**
  92629. * Sets associated effect (effect used to render this submesh)
  92630. * @param effect defines the effect to associate with
  92631. * @param defines defines the set of defines used to compile this effect
  92632. */
  92633. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  92634. }
  92635. /**
  92636. * Defines a subdivision inside a mesh
  92637. */
  92638. export class SubMesh extends BaseSubMesh implements ICullable {
  92639. /** the material index to use */
  92640. materialIndex: number;
  92641. /** vertex index start */
  92642. verticesStart: number;
  92643. /** vertices count */
  92644. verticesCount: number;
  92645. /** index start */
  92646. indexStart: number;
  92647. /** indices count */
  92648. indexCount: number;
  92649. /** @hidden */
  92650. _linesIndexCount: number;
  92651. private _mesh;
  92652. private _renderingMesh;
  92653. private _boundingInfo;
  92654. private _linesIndexBuffer;
  92655. /** @hidden */
  92656. _lastColliderWorldVertices: Nullable<Vector3[]>;
  92657. /** @hidden */
  92658. _trianglePlanes: Plane[];
  92659. /** @hidden */
  92660. _lastColliderTransformMatrix: Nullable<Matrix>;
  92661. /** @hidden */
  92662. _renderId: number;
  92663. /** @hidden */
  92664. _alphaIndex: number;
  92665. /** @hidden */
  92666. _distanceToCamera: number;
  92667. /** @hidden */
  92668. _id: number;
  92669. private _currentMaterial;
  92670. /**
  92671. * Add a new submesh to a mesh
  92672. * @param materialIndex defines the material index to use
  92673. * @param verticesStart defines vertex index start
  92674. * @param verticesCount defines vertices count
  92675. * @param indexStart defines index start
  92676. * @param indexCount defines indices count
  92677. * @param mesh defines the parent mesh
  92678. * @param renderingMesh defines an optional rendering mesh
  92679. * @param createBoundingBox defines if bounding box should be created for this submesh
  92680. * @returns the new submesh
  92681. */
  92682. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  92683. /**
  92684. * Creates a new submesh
  92685. * @param materialIndex defines the material index to use
  92686. * @param verticesStart defines vertex index start
  92687. * @param verticesCount defines vertices count
  92688. * @param indexStart defines index start
  92689. * @param indexCount defines indices count
  92690. * @param mesh defines the parent mesh
  92691. * @param renderingMesh defines an optional rendering mesh
  92692. * @param createBoundingBox defines if bounding box should be created for this submesh
  92693. */
  92694. constructor(
  92695. /** the material index to use */
  92696. materialIndex: number,
  92697. /** vertex index start */
  92698. verticesStart: number,
  92699. /** vertices count */
  92700. verticesCount: number,
  92701. /** index start */
  92702. indexStart: number,
  92703. /** indices count */
  92704. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  92705. /**
  92706. * Returns true if this submesh covers the entire parent mesh
  92707. * @ignorenaming
  92708. */
  92709. get IsGlobal(): boolean;
  92710. /**
  92711. * Returns the submesh BoudingInfo object
  92712. * @returns current bounding info (or mesh's one if the submesh is global)
  92713. */
  92714. getBoundingInfo(): BoundingInfo;
  92715. /**
  92716. * Sets the submesh BoundingInfo
  92717. * @param boundingInfo defines the new bounding info to use
  92718. * @returns the SubMesh
  92719. */
  92720. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  92721. /**
  92722. * Returns the mesh of the current submesh
  92723. * @return the parent mesh
  92724. */
  92725. getMesh(): AbstractMesh;
  92726. /**
  92727. * Returns the rendering mesh of the submesh
  92728. * @returns the rendering mesh (could be different from parent mesh)
  92729. */
  92730. getRenderingMesh(): Mesh;
  92731. /**
  92732. * Returns the submesh material
  92733. * @returns null or the current material
  92734. */
  92735. getMaterial(): Nullable<Material>;
  92736. /**
  92737. * Sets a new updated BoundingInfo object to the submesh
  92738. * @param data defines an optional position array to use to determine the bounding info
  92739. * @returns the SubMesh
  92740. */
  92741. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  92742. /** @hidden */
  92743. _checkCollision(collider: Collider): boolean;
  92744. /**
  92745. * Updates the submesh BoundingInfo
  92746. * @param world defines the world matrix to use to update the bounding info
  92747. * @returns the submesh
  92748. */
  92749. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  92750. /**
  92751. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  92752. * @param frustumPlanes defines the frustum planes
  92753. * @returns true if the submesh is intersecting with the frustum
  92754. */
  92755. isInFrustum(frustumPlanes: Plane[]): boolean;
  92756. /**
  92757. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  92758. * @param frustumPlanes defines the frustum planes
  92759. * @returns true if the submesh is inside the frustum
  92760. */
  92761. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92762. /**
  92763. * Renders the submesh
  92764. * @param enableAlphaMode defines if alpha needs to be used
  92765. * @returns the submesh
  92766. */
  92767. render(enableAlphaMode: boolean): SubMesh;
  92768. /**
  92769. * @hidden
  92770. */
  92771. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  92772. /**
  92773. * Checks if the submesh intersects with a ray
  92774. * @param ray defines the ray to test
  92775. * @returns true is the passed ray intersects the submesh bounding box
  92776. */
  92777. canIntersects(ray: Ray): boolean;
  92778. /**
  92779. * Intersects current submesh with a ray
  92780. * @param ray defines the ray to test
  92781. * @param positions defines mesh's positions array
  92782. * @param indices defines mesh's indices array
  92783. * @param fastCheck defines if only bounding info should be used
  92784. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92785. * @returns intersection info or null if no intersection
  92786. */
  92787. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  92788. /** @hidden */
  92789. private _intersectLines;
  92790. /** @hidden */
  92791. private _intersectUnIndexedLines;
  92792. /** @hidden */
  92793. private _intersectTriangles;
  92794. /** @hidden */
  92795. private _intersectUnIndexedTriangles;
  92796. /** @hidden */
  92797. _rebuild(): void;
  92798. /**
  92799. * Creates a new submesh from the passed mesh
  92800. * @param newMesh defines the new hosting mesh
  92801. * @param newRenderingMesh defines an optional rendering mesh
  92802. * @returns the new submesh
  92803. */
  92804. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  92805. /**
  92806. * Release associated resources
  92807. */
  92808. dispose(): void;
  92809. /**
  92810. * Gets the class name
  92811. * @returns the string "SubMesh".
  92812. */
  92813. getClassName(): string;
  92814. /**
  92815. * Creates a new submesh from indices data
  92816. * @param materialIndex the index of the main mesh material
  92817. * @param startIndex the index where to start the copy in the mesh indices array
  92818. * @param indexCount the number of indices to copy then from the startIndex
  92819. * @param mesh the main mesh to create the submesh from
  92820. * @param renderingMesh the optional rendering mesh
  92821. * @returns a new submesh
  92822. */
  92823. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  92824. }
  92825. }
  92826. declare module BABYLON {
  92827. /**
  92828. * Class used to represent data loading progression
  92829. */
  92830. export class SceneLoaderFlags {
  92831. private static _ForceFullSceneLoadingForIncremental;
  92832. private static _ShowLoadingScreen;
  92833. private static _CleanBoneMatrixWeights;
  92834. private static _loggingLevel;
  92835. /**
  92836. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92837. */
  92838. static get ForceFullSceneLoadingForIncremental(): boolean;
  92839. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92840. /**
  92841. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92842. */
  92843. static get ShowLoadingScreen(): boolean;
  92844. static set ShowLoadingScreen(value: boolean);
  92845. /**
  92846. * Defines the current logging level (while loading the scene)
  92847. * @ignorenaming
  92848. */
  92849. static get loggingLevel(): number;
  92850. static set loggingLevel(value: number);
  92851. /**
  92852. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92853. */
  92854. static get CleanBoneMatrixWeights(): boolean;
  92855. static set CleanBoneMatrixWeights(value: boolean);
  92856. }
  92857. }
  92858. declare module BABYLON {
  92859. /**
  92860. * Class used to store geometry data (vertex buffers + index buffer)
  92861. */
  92862. export class Geometry implements IGetSetVerticesData {
  92863. /**
  92864. * Gets or sets the ID of the geometry
  92865. */
  92866. id: string;
  92867. /**
  92868. * Gets or sets the unique ID of the geometry
  92869. */
  92870. uniqueId: number;
  92871. /**
  92872. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92873. */
  92874. delayLoadState: number;
  92875. /**
  92876. * Gets the file containing the data to load when running in delay load state
  92877. */
  92878. delayLoadingFile: Nullable<string>;
  92879. /**
  92880. * Callback called when the geometry is updated
  92881. */
  92882. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92883. private _scene;
  92884. private _engine;
  92885. private _meshes;
  92886. private _totalVertices;
  92887. /** @hidden */
  92888. _indices: IndicesArray;
  92889. /** @hidden */
  92890. _vertexBuffers: {
  92891. [key: string]: VertexBuffer;
  92892. };
  92893. private _isDisposed;
  92894. private _extend;
  92895. private _boundingBias;
  92896. /** @hidden */
  92897. _delayInfo: Array<string>;
  92898. private _indexBuffer;
  92899. private _indexBufferIsUpdatable;
  92900. /** @hidden */
  92901. _boundingInfo: Nullable<BoundingInfo>;
  92902. /** @hidden */
  92903. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92904. /** @hidden */
  92905. _softwareSkinningFrameId: number;
  92906. private _vertexArrayObjects;
  92907. private _updatable;
  92908. /** @hidden */
  92909. _positions: Nullable<Vector3[]>;
  92910. /**
  92911. * 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
  92912. */
  92913. get boundingBias(): Vector2;
  92914. /**
  92915. * 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
  92916. */
  92917. set boundingBias(value: Vector2);
  92918. /**
  92919. * Static function used to attach a new empty geometry to a mesh
  92920. * @param mesh defines the mesh to attach the geometry to
  92921. * @returns the new Geometry
  92922. */
  92923. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92924. /**
  92925. * Creates a new geometry
  92926. * @param id defines the unique ID
  92927. * @param scene defines the hosting scene
  92928. * @param vertexData defines the VertexData used to get geometry data
  92929. * @param updatable defines if geometry must be updatable (false by default)
  92930. * @param mesh defines the mesh that will be associated with the geometry
  92931. */
  92932. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92933. /**
  92934. * Gets the current extend of the geometry
  92935. */
  92936. get extend(): {
  92937. minimum: Vector3;
  92938. maximum: Vector3;
  92939. };
  92940. /**
  92941. * Gets the hosting scene
  92942. * @returns the hosting Scene
  92943. */
  92944. getScene(): Scene;
  92945. /**
  92946. * Gets the hosting engine
  92947. * @returns the hosting Engine
  92948. */
  92949. getEngine(): Engine;
  92950. /**
  92951. * Defines if the geometry is ready to use
  92952. * @returns true if the geometry is ready to be used
  92953. */
  92954. isReady(): boolean;
  92955. /**
  92956. * Gets a value indicating that the geometry should not be serialized
  92957. */
  92958. get doNotSerialize(): boolean;
  92959. /** @hidden */
  92960. _rebuild(): void;
  92961. /**
  92962. * Affects all geometry data in one call
  92963. * @param vertexData defines the geometry data
  92964. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92965. */
  92966. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92967. /**
  92968. * Set specific vertex data
  92969. * @param kind defines the data kind (Position, normal, etc...)
  92970. * @param data defines the vertex data to use
  92971. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92972. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92973. */
  92974. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92975. /**
  92976. * Removes a specific vertex data
  92977. * @param kind defines the data kind (Position, normal, etc...)
  92978. */
  92979. removeVerticesData(kind: string): void;
  92980. /**
  92981. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92982. * @param buffer defines the vertex buffer to use
  92983. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92984. */
  92985. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92986. /**
  92987. * Update a specific vertex buffer
  92988. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92989. * It will do nothing if the buffer is not updatable
  92990. * @param kind defines the data kind (Position, normal, etc...)
  92991. * @param data defines the data to use
  92992. * @param offset defines the offset in the target buffer where to store the data
  92993. * @param useBytes set to true if the offset is in bytes
  92994. */
  92995. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  92996. /**
  92997. * Update a specific vertex buffer
  92998. * This function will create a new buffer if the current one is not updatable
  92999. * @param kind defines the data kind (Position, normal, etc...)
  93000. * @param data defines the data to use
  93001. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  93002. */
  93003. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  93004. private _updateBoundingInfo;
  93005. /** @hidden */
  93006. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  93007. /**
  93008. * Gets total number of vertices
  93009. * @returns the total number of vertices
  93010. */
  93011. getTotalVertices(): number;
  93012. /**
  93013. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  93014. * @param kind defines the data kind (Position, normal, etc...)
  93015. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  93016. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93017. * @returns a float array containing vertex data
  93018. */
  93019. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93020. /**
  93021. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  93022. * @param kind defines the data kind (Position, normal, etc...)
  93023. * @returns true if the vertex buffer with the specified kind is updatable
  93024. */
  93025. isVertexBufferUpdatable(kind: string): boolean;
  93026. /**
  93027. * Gets a specific vertex buffer
  93028. * @param kind defines the data kind (Position, normal, etc...)
  93029. * @returns a VertexBuffer
  93030. */
  93031. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93032. /**
  93033. * Returns all vertex buffers
  93034. * @return an object holding all vertex buffers indexed by kind
  93035. */
  93036. getVertexBuffers(): Nullable<{
  93037. [key: string]: VertexBuffer;
  93038. }>;
  93039. /**
  93040. * Gets a boolean indicating if specific vertex buffer is present
  93041. * @param kind defines the data kind (Position, normal, etc...)
  93042. * @returns true if data is present
  93043. */
  93044. isVerticesDataPresent(kind: string): boolean;
  93045. /**
  93046. * Gets a list of all attached data kinds (Position, normal, etc...)
  93047. * @returns a list of string containing all kinds
  93048. */
  93049. getVerticesDataKinds(): string[];
  93050. /**
  93051. * Update index buffer
  93052. * @param indices defines the indices to store in the index buffer
  93053. * @param offset defines the offset in the target buffer where to store the data
  93054. * @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)
  93055. */
  93056. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  93057. /**
  93058. * Creates a new index buffer
  93059. * @param indices defines the indices to store in the index buffer
  93060. * @param totalVertices defines the total number of vertices (could be null)
  93061. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  93062. */
  93063. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  93064. /**
  93065. * Return the total number of indices
  93066. * @returns the total number of indices
  93067. */
  93068. getTotalIndices(): number;
  93069. /**
  93070. * Gets the index buffer array
  93071. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  93072. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93073. * @returns the index buffer array
  93074. */
  93075. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93076. /**
  93077. * Gets the index buffer
  93078. * @return the index buffer
  93079. */
  93080. getIndexBuffer(): Nullable<DataBuffer>;
  93081. /** @hidden */
  93082. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  93083. /**
  93084. * Release the associated resources for a specific mesh
  93085. * @param mesh defines the source mesh
  93086. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  93087. */
  93088. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  93089. /**
  93090. * Apply current geometry to a given mesh
  93091. * @param mesh defines the mesh to apply geometry to
  93092. */
  93093. applyToMesh(mesh: Mesh): void;
  93094. private _updateExtend;
  93095. private _applyToMesh;
  93096. private notifyUpdate;
  93097. /**
  93098. * Load the geometry if it was flagged as delay loaded
  93099. * @param scene defines the hosting scene
  93100. * @param onLoaded defines a callback called when the geometry is loaded
  93101. */
  93102. load(scene: Scene, onLoaded?: () => void): void;
  93103. private _queueLoad;
  93104. /**
  93105. * Invert the geometry to move from a right handed system to a left handed one.
  93106. */
  93107. toLeftHanded(): void;
  93108. /** @hidden */
  93109. _resetPointsArrayCache(): void;
  93110. /** @hidden */
  93111. _generatePointsArray(): boolean;
  93112. /**
  93113. * Gets a value indicating if the geometry is disposed
  93114. * @returns true if the geometry was disposed
  93115. */
  93116. isDisposed(): boolean;
  93117. private _disposeVertexArrayObjects;
  93118. /**
  93119. * Free all associated resources
  93120. */
  93121. dispose(): void;
  93122. /**
  93123. * Clone the current geometry into a new geometry
  93124. * @param id defines the unique ID of the new geometry
  93125. * @returns a new geometry object
  93126. */
  93127. copy(id: string): Geometry;
  93128. /**
  93129. * Serialize the current geometry info (and not the vertices data) into a JSON object
  93130. * @return a JSON representation of the current geometry data (without the vertices data)
  93131. */
  93132. serialize(): any;
  93133. private toNumberArray;
  93134. /**
  93135. * Serialize all vertices data into a JSON oject
  93136. * @returns a JSON representation of the current geometry data
  93137. */
  93138. serializeVerticeData(): any;
  93139. /**
  93140. * Extracts a clone of a mesh geometry
  93141. * @param mesh defines the source mesh
  93142. * @param id defines the unique ID of the new geometry object
  93143. * @returns the new geometry object
  93144. */
  93145. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  93146. /**
  93147. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  93148. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93149. * Be aware Math.random() could cause collisions, but:
  93150. * "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"
  93151. * @returns a string containing a new GUID
  93152. */
  93153. static RandomId(): string;
  93154. /** @hidden */
  93155. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  93156. private static _CleanMatricesWeights;
  93157. /**
  93158. * Create a new geometry from persisted data (Using .babylon file format)
  93159. * @param parsedVertexData defines the persisted data
  93160. * @param scene defines the hosting scene
  93161. * @param rootUrl defines the root url to use to load assets (like delayed data)
  93162. * @returns the new geometry object
  93163. */
  93164. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  93165. }
  93166. }
  93167. declare module BABYLON {
  93168. /**
  93169. * Define an interface for all classes that will get and set the data on vertices
  93170. */
  93171. export interface IGetSetVerticesData {
  93172. /**
  93173. * Gets a boolean indicating if specific vertex data is present
  93174. * @param kind defines the vertex data kind to use
  93175. * @returns true is data kind is present
  93176. */
  93177. isVerticesDataPresent(kind: string): boolean;
  93178. /**
  93179. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  93180. * @param kind defines the data kind (Position, normal, etc...)
  93181. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  93182. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93183. * @returns a float array containing vertex data
  93184. */
  93185. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93186. /**
  93187. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93188. * @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.
  93189. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93190. * @returns the indices array or an empty array if the mesh has no geometry
  93191. */
  93192. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93193. /**
  93194. * Set specific vertex data
  93195. * @param kind defines the data kind (Position, normal, etc...)
  93196. * @param data defines the vertex data to use
  93197. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  93198. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  93199. */
  93200. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  93201. /**
  93202. * Update a specific associated vertex buffer
  93203. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93204. * - VertexBuffer.PositionKind
  93205. * - VertexBuffer.UVKind
  93206. * - VertexBuffer.UV2Kind
  93207. * - VertexBuffer.UV3Kind
  93208. * - VertexBuffer.UV4Kind
  93209. * - VertexBuffer.UV5Kind
  93210. * - VertexBuffer.UV6Kind
  93211. * - VertexBuffer.ColorKind
  93212. * - VertexBuffer.MatricesIndicesKind
  93213. * - VertexBuffer.MatricesIndicesExtraKind
  93214. * - VertexBuffer.MatricesWeightsKind
  93215. * - VertexBuffer.MatricesWeightsExtraKind
  93216. * @param data defines the data source
  93217. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93218. * @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)
  93219. */
  93220. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  93221. /**
  93222. * Creates a new index buffer
  93223. * @param indices defines the indices to store in the index buffer
  93224. * @param totalVertices defines the total number of vertices (could be null)
  93225. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  93226. */
  93227. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  93228. }
  93229. /**
  93230. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  93231. */
  93232. export class VertexData {
  93233. /**
  93234. * Mesh side orientation : usually the external or front surface
  93235. */
  93236. static readonly FRONTSIDE: number;
  93237. /**
  93238. * Mesh side orientation : usually the internal or back surface
  93239. */
  93240. static readonly BACKSIDE: number;
  93241. /**
  93242. * Mesh side orientation : both internal and external or front and back surfaces
  93243. */
  93244. static readonly DOUBLESIDE: number;
  93245. /**
  93246. * Mesh side orientation : by default, `FRONTSIDE`
  93247. */
  93248. static readonly DEFAULTSIDE: number;
  93249. /**
  93250. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  93251. */
  93252. positions: Nullable<FloatArray>;
  93253. /**
  93254. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  93255. */
  93256. normals: Nullable<FloatArray>;
  93257. /**
  93258. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  93259. */
  93260. tangents: Nullable<FloatArray>;
  93261. /**
  93262. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93263. */
  93264. uvs: Nullable<FloatArray>;
  93265. /**
  93266. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93267. */
  93268. uvs2: Nullable<FloatArray>;
  93269. /**
  93270. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93271. */
  93272. uvs3: Nullable<FloatArray>;
  93273. /**
  93274. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93275. */
  93276. uvs4: Nullable<FloatArray>;
  93277. /**
  93278. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93279. */
  93280. uvs5: Nullable<FloatArray>;
  93281. /**
  93282. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93283. */
  93284. uvs6: Nullable<FloatArray>;
  93285. /**
  93286. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  93287. */
  93288. colors: Nullable<FloatArray>;
  93289. /**
  93290. * 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).
  93291. */
  93292. matricesIndices: Nullable<FloatArray>;
  93293. /**
  93294. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  93295. */
  93296. matricesWeights: Nullable<FloatArray>;
  93297. /**
  93298. * An array extending the number of possible indices
  93299. */
  93300. matricesIndicesExtra: Nullable<FloatArray>;
  93301. /**
  93302. * An array extending the number of possible weights when the number of indices is extended
  93303. */
  93304. matricesWeightsExtra: Nullable<FloatArray>;
  93305. /**
  93306. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  93307. */
  93308. indices: Nullable<IndicesArray>;
  93309. /**
  93310. * Uses the passed data array to set the set the values for the specified kind of data
  93311. * @param data a linear array of floating numbers
  93312. * @param kind the type of data that is being set, eg positions, colors etc
  93313. */
  93314. set(data: FloatArray, kind: string): void;
  93315. /**
  93316. * Associates the vertexData to the passed Mesh.
  93317. * Sets it as updatable or not (default `false`)
  93318. * @param mesh the mesh the vertexData is applied to
  93319. * @param updatable when used and having the value true allows new data to update the vertexData
  93320. * @returns the VertexData
  93321. */
  93322. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  93323. /**
  93324. * Associates the vertexData to the passed Geometry.
  93325. * Sets it as updatable or not (default `false`)
  93326. * @param geometry the geometry the vertexData is applied to
  93327. * @param updatable when used and having the value true allows new data to update the vertexData
  93328. * @returns VertexData
  93329. */
  93330. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  93331. /**
  93332. * Updates the associated mesh
  93333. * @param mesh the mesh to be updated
  93334. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  93335. * @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
  93336. * @returns VertexData
  93337. */
  93338. updateMesh(mesh: Mesh): VertexData;
  93339. /**
  93340. * Updates the associated geometry
  93341. * @param geometry the geometry to be updated
  93342. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  93343. * @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
  93344. * @returns VertexData.
  93345. */
  93346. updateGeometry(geometry: Geometry): VertexData;
  93347. private _applyTo;
  93348. private _update;
  93349. /**
  93350. * Transforms each position and each normal of the vertexData according to the passed Matrix
  93351. * @param matrix the transforming matrix
  93352. * @returns the VertexData
  93353. */
  93354. transform(matrix: Matrix): VertexData;
  93355. /**
  93356. * Merges the passed VertexData into the current one
  93357. * @param other the VertexData to be merged into the current one
  93358. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  93359. * @returns the modified VertexData
  93360. */
  93361. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  93362. private _mergeElement;
  93363. private _validate;
  93364. /**
  93365. * Serializes the VertexData
  93366. * @returns a serialized object
  93367. */
  93368. serialize(): any;
  93369. /**
  93370. * Extracts the vertexData from a mesh
  93371. * @param mesh the mesh from which to extract the VertexData
  93372. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  93373. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  93374. * @returns the object VertexData associated to the passed mesh
  93375. */
  93376. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  93377. /**
  93378. * Extracts the vertexData from the geometry
  93379. * @param geometry the geometry from which to extract the VertexData
  93380. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  93381. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  93382. * @returns the object VertexData associated to the passed mesh
  93383. */
  93384. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  93385. private static _ExtractFrom;
  93386. /**
  93387. * Creates the VertexData for a Ribbon
  93388. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  93389. * * pathArray array of paths, each of which an array of successive Vector3
  93390. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  93391. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  93392. * * 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
  93393. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93394. * * 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)
  93395. * * 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)
  93396. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  93397. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  93398. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  93399. * @returns the VertexData of the ribbon
  93400. */
  93401. static CreateRibbon(options: {
  93402. pathArray: Vector3[][];
  93403. closeArray?: boolean;
  93404. closePath?: boolean;
  93405. offset?: number;
  93406. sideOrientation?: number;
  93407. frontUVs?: Vector4;
  93408. backUVs?: Vector4;
  93409. invertUV?: boolean;
  93410. uvs?: Vector2[];
  93411. colors?: Color4[];
  93412. }): VertexData;
  93413. /**
  93414. * Creates the VertexData for a box
  93415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93416. * * size sets the width, height and depth of the box to the value of size, optional default 1
  93417. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  93418. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  93419. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  93420. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  93421. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  93422. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93423. * * 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)
  93424. * * 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)
  93425. * @returns the VertexData of the box
  93426. */
  93427. static CreateBox(options: {
  93428. size?: number;
  93429. width?: number;
  93430. height?: number;
  93431. depth?: number;
  93432. faceUV?: Vector4[];
  93433. faceColors?: Color4[];
  93434. sideOrientation?: number;
  93435. frontUVs?: Vector4;
  93436. backUVs?: Vector4;
  93437. }): VertexData;
  93438. /**
  93439. * Creates the VertexData for a tiled box
  93440. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93441. * * faceTiles sets the pattern, tile size and number of tiles for a face
  93442. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  93443. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  93444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93445. * @returns the VertexData of the box
  93446. */
  93447. static CreateTiledBox(options: {
  93448. pattern?: number;
  93449. width?: number;
  93450. height?: number;
  93451. depth?: number;
  93452. tileSize?: number;
  93453. tileWidth?: number;
  93454. tileHeight?: number;
  93455. alignHorizontal?: number;
  93456. alignVertical?: number;
  93457. faceUV?: Vector4[];
  93458. faceColors?: Color4[];
  93459. sideOrientation?: number;
  93460. }): VertexData;
  93461. /**
  93462. * Creates the VertexData for a tiled plane
  93463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93464. * * pattern a limited pattern arrangement depending on the number
  93465. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  93466. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  93467. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  93468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93469. * * 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)
  93470. * * 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)
  93471. * @returns the VertexData of the tiled plane
  93472. */
  93473. static CreateTiledPlane(options: {
  93474. pattern?: number;
  93475. tileSize?: number;
  93476. tileWidth?: number;
  93477. tileHeight?: number;
  93478. size?: number;
  93479. width?: number;
  93480. height?: number;
  93481. alignHorizontal?: number;
  93482. alignVertical?: number;
  93483. sideOrientation?: number;
  93484. frontUVs?: Vector4;
  93485. backUVs?: Vector4;
  93486. }): VertexData;
  93487. /**
  93488. * Creates the VertexData for an ellipsoid, defaults to a sphere
  93489. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93490. * * segments sets the number of horizontal strips optional, default 32
  93491. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  93492. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  93493. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  93494. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  93495. * * 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
  93496. * * 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
  93497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93498. * * 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)
  93499. * * 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)
  93500. * @returns the VertexData of the ellipsoid
  93501. */
  93502. static CreateSphere(options: {
  93503. segments?: number;
  93504. diameter?: number;
  93505. diameterX?: number;
  93506. diameterY?: number;
  93507. diameterZ?: number;
  93508. arc?: number;
  93509. slice?: number;
  93510. sideOrientation?: number;
  93511. frontUVs?: Vector4;
  93512. backUVs?: Vector4;
  93513. }): VertexData;
  93514. /**
  93515. * Creates the VertexData for a cylinder, cone or prism
  93516. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93517. * * height sets the height (y direction) of the cylinder, optional, default 2
  93518. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  93519. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  93520. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  93521. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  93522. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  93523. * * 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
  93524. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93525. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93526. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  93527. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  93528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93529. * * 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)
  93530. * * 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)
  93531. * @returns the VertexData of the cylinder, cone or prism
  93532. */
  93533. static CreateCylinder(options: {
  93534. height?: number;
  93535. diameterTop?: number;
  93536. diameterBottom?: number;
  93537. diameter?: number;
  93538. tessellation?: number;
  93539. subdivisions?: number;
  93540. arc?: number;
  93541. faceColors?: Color4[];
  93542. faceUV?: Vector4[];
  93543. hasRings?: boolean;
  93544. enclose?: boolean;
  93545. sideOrientation?: number;
  93546. frontUVs?: Vector4;
  93547. backUVs?: Vector4;
  93548. }): VertexData;
  93549. /**
  93550. * Creates the VertexData for a torus
  93551. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93552. * * diameter the diameter of the torus, optional default 1
  93553. * * thickness the diameter of the tube forming the torus, optional default 0.5
  93554. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  93555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93556. * * 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)
  93557. * * 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)
  93558. * @returns the VertexData of the torus
  93559. */
  93560. static CreateTorus(options: {
  93561. diameter?: number;
  93562. thickness?: number;
  93563. tessellation?: number;
  93564. sideOrientation?: number;
  93565. frontUVs?: Vector4;
  93566. backUVs?: Vector4;
  93567. }): VertexData;
  93568. /**
  93569. * Creates the VertexData of the LineSystem
  93570. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  93571. * - lines an array of lines, each line being an array of successive Vector3
  93572. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  93573. * @returns the VertexData of the LineSystem
  93574. */
  93575. static CreateLineSystem(options: {
  93576. lines: Vector3[][];
  93577. colors?: Nullable<Color4[][]>;
  93578. }): VertexData;
  93579. /**
  93580. * Create the VertexData for a DashedLines
  93581. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  93582. * - points an array successive Vector3
  93583. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  93584. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  93585. * - dashNb the intended total number of dashes, optional, default 200
  93586. * @returns the VertexData for the DashedLines
  93587. */
  93588. static CreateDashedLines(options: {
  93589. points: Vector3[];
  93590. dashSize?: number;
  93591. gapSize?: number;
  93592. dashNb?: number;
  93593. }): VertexData;
  93594. /**
  93595. * Creates the VertexData for a Ground
  93596. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  93597. * - width the width (x direction) of the ground, optional, default 1
  93598. * - height the height (z direction) of the ground, optional, default 1
  93599. * - subdivisions the number of subdivisions per side, optional, default 1
  93600. * @returns the VertexData of the Ground
  93601. */
  93602. static CreateGround(options: {
  93603. width?: number;
  93604. height?: number;
  93605. subdivisions?: number;
  93606. subdivisionsX?: number;
  93607. subdivisionsY?: number;
  93608. }): VertexData;
  93609. /**
  93610. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  93611. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  93612. * * xmin the ground minimum X coordinate, optional, default -1
  93613. * * zmin the ground minimum Z coordinate, optional, default -1
  93614. * * xmax the ground maximum X coordinate, optional, default 1
  93615. * * zmax the ground maximum Z coordinate, optional, default 1
  93616. * * 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}
  93617. * * 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}
  93618. * @returns the VertexData of the TiledGround
  93619. */
  93620. static CreateTiledGround(options: {
  93621. xmin: number;
  93622. zmin: number;
  93623. xmax: number;
  93624. zmax: number;
  93625. subdivisions?: {
  93626. w: number;
  93627. h: number;
  93628. };
  93629. precision?: {
  93630. w: number;
  93631. h: number;
  93632. };
  93633. }): VertexData;
  93634. /**
  93635. * Creates the VertexData of the Ground designed from a heightmap
  93636. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  93637. * * width the width (x direction) of the ground
  93638. * * height the height (z direction) of the ground
  93639. * * subdivisions the number of subdivisions per side
  93640. * * minHeight the minimum altitude on the ground, optional, default 0
  93641. * * maxHeight the maximum altitude on the ground, optional default 1
  93642. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  93643. * * buffer the array holding the image color data
  93644. * * bufferWidth the width of image
  93645. * * bufferHeight the height of image
  93646. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  93647. * @returns the VertexData of the Ground designed from a heightmap
  93648. */
  93649. static CreateGroundFromHeightMap(options: {
  93650. width: number;
  93651. height: number;
  93652. subdivisions: number;
  93653. minHeight: number;
  93654. maxHeight: number;
  93655. colorFilter: Color3;
  93656. buffer: Uint8Array;
  93657. bufferWidth: number;
  93658. bufferHeight: number;
  93659. alphaFilter: number;
  93660. }): VertexData;
  93661. /**
  93662. * Creates the VertexData for a Plane
  93663. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  93664. * * size sets the width and height of the plane to the value of size, optional default 1
  93665. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  93666. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  93667. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93668. * * 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)
  93669. * * 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)
  93670. * @returns the VertexData of the box
  93671. */
  93672. static CreatePlane(options: {
  93673. size?: number;
  93674. width?: number;
  93675. height?: number;
  93676. sideOrientation?: number;
  93677. frontUVs?: Vector4;
  93678. backUVs?: Vector4;
  93679. }): VertexData;
  93680. /**
  93681. * Creates the VertexData of the Disc or regular Polygon
  93682. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  93683. * * radius the radius of the disc, optional default 0.5
  93684. * * tessellation the number of polygon sides, optional, default 64
  93685. * * 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
  93686. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93687. * * 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)
  93688. * * 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)
  93689. * @returns the VertexData of the box
  93690. */
  93691. static CreateDisc(options: {
  93692. radius?: number;
  93693. tessellation?: number;
  93694. arc?: number;
  93695. sideOrientation?: number;
  93696. frontUVs?: Vector4;
  93697. backUVs?: Vector4;
  93698. }): VertexData;
  93699. /**
  93700. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  93701. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  93702. * @param polygon a mesh built from polygonTriangulation.build()
  93703. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93704. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93705. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93706. * @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)
  93707. * @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)
  93708. * @returns the VertexData of the Polygon
  93709. */
  93710. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  93711. /**
  93712. * Creates the VertexData of the IcoSphere
  93713. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  93714. * * radius the radius of the IcoSphere, optional default 1
  93715. * * radiusX allows stretching in the x direction, optional, default radius
  93716. * * radiusY allows stretching in the y direction, optional, default radius
  93717. * * radiusZ allows stretching in the z direction, optional, default radius
  93718. * * flat when true creates a flat shaded mesh, optional, default true
  93719. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93720. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93721. * * 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)
  93722. * * 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)
  93723. * @returns the VertexData of the IcoSphere
  93724. */
  93725. static CreateIcoSphere(options: {
  93726. radius?: number;
  93727. radiusX?: number;
  93728. radiusY?: number;
  93729. radiusZ?: number;
  93730. flat?: boolean;
  93731. subdivisions?: number;
  93732. sideOrientation?: number;
  93733. frontUVs?: Vector4;
  93734. backUVs?: Vector4;
  93735. }): VertexData;
  93736. /**
  93737. * Creates the VertexData for a Polyhedron
  93738. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  93739. * * type provided types are:
  93740. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  93741. * * 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)
  93742. * * size the size of the IcoSphere, optional default 1
  93743. * * sizeX allows stretching in the x direction, optional, default size
  93744. * * sizeY allows stretching in the y direction, optional, default size
  93745. * * sizeZ allows stretching in the z direction, optional, default size
  93746. * * 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
  93747. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93748. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93749. * * flat when true creates a flat shaded mesh, optional, default true
  93750. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93751. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93752. * * 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)
  93753. * * 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)
  93754. * @returns the VertexData of the Polyhedron
  93755. */
  93756. static CreatePolyhedron(options: {
  93757. type?: number;
  93758. size?: number;
  93759. sizeX?: number;
  93760. sizeY?: number;
  93761. sizeZ?: number;
  93762. custom?: any;
  93763. faceUV?: Vector4[];
  93764. faceColors?: Color4[];
  93765. flat?: boolean;
  93766. sideOrientation?: number;
  93767. frontUVs?: Vector4;
  93768. backUVs?: Vector4;
  93769. }): VertexData;
  93770. /**
  93771. * Creates the VertexData for a TorusKnot
  93772. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  93773. * * radius the radius of the torus knot, optional, default 2
  93774. * * tube the thickness of the tube, optional, default 0.5
  93775. * * radialSegments the number of sides on each tube segments, optional, default 32
  93776. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  93777. * * p the number of windings around the z axis, optional, default 2
  93778. * * q the number of windings around the x axis, optional, default 3
  93779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93780. * * 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)
  93781. * * 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)
  93782. * @returns the VertexData of the Torus Knot
  93783. */
  93784. static CreateTorusKnot(options: {
  93785. radius?: number;
  93786. tube?: number;
  93787. radialSegments?: number;
  93788. tubularSegments?: number;
  93789. p?: number;
  93790. q?: number;
  93791. sideOrientation?: number;
  93792. frontUVs?: Vector4;
  93793. backUVs?: Vector4;
  93794. }): VertexData;
  93795. /**
  93796. * Compute normals for given positions and indices
  93797. * @param positions an array of vertex positions, [...., x, y, z, ......]
  93798. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  93799. * @param normals an array of vertex normals, [...., x, y, z, ......]
  93800. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  93801. * * facetNormals : optional array of facet normals (vector3)
  93802. * * facetPositions : optional array of facet positions (vector3)
  93803. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  93804. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  93805. * * bInfo : optional bounding info, required for facetPartitioning computation
  93806. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  93807. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  93808. * * useRightHandedSystem: optional boolean to for right handed system computation
  93809. * * depthSort : optional boolean to enable the facet depth sort computation
  93810. * * distanceTo : optional Vector3 to compute the facet depth from this location
  93811. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  93812. */
  93813. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  93814. facetNormals?: any;
  93815. facetPositions?: any;
  93816. facetPartitioning?: any;
  93817. ratio?: number;
  93818. bInfo?: any;
  93819. bbSize?: Vector3;
  93820. subDiv?: any;
  93821. useRightHandedSystem?: boolean;
  93822. depthSort?: boolean;
  93823. distanceTo?: Vector3;
  93824. depthSortedFacets?: any;
  93825. }): void;
  93826. /** @hidden */
  93827. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  93828. /**
  93829. * Applies VertexData created from the imported parameters to the geometry
  93830. * @param parsedVertexData the parsed data from an imported file
  93831. * @param geometry the geometry to apply the VertexData to
  93832. */
  93833. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  93834. }
  93835. }
  93836. declare module BABYLON {
  93837. /**
  93838. * Defines a target to use with MorphTargetManager
  93839. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93840. */
  93841. export class MorphTarget implements IAnimatable {
  93842. /** defines the name of the target */
  93843. name: string;
  93844. /**
  93845. * Gets or sets the list of animations
  93846. */
  93847. animations: Animation[];
  93848. private _scene;
  93849. private _positions;
  93850. private _normals;
  93851. private _tangents;
  93852. private _uvs;
  93853. private _influence;
  93854. private _uniqueId;
  93855. /**
  93856. * Observable raised when the influence changes
  93857. */
  93858. onInfluenceChanged: Observable<boolean>;
  93859. /** @hidden */
  93860. _onDataLayoutChanged: Observable<void>;
  93861. /**
  93862. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93863. */
  93864. get influence(): number;
  93865. set influence(influence: number);
  93866. /**
  93867. * Gets or sets the id of the morph Target
  93868. */
  93869. id: string;
  93870. private _animationPropertiesOverride;
  93871. /**
  93872. * Gets or sets the animation properties override
  93873. */
  93874. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93875. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93876. /**
  93877. * Creates a new MorphTarget
  93878. * @param name defines the name of the target
  93879. * @param influence defines the influence to use
  93880. * @param scene defines the scene the morphtarget belongs to
  93881. */
  93882. constructor(
  93883. /** defines the name of the target */
  93884. name: string, influence?: number, scene?: Nullable<Scene>);
  93885. /**
  93886. * Gets the unique ID of this manager
  93887. */
  93888. get uniqueId(): number;
  93889. /**
  93890. * Gets a boolean defining if the target contains position data
  93891. */
  93892. get hasPositions(): boolean;
  93893. /**
  93894. * Gets a boolean defining if the target contains normal data
  93895. */
  93896. get hasNormals(): boolean;
  93897. /**
  93898. * Gets a boolean defining if the target contains tangent data
  93899. */
  93900. get hasTangents(): boolean;
  93901. /**
  93902. * Gets a boolean defining if the target contains texture coordinates data
  93903. */
  93904. get hasUVs(): boolean;
  93905. /**
  93906. * Affects position data to this target
  93907. * @param data defines the position data to use
  93908. */
  93909. setPositions(data: Nullable<FloatArray>): void;
  93910. /**
  93911. * Gets the position data stored in this target
  93912. * @returns a FloatArray containing the position data (or null if not present)
  93913. */
  93914. getPositions(): Nullable<FloatArray>;
  93915. /**
  93916. * Affects normal data to this target
  93917. * @param data defines the normal data to use
  93918. */
  93919. setNormals(data: Nullable<FloatArray>): void;
  93920. /**
  93921. * Gets the normal data stored in this target
  93922. * @returns a FloatArray containing the normal data (or null if not present)
  93923. */
  93924. getNormals(): Nullable<FloatArray>;
  93925. /**
  93926. * Affects tangent data to this target
  93927. * @param data defines the tangent data to use
  93928. */
  93929. setTangents(data: Nullable<FloatArray>): void;
  93930. /**
  93931. * Gets the tangent data stored in this target
  93932. * @returns a FloatArray containing the tangent data (or null if not present)
  93933. */
  93934. getTangents(): Nullable<FloatArray>;
  93935. /**
  93936. * Affects texture coordinates data to this target
  93937. * @param data defines the texture coordinates data to use
  93938. */
  93939. setUVs(data: Nullable<FloatArray>): void;
  93940. /**
  93941. * Gets the texture coordinates data stored in this target
  93942. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93943. */
  93944. getUVs(): Nullable<FloatArray>;
  93945. /**
  93946. * Clone the current target
  93947. * @returns a new MorphTarget
  93948. */
  93949. clone(): MorphTarget;
  93950. /**
  93951. * Serializes the current target into a Serialization object
  93952. * @returns the serialized object
  93953. */
  93954. serialize(): any;
  93955. /**
  93956. * Returns the string "MorphTarget"
  93957. * @returns "MorphTarget"
  93958. */
  93959. getClassName(): string;
  93960. /**
  93961. * Creates a new target from serialized data
  93962. * @param serializationObject defines the serialized data to use
  93963. * @returns a new MorphTarget
  93964. */
  93965. static Parse(serializationObject: any): MorphTarget;
  93966. /**
  93967. * Creates a MorphTarget from mesh data
  93968. * @param mesh defines the source mesh
  93969. * @param name defines the name to use for the new target
  93970. * @param influence defines the influence to attach to the target
  93971. * @returns a new MorphTarget
  93972. */
  93973. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93974. }
  93975. }
  93976. declare module BABYLON {
  93977. /**
  93978. * This class is used to deform meshes using morphing between different targets
  93979. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93980. */
  93981. export class MorphTargetManager {
  93982. private _targets;
  93983. private _targetInfluenceChangedObservers;
  93984. private _targetDataLayoutChangedObservers;
  93985. private _activeTargets;
  93986. private _scene;
  93987. private _influences;
  93988. private _supportsNormals;
  93989. private _supportsTangents;
  93990. private _supportsUVs;
  93991. private _vertexCount;
  93992. private _uniqueId;
  93993. private _tempInfluences;
  93994. /**
  93995. * Gets or sets a boolean indicating if normals must be morphed
  93996. */
  93997. enableNormalMorphing: boolean;
  93998. /**
  93999. * Gets or sets a boolean indicating if tangents must be morphed
  94000. */
  94001. enableTangentMorphing: boolean;
  94002. /**
  94003. * Gets or sets a boolean indicating if UV must be morphed
  94004. */
  94005. enableUVMorphing: boolean;
  94006. /**
  94007. * Creates a new MorphTargetManager
  94008. * @param scene defines the current scene
  94009. */
  94010. constructor(scene?: Nullable<Scene>);
  94011. /**
  94012. * Gets the unique ID of this manager
  94013. */
  94014. get uniqueId(): number;
  94015. /**
  94016. * Gets the number of vertices handled by this manager
  94017. */
  94018. get vertexCount(): number;
  94019. /**
  94020. * Gets a boolean indicating if this manager supports morphing of normals
  94021. */
  94022. get supportsNormals(): boolean;
  94023. /**
  94024. * Gets a boolean indicating if this manager supports morphing of tangents
  94025. */
  94026. get supportsTangents(): boolean;
  94027. /**
  94028. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  94029. */
  94030. get supportsUVs(): boolean;
  94031. /**
  94032. * Gets the number of targets stored in this manager
  94033. */
  94034. get numTargets(): number;
  94035. /**
  94036. * Gets the number of influencers (ie. the number of targets with influences > 0)
  94037. */
  94038. get numInfluencers(): number;
  94039. /**
  94040. * Gets the list of influences (one per target)
  94041. */
  94042. get influences(): Float32Array;
  94043. /**
  94044. * Gets the active target at specified index. An active target is a target with an influence > 0
  94045. * @param index defines the index to check
  94046. * @returns the requested target
  94047. */
  94048. getActiveTarget(index: number): MorphTarget;
  94049. /**
  94050. * Gets the target at specified index
  94051. * @param index defines the index to check
  94052. * @returns the requested target
  94053. */
  94054. getTarget(index: number): MorphTarget;
  94055. /**
  94056. * Add a new target to this manager
  94057. * @param target defines the target to add
  94058. */
  94059. addTarget(target: MorphTarget): void;
  94060. /**
  94061. * Removes a target from the manager
  94062. * @param target defines the target to remove
  94063. */
  94064. removeTarget(target: MorphTarget): void;
  94065. /**
  94066. * Clone the current manager
  94067. * @returns a new MorphTargetManager
  94068. */
  94069. clone(): MorphTargetManager;
  94070. /**
  94071. * Serializes the current manager into a Serialization object
  94072. * @returns the serialized object
  94073. */
  94074. serialize(): any;
  94075. private _syncActiveTargets;
  94076. /**
  94077. * Syncrhonize the targets with all the meshes using this morph target manager
  94078. */
  94079. synchronize(): void;
  94080. /**
  94081. * Creates a new MorphTargetManager from serialized data
  94082. * @param serializationObject defines the serialized data
  94083. * @param scene defines the hosting scene
  94084. * @returns the new MorphTargetManager
  94085. */
  94086. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  94087. }
  94088. }
  94089. declare module BABYLON {
  94090. /**
  94091. * Class used to represent a specific level of detail of a mesh
  94092. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94093. */
  94094. export class MeshLODLevel {
  94095. /** Defines the distance where this level should start being displayed */
  94096. distance: number;
  94097. /** Defines the mesh to use to render this level */
  94098. mesh: Nullable<Mesh>;
  94099. /**
  94100. * Creates a new LOD level
  94101. * @param distance defines the distance where this level should star being displayed
  94102. * @param mesh defines the mesh to use to render this level
  94103. */
  94104. constructor(
  94105. /** Defines the distance where this level should start being displayed */
  94106. distance: number,
  94107. /** Defines the mesh to use to render this level */
  94108. mesh: Nullable<Mesh>);
  94109. }
  94110. }
  94111. declare module BABYLON {
  94112. /**
  94113. * Mesh representing the gorund
  94114. */
  94115. export class GroundMesh extends Mesh {
  94116. /** If octree should be generated */
  94117. generateOctree: boolean;
  94118. private _heightQuads;
  94119. /** @hidden */
  94120. _subdivisionsX: number;
  94121. /** @hidden */
  94122. _subdivisionsY: number;
  94123. /** @hidden */
  94124. _width: number;
  94125. /** @hidden */
  94126. _height: number;
  94127. /** @hidden */
  94128. _minX: number;
  94129. /** @hidden */
  94130. _maxX: number;
  94131. /** @hidden */
  94132. _minZ: number;
  94133. /** @hidden */
  94134. _maxZ: number;
  94135. constructor(name: string, scene: Scene);
  94136. /**
  94137. * "GroundMesh"
  94138. * @returns "GroundMesh"
  94139. */
  94140. getClassName(): string;
  94141. /**
  94142. * The minimum of x and y subdivisions
  94143. */
  94144. get subdivisions(): number;
  94145. /**
  94146. * X subdivisions
  94147. */
  94148. get subdivisionsX(): number;
  94149. /**
  94150. * Y subdivisions
  94151. */
  94152. get subdivisionsY(): number;
  94153. /**
  94154. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  94155. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  94156. * @param chunksCount the number of subdivisions for x and y
  94157. * @param octreeBlocksSize (Default: 32)
  94158. */
  94159. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  94160. /**
  94161. * Returns a height (y) value in the Worl system :
  94162. * the ground altitude at the coordinates (x, z) expressed in the World system.
  94163. * @param x x coordinate
  94164. * @param z z coordinate
  94165. * @returns the ground y position if (x, z) are outside the ground surface.
  94166. */
  94167. getHeightAtCoordinates(x: number, z: number): number;
  94168. /**
  94169. * Returns a normalized vector (Vector3) orthogonal to the ground
  94170. * at the ground coordinates (x, z) expressed in the World system.
  94171. * @param x x coordinate
  94172. * @param z z coordinate
  94173. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  94174. */
  94175. getNormalAtCoordinates(x: number, z: number): Vector3;
  94176. /**
  94177. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  94178. * at the ground coordinates (x, z) expressed in the World system.
  94179. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  94180. * @param x x coordinate
  94181. * @param z z coordinate
  94182. * @param ref vector to store the result
  94183. * @returns the GroundMesh.
  94184. */
  94185. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  94186. /**
  94187. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  94188. * if the ground has been updated.
  94189. * This can be used in the render loop.
  94190. * @returns the GroundMesh.
  94191. */
  94192. updateCoordinateHeights(): GroundMesh;
  94193. private _getFacetAt;
  94194. private _initHeightQuads;
  94195. private _computeHeightQuads;
  94196. /**
  94197. * Serializes this ground mesh
  94198. * @param serializationObject object to write serialization to
  94199. */
  94200. serialize(serializationObject: any): void;
  94201. /**
  94202. * Parses a serialized ground mesh
  94203. * @param parsedMesh the serialized mesh
  94204. * @param scene the scene to create the ground mesh in
  94205. * @returns the created ground mesh
  94206. */
  94207. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  94208. }
  94209. }
  94210. declare module BABYLON {
  94211. /**
  94212. * Interface for Physics-Joint data
  94213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94214. */
  94215. export interface PhysicsJointData {
  94216. /**
  94217. * The main pivot of the joint
  94218. */
  94219. mainPivot?: Vector3;
  94220. /**
  94221. * The connected pivot of the joint
  94222. */
  94223. connectedPivot?: Vector3;
  94224. /**
  94225. * The main axis of the joint
  94226. */
  94227. mainAxis?: Vector3;
  94228. /**
  94229. * The connected axis of the joint
  94230. */
  94231. connectedAxis?: Vector3;
  94232. /**
  94233. * The collision of the joint
  94234. */
  94235. collision?: boolean;
  94236. /**
  94237. * Native Oimo/Cannon/Energy data
  94238. */
  94239. nativeParams?: any;
  94240. }
  94241. /**
  94242. * This is a holder class for the physics joint created by the physics plugin
  94243. * It holds a set of functions to control the underlying joint
  94244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94245. */
  94246. export class PhysicsJoint {
  94247. /**
  94248. * The type of the physics joint
  94249. */
  94250. type: number;
  94251. /**
  94252. * The data for the physics joint
  94253. */
  94254. jointData: PhysicsJointData;
  94255. private _physicsJoint;
  94256. protected _physicsPlugin: IPhysicsEnginePlugin;
  94257. /**
  94258. * Initializes the physics joint
  94259. * @param type The type of the physics joint
  94260. * @param jointData The data for the physics joint
  94261. */
  94262. constructor(
  94263. /**
  94264. * The type of the physics joint
  94265. */
  94266. type: number,
  94267. /**
  94268. * The data for the physics joint
  94269. */
  94270. jointData: PhysicsJointData);
  94271. /**
  94272. * Gets the physics joint
  94273. */
  94274. get physicsJoint(): any;
  94275. /**
  94276. * Sets the physics joint
  94277. */
  94278. set physicsJoint(newJoint: any);
  94279. /**
  94280. * Sets the physics plugin
  94281. */
  94282. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  94283. /**
  94284. * Execute a function that is physics-plugin specific.
  94285. * @param {Function} func the function that will be executed.
  94286. * It accepts two parameters: the physics world and the physics joint
  94287. */
  94288. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  94289. /**
  94290. * Distance-Joint type
  94291. */
  94292. static DistanceJoint: number;
  94293. /**
  94294. * Hinge-Joint type
  94295. */
  94296. static HingeJoint: number;
  94297. /**
  94298. * Ball-and-Socket joint type
  94299. */
  94300. static BallAndSocketJoint: number;
  94301. /**
  94302. * Wheel-Joint type
  94303. */
  94304. static WheelJoint: number;
  94305. /**
  94306. * Slider-Joint type
  94307. */
  94308. static SliderJoint: number;
  94309. /**
  94310. * Prismatic-Joint type
  94311. */
  94312. static PrismaticJoint: number;
  94313. /**
  94314. * Universal-Joint type
  94315. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  94316. */
  94317. static UniversalJoint: number;
  94318. /**
  94319. * Hinge-Joint 2 type
  94320. */
  94321. static Hinge2Joint: number;
  94322. /**
  94323. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  94324. */
  94325. static PointToPointJoint: number;
  94326. /**
  94327. * Spring-Joint type
  94328. */
  94329. static SpringJoint: number;
  94330. /**
  94331. * Lock-Joint type
  94332. */
  94333. static LockJoint: number;
  94334. }
  94335. /**
  94336. * A class representing a physics distance joint
  94337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94338. */
  94339. export class DistanceJoint extends PhysicsJoint {
  94340. /**
  94341. *
  94342. * @param jointData The data for the Distance-Joint
  94343. */
  94344. constructor(jointData: DistanceJointData);
  94345. /**
  94346. * Update the predefined distance.
  94347. * @param maxDistance The maximum preferred distance
  94348. * @param minDistance The minimum preferred distance
  94349. */
  94350. updateDistance(maxDistance: number, minDistance?: number): void;
  94351. }
  94352. /**
  94353. * Represents a Motor-Enabled Joint
  94354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94355. */
  94356. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  94357. /**
  94358. * Initializes the Motor-Enabled Joint
  94359. * @param type The type of the joint
  94360. * @param jointData The physica joint data for the joint
  94361. */
  94362. constructor(type: number, jointData: PhysicsJointData);
  94363. /**
  94364. * Set the motor values.
  94365. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94366. * @param force the force to apply
  94367. * @param maxForce max force for this motor.
  94368. */
  94369. setMotor(force?: number, maxForce?: number): void;
  94370. /**
  94371. * Set the motor's limits.
  94372. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94373. * @param upperLimit The upper limit of the motor
  94374. * @param lowerLimit The lower limit of the motor
  94375. */
  94376. setLimit(upperLimit: number, lowerLimit?: number): void;
  94377. }
  94378. /**
  94379. * This class represents a single physics Hinge-Joint
  94380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94381. */
  94382. export class HingeJoint extends MotorEnabledJoint {
  94383. /**
  94384. * Initializes the Hinge-Joint
  94385. * @param jointData The joint data for the Hinge-Joint
  94386. */
  94387. constructor(jointData: PhysicsJointData);
  94388. /**
  94389. * Set the motor values.
  94390. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94391. * @param {number} force the force to apply
  94392. * @param {number} maxForce max force for this motor.
  94393. */
  94394. setMotor(force?: number, maxForce?: number): void;
  94395. /**
  94396. * Set the motor's limits.
  94397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94398. * @param upperLimit The upper limit of the motor
  94399. * @param lowerLimit The lower limit of the motor
  94400. */
  94401. setLimit(upperLimit: number, lowerLimit?: number): void;
  94402. }
  94403. /**
  94404. * This class represents a dual hinge physics joint (same as wheel joint)
  94405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94406. */
  94407. export class Hinge2Joint extends MotorEnabledJoint {
  94408. /**
  94409. * Initializes the Hinge2-Joint
  94410. * @param jointData The joint data for the Hinge2-Joint
  94411. */
  94412. constructor(jointData: PhysicsJointData);
  94413. /**
  94414. * Set the motor values.
  94415. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94416. * @param {number} targetSpeed the speed the motor is to reach
  94417. * @param {number} maxForce max force for this motor.
  94418. * @param {motorIndex} the motor's index, 0 or 1.
  94419. */
  94420. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  94421. /**
  94422. * Set the motor limits.
  94423. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94424. * @param {number} upperLimit the upper limit
  94425. * @param {number} lowerLimit lower limit
  94426. * @param {motorIndex} the motor's index, 0 or 1.
  94427. */
  94428. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  94429. }
  94430. /**
  94431. * Interface for a motor enabled joint
  94432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94433. */
  94434. export interface IMotorEnabledJoint {
  94435. /**
  94436. * Physics joint
  94437. */
  94438. physicsJoint: any;
  94439. /**
  94440. * Sets the motor of the motor-enabled joint
  94441. * @param force The force of the motor
  94442. * @param maxForce The maximum force of the motor
  94443. * @param motorIndex The index of the motor
  94444. */
  94445. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  94446. /**
  94447. * Sets the limit of the motor
  94448. * @param upperLimit The upper limit of the motor
  94449. * @param lowerLimit The lower limit of the motor
  94450. * @param motorIndex The index of the motor
  94451. */
  94452. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  94453. }
  94454. /**
  94455. * Joint data for a Distance-Joint
  94456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94457. */
  94458. export interface DistanceJointData extends PhysicsJointData {
  94459. /**
  94460. * Max distance the 2 joint objects can be apart
  94461. */
  94462. maxDistance: number;
  94463. }
  94464. /**
  94465. * Joint data from a spring joint
  94466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94467. */
  94468. export interface SpringJointData extends PhysicsJointData {
  94469. /**
  94470. * Length of the spring
  94471. */
  94472. length: number;
  94473. /**
  94474. * Stiffness of the spring
  94475. */
  94476. stiffness: number;
  94477. /**
  94478. * Damping of the spring
  94479. */
  94480. damping: number;
  94481. /** this callback will be called when applying the force to the impostors. */
  94482. forceApplicationCallback: () => void;
  94483. }
  94484. }
  94485. declare module BABYLON {
  94486. /**
  94487. * Holds the data for the raycast result
  94488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94489. */
  94490. export class PhysicsRaycastResult {
  94491. private _hasHit;
  94492. private _hitDistance;
  94493. private _hitNormalWorld;
  94494. private _hitPointWorld;
  94495. private _rayFromWorld;
  94496. private _rayToWorld;
  94497. /**
  94498. * Gets if there was a hit
  94499. */
  94500. get hasHit(): boolean;
  94501. /**
  94502. * Gets the distance from the hit
  94503. */
  94504. get hitDistance(): number;
  94505. /**
  94506. * Gets the hit normal/direction in the world
  94507. */
  94508. get hitNormalWorld(): Vector3;
  94509. /**
  94510. * Gets the hit point in the world
  94511. */
  94512. get hitPointWorld(): Vector3;
  94513. /**
  94514. * Gets the ray "start point" of the ray in the world
  94515. */
  94516. get rayFromWorld(): Vector3;
  94517. /**
  94518. * Gets the ray "end point" of the ray in the world
  94519. */
  94520. get rayToWorld(): Vector3;
  94521. /**
  94522. * Sets the hit data (normal & point in world space)
  94523. * @param hitNormalWorld defines the normal in world space
  94524. * @param hitPointWorld defines the point in world space
  94525. */
  94526. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  94527. /**
  94528. * Sets the distance from the start point to the hit point
  94529. * @param distance
  94530. */
  94531. setHitDistance(distance: number): void;
  94532. /**
  94533. * Calculates the distance manually
  94534. */
  94535. calculateHitDistance(): void;
  94536. /**
  94537. * Resets all the values to default
  94538. * @param from The from point on world space
  94539. * @param to The to point on world space
  94540. */
  94541. reset(from?: Vector3, to?: Vector3): void;
  94542. }
  94543. /**
  94544. * Interface for the size containing width and height
  94545. */
  94546. interface IXYZ {
  94547. /**
  94548. * X
  94549. */
  94550. x: number;
  94551. /**
  94552. * Y
  94553. */
  94554. y: number;
  94555. /**
  94556. * Z
  94557. */
  94558. z: number;
  94559. }
  94560. }
  94561. declare module BABYLON {
  94562. /**
  94563. * Interface used to describe a physics joint
  94564. */
  94565. export interface PhysicsImpostorJoint {
  94566. /** Defines the main impostor to which the joint is linked */
  94567. mainImpostor: PhysicsImpostor;
  94568. /** Defines the impostor that is connected to the main impostor using this joint */
  94569. connectedImpostor: PhysicsImpostor;
  94570. /** Defines the joint itself */
  94571. joint: PhysicsJoint;
  94572. }
  94573. /** @hidden */
  94574. export interface IPhysicsEnginePlugin {
  94575. world: any;
  94576. name: string;
  94577. setGravity(gravity: Vector3): void;
  94578. setTimeStep(timeStep: number): void;
  94579. getTimeStep(): number;
  94580. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  94581. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  94582. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  94583. generatePhysicsBody(impostor: PhysicsImpostor): void;
  94584. removePhysicsBody(impostor: PhysicsImpostor): void;
  94585. generateJoint(joint: PhysicsImpostorJoint): void;
  94586. removeJoint(joint: PhysicsImpostorJoint): void;
  94587. isSupported(): boolean;
  94588. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  94589. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  94590. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  94591. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  94592. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  94593. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  94594. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  94595. getBodyMass(impostor: PhysicsImpostor): number;
  94596. getBodyFriction(impostor: PhysicsImpostor): number;
  94597. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  94598. getBodyRestitution(impostor: PhysicsImpostor): number;
  94599. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  94600. getBodyPressure?(impostor: PhysicsImpostor): number;
  94601. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  94602. getBodyStiffness?(impostor: PhysicsImpostor): number;
  94603. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  94604. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  94605. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  94606. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  94607. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  94608. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  94609. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  94610. sleepBody(impostor: PhysicsImpostor): void;
  94611. wakeUpBody(impostor: PhysicsImpostor): void;
  94612. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  94613. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  94614. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  94615. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  94616. getRadius(impostor: PhysicsImpostor): number;
  94617. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  94618. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  94619. dispose(): void;
  94620. }
  94621. /**
  94622. * Interface used to define a physics engine
  94623. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  94624. */
  94625. export interface IPhysicsEngine {
  94626. /**
  94627. * Gets the gravity vector used by the simulation
  94628. */
  94629. gravity: Vector3;
  94630. /**
  94631. * Sets the gravity vector used by the simulation
  94632. * @param gravity defines the gravity vector to use
  94633. */
  94634. setGravity(gravity: Vector3): void;
  94635. /**
  94636. * Set the time step of the physics engine.
  94637. * Default is 1/60.
  94638. * To slow it down, enter 1/600 for example.
  94639. * To speed it up, 1/30
  94640. * @param newTimeStep the new timestep to apply to this world.
  94641. */
  94642. setTimeStep(newTimeStep: number): void;
  94643. /**
  94644. * Get the time step of the physics engine.
  94645. * @returns the current time step
  94646. */
  94647. getTimeStep(): number;
  94648. /**
  94649. * Set the sub time step of the physics engine.
  94650. * Default is 0 meaning there is no sub steps
  94651. * To increase physics resolution precision, set a small value (like 1 ms)
  94652. * @param subTimeStep defines the new sub timestep used for physics resolution.
  94653. */
  94654. setSubTimeStep(subTimeStep: number): void;
  94655. /**
  94656. * Get the sub time step of the physics engine.
  94657. * @returns the current sub time step
  94658. */
  94659. getSubTimeStep(): number;
  94660. /**
  94661. * Release all resources
  94662. */
  94663. dispose(): void;
  94664. /**
  94665. * Gets the name of the current physics plugin
  94666. * @returns the name of the plugin
  94667. */
  94668. getPhysicsPluginName(): string;
  94669. /**
  94670. * Adding a new impostor for the impostor tracking.
  94671. * This will be done by the impostor itself.
  94672. * @param impostor the impostor to add
  94673. */
  94674. addImpostor(impostor: PhysicsImpostor): void;
  94675. /**
  94676. * Remove an impostor from the engine.
  94677. * This impostor and its mesh will not longer be updated by the physics engine.
  94678. * @param impostor the impostor to remove
  94679. */
  94680. removeImpostor(impostor: PhysicsImpostor): void;
  94681. /**
  94682. * Add a joint to the physics engine
  94683. * @param mainImpostor defines the main impostor to which the joint is added.
  94684. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  94685. * @param joint defines the joint that will connect both impostors.
  94686. */
  94687. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  94688. /**
  94689. * Removes a joint from the simulation
  94690. * @param mainImpostor defines the impostor used with the joint
  94691. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  94692. * @param joint defines the joint to remove
  94693. */
  94694. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  94695. /**
  94696. * Gets the current plugin used to run the simulation
  94697. * @returns current plugin
  94698. */
  94699. getPhysicsPlugin(): IPhysicsEnginePlugin;
  94700. /**
  94701. * Gets the list of physic impostors
  94702. * @returns an array of PhysicsImpostor
  94703. */
  94704. getImpostors(): Array<PhysicsImpostor>;
  94705. /**
  94706. * Gets the impostor for a physics enabled object
  94707. * @param object defines the object impersonated by the impostor
  94708. * @returns the PhysicsImpostor or null if not found
  94709. */
  94710. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94711. /**
  94712. * Gets the impostor for a physics body object
  94713. * @param body defines physics body used by the impostor
  94714. * @returns the PhysicsImpostor or null if not found
  94715. */
  94716. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  94717. /**
  94718. * Does a raycast in the physics world
  94719. * @param from when should the ray start?
  94720. * @param to when should the ray end?
  94721. * @returns PhysicsRaycastResult
  94722. */
  94723. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  94724. /**
  94725. * Called by the scene. No need to call it.
  94726. * @param delta defines the timespam between frames
  94727. */
  94728. _step(delta: number): void;
  94729. }
  94730. }
  94731. declare module BABYLON {
  94732. /**
  94733. * The interface for the physics imposter parameters
  94734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94735. */
  94736. export interface PhysicsImpostorParameters {
  94737. /**
  94738. * The mass of the physics imposter
  94739. */
  94740. mass: number;
  94741. /**
  94742. * The friction of the physics imposter
  94743. */
  94744. friction?: number;
  94745. /**
  94746. * The coefficient of restitution of the physics imposter
  94747. */
  94748. restitution?: number;
  94749. /**
  94750. * The native options of the physics imposter
  94751. */
  94752. nativeOptions?: any;
  94753. /**
  94754. * Specifies if the parent should be ignored
  94755. */
  94756. ignoreParent?: boolean;
  94757. /**
  94758. * Specifies if bi-directional transformations should be disabled
  94759. */
  94760. disableBidirectionalTransformation?: boolean;
  94761. /**
  94762. * The pressure inside the physics imposter, soft object only
  94763. */
  94764. pressure?: number;
  94765. /**
  94766. * The stiffness the physics imposter, soft object only
  94767. */
  94768. stiffness?: number;
  94769. /**
  94770. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  94771. */
  94772. velocityIterations?: number;
  94773. /**
  94774. * The number of iterations used in maintaining consistent vertex positions, soft object only
  94775. */
  94776. positionIterations?: number;
  94777. /**
  94778. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  94779. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  94780. * Add to fix multiple points
  94781. */
  94782. fixedPoints?: number;
  94783. /**
  94784. * The collision margin around a soft object
  94785. */
  94786. margin?: number;
  94787. /**
  94788. * The collision margin around a soft object
  94789. */
  94790. damping?: number;
  94791. /**
  94792. * The path for a rope based on an extrusion
  94793. */
  94794. path?: any;
  94795. /**
  94796. * The shape of an extrusion used for a rope based on an extrusion
  94797. */
  94798. shape?: any;
  94799. }
  94800. /**
  94801. * Interface for a physics-enabled object
  94802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94803. */
  94804. export interface IPhysicsEnabledObject {
  94805. /**
  94806. * The position of the physics-enabled object
  94807. */
  94808. position: Vector3;
  94809. /**
  94810. * The rotation of the physics-enabled object
  94811. */
  94812. rotationQuaternion: Nullable<Quaternion>;
  94813. /**
  94814. * The scale of the physics-enabled object
  94815. */
  94816. scaling: Vector3;
  94817. /**
  94818. * The rotation of the physics-enabled object
  94819. */
  94820. rotation?: Vector3;
  94821. /**
  94822. * The parent of the physics-enabled object
  94823. */
  94824. parent?: any;
  94825. /**
  94826. * The bounding info of the physics-enabled object
  94827. * @returns The bounding info of the physics-enabled object
  94828. */
  94829. getBoundingInfo(): BoundingInfo;
  94830. /**
  94831. * Computes the world matrix
  94832. * @param force Specifies if the world matrix should be computed by force
  94833. * @returns A world matrix
  94834. */
  94835. computeWorldMatrix(force: boolean): Matrix;
  94836. /**
  94837. * Gets the world matrix
  94838. * @returns A world matrix
  94839. */
  94840. getWorldMatrix?(): Matrix;
  94841. /**
  94842. * Gets the child meshes
  94843. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94844. * @returns An array of abstract meshes
  94845. */
  94846. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94847. /**
  94848. * Gets the vertex data
  94849. * @param kind The type of vertex data
  94850. * @returns A nullable array of numbers, or a float32 array
  94851. */
  94852. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94853. /**
  94854. * Gets the indices from the mesh
  94855. * @returns A nullable array of index arrays
  94856. */
  94857. getIndices?(): Nullable<IndicesArray>;
  94858. /**
  94859. * Gets the scene from the mesh
  94860. * @returns the indices array or null
  94861. */
  94862. getScene?(): Scene;
  94863. /**
  94864. * Gets the absolute position from the mesh
  94865. * @returns the absolute position
  94866. */
  94867. getAbsolutePosition(): Vector3;
  94868. /**
  94869. * Gets the absolute pivot point from the mesh
  94870. * @returns the absolute pivot point
  94871. */
  94872. getAbsolutePivotPoint(): Vector3;
  94873. /**
  94874. * Rotates the mesh
  94875. * @param axis The axis of rotation
  94876. * @param amount The amount of rotation
  94877. * @param space The space of the rotation
  94878. * @returns The rotation transform node
  94879. */
  94880. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94881. /**
  94882. * Translates the mesh
  94883. * @param axis The axis of translation
  94884. * @param distance The distance of translation
  94885. * @param space The space of the translation
  94886. * @returns The transform node
  94887. */
  94888. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94889. /**
  94890. * Sets the absolute position of the mesh
  94891. * @param absolutePosition The absolute position of the mesh
  94892. * @returns The transform node
  94893. */
  94894. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94895. /**
  94896. * Gets the class name of the mesh
  94897. * @returns The class name
  94898. */
  94899. getClassName(): string;
  94900. }
  94901. /**
  94902. * Represents a physics imposter
  94903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94904. */
  94905. export class PhysicsImpostor {
  94906. /**
  94907. * The physics-enabled object used as the physics imposter
  94908. */
  94909. object: IPhysicsEnabledObject;
  94910. /**
  94911. * The type of the physics imposter
  94912. */
  94913. type: number;
  94914. private _options;
  94915. private _scene?;
  94916. /**
  94917. * The default object size of the imposter
  94918. */
  94919. static DEFAULT_OBJECT_SIZE: Vector3;
  94920. /**
  94921. * The identity quaternion of the imposter
  94922. */
  94923. static IDENTITY_QUATERNION: Quaternion;
  94924. /** @hidden */
  94925. _pluginData: any;
  94926. private _physicsEngine;
  94927. private _physicsBody;
  94928. private _bodyUpdateRequired;
  94929. private _onBeforePhysicsStepCallbacks;
  94930. private _onAfterPhysicsStepCallbacks;
  94931. /** @hidden */
  94932. _onPhysicsCollideCallbacks: Array<{
  94933. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94934. otherImpostors: Array<PhysicsImpostor>;
  94935. }>;
  94936. private _deltaPosition;
  94937. private _deltaRotation;
  94938. private _deltaRotationConjugated;
  94939. /** @hidden */
  94940. _isFromLine: boolean;
  94941. private _parent;
  94942. private _isDisposed;
  94943. private static _tmpVecs;
  94944. private static _tmpQuat;
  94945. /**
  94946. * Specifies if the physics imposter is disposed
  94947. */
  94948. get isDisposed(): boolean;
  94949. /**
  94950. * Gets the mass of the physics imposter
  94951. */
  94952. get mass(): number;
  94953. set mass(value: number);
  94954. /**
  94955. * Gets the coefficient of friction
  94956. */
  94957. get friction(): number;
  94958. /**
  94959. * Sets the coefficient of friction
  94960. */
  94961. set friction(value: number);
  94962. /**
  94963. * Gets the coefficient of restitution
  94964. */
  94965. get restitution(): number;
  94966. /**
  94967. * Sets the coefficient of restitution
  94968. */
  94969. set restitution(value: number);
  94970. /**
  94971. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94972. */
  94973. get pressure(): number;
  94974. /**
  94975. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94976. */
  94977. set pressure(value: number);
  94978. /**
  94979. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94980. */
  94981. get stiffness(): number;
  94982. /**
  94983. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94984. */
  94985. set stiffness(value: number);
  94986. /**
  94987. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94988. */
  94989. get velocityIterations(): number;
  94990. /**
  94991. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94992. */
  94993. set velocityIterations(value: number);
  94994. /**
  94995. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94996. */
  94997. get positionIterations(): number;
  94998. /**
  94999. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  95000. */
  95001. set positionIterations(value: number);
  95002. /**
  95003. * The unique id of the physics imposter
  95004. * set by the physics engine when adding this impostor to the array
  95005. */
  95006. uniqueId: number;
  95007. /**
  95008. * @hidden
  95009. */
  95010. soft: boolean;
  95011. /**
  95012. * @hidden
  95013. */
  95014. segments: number;
  95015. private _joints;
  95016. /**
  95017. * Initializes the physics imposter
  95018. * @param object The physics-enabled object used as the physics imposter
  95019. * @param type The type of the physics imposter
  95020. * @param _options The options for the physics imposter
  95021. * @param _scene The Babylon scene
  95022. */
  95023. constructor(
  95024. /**
  95025. * The physics-enabled object used as the physics imposter
  95026. */
  95027. object: IPhysicsEnabledObject,
  95028. /**
  95029. * The type of the physics imposter
  95030. */
  95031. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  95032. /**
  95033. * This function will completly initialize this impostor.
  95034. * It will create a new body - but only if this mesh has no parent.
  95035. * If it has, this impostor will not be used other than to define the impostor
  95036. * of the child mesh.
  95037. * @hidden
  95038. */
  95039. _init(): void;
  95040. private _getPhysicsParent;
  95041. /**
  95042. * Should a new body be generated.
  95043. * @returns boolean specifying if body initialization is required
  95044. */
  95045. isBodyInitRequired(): boolean;
  95046. /**
  95047. * Sets the updated scaling
  95048. * @param updated Specifies if the scaling is updated
  95049. */
  95050. setScalingUpdated(): void;
  95051. /**
  95052. * Force a regeneration of this or the parent's impostor's body.
  95053. * Use under cautious - This will remove all joints already implemented.
  95054. */
  95055. forceUpdate(): void;
  95056. /**
  95057. * Gets the body that holds this impostor. Either its own, or its parent.
  95058. */
  95059. get physicsBody(): any;
  95060. /**
  95061. * Get the parent of the physics imposter
  95062. * @returns Physics imposter or null
  95063. */
  95064. get parent(): Nullable<PhysicsImpostor>;
  95065. /**
  95066. * Sets the parent of the physics imposter
  95067. */
  95068. set parent(value: Nullable<PhysicsImpostor>);
  95069. /**
  95070. * Set the physics body. Used mainly by the physics engine/plugin
  95071. */
  95072. set physicsBody(physicsBody: any);
  95073. /**
  95074. * Resets the update flags
  95075. */
  95076. resetUpdateFlags(): void;
  95077. /**
  95078. * Gets the object extend size
  95079. * @returns the object extend size
  95080. */
  95081. getObjectExtendSize(): Vector3;
  95082. /**
  95083. * Gets the object center
  95084. * @returns The object center
  95085. */
  95086. getObjectCenter(): Vector3;
  95087. /**
  95088. * Get a specific parametes from the options parameter
  95089. * @param paramName The object parameter name
  95090. * @returns The object parameter
  95091. */
  95092. getParam(paramName: string): any;
  95093. /**
  95094. * Sets a specific parameter in the options given to the physics plugin
  95095. * @param paramName The parameter name
  95096. * @param value The value of the parameter
  95097. */
  95098. setParam(paramName: string, value: number): void;
  95099. /**
  95100. * Specifically change the body's mass option. Won't recreate the physics body object
  95101. * @param mass The mass of the physics imposter
  95102. */
  95103. setMass(mass: number): void;
  95104. /**
  95105. * Gets the linear velocity
  95106. * @returns linear velocity or null
  95107. */
  95108. getLinearVelocity(): Nullable<Vector3>;
  95109. /**
  95110. * Sets the linear velocity
  95111. * @param velocity linear velocity or null
  95112. */
  95113. setLinearVelocity(velocity: Nullable<Vector3>): void;
  95114. /**
  95115. * Gets the angular velocity
  95116. * @returns angular velocity or null
  95117. */
  95118. getAngularVelocity(): Nullable<Vector3>;
  95119. /**
  95120. * Sets the angular velocity
  95121. * @param velocity The velocity or null
  95122. */
  95123. setAngularVelocity(velocity: Nullable<Vector3>): void;
  95124. /**
  95125. * Execute a function with the physics plugin native code
  95126. * Provide a function the will have two variables - the world object and the physics body object
  95127. * @param func The function to execute with the physics plugin native code
  95128. */
  95129. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  95130. /**
  95131. * Register a function that will be executed before the physics world is stepping forward
  95132. * @param func The function to execute before the physics world is stepped forward
  95133. */
  95134. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95135. /**
  95136. * Unregister a function that will be executed before the physics world is stepping forward
  95137. * @param func The function to execute before the physics world is stepped forward
  95138. */
  95139. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95140. /**
  95141. * Register a function that will be executed after the physics step
  95142. * @param func The function to execute after physics step
  95143. */
  95144. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95145. /**
  95146. * Unregisters a function that will be executed after the physics step
  95147. * @param func The function to execute after physics step
  95148. */
  95149. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95150. /**
  95151. * register a function that will be executed when this impostor collides against a different body
  95152. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  95153. * @param func Callback that is executed on collision
  95154. */
  95155. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  95156. /**
  95157. * Unregisters the physics imposter on contact
  95158. * @param collideAgainst The physics object to collide against
  95159. * @param func Callback to execute on collision
  95160. */
  95161. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  95162. private _tmpQuat;
  95163. private _tmpQuat2;
  95164. /**
  95165. * Get the parent rotation
  95166. * @returns The parent rotation
  95167. */
  95168. getParentsRotation(): Quaternion;
  95169. /**
  95170. * this function is executed by the physics engine.
  95171. */
  95172. beforeStep: () => void;
  95173. /**
  95174. * this function is executed by the physics engine
  95175. */
  95176. afterStep: () => void;
  95177. /**
  95178. * Legacy collision detection event support
  95179. */
  95180. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  95181. /**
  95182. * event and body object due to cannon's event-based architecture.
  95183. */
  95184. onCollide: (e: {
  95185. body: any;
  95186. }) => void;
  95187. /**
  95188. * Apply a force
  95189. * @param force The force to apply
  95190. * @param contactPoint The contact point for the force
  95191. * @returns The physics imposter
  95192. */
  95193. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  95194. /**
  95195. * Apply an impulse
  95196. * @param force The impulse force
  95197. * @param contactPoint The contact point for the impulse force
  95198. * @returns The physics imposter
  95199. */
  95200. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  95201. /**
  95202. * A help function to create a joint
  95203. * @param otherImpostor A physics imposter used to create a joint
  95204. * @param jointType The type of joint
  95205. * @param jointData The data for the joint
  95206. * @returns The physics imposter
  95207. */
  95208. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  95209. /**
  95210. * Add a joint to this impostor with a different impostor
  95211. * @param otherImpostor A physics imposter used to add a joint
  95212. * @param joint The joint to add
  95213. * @returns The physics imposter
  95214. */
  95215. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  95216. /**
  95217. * Add an anchor to a cloth impostor
  95218. * @param otherImpostor rigid impostor to anchor to
  95219. * @param width ratio across width from 0 to 1
  95220. * @param height ratio up height from 0 to 1
  95221. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  95222. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  95223. * @returns impostor the soft imposter
  95224. */
  95225. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  95226. /**
  95227. * Add a hook to a rope impostor
  95228. * @param otherImpostor rigid impostor to anchor to
  95229. * @param length ratio across rope from 0 to 1
  95230. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  95231. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  95232. * @returns impostor the rope imposter
  95233. */
  95234. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  95235. /**
  95236. * Will keep this body still, in a sleep mode.
  95237. * @returns the physics imposter
  95238. */
  95239. sleep(): PhysicsImpostor;
  95240. /**
  95241. * Wake the body up.
  95242. * @returns The physics imposter
  95243. */
  95244. wakeUp(): PhysicsImpostor;
  95245. /**
  95246. * Clones the physics imposter
  95247. * @param newObject The physics imposter clones to this physics-enabled object
  95248. * @returns A nullable physics imposter
  95249. */
  95250. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  95251. /**
  95252. * Disposes the physics imposter
  95253. */
  95254. dispose(): void;
  95255. /**
  95256. * Sets the delta position
  95257. * @param position The delta position amount
  95258. */
  95259. setDeltaPosition(position: Vector3): void;
  95260. /**
  95261. * Sets the delta rotation
  95262. * @param rotation The delta rotation amount
  95263. */
  95264. setDeltaRotation(rotation: Quaternion): void;
  95265. /**
  95266. * Gets the box size of the physics imposter and stores the result in the input parameter
  95267. * @param result Stores the box size
  95268. * @returns The physics imposter
  95269. */
  95270. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  95271. /**
  95272. * Gets the radius of the physics imposter
  95273. * @returns Radius of the physics imposter
  95274. */
  95275. getRadius(): number;
  95276. /**
  95277. * Sync a bone with this impostor
  95278. * @param bone The bone to sync to the impostor.
  95279. * @param boneMesh The mesh that the bone is influencing.
  95280. * @param jointPivot The pivot of the joint / bone in local space.
  95281. * @param distToJoint Optional distance from the impostor to the joint.
  95282. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  95283. */
  95284. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  95285. /**
  95286. * Sync impostor to a bone
  95287. * @param bone The bone that the impostor will be synced to.
  95288. * @param boneMesh The mesh that the bone is influencing.
  95289. * @param jointPivot The pivot of the joint / bone in local space.
  95290. * @param distToJoint Optional distance from the impostor to the joint.
  95291. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  95292. * @param boneAxis Optional vector3 axis the bone is aligned with
  95293. */
  95294. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  95295. /**
  95296. * No-Imposter type
  95297. */
  95298. static NoImpostor: number;
  95299. /**
  95300. * Sphere-Imposter type
  95301. */
  95302. static SphereImpostor: number;
  95303. /**
  95304. * Box-Imposter type
  95305. */
  95306. static BoxImpostor: number;
  95307. /**
  95308. * Plane-Imposter type
  95309. */
  95310. static PlaneImpostor: number;
  95311. /**
  95312. * Mesh-imposter type
  95313. */
  95314. static MeshImpostor: number;
  95315. /**
  95316. * Capsule-Impostor type (Ammo.js plugin only)
  95317. */
  95318. static CapsuleImpostor: number;
  95319. /**
  95320. * Cylinder-Imposter type
  95321. */
  95322. static CylinderImpostor: number;
  95323. /**
  95324. * Particle-Imposter type
  95325. */
  95326. static ParticleImpostor: number;
  95327. /**
  95328. * Heightmap-Imposter type
  95329. */
  95330. static HeightmapImpostor: number;
  95331. /**
  95332. * ConvexHull-Impostor type (Ammo.js plugin only)
  95333. */
  95334. static ConvexHullImpostor: number;
  95335. /**
  95336. * Custom-Imposter type (Ammo.js plugin only)
  95337. */
  95338. static CustomImpostor: number;
  95339. /**
  95340. * Rope-Imposter type
  95341. */
  95342. static RopeImpostor: number;
  95343. /**
  95344. * Cloth-Imposter type
  95345. */
  95346. static ClothImpostor: number;
  95347. /**
  95348. * Softbody-Imposter type
  95349. */
  95350. static SoftbodyImpostor: number;
  95351. }
  95352. }
  95353. declare module BABYLON {
  95354. /**
  95355. * @hidden
  95356. **/
  95357. export class _CreationDataStorage {
  95358. closePath?: boolean;
  95359. closeArray?: boolean;
  95360. idx: number[];
  95361. dashSize: number;
  95362. gapSize: number;
  95363. path3D: Path3D;
  95364. pathArray: Vector3[][];
  95365. arc: number;
  95366. radius: number;
  95367. cap: number;
  95368. tessellation: number;
  95369. }
  95370. /**
  95371. * @hidden
  95372. **/
  95373. class _InstanceDataStorage {
  95374. visibleInstances: any;
  95375. batchCache: _InstancesBatch;
  95376. instancesBufferSize: number;
  95377. instancesBuffer: Nullable<Buffer>;
  95378. instancesData: Float32Array;
  95379. overridenInstanceCount: number;
  95380. isFrozen: boolean;
  95381. previousBatch: Nullable<_InstancesBatch>;
  95382. hardwareInstancedRendering: boolean;
  95383. sideOrientation: number;
  95384. manualUpdate: boolean;
  95385. }
  95386. /**
  95387. * @hidden
  95388. **/
  95389. export class _InstancesBatch {
  95390. mustReturn: boolean;
  95391. visibleInstances: Nullable<InstancedMesh[]>[];
  95392. renderSelf: boolean[];
  95393. hardwareInstancedRendering: boolean[];
  95394. }
  95395. /**
  95396. * Class used to represent renderable models
  95397. */
  95398. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  95399. /**
  95400. * Mesh side orientation : usually the external or front surface
  95401. */
  95402. static readonly FRONTSIDE: number;
  95403. /**
  95404. * Mesh side orientation : usually the internal or back surface
  95405. */
  95406. static readonly BACKSIDE: number;
  95407. /**
  95408. * Mesh side orientation : both internal and external or front and back surfaces
  95409. */
  95410. static readonly DOUBLESIDE: number;
  95411. /**
  95412. * Mesh side orientation : by default, `FRONTSIDE`
  95413. */
  95414. static readonly DEFAULTSIDE: number;
  95415. /**
  95416. * Mesh cap setting : no cap
  95417. */
  95418. static readonly NO_CAP: number;
  95419. /**
  95420. * Mesh cap setting : one cap at the beginning of the mesh
  95421. */
  95422. static readonly CAP_START: number;
  95423. /**
  95424. * Mesh cap setting : one cap at the end of the mesh
  95425. */
  95426. static readonly CAP_END: number;
  95427. /**
  95428. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  95429. */
  95430. static readonly CAP_ALL: number;
  95431. /**
  95432. * Mesh pattern setting : no flip or rotate
  95433. */
  95434. static readonly NO_FLIP: number;
  95435. /**
  95436. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  95437. */
  95438. static readonly FLIP_TILE: number;
  95439. /**
  95440. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  95441. */
  95442. static readonly ROTATE_TILE: number;
  95443. /**
  95444. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  95445. */
  95446. static readonly FLIP_ROW: number;
  95447. /**
  95448. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  95449. */
  95450. static readonly ROTATE_ROW: number;
  95451. /**
  95452. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  95453. */
  95454. static readonly FLIP_N_ROTATE_TILE: number;
  95455. /**
  95456. * Mesh pattern setting : rotate pattern and rotate
  95457. */
  95458. static readonly FLIP_N_ROTATE_ROW: number;
  95459. /**
  95460. * Mesh tile positioning : part tiles same on left/right or top/bottom
  95461. */
  95462. static readonly CENTER: number;
  95463. /**
  95464. * Mesh tile positioning : part tiles on left
  95465. */
  95466. static readonly LEFT: number;
  95467. /**
  95468. * Mesh tile positioning : part tiles on right
  95469. */
  95470. static readonly RIGHT: number;
  95471. /**
  95472. * Mesh tile positioning : part tiles on top
  95473. */
  95474. static readonly TOP: number;
  95475. /**
  95476. * Mesh tile positioning : part tiles on bottom
  95477. */
  95478. static readonly BOTTOM: number;
  95479. /**
  95480. * Gets the default side orientation.
  95481. * @param orientation the orientation to value to attempt to get
  95482. * @returns the default orientation
  95483. * @hidden
  95484. */
  95485. static _GetDefaultSideOrientation(orientation?: number): number;
  95486. private _internalMeshDataInfo;
  95487. /**
  95488. * An event triggered before rendering the mesh
  95489. */
  95490. get onBeforeRenderObservable(): Observable<Mesh>;
  95491. /**
  95492. * An event triggered before binding the mesh
  95493. */
  95494. get onBeforeBindObservable(): Observable<Mesh>;
  95495. /**
  95496. * An event triggered after rendering the mesh
  95497. */
  95498. get onAfterRenderObservable(): Observable<Mesh>;
  95499. /**
  95500. * An event triggered before drawing the mesh
  95501. */
  95502. get onBeforeDrawObservable(): Observable<Mesh>;
  95503. private _onBeforeDrawObserver;
  95504. /**
  95505. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  95506. */
  95507. set onBeforeDraw(callback: () => void);
  95508. get hasInstances(): boolean;
  95509. /**
  95510. * Gets the delay loading state of the mesh (when delay loading is turned on)
  95511. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  95512. */
  95513. delayLoadState: number;
  95514. /**
  95515. * Gets the list of instances created from this mesh
  95516. * it is not supposed to be modified manually.
  95517. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  95518. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95519. */
  95520. instances: InstancedMesh[];
  95521. /**
  95522. * Gets the file containing delay loading data for this mesh
  95523. */
  95524. delayLoadingFile: string;
  95525. /** @hidden */
  95526. _binaryInfo: any;
  95527. /**
  95528. * User defined function used to change how LOD level selection is done
  95529. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  95530. */
  95531. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  95532. /**
  95533. * Gets or sets the morph target manager
  95534. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95535. */
  95536. get morphTargetManager(): Nullable<MorphTargetManager>;
  95537. set morphTargetManager(value: Nullable<MorphTargetManager>);
  95538. /** @hidden */
  95539. _creationDataStorage: Nullable<_CreationDataStorage>;
  95540. /** @hidden */
  95541. _geometry: Nullable<Geometry>;
  95542. /** @hidden */
  95543. _delayInfo: Array<string>;
  95544. /** @hidden */
  95545. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  95546. /** @hidden */
  95547. _instanceDataStorage: _InstanceDataStorage;
  95548. private _effectiveMaterial;
  95549. /** @hidden */
  95550. _shouldGenerateFlatShading: boolean;
  95551. /** @hidden */
  95552. _originalBuilderSideOrientation: number;
  95553. /**
  95554. * Use this property to change the original side orientation defined at construction time
  95555. */
  95556. overrideMaterialSideOrientation: Nullable<number>;
  95557. /**
  95558. * Gets the source mesh (the one used to clone this one from)
  95559. */
  95560. get source(): Nullable<Mesh>;
  95561. /**
  95562. * Gets or sets a boolean indicating that this mesh does not use index buffer
  95563. */
  95564. get isUnIndexed(): boolean;
  95565. set isUnIndexed(value: boolean);
  95566. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  95567. get worldMatrixInstancedBuffer(): Float32Array;
  95568. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  95569. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  95570. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  95571. /**
  95572. * @constructor
  95573. * @param name The value used by scene.getMeshByName() to do a lookup.
  95574. * @param scene The scene to add this mesh to.
  95575. * @param parent The parent of this mesh, if it has one
  95576. * @param source An optional Mesh from which geometry is shared, cloned.
  95577. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95578. * When false, achieved by calling a clone(), also passing False.
  95579. * This will make creation of children, recursive.
  95580. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  95581. */
  95582. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  95583. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95584. doNotInstantiate: boolean;
  95585. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95586. /**
  95587. * Gets the class name
  95588. * @returns the string "Mesh".
  95589. */
  95590. getClassName(): string;
  95591. /** @hidden */
  95592. get _isMesh(): boolean;
  95593. /**
  95594. * Returns a description of this mesh
  95595. * @param fullDetails define if full details about this mesh must be used
  95596. * @returns a descriptive string representing this mesh
  95597. */
  95598. toString(fullDetails?: boolean): string;
  95599. /** @hidden */
  95600. _unBindEffect(): void;
  95601. /**
  95602. * Gets a boolean indicating if this mesh has LOD
  95603. */
  95604. get hasLODLevels(): boolean;
  95605. /**
  95606. * Gets the list of MeshLODLevel associated with the current mesh
  95607. * @returns an array of MeshLODLevel
  95608. */
  95609. getLODLevels(): MeshLODLevel[];
  95610. private _sortLODLevels;
  95611. /**
  95612. * Add a mesh as LOD level triggered at the given distance.
  95613. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95614. * @param distance The distance from the center of the object to show this level
  95615. * @param mesh The mesh to be added as LOD level (can be null)
  95616. * @return This mesh (for chaining)
  95617. */
  95618. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  95619. /**
  95620. * Returns the LOD level mesh at the passed distance or null if not found.
  95621. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95622. * @param distance The distance from the center of the object to show this level
  95623. * @returns a Mesh or `null`
  95624. */
  95625. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  95626. /**
  95627. * Remove a mesh from the LOD array
  95628. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95629. * @param mesh defines the mesh to be removed
  95630. * @return This mesh (for chaining)
  95631. */
  95632. removeLODLevel(mesh: Mesh): Mesh;
  95633. /**
  95634. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  95635. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95636. * @param camera defines the camera to use to compute distance
  95637. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  95638. * @return This mesh (for chaining)
  95639. */
  95640. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  95641. /**
  95642. * Gets the mesh internal Geometry object
  95643. */
  95644. get geometry(): Nullable<Geometry>;
  95645. /**
  95646. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  95647. * @returns the total number of vertices
  95648. */
  95649. getTotalVertices(): number;
  95650. /**
  95651. * Returns the content of an associated vertex buffer
  95652. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95653. * - VertexBuffer.PositionKind
  95654. * - VertexBuffer.UVKind
  95655. * - VertexBuffer.UV2Kind
  95656. * - VertexBuffer.UV3Kind
  95657. * - VertexBuffer.UV4Kind
  95658. * - VertexBuffer.UV5Kind
  95659. * - VertexBuffer.UV6Kind
  95660. * - VertexBuffer.ColorKind
  95661. * - VertexBuffer.MatricesIndicesKind
  95662. * - VertexBuffer.MatricesIndicesExtraKind
  95663. * - VertexBuffer.MatricesWeightsKind
  95664. * - VertexBuffer.MatricesWeightsExtraKind
  95665. * @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
  95666. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  95667. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  95668. */
  95669. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95670. /**
  95671. * Returns the mesh VertexBuffer object from the requested `kind`
  95672. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95673. * - VertexBuffer.PositionKind
  95674. * - VertexBuffer.NormalKind
  95675. * - VertexBuffer.UVKind
  95676. * - VertexBuffer.UV2Kind
  95677. * - VertexBuffer.UV3Kind
  95678. * - VertexBuffer.UV4Kind
  95679. * - VertexBuffer.UV5Kind
  95680. * - VertexBuffer.UV6Kind
  95681. * - VertexBuffer.ColorKind
  95682. * - VertexBuffer.MatricesIndicesKind
  95683. * - VertexBuffer.MatricesIndicesExtraKind
  95684. * - VertexBuffer.MatricesWeightsKind
  95685. * - VertexBuffer.MatricesWeightsExtraKind
  95686. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  95687. */
  95688. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95689. /**
  95690. * Tests if a specific vertex buffer is associated with this mesh
  95691. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  95692. * - VertexBuffer.PositionKind
  95693. * - VertexBuffer.NormalKind
  95694. * - VertexBuffer.UVKind
  95695. * - VertexBuffer.UV2Kind
  95696. * - VertexBuffer.UV3Kind
  95697. * - VertexBuffer.UV4Kind
  95698. * - VertexBuffer.UV5Kind
  95699. * - VertexBuffer.UV6Kind
  95700. * - VertexBuffer.ColorKind
  95701. * - VertexBuffer.MatricesIndicesKind
  95702. * - VertexBuffer.MatricesIndicesExtraKind
  95703. * - VertexBuffer.MatricesWeightsKind
  95704. * - VertexBuffer.MatricesWeightsExtraKind
  95705. * @returns a boolean
  95706. */
  95707. isVerticesDataPresent(kind: string): boolean;
  95708. /**
  95709. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  95710. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  95711. * - VertexBuffer.PositionKind
  95712. * - VertexBuffer.UVKind
  95713. * - VertexBuffer.UV2Kind
  95714. * - VertexBuffer.UV3Kind
  95715. * - VertexBuffer.UV4Kind
  95716. * - VertexBuffer.UV5Kind
  95717. * - VertexBuffer.UV6Kind
  95718. * - VertexBuffer.ColorKind
  95719. * - VertexBuffer.MatricesIndicesKind
  95720. * - VertexBuffer.MatricesIndicesExtraKind
  95721. * - VertexBuffer.MatricesWeightsKind
  95722. * - VertexBuffer.MatricesWeightsExtraKind
  95723. * @returns a boolean
  95724. */
  95725. isVertexBufferUpdatable(kind: string): boolean;
  95726. /**
  95727. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  95728. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95729. * - VertexBuffer.PositionKind
  95730. * - VertexBuffer.NormalKind
  95731. * - VertexBuffer.UVKind
  95732. * - VertexBuffer.UV2Kind
  95733. * - VertexBuffer.UV3Kind
  95734. * - VertexBuffer.UV4Kind
  95735. * - VertexBuffer.UV5Kind
  95736. * - VertexBuffer.UV6Kind
  95737. * - VertexBuffer.ColorKind
  95738. * - VertexBuffer.MatricesIndicesKind
  95739. * - VertexBuffer.MatricesIndicesExtraKind
  95740. * - VertexBuffer.MatricesWeightsKind
  95741. * - VertexBuffer.MatricesWeightsExtraKind
  95742. * @returns an array of strings
  95743. */
  95744. getVerticesDataKinds(): string[];
  95745. /**
  95746. * Returns a positive integer : the total number of indices in this mesh geometry.
  95747. * @returns the numner of indices or zero if the mesh has no geometry.
  95748. */
  95749. getTotalIndices(): number;
  95750. /**
  95751. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95752. * @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.
  95753. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95754. * @returns the indices array or an empty array if the mesh has no geometry
  95755. */
  95756. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95757. get isBlocked(): boolean;
  95758. /**
  95759. * Determine if the current mesh is ready to be rendered
  95760. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95761. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  95762. * @returns true if all associated assets are ready (material, textures, shaders)
  95763. */
  95764. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  95765. /**
  95766. * 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.
  95767. */
  95768. get areNormalsFrozen(): boolean;
  95769. /**
  95770. * 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.
  95771. * @returns the current mesh
  95772. */
  95773. freezeNormals(): Mesh;
  95774. /**
  95775. * 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
  95776. * @returns the current mesh
  95777. */
  95778. unfreezeNormals(): Mesh;
  95779. /**
  95780. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  95781. */
  95782. set overridenInstanceCount(count: number);
  95783. /** @hidden */
  95784. _preActivate(): Mesh;
  95785. /** @hidden */
  95786. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95787. /** @hidden */
  95788. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  95789. /**
  95790. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95791. * This means the mesh underlying bounding box and sphere are recomputed.
  95792. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95793. * @returns the current mesh
  95794. */
  95795. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  95796. /** @hidden */
  95797. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  95798. /**
  95799. * This function will subdivide the mesh into multiple submeshes
  95800. * @param count defines the expected number of submeshes
  95801. */
  95802. subdivide(count: number): void;
  95803. /**
  95804. * Copy a FloatArray into a specific associated vertex buffer
  95805. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95806. * - VertexBuffer.PositionKind
  95807. * - VertexBuffer.UVKind
  95808. * - VertexBuffer.UV2Kind
  95809. * - VertexBuffer.UV3Kind
  95810. * - VertexBuffer.UV4Kind
  95811. * - VertexBuffer.UV5Kind
  95812. * - VertexBuffer.UV6Kind
  95813. * - VertexBuffer.ColorKind
  95814. * - VertexBuffer.MatricesIndicesKind
  95815. * - VertexBuffer.MatricesIndicesExtraKind
  95816. * - VertexBuffer.MatricesWeightsKind
  95817. * - VertexBuffer.MatricesWeightsExtraKind
  95818. * @param data defines the data source
  95819. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95820. * @param stride defines the data stride size (can be null)
  95821. * @returns the current mesh
  95822. */
  95823. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95824. /**
  95825. * Delete a vertex buffer associated with this mesh
  95826. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  95827. * - VertexBuffer.PositionKind
  95828. * - VertexBuffer.UVKind
  95829. * - VertexBuffer.UV2Kind
  95830. * - VertexBuffer.UV3Kind
  95831. * - VertexBuffer.UV4Kind
  95832. * - VertexBuffer.UV5Kind
  95833. * - VertexBuffer.UV6Kind
  95834. * - VertexBuffer.ColorKind
  95835. * - VertexBuffer.MatricesIndicesKind
  95836. * - VertexBuffer.MatricesIndicesExtraKind
  95837. * - VertexBuffer.MatricesWeightsKind
  95838. * - VertexBuffer.MatricesWeightsExtraKind
  95839. */
  95840. removeVerticesData(kind: string): void;
  95841. /**
  95842. * Flags an associated vertex buffer as updatable
  95843. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95844. * - VertexBuffer.PositionKind
  95845. * - VertexBuffer.UVKind
  95846. * - VertexBuffer.UV2Kind
  95847. * - VertexBuffer.UV3Kind
  95848. * - VertexBuffer.UV4Kind
  95849. * - VertexBuffer.UV5Kind
  95850. * - VertexBuffer.UV6Kind
  95851. * - VertexBuffer.ColorKind
  95852. * - VertexBuffer.MatricesIndicesKind
  95853. * - VertexBuffer.MatricesIndicesExtraKind
  95854. * - VertexBuffer.MatricesWeightsKind
  95855. * - VertexBuffer.MatricesWeightsExtraKind
  95856. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95857. */
  95858. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95859. /**
  95860. * Sets the mesh global Vertex Buffer
  95861. * @param buffer defines the buffer to use
  95862. * @returns the current mesh
  95863. */
  95864. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95865. /**
  95866. * Update a specific associated vertex buffer
  95867. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95868. * - VertexBuffer.PositionKind
  95869. * - VertexBuffer.UVKind
  95870. * - VertexBuffer.UV2Kind
  95871. * - VertexBuffer.UV3Kind
  95872. * - VertexBuffer.UV4Kind
  95873. * - VertexBuffer.UV5Kind
  95874. * - VertexBuffer.UV6Kind
  95875. * - VertexBuffer.ColorKind
  95876. * - VertexBuffer.MatricesIndicesKind
  95877. * - VertexBuffer.MatricesIndicesExtraKind
  95878. * - VertexBuffer.MatricesWeightsKind
  95879. * - VertexBuffer.MatricesWeightsExtraKind
  95880. * @param data defines the data source
  95881. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95882. * @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)
  95883. * @returns the current mesh
  95884. */
  95885. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95886. /**
  95887. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95888. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95889. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95890. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95891. * @returns the current mesh
  95892. */
  95893. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95894. /**
  95895. * Creates a un-shared specific occurence of the geometry for the mesh.
  95896. * @returns the current mesh
  95897. */
  95898. makeGeometryUnique(): Mesh;
  95899. /**
  95900. * Set the index buffer of this mesh
  95901. * @param indices defines the source data
  95902. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95903. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95904. * @returns the current mesh
  95905. */
  95906. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95907. /**
  95908. * Update the current index buffer
  95909. * @param indices defines the source data
  95910. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95911. * @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)
  95912. * @returns the current mesh
  95913. */
  95914. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95915. /**
  95916. * Invert the geometry to move from a right handed system to a left handed one.
  95917. * @returns the current mesh
  95918. */
  95919. toLeftHanded(): Mesh;
  95920. /** @hidden */
  95921. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95922. /** @hidden */
  95923. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95924. /**
  95925. * Registers for this mesh a javascript function called just before the rendering process
  95926. * @param func defines the function to call before rendering this mesh
  95927. * @returns the current mesh
  95928. */
  95929. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95930. /**
  95931. * Disposes a previously registered javascript function called before the rendering
  95932. * @param func defines the function to remove
  95933. * @returns the current mesh
  95934. */
  95935. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95936. /**
  95937. * Registers for this mesh a javascript function called just after the rendering is complete
  95938. * @param func defines the function to call after rendering this mesh
  95939. * @returns the current mesh
  95940. */
  95941. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95942. /**
  95943. * Disposes a previously registered javascript function called after the rendering.
  95944. * @param func defines the function to remove
  95945. * @returns the current mesh
  95946. */
  95947. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95948. /** @hidden */
  95949. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95950. /** @hidden */
  95951. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95952. /** @hidden */
  95953. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95954. /** @hidden */
  95955. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95956. /** @hidden */
  95957. _rebuild(): void;
  95958. /** @hidden */
  95959. _freeze(): void;
  95960. /** @hidden */
  95961. _unFreeze(): void;
  95962. /**
  95963. * 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
  95964. * @param subMesh defines the subMesh to render
  95965. * @param enableAlphaMode defines if alpha mode can be changed
  95966. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95967. * @returns the current mesh
  95968. */
  95969. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95970. private _onBeforeDraw;
  95971. /**
  95972. * Renormalize the mesh and patch it up if there are no weights
  95973. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95974. * However in the case of zero weights then we set just a single influence to 1.
  95975. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95976. */
  95977. cleanMatrixWeights(): void;
  95978. private normalizeSkinFourWeights;
  95979. private normalizeSkinWeightsAndExtra;
  95980. /**
  95981. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95982. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95983. * the user know there was an issue with importing the mesh
  95984. * @returns a validation object with skinned, valid and report string
  95985. */
  95986. validateSkinning(): {
  95987. skinned: boolean;
  95988. valid: boolean;
  95989. report: string;
  95990. };
  95991. /** @hidden */
  95992. _checkDelayState(): Mesh;
  95993. private _queueLoad;
  95994. /**
  95995. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95996. * A mesh is in the frustum if its bounding box intersects the frustum
  95997. * @param frustumPlanes defines the frustum to test
  95998. * @returns true if the mesh is in the frustum planes
  95999. */
  96000. isInFrustum(frustumPlanes: Plane[]): boolean;
  96001. /**
  96002. * Sets the mesh material by the material or multiMaterial `id` property
  96003. * @param id is a string identifying the material or the multiMaterial
  96004. * @returns the current mesh
  96005. */
  96006. setMaterialByID(id: string): Mesh;
  96007. /**
  96008. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  96009. * @returns an array of IAnimatable
  96010. */
  96011. getAnimatables(): IAnimatable[];
  96012. /**
  96013. * Modifies the mesh geometry according to the passed transformation matrix.
  96014. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  96015. * The mesh normals are modified using the same transformation.
  96016. * Note that, under the hood, this method sets a new VertexBuffer each call.
  96017. * @param transform defines the transform matrix to use
  96018. * @see http://doc.babylonjs.com/resources/baking_transformations
  96019. * @returns the current mesh
  96020. */
  96021. bakeTransformIntoVertices(transform: Matrix): Mesh;
  96022. /**
  96023. * Modifies the mesh geometry according to its own current World Matrix.
  96024. * The mesh World Matrix is then reset.
  96025. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  96026. * Note that, under the hood, this method sets a new VertexBuffer each call.
  96027. * @see http://doc.babylonjs.com/resources/baking_transformations
  96028. * @returns the current mesh
  96029. */
  96030. bakeCurrentTransformIntoVertices(): Mesh;
  96031. /** @hidden */
  96032. get _positions(): Nullable<Vector3[]>;
  96033. /** @hidden */
  96034. _resetPointsArrayCache(): Mesh;
  96035. /** @hidden */
  96036. _generatePointsArray(): boolean;
  96037. /**
  96038. * Returns a new Mesh object generated from the current mesh properties.
  96039. * This method must not get confused with createInstance()
  96040. * @param name is a string, the name given to the new mesh
  96041. * @param newParent can be any Node object (default `null`)
  96042. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  96043. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  96044. * @returns a new mesh
  96045. */
  96046. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  96047. /**
  96048. * Releases resources associated with this mesh.
  96049. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96050. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96051. */
  96052. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96053. /** @hidden */
  96054. _disposeInstanceSpecificData(): void;
  96055. /**
  96056. * Modifies the mesh geometry according to a displacement map.
  96057. * 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.
  96058. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  96059. * @param url is a string, the URL from the image file is to be downloaded.
  96060. * @param minHeight is the lower limit of the displacement.
  96061. * @param maxHeight is the upper limit of the displacement.
  96062. * @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.
  96063. * @param uvOffset is an optional vector2 used to offset UV.
  96064. * @param uvScale is an optional vector2 used to scale UV.
  96065. * @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.
  96066. * @returns the Mesh.
  96067. */
  96068. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  96069. /**
  96070. * Modifies the mesh geometry according to a displacementMap buffer.
  96071. * 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.
  96072. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  96073. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  96074. * @param heightMapWidth is the width of the buffer image.
  96075. * @param heightMapHeight is the height of the buffer image.
  96076. * @param minHeight is the lower limit of the displacement.
  96077. * @param maxHeight is the upper limit of the displacement.
  96078. * @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.
  96079. * @param uvOffset is an optional vector2 used to offset UV.
  96080. * @param uvScale is an optional vector2 used to scale UV.
  96081. * @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.
  96082. * @returns the Mesh.
  96083. */
  96084. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  96085. /**
  96086. * Modify the mesh to get a flat shading rendering.
  96087. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  96088. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  96089. * @returns current mesh
  96090. */
  96091. convertToFlatShadedMesh(): Mesh;
  96092. /**
  96093. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  96094. * In other words, more vertices, no more indices and a single bigger VBO.
  96095. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  96096. * @returns current mesh
  96097. */
  96098. convertToUnIndexedMesh(): Mesh;
  96099. /**
  96100. * Inverses facet orientations.
  96101. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  96102. * @param flipNormals will also inverts the normals
  96103. * @returns current mesh
  96104. */
  96105. flipFaces(flipNormals?: boolean): Mesh;
  96106. /**
  96107. * Increase the number of facets and hence vertices in a mesh
  96108. * Vertex normals are interpolated from existing vertex normals
  96109. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  96110. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  96111. */
  96112. increaseVertices(numberPerEdge: number): void;
  96113. /**
  96114. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  96115. * This will undo any application of covertToFlatShadedMesh
  96116. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  96117. */
  96118. forceSharedVertices(): void;
  96119. /** @hidden */
  96120. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  96121. /** @hidden */
  96122. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  96123. /**
  96124. * Creates a new InstancedMesh object from the mesh model.
  96125. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  96126. * @param name defines the name of the new instance
  96127. * @returns a new InstancedMesh
  96128. */
  96129. createInstance(name: string): InstancedMesh;
  96130. /**
  96131. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  96132. * After this call, all the mesh instances have the same submeshes than the current mesh.
  96133. * @returns the current mesh
  96134. */
  96135. synchronizeInstances(): Mesh;
  96136. /**
  96137. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  96138. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  96139. * This should be used together with the simplification to avoid disappearing triangles.
  96140. * @param successCallback an optional success callback to be called after the optimization finished.
  96141. * @returns the current mesh
  96142. */
  96143. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  96144. /**
  96145. * Serialize current mesh
  96146. * @param serializationObject defines the object which will receive the serialization data
  96147. */
  96148. serialize(serializationObject: any): void;
  96149. /** @hidden */
  96150. _syncGeometryWithMorphTargetManager(): void;
  96151. /** @hidden */
  96152. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  96153. /**
  96154. * Returns a new Mesh object parsed from the source provided.
  96155. * @param parsedMesh is the source
  96156. * @param scene defines the hosting scene
  96157. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  96158. * @returns a new Mesh
  96159. */
  96160. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  96161. /**
  96162. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  96163. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  96164. * @param name defines the name of the mesh to create
  96165. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  96166. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  96167. * @param closePath creates a seam between the first and the last points of each path of the path array
  96168. * @param offset is taken in account only if the `pathArray` is containing a single path
  96169. * @param scene defines the hosting scene
  96170. * @param updatable defines if the mesh must be flagged as updatable
  96171. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96172. * @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)
  96173. * @returns a new Mesh
  96174. */
  96175. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  96176. /**
  96177. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  96178. * @param name defines the name of the mesh to create
  96179. * @param radius sets the radius size (float) of the polygon (default 0.5)
  96180. * @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
  96181. * @param scene defines the hosting scene
  96182. * @param updatable defines if the mesh must be flagged as updatable
  96183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96184. * @returns a new Mesh
  96185. */
  96186. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  96187. /**
  96188. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  96189. * @param name defines the name of the mesh to create
  96190. * @param size sets the size (float) of each box side (default 1)
  96191. * @param scene defines the hosting scene
  96192. * @param updatable defines if the mesh must be flagged as updatable
  96193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96194. * @returns a new Mesh
  96195. */
  96196. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  96197. /**
  96198. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  96199. * @param name defines the name of the mesh to create
  96200. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  96201. * @param diameter sets the diameter size (float) of the sphere (default 1)
  96202. * @param scene defines the hosting scene
  96203. * @param updatable defines if the mesh must be flagged as updatable
  96204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96205. * @returns a new Mesh
  96206. */
  96207. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96208. /**
  96209. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  96210. * @param name defines the name of the mesh to create
  96211. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  96212. * @param diameter sets the diameter size (float) of the sphere (default 1)
  96213. * @param scene defines the hosting scene
  96214. * @returns a new Mesh
  96215. */
  96216. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  96217. /**
  96218. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  96219. * @param name defines the name of the mesh to create
  96220. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  96221. * @param diameterTop set the top cap diameter (floats, default 1)
  96222. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  96223. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  96224. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  96225. * @param scene defines the hosting scene
  96226. * @param updatable defines if the mesh must be flagged as updatable
  96227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96228. * @returns a new Mesh
  96229. */
  96230. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  96231. /**
  96232. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  96233. * @param name defines the name of the mesh to create
  96234. * @param diameter sets the diameter size (float) of the torus (default 1)
  96235. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  96236. * @param tessellation sets the number of torus sides (postive integer, default 16)
  96237. * @param scene defines the hosting scene
  96238. * @param updatable defines if the mesh must be flagged as updatable
  96239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96240. * @returns a new Mesh
  96241. */
  96242. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96243. /**
  96244. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  96245. * @param name defines the name of the mesh to create
  96246. * @param radius sets the global radius size (float) of the torus knot (default 2)
  96247. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  96248. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  96249. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  96250. * @param p the number of windings on X axis (positive integers, default 2)
  96251. * @param q the number of windings on Y axis (positive integers, default 3)
  96252. * @param scene defines the hosting scene
  96253. * @param updatable defines if the mesh must be flagged as updatable
  96254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96255. * @returns a new Mesh
  96256. */
  96257. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96258. /**
  96259. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  96260. * @param name defines the name of the mesh to create
  96261. * @param points is an array successive Vector3
  96262. * @param scene defines the hosting scene
  96263. * @param updatable defines if the mesh must be flagged as updatable
  96264. * @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).
  96265. * @returns a new Mesh
  96266. */
  96267. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  96268. /**
  96269. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  96270. * @param name defines the name of the mesh to create
  96271. * @param points is an array successive Vector3
  96272. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  96273. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  96274. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  96275. * @param scene defines the hosting scene
  96276. * @param updatable defines if the mesh must be flagged as updatable
  96277. * @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)
  96278. * @returns a new Mesh
  96279. */
  96280. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  96281. /**
  96282. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  96283. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  96284. * 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.
  96285. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96286. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96287. * Remember you can only change the shape positions, not their number when updating a polygon.
  96288. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  96289. * @param name defines the name of the mesh to create
  96290. * @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
  96291. * @param scene defines the hosting scene
  96292. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  96293. * @param updatable defines if the mesh must be flagged as updatable
  96294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96295. * @param earcutInjection can be used to inject your own earcut reference
  96296. * @returns a new Mesh
  96297. */
  96298. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  96299. /**
  96300. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  96301. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  96302. * @param name defines the name of the mesh to create
  96303. * @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
  96304. * @param depth defines the height of extrusion
  96305. * @param scene defines the hosting scene
  96306. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  96307. * @param updatable defines if the mesh must be flagged as updatable
  96308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96309. * @param earcutInjection can be used to inject your own earcut reference
  96310. * @returns a new Mesh
  96311. */
  96312. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  96313. /**
  96314. * Creates an extruded shape mesh.
  96315. * 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
  96316. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  96317. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  96318. * @param name defines the name of the mesh to create
  96319. * @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
  96320. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  96321. * @param scale is the value to scale the shape
  96322. * @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
  96323. * @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
  96324. * @param scene defines the hosting scene
  96325. * @param updatable defines if the mesh must be flagged as updatable
  96326. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96327. * @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)
  96328. * @returns a new Mesh
  96329. */
  96330. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  96331. /**
  96332. * Creates an custom extruded shape mesh.
  96333. * The custom extrusion is a parametric shape.
  96334. * It has no predefined shape. Its final shape will depend on the input parameters.
  96335. * Please consider using the same method from the MeshBuilder class instead
  96336. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  96337. * @param name defines the name of the mesh to create
  96338. * @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
  96339. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  96340. * @param scaleFunction is a custom Javascript function called on each path point
  96341. * @param rotationFunction is a custom Javascript function called on each path point
  96342. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  96343. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  96344. * @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
  96345. * @param scene defines the hosting scene
  96346. * @param updatable defines if the mesh must be flagged as updatable
  96347. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96348. * @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)
  96349. * @returns a new Mesh
  96350. */
  96351. 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;
  96352. /**
  96353. * Creates lathe mesh.
  96354. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  96355. * Please consider using the same method from the MeshBuilder class instead
  96356. * @param name defines the name of the mesh to create
  96357. * @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
  96358. * @param radius is the radius value of the lathe
  96359. * @param tessellation is the side number of the lathe.
  96360. * @param scene defines the hosting scene
  96361. * @param updatable defines if the mesh must be flagged as updatable
  96362. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96363. * @returns a new Mesh
  96364. */
  96365. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96366. /**
  96367. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  96368. * @param name defines the name of the mesh to create
  96369. * @param size sets the size (float) of both sides of the plane at once (default 1)
  96370. * @param scene defines the hosting scene
  96371. * @param updatable defines if the mesh must be flagged as updatable
  96372. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96373. * @returns a new Mesh
  96374. */
  96375. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96376. /**
  96377. * Creates a ground mesh.
  96378. * Please consider using the same method from the MeshBuilder class instead
  96379. * @param name defines the name of the mesh to create
  96380. * @param width set the width of the ground
  96381. * @param height set the height of the ground
  96382. * @param subdivisions sets the number of subdivisions per side
  96383. * @param scene defines the hosting scene
  96384. * @param updatable defines if the mesh must be flagged as updatable
  96385. * @returns a new Mesh
  96386. */
  96387. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  96388. /**
  96389. * Creates a tiled ground mesh.
  96390. * Please consider using the same method from the MeshBuilder class instead
  96391. * @param name defines the name of the mesh to create
  96392. * @param xmin set the ground minimum X coordinate
  96393. * @param zmin set the ground minimum Y coordinate
  96394. * @param xmax set the ground maximum X coordinate
  96395. * @param zmax set the ground maximum Z coordinate
  96396. * @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
  96397. * @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
  96398. * @param scene defines the hosting scene
  96399. * @param updatable defines if the mesh must be flagged as updatable
  96400. * @returns a new Mesh
  96401. */
  96402. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  96403. w: number;
  96404. h: number;
  96405. }, precision: {
  96406. w: number;
  96407. h: number;
  96408. }, scene: Scene, updatable?: boolean): Mesh;
  96409. /**
  96410. * Creates a ground mesh from a height map.
  96411. * Please consider using the same method from the MeshBuilder class instead
  96412. * @see http://doc.babylonjs.com/babylon101/height_map
  96413. * @param name defines the name of the mesh to create
  96414. * @param url sets the URL of the height map image resource
  96415. * @param width set the ground width size
  96416. * @param height set the ground height size
  96417. * @param subdivisions sets the number of subdivision per side
  96418. * @param minHeight is the minimum altitude on the ground
  96419. * @param maxHeight is the maximum altitude on the ground
  96420. * @param scene defines the hosting scene
  96421. * @param updatable defines if the mesh must be flagged as updatable
  96422. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  96423. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96424. * @returns a new Mesh
  96425. */
  96426. 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;
  96427. /**
  96428. * Creates a tube mesh.
  96429. * The tube is a parametric shape.
  96430. * It has no predefined shape. Its final shape will depend on the input parameters.
  96431. * Please consider using the same method from the MeshBuilder class instead
  96432. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  96433. * @param name defines the name of the mesh to create
  96434. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  96435. * @param radius sets the tube radius size
  96436. * @param tessellation is the number of sides on the tubular surface
  96437. * @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
  96438. * @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
  96439. * @param scene defines the hosting scene
  96440. * @param updatable defines if the mesh must be flagged as updatable
  96441. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96442. * @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)
  96443. * @returns a new Mesh
  96444. */
  96445. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  96446. (i: number, distance: number): number;
  96447. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  96448. /**
  96449. * Creates a polyhedron mesh.
  96450. * Please consider using the same method from the MeshBuilder class instead.
  96451. * * 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
  96452. * * The parameter `size` (positive float, default 1) sets the polygon size
  96453. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  96454. * * 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`
  96455. * * 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
  96456. * * 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)`)
  96457. * * 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
  96458. * * 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
  96459. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96460. * * If you create a double-sided mesh, you can choose what parts of 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
  96461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96462. * @param name defines the name of the mesh to create
  96463. * @param options defines the options used to create the mesh
  96464. * @param scene defines the hosting scene
  96465. * @returns a new Mesh
  96466. */
  96467. static CreatePolyhedron(name: string, options: {
  96468. type?: number;
  96469. size?: number;
  96470. sizeX?: number;
  96471. sizeY?: number;
  96472. sizeZ?: number;
  96473. custom?: any;
  96474. faceUV?: Vector4[];
  96475. faceColors?: Color4[];
  96476. updatable?: boolean;
  96477. sideOrientation?: number;
  96478. }, scene: Scene): Mesh;
  96479. /**
  96480. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  96481. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  96482. * * 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`)
  96483. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  96484. * * 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
  96485. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96486. * * If you create a double-sided mesh, you can choose what parts of 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
  96487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96488. * @param name defines the name of the mesh
  96489. * @param options defines the options used to create the mesh
  96490. * @param scene defines the hosting scene
  96491. * @returns a new Mesh
  96492. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  96493. */
  96494. static CreateIcoSphere(name: string, options: {
  96495. radius?: number;
  96496. flat?: boolean;
  96497. subdivisions?: number;
  96498. sideOrientation?: number;
  96499. updatable?: boolean;
  96500. }, scene: Scene): Mesh;
  96501. /**
  96502. * Creates a decal mesh.
  96503. * Please consider using the same method from the MeshBuilder class instead.
  96504. * A decal is a mesh usually applied as a model onto the surface of another mesh
  96505. * @param name defines the name of the mesh
  96506. * @param sourceMesh defines the mesh receiving the decal
  96507. * @param position sets the position of the decal in world coordinates
  96508. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  96509. * @param size sets the decal scaling
  96510. * @param angle sets the angle to rotate the decal
  96511. * @returns a new Mesh
  96512. */
  96513. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  96514. /**
  96515. * Prepare internal position array for software CPU skinning
  96516. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  96517. */
  96518. setPositionsForCPUSkinning(): Float32Array;
  96519. /**
  96520. * Prepare internal normal array for software CPU skinning
  96521. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  96522. */
  96523. setNormalsForCPUSkinning(): Float32Array;
  96524. /**
  96525. * Updates the vertex buffer by applying transformation from the bones
  96526. * @param skeleton defines the skeleton to apply to current mesh
  96527. * @returns the current mesh
  96528. */
  96529. applySkeleton(skeleton: Skeleton): Mesh;
  96530. /**
  96531. * 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
  96532. * @param meshes defines the list of meshes to scan
  96533. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  96534. */
  96535. static MinMax(meshes: AbstractMesh[]): {
  96536. min: Vector3;
  96537. max: Vector3;
  96538. };
  96539. /**
  96540. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  96541. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  96542. * @returns a vector3
  96543. */
  96544. static Center(meshesOrMinMaxVector: {
  96545. min: Vector3;
  96546. max: Vector3;
  96547. } | AbstractMesh[]): Vector3;
  96548. /**
  96549. * Merge the array of meshes into a single mesh for performance reasons.
  96550. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  96551. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  96552. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  96553. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  96554. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  96555. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  96556. * @returns a new mesh
  96557. */
  96558. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  96559. /** @hidden */
  96560. addInstance(instance: InstancedMesh): void;
  96561. /** @hidden */
  96562. removeInstance(instance: InstancedMesh): void;
  96563. }
  96564. }
  96565. declare module BABYLON {
  96566. /**
  96567. * This is the base class of all the camera used in the application.
  96568. * @see http://doc.babylonjs.com/features/cameras
  96569. */
  96570. export class Camera extends Node {
  96571. /** @hidden */
  96572. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  96573. /**
  96574. * This is the default projection mode used by the cameras.
  96575. * It helps recreating a feeling of perspective and better appreciate depth.
  96576. * This is the best way to simulate real life cameras.
  96577. */
  96578. static readonly PERSPECTIVE_CAMERA: number;
  96579. /**
  96580. * This helps creating camera with an orthographic mode.
  96581. * 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.
  96582. */
  96583. static readonly ORTHOGRAPHIC_CAMERA: number;
  96584. /**
  96585. * This is the default FOV mode for perspective cameras.
  96586. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  96587. */
  96588. static readonly FOVMODE_VERTICAL_FIXED: number;
  96589. /**
  96590. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  96591. */
  96592. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  96593. /**
  96594. * This specifies ther is no need for a camera rig.
  96595. * Basically only one eye is rendered corresponding to the camera.
  96596. */
  96597. static readonly RIG_MODE_NONE: number;
  96598. /**
  96599. * Simulates a camera Rig with one blue eye and one red eye.
  96600. * This can be use with 3d blue and red glasses.
  96601. */
  96602. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  96603. /**
  96604. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  96605. */
  96606. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  96607. /**
  96608. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  96609. */
  96610. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  96611. /**
  96612. * Defines that both eyes of the camera will be rendered over under each other.
  96613. */
  96614. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  96615. /**
  96616. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  96617. */
  96618. static readonly RIG_MODE_VR: number;
  96619. /**
  96620. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  96621. */
  96622. static readonly RIG_MODE_WEBVR: number;
  96623. /**
  96624. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  96625. */
  96626. static readonly RIG_MODE_CUSTOM: number;
  96627. /**
  96628. * Defines if by default attaching controls should prevent the default javascript event to continue.
  96629. */
  96630. static ForceAttachControlToAlwaysPreventDefault: boolean;
  96631. /**
  96632. * Define the input manager associated with the camera.
  96633. */
  96634. inputs: CameraInputsManager<Camera>;
  96635. /** @hidden */
  96636. _position: Vector3;
  96637. /**
  96638. * Define the current local position of the camera in the scene
  96639. */
  96640. get position(): Vector3;
  96641. set position(newPosition: Vector3);
  96642. /**
  96643. * The vector the camera should consider as up.
  96644. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  96645. */
  96646. upVector: Vector3;
  96647. /**
  96648. * Define the current limit on the left side for an orthographic camera
  96649. * In scene unit
  96650. */
  96651. orthoLeft: Nullable<number>;
  96652. /**
  96653. * Define the current limit on the right side for an orthographic camera
  96654. * In scene unit
  96655. */
  96656. orthoRight: Nullable<number>;
  96657. /**
  96658. * Define the current limit on the bottom side for an orthographic camera
  96659. * In scene unit
  96660. */
  96661. orthoBottom: Nullable<number>;
  96662. /**
  96663. * Define the current limit on the top side for an orthographic camera
  96664. * In scene unit
  96665. */
  96666. orthoTop: Nullable<number>;
  96667. /**
  96668. * Field Of View is set in Radians. (default is 0.8)
  96669. */
  96670. fov: number;
  96671. /**
  96672. * Define the minimum distance the camera can see from.
  96673. * This is important to note that the depth buffer are not infinite and the closer it starts
  96674. * the more your scene might encounter depth fighting issue.
  96675. */
  96676. minZ: number;
  96677. /**
  96678. * Define the maximum distance the camera can see to.
  96679. * This is important to note that the depth buffer are not infinite and the further it end
  96680. * the more your scene might encounter depth fighting issue.
  96681. */
  96682. maxZ: number;
  96683. /**
  96684. * Define the default inertia of the camera.
  96685. * This helps giving a smooth feeling to the camera movement.
  96686. */
  96687. inertia: number;
  96688. /**
  96689. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  96690. */
  96691. mode: number;
  96692. /**
  96693. * Define wether the camera is intermediate.
  96694. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  96695. */
  96696. isIntermediate: boolean;
  96697. /**
  96698. * Define the viewport of the camera.
  96699. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  96700. */
  96701. viewport: Viewport;
  96702. /**
  96703. * Restricts the camera to viewing objects with the same layerMask.
  96704. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  96705. */
  96706. layerMask: number;
  96707. /**
  96708. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  96709. */
  96710. fovMode: number;
  96711. /**
  96712. * Rig mode of the camera.
  96713. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  96714. * This is normally controlled byt the camera themselves as internal use.
  96715. */
  96716. cameraRigMode: number;
  96717. /**
  96718. * Defines the distance between both "eyes" in case of a RIG
  96719. */
  96720. interaxialDistance: number;
  96721. /**
  96722. * Defines if stereoscopic rendering is done side by side or over under.
  96723. */
  96724. isStereoscopicSideBySide: boolean;
  96725. /**
  96726. * 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
  96727. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  96728. * else in the scene. (Eg. security camera)
  96729. *
  96730. * 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)
  96731. */
  96732. customRenderTargets: RenderTargetTexture[];
  96733. /**
  96734. * When set, the camera will render to this render target instead of the default canvas
  96735. *
  96736. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  96737. */
  96738. outputRenderTarget: Nullable<RenderTargetTexture>;
  96739. /**
  96740. * Observable triggered when the camera view matrix has changed.
  96741. */
  96742. onViewMatrixChangedObservable: Observable<Camera>;
  96743. /**
  96744. * Observable triggered when the camera Projection matrix has changed.
  96745. */
  96746. onProjectionMatrixChangedObservable: Observable<Camera>;
  96747. /**
  96748. * Observable triggered when the inputs have been processed.
  96749. */
  96750. onAfterCheckInputsObservable: Observable<Camera>;
  96751. /**
  96752. * Observable triggered when reset has been called and applied to the camera.
  96753. */
  96754. onRestoreStateObservable: Observable<Camera>;
  96755. /** @hidden */
  96756. _cameraRigParams: any;
  96757. /** @hidden */
  96758. _rigCameras: Camera[];
  96759. /** @hidden */
  96760. _rigPostProcess: Nullable<PostProcess>;
  96761. protected _webvrViewMatrix: Matrix;
  96762. /** @hidden */
  96763. _skipRendering: boolean;
  96764. /** @hidden */
  96765. _projectionMatrix: Matrix;
  96766. /** @hidden */
  96767. _postProcesses: Nullable<PostProcess>[];
  96768. /** @hidden */
  96769. _activeMeshes: SmartArray<AbstractMesh>;
  96770. protected _globalPosition: Vector3;
  96771. /** @hidden */
  96772. _computedViewMatrix: Matrix;
  96773. private _doNotComputeProjectionMatrix;
  96774. private _transformMatrix;
  96775. private _frustumPlanes;
  96776. private _refreshFrustumPlanes;
  96777. private _storedFov;
  96778. private _stateStored;
  96779. /**
  96780. * Instantiates a new camera object.
  96781. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  96782. * @see http://doc.babylonjs.com/features/cameras
  96783. * @param name Defines the name of the camera in the scene
  96784. * @param position Defines the position of the camera
  96785. * @param scene Defines the scene the camera belongs too
  96786. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  96787. */
  96788. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96789. /**
  96790. * Store current camera state (fov, position, etc..)
  96791. * @returns the camera
  96792. */
  96793. storeState(): Camera;
  96794. /**
  96795. * Restores the camera state values if it has been stored. You must call storeState() first
  96796. */
  96797. protected _restoreStateValues(): boolean;
  96798. /**
  96799. * Restored camera state. You must call storeState() first.
  96800. * @returns true if restored and false otherwise
  96801. */
  96802. restoreState(): boolean;
  96803. /**
  96804. * Gets the class name of the camera.
  96805. * @returns the class name
  96806. */
  96807. getClassName(): string;
  96808. /** @hidden */
  96809. readonly _isCamera: boolean;
  96810. /**
  96811. * Gets a string representation of the camera useful for debug purpose.
  96812. * @param fullDetails Defines that a more verboe level of logging is required
  96813. * @returns the string representation
  96814. */
  96815. toString(fullDetails?: boolean): string;
  96816. /**
  96817. * Gets the current world space position of the camera.
  96818. */
  96819. get globalPosition(): Vector3;
  96820. /**
  96821. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  96822. * @returns the active meshe list
  96823. */
  96824. getActiveMeshes(): SmartArray<AbstractMesh>;
  96825. /**
  96826. * Check wether a mesh is part of the current active mesh list of the camera
  96827. * @param mesh Defines the mesh to check
  96828. * @returns true if active, false otherwise
  96829. */
  96830. isActiveMesh(mesh: Mesh): boolean;
  96831. /**
  96832. * Is this camera ready to be used/rendered
  96833. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  96834. * @return true if the camera is ready
  96835. */
  96836. isReady(completeCheck?: boolean): boolean;
  96837. /** @hidden */
  96838. _initCache(): void;
  96839. /** @hidden */
  96840. _updateCache(ignoreParentClass?: boolean): void;
  96841. /** @hidden */
  96842. _isSynchronized(): boolean;
  96843. /** @hidden */
  96844. _isSynchronizedViewMatrix(): boolean;
  96845. /** @hidden */
  96846. _isSynchronizedProjectionMatrix(): boolean;
  96847. /**
  96848. * Attach the input controls to a specific dom element to get the input from.
  96849. * @param element Defines the element the controls should be listened from
  96850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96851. */
  96852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96853. /**
  96854. * Detach the current controls from the specified dom element.
  96855. * @param element Defines the element to stop listening the inputs from
  96856. */
  96857. detachControl(element: HTMLElement): void;
  96858. /**
  96859. * Update the camera state according to the different inputs gathered during the frame.
  96860. */
  96861. update(): void;
  96862. /** @hidden */
  96863. _checkInputs(): void;
  96864. /** @hidden */
  96865. get rigCameras(): Camera[];
  96866. /**
  96867. * Gets the post process used by the rig cameras
  96868. */
  96869. get rigPostProcess(): Nullable<PostProcess>;
  96870. /**
  96871. * Internal, gets the first post proces.
  96872. * @returns the first post process to be run on this camera.
  96873. */
  96874. _getFirstPostProcess(): Nullable<PostProcess>;
  96875. private _cascadePostProcessesToRigCams;
  96876. /**
  96877. * Attach a post process to the camera.
  96878. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96879. * @param postProcess The post process to attach to the camera
  96880. * @param insertAt The position of the post process in case several of them are in use in the scene
  96881. * @returns the position the post process has been inserted at
  96882. */
  96883. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96884. /**
  96885. * Detach a post process to the camera.
  96886. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96887. * @param postProcess The post process to detach from the camera
  96888. */
  96889. detachPostProcess(postProcess: PostProcess): void;
  96890. /**
  96891. * Gets the current world matrix of the camera
  96892. */
  96893. getWorldMatrix(): Matrix;
  96894. /** @hidden */
  96895. _getViewMatrix(): Matrix;
  96896. /**
  96897. * Gets the current view matrix of the camera.
  96898. * @param force forces the camera to recompute the matrix without looking at the cached state
  96899. * @returns the view matrix
  96900. */
  96901. getViewMatrix(force?: boolean): Matrix;
  96902. /**
  96903. * Freeze the projection matrix.
  96904. * It will prevent the cache check of the camera projection compute and can speed up perf
  96905. * if no parameter of the camera are meant to change
  96906. * @param projection Defines manually a projection if necessary
  96907. */
  96908. freezeProjectionMatrix(projection?: Matrix): void;
  96909. /**
  96910. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96911. */
  96912. unfreezeProjectionMatrix(): void;
  96913. /**
  96914. * Gets the current projection matrix of the camera.
  96915. * @param force forces the camera to recompute the matrix without looking at the cached state
  96916. * @returns the projection matrix
  96917. */
  96918. getProjectionMatrix(force?: boolean): Matrix;
  96919. /**
  96920. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96921. * @returns a Matrix
  96922. */
  96923. getTransformationMatrix(): Matrix;
  96924. private _updateFrustumPlanes;
  96925. /**
  96926. * Checks if a cullable object (mesh...) is in the camera frustum
  96927. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96928. * @param target The object to check
  96929. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96930. * @returns true if the object is in frustum otherwise false
  96931. */
  96932. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96933. /**
  96934. * Checks if a cullable object (mesh...) is in the camera frustum
  96935. * Unlike isInFrustum this cheks the full bounding box
  96936. * @param target The object to check
  96937. * @returns true if the object is in frustum otherwise false
  96938. */
  96939. isCompletelyInFrustum(target: ICullable): boolean;
  96940. /**
  96941. * Gets a ray in the forward direction from the camera.
  96942. * @param length Defines the length of the ray to create
  96943. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96944. * @param origin Defines the start point of the ray which defaults to the camera position
  96945. * @returns the forward ray
  96946. */
  96947. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96948. /**
  96949. * Releases resources associated with this node.
  96950. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96951. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96952. */
  96953. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96954. /** @hidden */
  96955. _isLeftCamera: boolean;
  96956. /**
  96957. * Gets the left camera of a rig setup in case of Rigged Camera
  96958. */
  96959. get isLeftCamera(): boolean;
  96960. /** @hidden */
  96961. _isRightCamera: boolean;
  96962. /**
  96963. * Gets the right camera of a rig setup in case of Rigged Camera
  96964. */
  96965. get isRightCamera(): boolean;
  96966. /**
  96967. * Gets the left camera of a rig setup in case of Rigged Camera
  96968. */
  96969. get leftCamera(): Nullable<FreeCamera>;
  96970. /**
  96971. * Gets the right camera of a rig setup in case of Rigged Camera
  96972. */
  96973. get rightCamera(): Nullable<FreeCamera>;
  96974. /**
  96975. * Gets the left camera target of a rig setup in case of Rigged Camera
  96976. * @returns the target position
  96977. */
  96978. getLeftTarget(): Nullable<Vector3>;
  96979. /**
  96980. * Gets the right camera target of a rig setup in case of Rigged Camera
  96981. * @returns the target position
  96982. */
  96983. getRightTarget(): Nullable<Vector3>;
  96984. /**
  96985. * @hidden
  96986. */
  96987. setCameraRigMode(mode: number, rigParams: any): void;
  96988. /** @hidden */
  96989. static _setStereoscopicRigMode(camera: Camera): void;
  96990. /** @hidden */
  96991. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96992. /** @hidden */
  96993. static _setVRRigMode(camera: Camera, rigParams: any): void;
  96994. /** @hidden */
  96995. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  96996. /** @hidden */
  96997. _getVRProjectionMatrix(): Matrix;
  96998. protected _updateCameraRotationMatrix(): void;
  96999. protected _updateWebVRCameraRotationMatrix(): void;
  97000. /**
  97001. * This function MUST be overwritten by the different WebVR cameras available.
  97002. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  97003. * @hidden
  97004. */
  97005. _getWebVRProjectionMatrix(): Matrix;
  97006. /**
  97007. * This function MUST be overwritten by the different WebVR cameras available.
  97008. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  97009. * @hidden
  97010. */
  97011. _getWebVRViewMatrix(): Matrix;
  97012. /** @hidden */
  97013. setCameraRigParameter(name: string, value: any): void;
  97014. /**
  97015. * needs to be overridden by children so sub has required properties to be copied
  97016. * @hidden
  97017. */
  97018. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97019. /**
  97020. * May need to be overridden by children
  97021. * @hidden
  97022. */
  97023. _updateRigCameras(): void;
  97024. /** @hidden */
  97025. _setupInputs(): void;
  97026. /**
  97027. * Serialiaze the camera setup to a json represention
  97028. * @returns the JSON representation
  97029. */
  97030. serialize(): any;
  97031. /**
  97032. * Clones the current camera.
  97033. * @param name The cloned camera name
  97034. * @returns the cloned camera
  97035. */
  97036. clone(name: string): Camera;
  97037. /**
  97038. * Gets the direction of the camera relative to a given local axis.
  97039. * @param localAxis Defines the reference axis to provide a relative direction.
  97040. * @return the direction
  97041. */
  97042. getDirection(localAxis: Vector3): Vector3;
  97043. /**
  97044. * Returns the current camera absolute rotation
  97045. */
  97046. get absoluteRotation(): Quaternion;
  97047. /**
  97048. * Gets the direction of the camera relative to a given local axis into a passed vector.
  97049. * @param localAxis Defines the reference axis to provide a relative direction.
  97050. * @param result Defines the vector to store the result in
  97051. */
  97052. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  97053. /**
  97054. * Gets a camera constructor for a given camera type
  97055. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  97056. * @param name The name of the camera the result will be able to instantiate
  97057. * @param scene The scene the result will construct the camera in
  97058. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  97059. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  97060. * @returns a factory method to construc the camera
  97061. */
  97062. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  97063. /**
  97064. * Compute the world matrix of the camera.
  97065. * @returns the camera world matrix
  97066. */
  97067. computeWorldMatrix(): Matrix;
  97068. /**
  97069. * Parse a JSON and creates the camera from the parsed information
  97070. * @param parsedCamera The JSON to parse
  97071. * @param scene The scene to instantiate the camera in
  97072. * @returns the newly constructed camera
  97073. */
  97074. static Parse(parsedCamera: any, scene: Scene): Camera;
  97075. }
  97076. }
  97077. declare module BABYLON {
  97078. /**
  97079. * Class containing static functions to help procedurally build meshes
  97080. */
  97081. export class DiscBuilder {
  97082. /**
  97083. * Creates a plane polygonal mesh. By default, this is a disc
  97084. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  97085. * * 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
  97086. * * 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
  97087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97090. * @param name defines the name of the mesh
  97091. * @param options defines the options used to create the mesh
  97092. * @param scene defines the hosting scene
  97093. * @returns the plane polygonal mesh
  97094. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  97095. */
  97096. static CreateDisc(name: string, options: {
  97097. radius?: number;
  97098. tessellation?: number;
  97099. arc?: number;
  97100. updatable?: boolean;
  97101. sideOrientation?: number;
  97102. frontUVs?: Vector4;
  97103. backUVs?: Vector4;
  97104. }, scene?: Nullable<Scene>): Mesh;
  97105. }
  97106. }
  97107. declare module BABYLON {
  97108. /**
  97109. * This represents all the required information to add a fresnel effect on a material:
  97110. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97111. */
  97112. export class FresnelParameters {
  97113. private _isEnabled;
  97114. /**
  97115. * Define if the fresnel effect is enable or not.
  97116. */
  97117. get isEnabled(): boolean;
  97118. set isEnabled(value: boolean);
  97119. /**
  97120. * Define the color used on edges (grazing angle)
  97121. */
  97122. leftColor: Color3;
  97123. /**
  97124. * Define the color used on center
  97125. */
  97126. rightColor: Color3;
  97127. /**
  97128. * Define bias applied to computed fresnel term
  97129. */
  97130. bias: number;
  97131. /**
  97132. * Defined the power exponent applied to fresnel term
  97133. */
  97134. power: number;
  97135. /**
  97136. * Clones the current fresnel and its valuues
  97137. * @returns a clone fresnel configuration
  97138. */
  97139. clone(): FresnelParameters;
  97140. /**
  97141. * Serializes the current fresnel parameters to a JSON representation.
  97142. * @return the JSON serialization
  97143. */
  97144. serialize(): any;
  97145. /**
  97146. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  97147. * @param parsedFresnelParameters Define the JSON representation
  97148. * @returns the parsed parameters
  97149. */
  97150. static Parse(parsedFresnelParameters: any): FresnelParameters;
  97151. }
  97152. }
  97153. declare module BABYLON {
  97154. /**
  97155. * Base class of materials working in push mode in babylon JS
  97156. * @hidden
  97157. */
  97158. export class PushMaterial extends Material {
  97159. protected _activeEffect: Effect;
  97160. protected _normalMatrix: Matrix;
  97161. /**
  97162. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97163. * This means that the material can keep using a previous shader while a new one is being compiled.
  97164. * This is mostly used when shader parallel compilation is supported (true by default)
  97165. */
  97166. allowShaderHotSwapping: boolean;
  97167. constructor(name: string, scene: Scene);
  97168. getEffect(): Effect;
  97169. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97170. /**
  97171. * Binds the given world matrix to the active effect
  97172. *
  97173. * @param world the matrix to bind
  97174. */
  97175. bindOnlyWorldMatrix(world: Matrix): void;
  97176. /**
  97177. * Binds the given normal matrix to the active effect
  97178. *
  97179. * @param normalMatrix the matrix to bind
  97180. */
  97181. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97182. bind(world: Matrix, mesh?: Mesh): void;
  97183. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97184. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97185. }
  97186. }
  97187. declare module BABYLON {
  97188. /**
  97189. * This groups all the flags used to control the materials channel.
  97190. */
  97191. export class MaterialFlags {
  97192. private static _DiffuseTextureEnabled;
  97193. /**
  97194. * Are diffuse textures enabled in the application.
  97195. */
  97196. static get DiffuseTextureEnabled(): boolean;
  97197. static set DiffuseTextureEnabled(value: boolean);
  97198. private static _AmbientTextureEnabled;
  97199. /**
  97200. * Are ambient textures enabled in the application.
  97201. */
  97202. static get AmbientTextureEnabled(): boolean;
  97203. static set AmbientTextureEnabled(value: boolean);
  97204. private static _OpacityTextureEnabled;
  97205. /**
  97206. * Are opacity textures enabled in the application.
  97207. */
  97208. static get OpacityTextureEnabled(): boolean;
  97209. static set OpacityTextureEnabled(value: boolean);
  97210. private static _ReflectionTextureEnabled;
  97211. /**
  97212. * Are reflection textures enabled in the application.
  97213. */
  97214. static get ReflectionTextureEnabled(): boolean;
  97215. static set ReflectionTextureEnabled(value: boolean);
  97216. private static _EmissiveTextureEnabled;
  97217. /**
  97218. * Are emissive textures enabled in the application.
  97219. */
  97220. static get EmissiveTextureEnabled(): boolean;
  97221. static set EmissiveTextureEnabled(value: boolean);
  97222. private static _SpecularTextureEnabled;
  97223. /**
  97224. * Are specular textures enabled in the application.
  97225. */
  97226. static get SpecularTextureEnabled(): boolean;
  97227. static set SpecularTextureEnabled(value: boolean);
  97228. private static _BumpTextureEnabled;
  97229. /**
  97230. * Are bump textures enabled in the application.
  97231. */
  97232. static get BumpTextureEnabled(): boolean;
  97233. static set BumpTextureEnabled(value: boolean);
  97234. private static _LightmapTextureEnabled;
  97235. /**
  97236. * Are lightmap textures enabled in the application.
  97237. */
  97238. static get LightmapTextureEnabled(): boolean;
  97239. static set LightmapTextureEnabled(value: boolean);
  97240. private static _RefractionTextureEnabled;
  97241. /**
  97242. * Are refraction textures enabled in the application.
  97243. */
  97244. static get RefractionTextureEnabled(): boolean;
  97245. static set RefractionTextureEnabled(value: boolean);
  97246. private static _ColorGradingTextureEnabled;
  97247. /**
  97248. * Are color grading textures enabled in the application.
  97249. */
  97250. static get ColorGradingTextureEnabled(): boolean;
  97251. static set ColorGradingTextureEnabled(value: boolean);
  97252. private static _FresnelEnabled;
  97253. /**
  97254. * Are fresnels enabled in the application.
  97255. */
  97256. static get FresnelEnabled(): boolean;
  97257. static set FresnelEnabled(value: boolean);
  97258. private static _ClearCoatTextureEnabled;
  97259. /**
  97260. * Are clear coat textures enabled in the application.
  97261. */
  97262. static get ClearCoatTextureEnabled(): boolean;
  97263. static set ClearCoatTextureEnabled(value: boolean);
  97264. private static _ClearCoatBumpTextureEnabled;
  97265. /**
  97266. * Are clear coat bump textures enabled in the application.
  97267. */
  97268. static get ClearCoatBumpTextureEnabled(): boolean;
  97269. static set ClearCoatBumpTextureEnabled(value: boolean);
  97270. private static _ClearCoatTintTextureEnabled;
  97271. /**
  97272. * Are clear coat tint textures enabled in the application.
  97273. */
  97274. static get ClearCoatTintTextureEnabled(): boolean;
  97275. static set ClearCoatTintTextureEnabled(value: boolean);
  97276. private static _SheenTextureEnabled;
  97277. /**
  97278. * Are sheen textures enabled in the application.
  97279. */
  97280. static get SheenTextureEnabled(): boolean;
  97281. static set SheenTextureEnabled(value: boolean);
  97282. private static _AnisotropicTextureEnabled;
  97283. /**
  97284. * Are anisotropic textures enabled in the application.
  97285. */
  97286. static get AnisotropicTextureEnabled(): boolean;
  97287. static set AnisotropicTextureEnabled(value: boolean);
  97288. private static _ThicknessTextureEnabled;
  97289. /**
  97290. * Are thickness textures enabled in the application.
  97291. */
  97292. static get ThicknessTextureEnabled(): boolean;
  97293. static set ThicknessTextureEnabled(value: boolean);
  97294. }
  97295. }
  97296. declare module BABYLON {
  97297. /** @hidden */
  97298. export var defaultFragmentDeclaration: {
  97299. name: string;
  97300. shader: string;
  97301. };
  97302. }
  97303. declare module BABYLON {
  97304. /** @hidden */
  97305. export var defaultUboDeclaration: {
  97306. name: string;
  97307. shader: string;
  97308. };
  97309. }
  97310. declare module BABYLON {
  97311. /** @hidden */
  97312. export var lightFragmentDeclaration: {
  97313. name: string;
  97314. shader: string;
  97315. };
  97316. }
  97317. declare module BABYLON {
  97318. /** @hidden */
  97319. export var lightUboDeclaration: {
  97320. name: string;
  97321. shader: string;
  97322. };
  97323. }
  97324. declare module BABYLON {
  97325. /** @hidden */
  97326. export var lightsFragmentFunctions: {
  97327. name: string;
  97328. shader: string;
  97329. };
  97330. }
  97331. declare module BABYLON {
  97332. /** @hidden */
  97333. export var shadowsFragmentFunctions: {
  97334. name: string;
  97335. shader: string;
  97336. };
  97337. }
  97338. declare module BABYLON {
  97339. /** @hidden */
  97340. export var fresnelFunction: {
  97341. name: string;
  97342. shader: string;
  97343. };
  97344. }
  97345. declare module BABYLON {
  97346. /** @hidden */
  97347. export var reflectionFunction: {
  97348. name: string;
  97349. shader: string;
  97350. };
  97351. }
  97352. declare module BABYLON {
  97353. /** @hidden */
  97354. export var bumpFragmentFunctions: {
  97355. name: string;
  97356. shader: string;
  97357. };
  97358. }
  97359. declare module BABYLON {
  97360. /** @hidden */
  97361. export var logDepthDeclaration: {
  97362. name: string;
  97363. shader: string;
  97364. };
  97365. }
  97366. declare module BABYLON {
  97367. /** @hidden */
  97368. export var bumpFragment: {
  97369. name: string;
  97370. shader: string;
  97371. };
  97372. }
  97373. declare module BABYLON {
  97374. /** @hidden */
  97375. export var depthPrePass: {
  97376. name: string;
  97377. shader: string;
  97378. };
  97379. }
  97380. declare module BABYLON {
  97381. /** @hidden */
  97382. export var lightFragment: {
  97383. name: string;
  97384. shader: string;
  97385. };
  97386. }
  97387. declare module BABYLON {
  97388. /** @hidden */
  97389. export var logDepthFragment: {
  97390. name: string;
  97391. shader: string;
  97392. };
  97393. }
  97394. declare module BABYLON {
  97395. /** @hidden */
  97396. export var defaultPixelShader: {
  97397. name: string;
  97398. shader: string;
  97399. };
  97400. }
  97401. declare module BABYLON {
  97402. /** @hidden */
  97403. export var defaultVertexDeclaration: {
  97404. name: string;
  97405. shader: string;
  97406. };
  97407. }
  97408. declare module BABYLON {
  97409. /** @hidden */
  97410. export var bumpVertexDeclaration: {
  97411. name: string;
  97412. shader: string;
  97413. };
  97414. }
  97415. declare module BABYLON {
  97416. /** @hidden */
  97417. export var bumpVertex: {
  97418. name: string;
  97419. shader: string;
  97420. };
  97421. }
  97422. declare module BABYLON {
  97423. /** @hidden */
  97424. export var fogVertex: {
  97425. name: string;
  97426. shader: string;
  97427. };
  97428. }
  97429. declare module BABYLON {
  97430. /** @hidden */
  97431. export var shadowsVertex: {
  97432. name: string;
  97433. shader: string;
  97434. };
  97435. }
  97436. declare module BABYLON {
  97437. /** @hidden */
  97438. export var pointCloudVertex: {
  97439. name: string;
  97440. shader: string;
  97441. };
  97442. }
  97443. declare module BABYLON {
  97444. /** @hidden */
  97445. export var logDepthVertex: {
  97446. name: string;
  97447. shader: string;
  97448. };
  97449. }
  97450. declare module BABYLON {
  97451. /** @hidden */
  97452. export var defaultVertexShader: {
  97453. name: string;
  97454. shader: string;
  97455. };
  97456. }
  97457. declare module BABYLON {
  97458. /** @hidden */
  97459. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97460. MAINUV1: boolean;
  97461. MAINUV2: boolean;
  97462. DIFFUSE: boolean;
  97463. DIFFUSEDIRECTUV: number;
  97464. AMBIENT: boolean;
  97465. AMBIENTDIRECTUV: number;
  97466. OPACITY: boolean;
  97467. OPACITYDIRECTUV: number;
  97468. OPACITYRGB: boolean;
  97469. REFLECTION: boolean;
  97470. EMISSIVE: boolean;
  97471. EMISSIVEDIRECTUV: number;
  97472. SPECULAR: boolean;
  97473. SPECULARDIRECTUV: number;
  97474. BUMP: boolean;
  97475. BUMPDIRECTUV: number;
  97476. PARALLAX: boolean;
  97477. PARALLAXOCCLUSION: boolean;
  97478. SPECULAROVERALPHA: boolean;
  97479. CLIPPLANE: boolean;
  97480. CLIPPLANE2: boolean;
  97481. CLIPPLANE3: boolean;
  97482. CLIPPLANE4: boolean;
  97483. CLIPPLANE5: boolean;
  97484. CLIPPLANE6: boolean;
  97485. ALPHATEST: boolean;
  97486. DEPTHPREPASS: boolean;
  97487. ALPHAFROMDIFFUSE: boolean;
  97488. POINTSIZE: boolean;
  97489. FOG: boolean;
  97490. SPECULARTERM: boolean;
  97491. DIFFUSEFRESNEL: boolean;
  97492. OPACITYFRESNEL: boolean;
  97493. REFLECTIONFRESNEL: boolean;
  97494. REFRACTIONFRESNEL: boolean;
  97495. EMISSIVEFRESNEL: boolean;
  97496. FRESNEL: boolean;
  97497. NORMAL: boolean;
  97498. UV1: boolean;
  97499. UV2: boolean;
  97500. VERTEXCOLOR: boolean;
  97501. VERTEXALPHA: boolean;
  97502. NUM_BONE_INFLUENCERS: number;
  97503. BonesPerMesh: number;
  97504. BONETEXTURE: boolean;
  97505. INSTANCES: boolean;
  97506. GLOSSINESS: boolean;
  97507. ROUGHNESS: boolean;
  97508. EMISSIVEASILLUMINATION: boolean;
  97509. LINKEMISSIVEWITHDIFFUSE: boolean;
  97510. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97511. LIGHTMAP: boolean;
  97512. LIGHTMAPDIRECTUV: number;
  97513. OBJECTSPACE_NORMALMAP: boolean;
  97514. USELIGHTMAPASSHADOWMAP: boolean;
  97515. REFLECTIONMAP_3D: boolean;
  97516. REFLECTIONMAP_SPHERICAL: boolean;
  97517. REFLECTIONMAP_PLANAR: boolean;
  97518. REFLECTIONMAP_CUBIC: boolean;
  97519. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97520. REFLECTIONMAP_PROJECTION: boolean;
  97521. REFLECTIONMAP_SKYBOX: boolean;
  97522. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97523. REFLECTIONMAP_EXPLICIT: boolean;
  97524. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97525. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97526. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97527. INVERTCUBICMAP: boolean;
  97528. LOGARITHMICDEPTH: boolean;
  97529. REFRACTION: boolean;
  97530. REFRACTIONMAP_3D: boolean;
  97531. REFLECTIONOVERALPHA: boolean;
  97532. TWOSIDEDLIGHTING: boolean;
  97533. SHADOWFLOAT: boolean;
  97534. MORPHTARGETS: boolean;
  97535. MORPHTARGETS_NORMAL: boolean;
  97536. MORPHTARGETS_TANGENT: boolean;
  97537. MORPHTARGETS_UV: boolean;
  97538. NUM_MORPH_INFLUENCERS: number;
  97539. NONUNIFORMSCALING: boolean;
  97540. PREMULTIPLYALPHA: boolean;
  97541. IMAGEPROCESSING: boolean;
  97542. VIGNETTE: boolean;
  97543. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97544. VIGNETTEBLENDMODEOPAQUE: boolean;
  97545. TONEMAPPING: boolean;
  97546. TONEMAPPING_ACES: boolean;
  97547. CONTRAST: boolean;
  97548. COLORCURVES: boolean;
  97549. COLORGRADING: boolean;
  97550. COLORGRADING3D: boolean;
  97551. SAMPLER3DGREENDEPTH: boolean;
  97552. SAMPLER3DBGRMAP: boolean;
  97553. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97554. MULTIVIEW: boolean;
  97555. /**
  97556. * If the reflection texture on this material is in linear color space
  97557. * @hidden
  97558. */
  97559. IS_REFLECTION_LINEAR: boolean;
  97560. /**
  97561. * If the refraction texture on this material is in linear color space
  97562. * @hidden
  97563. */
  97564. IS_REFRACTION_LINEAR: boolean;
  97565. EXPOSURE: boolean;
  97566. constructor();
  97567. setReflectionMode(modeToEnable: string): void;
  97568. }
  97569. /**
  97570. * This is the default material used in Babylon. It is the best trade off between quality
  97571. * and performances.
  97572. * @see http://doc.babylonjs.com/babylon101/materials
  97573. */
  97574. export class StandardMaterial extends PushMaterial {
  97575. private _diffuseTexture;
  97576. /**
  97577. * The basic texture of the material as viewed under a light.
  97578. */
  97579. diffuseTexture: Nullable<BaseTexture>;
  97580. private _ambientTexture;
  97581. /**
  97582. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97583. */
  97584. ambientTexture: Nullable<BaseTexture>;
  97585. private _opacityTexture;
  97586. /**
  97587. * Define the transparency of the material from a texture.
  97588. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97589. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97590. */
  97591. opacityTexture: Nullable<BaseTexture>;
  97592. private _reflectionTexture;
  97593. /**
  97594. * Define the texture used to display the reflection.
  97595. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97596. */
  97597. reflectionTexture: Nullable<BaseTexture>;
  97598. private _emissiveTexture;
  97599. /**
  97600. * Define texture of the material as if self lit.
  97601. * This will be mixed in the final result even in the absence of light.
  97602. */
  97603. emissiveTexture: Nullable<BaseTexture>;
  97604. private _specularTexture;
  97605. /**
  97606. * Define how the color and intensity of the highlight given by the light in the material.
  97607. */
  97608. specularTexture: Nullable<BaseTexture>;
  97609. private _bumpTexture;
  97610. /**
  97611. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97612. * 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.
  97613. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97614. */
  97615. bumpTexture: Nullable<BaseTexture>;
  97616. private _lightmapTexture;
  97617. /**
  97618. * Complex lighting can be computationally expensive to compute at runtime.
  97619. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97620. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97621. */
  97622. lightmapTexture: Nullable<BaseTexture>;
  97623. private _refractionTexture;
  97624. /**
  97625. * Define the texture used to display the refraction.
  97626. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97627. */
  97628. refractionTexture: Nullable<BaseTexture>;
  97629. /**
  97630. * The color of the material lit by the environmental background lighting.
  97631. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97632. */
  97633. ambientColor: Color3;
  97634. /**
  97635. * The basic color of the material as viewed under a light.
  97636. */
  97637. diffuseColor: Color3;
  97638. /**
  97639. * Define how the color and intensity of the highlight given by the light in the material.
  97640. */
  97641. specularColor: Color3;
  97642. /**
  97643. * Define the color of the material as if self lit.
  97644. * This will be mixed in the final result even in the absence of light.
  97645. */
  97646. emissiveColor: Color3;
  97647. /**
  97648. * Defines how sharp are the highlights in the material.
  97649. * The bigger the value the sharper giving a more glossy feeling to the result.
  97650. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97651. */
  97652. specularPower: number;
  97653. private _useAlphaFromDiffuseTexture;
  97654. /**
  97655. * Does the transparency come from the diffuse texture alpha channel.
  97656. */
  97657. useAlphaFromDiffuseTexture: boolean;
  97658. private _useEmissiveAsIllumination;
  97659. /**
  97660. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97661. */
  97662. useEmissiveAsIllumination: boolean;
  97663. private _linkEmissiveWithDiffuse;
  97664. /**
  97665. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97666. * the emissive level when the final color is close to one.
  97667. */
  97668. linkEmissiveWithDiffuse: boolean;
  97669. private _useSpecularOverAlpha;
  97670. /**
  97671. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97672. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97673. */
  97674. useSpecularOverAlpha: boolean;
  97675. private _useReflectionOverAlpha;
  97676. /**
  97677. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97678. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97679. */
  97680. useReflectionOverAlpha: boolean;
  97681. private _disableLighting;
  97682. /**
  97683. * Does lights from the scene impacts this material.
  97684. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97685. */
  97686. disableLighting: boolean;
  97687. private _useObjectSpaceNormalMap;
  97688. /**
  97689. * Allows using an object space normal map (instead of tangent space).
  97690. */
  97691. useObjectSpaceNormalMap: boolean;
  97692. private _useParallax;
  97693. /**
  97694. * Is parallax enabled or not.
  97695. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97696. */
  97697. useParallax: boolean;
  97698. private _useParallaxOcclusion;
  97699. /**
  97700. * Is parallax occlusion enabled or not.
  97701. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97702. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97703. */
  97704. useParallaxOcclusion: boolean;
  97705. /**
  97706. * 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.
  97707. */
  97708. parallaxScaleBias: number;
  97709. private _roughness;
  97710. /**
  97711. * Helps to define how blurry the reflections should appears in the material.
  97712. */
  97713. roughness: number;
  97714. /**
  97715. * In case of refraction, define the value of the index of refraction.
  97716. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97717. */
  97718. indexOfRefraction: number;
  97719. /**
  97720. * Invert the refraction texture alongside the y axis.
  97721. * It can be useful with procedural textures or probe for instance.
  97722. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97723. */
  97724. invertRefractionY: boolean;
  97725. /**
  97726. * Defines the alpha limits in alpha test mode.
  97727. */
  97728. alphaCutOff: number;
  97729. private _useLightmapAsShadowmap;
  97730. /**
  97731. * In case of light mapping, define whether the map contains light or shadow informations.
  97732. */
  97733. useLightmapAsShadowmap: boolean;
  97734. private _diffuseFresnelParameters;
  97735. /**
  97736. * Define the diffuse fresnel parameters of the material.
  97737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97738. */
  97739. diffuseFresnelParameters: FresnelParameters;
  97740. private _opacityFresnelParameters;
  97741. /**
  97742. * Define the opacity fresnel parameters of the material.
  97743. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97744. */
  97745. opacityFresnelParameters: FresnelParameters;
  97746. private _reflectionFresnelParameters;
  97747. /**
  97748. * Define the reflection fresnel parameters of the material.
  97749. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97750. */
  97751. reflectionFresnelParameters: FresnelParameters;
  97752. private _refractionFresnelParameters;
  97753. /**
  97754. * Define the refraction fresnel parameters of the material.
  97755. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97756. */
  97757. refractionFresnelParameters: FresnelParameters;
  97758. private _emissiveFresnelParameters;
  97759. /**
  97760. * Define the emissive fresnel parameters of the material.
  97761. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97762. */
  97763. emissiveFresnelParameters: FresnelParameters;
  97764. private _useReflectionFresnelFromSpecular;
  97765. /**
  97766. * If true automatically deducts the fresnels values from the material specularity.
  97767. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97768. */
  97769. useReflectionFresnelFromSpecular: boolean;
  97770. private _useGlossinessFromSpecularMapAlpha;
  97771. /**
  97772. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97773. */
  97774. useGlossinessFromSpecularMapAlpha: boolean;
  97775. private _maxSimultaneousLights;
  97776. /**
  97777. * Defines the maximum number of lights that can be used in the material
  97778. */
  97779. maxSimultaneousLights: number;
  97780. private _invertNormalMapX;
  97781. /**
  97782. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97783. */
  97784. invertNormalMapX: boolean;
  97785. private _invertNormalMapY;
  97786. /**
  97787. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97788. */
  97789. invertNormalMapY: boolean;
  97790. private _twoSidedLighting;
  97791. /**
  97792. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97793. */
  97794. twoSidedLighting: boolean;
  97795. /**
  97796. * Default configuration related to image processing available in the standard Material.
  97797. */
  97798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97799. /**
  97800. * Gets the image processing configuration used either in this material.
  97801. */
  97802. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  97803. /**
  97804. * Sets the Default image processing configuration used either in the this material.
  97805. *
  97806. * If sets to null, the scene one is in use.
  97807. */
  97808. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  97809. /**
  97810. * Keep track of the image processing observer to allow dispose and replace.
  97811. */
  97812. private _imageProcessingObserver;
  97813. /**
  97814. * Attaches a new image processing configuration to the Standard Material.
  97815. * @param configuration
  97816. */
  97817. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97818. /**
  97819. * Gets wether the color curves effect is enabled.
  97820. */
  97821. get cameraColorCurvesEnabled(): boolean;
  97822. /**
  97823. * Sets wether the color curves effect is enabled.
  97824. */
  97825. set cameraColorCurvesEnabled(value: boolean);
  97826. /**
  97827. * Gets wether the color grading effect is enabled.
  97828. */
  97829. get cameraColorGradingEnabled(): boolean;
  97830. /**
  97831. * Gets wether the color grading effect is enabled.
  97832. */
  97833. set cameraColorGradingEnabled(value: boolean);
  97834. /**
  97835. * Gets wether tonemapping is enabled or not.
  97836. */
  97837. get cameraToneMappingEnabled(): boolean;
  97838. /**
  97839. * Sets wether tonemapping is enabled or not
  97840. */
  97841. set cameraToneMappingEnabled(value: boolean);
  97842. /**
  97843. * The camera exposure used on this material.
  97844. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97845. * This corresponds to a photographic exposure.
  97846. */
  97847. get cameraExposure(): number;
  97848. /**
  97849. * The camera exposure used on this material.
  97850. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97851. * This corresponds to a photographic exposure.
  97852. */
  97853. set cameraExposure(value: number);
  97854. /**
  97855. * Gets The camera contrast used on this material.
  97856. */
  97857. get cameraContrast(): number;
  97858. /**
  97859. * Sets The camera contrast used on this material.
  97860. */
  97861. set cameraContrast(value: number);
  97862. /**
  97863. * Gets the Color Grading 2D Lookup Texture.
  97864. */
  97865. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97866. /**
  97867. * Sets the Color Grading 2D Lookup Texture.
  97868. */
  97869. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97870. /**
  97871. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97872. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97873. * 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;
  97874. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97875. */
  97876. get cameraColorCurves(): Nullable<ColorCurves>;
  97877. /**
  97878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97880. * 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;
  97881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97882. */
  97883. set cameraColorCurves(value: Nullable<ColorCurves>);
  97884. /**
  97885. * Custom callback helping to override the default shader used in the material.
  97886. */
  97887. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97888. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97889. protected _worldViewProjectionMatrix: Matrix;
  97890. protected _globalAmbientColor: Color3;
  97891. protected _useLogarithmicDepth: boolean;
  97892. protected _rebuildInParallel: boolean;
  97893. /**
  97894. * Instantiates a new standard material.
  97895. * This is the default material used in Babylon. It is the best trade off between quality
  97896. * and performances.
  97897. * @see http://doc.babylonjs.com/babylon101/materials
  97898. * @param name Define the name of the material in the scene
  97899. * @param scene Define the scene the material belong to
  97900. */
  97901. constructor(name: string, scene: Scene);
  97902. /**
  97903. * Gets a boolean indicating that current material needs to register RTT
  97904. */
  97905. get hasRenderTargetTextures(): boolean;
  97906. /**
  97907. * Gets the current class name of the material e.g. "StandardMaterial"
  97908. * Mainly use in serialization.
  97909. * @returns the class name
  97910. */
  97911. getClassName(): string;
  97912. /**
  97913. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97914. * You can try switching to logarithmic depth.
  97915. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97916. */
  97917. get useLogarithmicDepth(): boolean;
  97918. set useLogarithmicDepth(value: boolean);
  97919. /**
  97920. * Specifies if the material will require alpha blending
  97921. * @returns a boolean specifying if alpha blending is needed
  97922. */
  97923. needAlphaBlending(): boolean;
  97924. /**
  97925. * Specifies if this material should be rendered in alpha test mode
  97926. * @returns a boolean specifying if an alpha test is needed.
  97927. */
  97928. needAlphaTesting(): boolean;
  97929. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97930. /**
  97931. * Get the texture used for alpha test purpose.
  97932. * @returns the diffuse texture in case of the standard material.
  97933. */
  97934. getAlphaTestTexture(): Nullable<BaseTexture>;
  97935. /**
  97936. * Get if the submesh is ready to be used and all its information available.
  97937. * Child classes can use it to update shaders
  97938. * @param mesh defines the mesh to check
  97939. * @param subMesh defines which submesh to check
  97940. * @param useInstances specifies that instances should be used
  97941. * @returns a boolean indicating that the submesh is ready or not
  97942. */
  97943. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97944. /**
  97945. * Builds the material UBO layouts.
  97946. * Used internally during the effect preparation.
  97947. */
  97948. buildUniformLayout(): void;
  97949. /**
  97950. * Unbinds the material from the mesh
  97951. */
  97952. unbind(): void;
  97953. /**
  97954. * Binds the submesh to this material by preparing the effect and shader to draw
  97955. * @param world defines the world transformation matrix
  97956. * @param mesh defines the mesh containing the submesh
  97957. * @param subMesh defines the submesh to bind the material to
  97958. */
  97959. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97960. /**
  97961. * Get the list of animatables in the material.
  97962. * @returns the list of animatables object used in the material
  97963. */
  97964. getAnimatables(): IAnimatable[];
  97965. /**
  97966. * Gets the active textures from the material
  97967. * @returns an array of textures
  97968. */
  97969. getActiveTextures(): BaseTexture[];
  97970. /**
  97971. * Specifies if the material uses a texture
  97972. * @param texture defines the texture to check against the material
  97973. * @returns a boolean specifying if the material uses the texture
  97974. */
  97975. hasTexture(texture: BaseTexture): boolean;
  97976. /**
  97977. * Disposes the material
  97978. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97979. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97980. */
  97981. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97982. /**
  97983. * Makes a duplicate of the material, and gives it a new name
  97984. * @param name defines the new name for the duplicated material
  97985. * @returns the cloned material
  97986. */
  97987. clone(name: string): StandardMaterial;
  97988. /**
  97989. * Serializes this material in a JSON representation
  97990. * @returns the serialized material object
  97991. */
  97992. serialize(): any;
  97993. /**
  97994. * Creates a standard material from parsed material data
  97995. * @param source defines the JSON representation of the material
  97996. * @param scene defines the hosting scene
  97997. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97998. * @returns a new standard material
  97999. */
  98000. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98001. /**
  98002. * Are diffuse textures enabled in the application.
  98003. */
  98004. static get DiffuseTextureEnabled(): boolean;
  98005. static set DiffuseTextureEnabled(value: boolean);
  98006. /**
  98007. * Are ambient textures enabled in the application.
  98008. */
  98009. static get AmbientTextureEnabled(): boolean;
  98010. static set AmbientTextureEnabled(value: boolean);
  98011. /**
  98012. * Are opacity textures enabled in the application.
  98013. */
  98014. static get OpacityTextureEnabled(): boolean;
  98015. static set OpacityTextureEnabled(value: boolean);
  98016. /**
  98017. * Are reflection textures enabled in the application.
  98018. */
  98019. static get ReflectionTextureEnabled(): boolean;
  98020. static set ReflectionTextureEnabled(value: boolean);
  98021. /**
  98022. * Are emissive textures enabled in the application.
  98023. */
  98024. static get EmissiveTextureEnabled(): boolean;
  98025. static set EmissiveTextureEnabled(value: boolean);
  98026. /**
  98027. * Are specular textures enabled in the application.
  98028. */
  98029. static get SpecularTextureEnabled(): boolean;
  98030. static set SpecularTextureEnabled(value: boolean);
  98031. /**
  98032. * Are bump textures enabled in the application.
  98033. */
  98034. static get BumpTextureEnabled(): boolean;
  98035. static set BumpTextureEnabled(value: boolean);
  98036. /**
  98037. * Are lightmap textures enabled in the application.
  98038. */
  98039. static get LightmapTextureEnabled(): boolean;
  98040. static set LightmapTextureEnabled(value: boolean);
  98041. /**
  98042. * Are refraction textures enabled in the application.
  98043. */
  98044. static get RefractionTextureEnabled(): boolean;
  98045. static set RefractionTextureEnabled(value: boolean);
  98046. /**
  98047. * Are color grading textures enabled in the application.
  98048. */
  98049. static get ColorGradingTextureEnabled(): boolean;
  98050. static set ColorGradingTextureEnabled(value: boolean);
  98051. /**
  98052. * Are fresnels enabled in the application.
  98053. */
  98054. static get FresnelEnabled(): boolean;
  98055. static set FresnelEnabled(value: boolean);
  98056. }
  98057. }
  98058. declare module BABYLON {
  98059. /**
  98060. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  98061. *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.
  98062. * The SPS is also a particle system. It provides some methods to manage the particles.
  98063. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  98064. *
  98065. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  98066. */
  98067. export class SolidParticleSystem implements IDisposable {
  98068. /**
  98069. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  98070. * Example : var p = SPS.particles[i];
  98071. */
  98072. particles: SolidParticle[];
  98073. /**
  98074. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  98075. */
  98076. nbParticles: number;
  98077. /**
  98078. * If the particles must ever face the camera (default false). Useful for planar particles.
  98079. */
  98080. billboard: boolean;
  98081. /**
  98082. * Recompute normals when adding a shape
  98083. */
  98084. recomputeNormals: boolean;
  98085. /**
  98086. * This a counter ofr your own usage. It's not set by any SPS functions.
  98087. */
  98088. counter: number;
  98089. /**
  98090. * The SPS name. This name is also given to the underlying mesh.
  98091. */
  98092. name: string;
  98093. /**
  98094. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  98095. */
  98096. mesh: Mesh;
  98097. /**
  98098. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  98099. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  98100. */
  98101. vars: any;
  98102. /**
  98103. * This array is populated when the SPS is set as 'pickable'.
  98104. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  98105. * Each element of this array is an object `{idx: int, faceId: int}`.
  98106. * `idx` is the picked particle index in the `SPS.particles` array
  98107. * `faceId` is the picked face index counted within this particle.
  98108. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  98109. */
  98110. pickedParticles: {
  98111. idx: number;
  98112. faceId: number;
  98113. }[];
  98114. /**
  98115. * This array is populated when `enableDepthSort` is set to true.
  98116. * Each element of this array is an instance of the class DepthSortedParticle.
  98117. */
  98118. depthSortedParticles: DepthSortedParticle[];
  98119. /**
  98120. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  98121. * @hidden
  98122. */
  98123. _bSphereOnly: boolean;
  98124. /**
  98125. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  98126. * @hidden
  98127. */
  98128. _bSphereRadiusFactor: number;
  98129. private _scene;
  98130. private _positions;
  98131. private _indices;
  98132. private _normals;
  98133. private _colors;
  98134. private _uvs;
  98135. private _indices32;
  98136. private _positions32;
  98137. private _normals32;
  98138. private _fixedNormal32;
  98139. private _colors32;
  98140. private _uvs32;
  98141. private _index;
  98142. private _updatable;
  98143. private _pickable;
  98144. private _isVisibilityBoxLocked;
  98145. private _alwaysVisible;
  98146. private _depthSort;
  98147. private _expandable;
  98148. private _shapeCounter;
  98149. private _copy;
  98150. private _color;
  98151. private _computeParticleColor;
  98152. private _computeParticleTexture;
  98153. private _computeParticleRotation;
  98154. private _computeParticleVertex;
  98155. private _computeBoundingBox;
  98156. private _depthSortParticles;
  98157. private _camera;
  98158. private _mustUnrotateFixedNormals;
  98159. private _particlesIntersect;
  98160. private _needs32Bits;
  98161. private _isNotBuilt;
  98162. private _lastParticleId;
  98163. private _idxOfId;
  98164. private _multimaterialEnabled;
  98165. private _useModelMaterial;
  98166. private _indicesByMaterial;
  98167. private _materialIndexes;
  98168. private _depthSortFunction;
  98169. private _materialSortFunction;
  98170. private _materials;
  98171. private _multimaterial;
  98172. private _materialIndexesById;
  98173. private _defaultMaterial;
  98174. private _autoUpdateSubMeshes;
  98175. /**
  98176. * Creates a SPS (Solid Particle System) object.
  98177. * @param name (String) is the SPS name, this will be the underlying mesh name.
  98178. * @param scene (Scene) is the scene in which the SPS is added.
  98179. * @param options defines the options of the sps e.g.
  98180. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  98181. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  98182. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  98183. * * 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.
  98184. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  98185. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  98186. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  98187. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  98188. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  98189. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  98190. */
  98191. constructor(name: string, scene: Scene, options?: {
  98192. updatable?: boolean;
  98193. isPickable?: boolean;
  98194. enableDepthSort?: boolean;
  98195. particleIntersection?: boolean;
  98196. boundingSphereOnly?: boolean;
  98197. bSphereRadiusFactor?: number;
  98198. expandable?: boolean;
  98199. useModelMaterial?: boolean;
  98200. enableMultiMaterial?: boolean;
  98201. });
  98202. /**
  98203. * Builds the SPS underlying mesh. Returns a standard Mesh.
  98204. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  98205. * @returns the created mesh
  98206. */
  98207. buildMesh(): Mesh;
  98208. /**
  98209. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  98210. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  98211. * Thus the particles generated from `digest()` have their property `position` set yet.
  98212. * @param mesh ( Mesh ) is the mesh to be digested
  98213. * @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
  98214. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  98215. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  98216. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  98217. * @returns the current SPS
  98218. */
  98219. digest(mesh: Mesh, options?: {
  98220. facetNb?: number;
  98221. number?: number;
  98222. delta?: number;
  98223. storage?: [];
  98224. }): SolidParticleSystem;
  98225. /**
  98226. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  98227. * @hidden
  98228. */
  98229. private _unrotateFixedNormals;
  98230. /**
  98231. * Resets the temporary working copy particle
  98232. * @hidden
  98233. */
  98234. private _resetCopy;
  98235. /**
  98236. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  98237. * @param p the current index in the positions array to be updated
  98238. * @param ind the current index in the indices array
  98239. * @param shape a Vector3 array, the shape geometry
  98240. * @param positions the positions array to be updated
  98241. * @param meshInd the shape indices array
  98242. * @param indices the indices array to be updated
  98243. * @param meshUV the shape uv array
  98244. * @param uvs the uv array to be updated
  98245. * @param meshCol the shape color array
  98246. * @param colors the color array to be updated
  98247. * @param meshNor the shape normals array
  98248. * @param normals the normals array to be updated
  98249. * @param idx the particle index
  98250. * @param idxInShape the particle index in its shape
  98251. * @param options the addShape() method passed options
  98252. * @model the particle model
  98253. * @hidden
  98254. */
  98255. private _meshBuilder;
  98256. /**
  98257. * Returns a shape Vector3 array from positions float array
  98258. * @param positions float array
  98259. * @returns a vector3 array
  98260. * @hidden
  98261. */
  98262. private _posToShape;
  98263. /**
  98264. * Returns a shapeUV array from a float uvs (array deep copy)
  98265. * @param uvs as a float array
  98266. * @returns a shapeUV array
  98267. * @hidden
  98268. */
  98269. private _uvsToShapeUV;
  98270. /**
  98271. * Adds a new particle object in the particles array
  98272. * @param idx particle index in particles array
  98273. * @param id particle id
  98274. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  98275. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  98276. * @param model particle ModelShape object
  98277. * @param shapeId model shape identifier
  98278. * @param idxInShape index of the particle in the current model
  98279. * @param bInfo model bounding info object
  98280. * @param storage target storage array, if any
  98281. * @hidden
  98282. */
  98283. private _addParticle;
  98284. /**
  98285. * Adds some particles to the SPS from the model shape. Returns the shape id.
  98286. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  98287. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  98288. * @param nb (positive integer) the number of particles to be created from this model
  98289. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  98290. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  98291. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  98292. * @returns the number of shapes in the system
  98293. */
  98294. addShape(mesh: Mesh, nb: number, options?: {
  98295. positionFunction?: any;
  98296. vertexFunction?: any;
  98297. storage?: [];
  98298. }): number;
  98299. /**
  98300. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  98301. * @hidden
  98302. */
  98303. private _rebuildParticle;
  98304. /**
  98305. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  98306. * @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.
  98307. * @returns the SPS.
  98308. */
  98309. rebuildMesh(reset?: boolean): SolidParticleSystem;
  98310. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  98311. * Returns an array with the removed particles.
  98312. * 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.
  98313. * The SPS can't be empty so at least one particle needs to remain in place.
  98314. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  98315. * @param start index of the first particle to remove
  98316. * @param end index of the last particle to remove (included)
  98317. * @returns an array populated with the removed particles
  98318. */
  98319. removeParticles(start: number, end: number): SolidParticle[];
  98320. /**
  98321. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  98322. * @param solidParticleArray an array populated with Solid Particles objects
  98323. * @returns the SPS
  98324. */
  98325. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  98326. /**
  98327. * Creates a new particle and modifies the SPS mesh geometry :
  98328. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  98329. * - calls _addParticle() to populate the particle array
  98330. * factorized code from addShape() and insertParticlesFromArray()
  98331. * @param idx particle index in the particles array
  98332. * @param i particle index in its shape
  98333. * @param modelShape particle ModelShape object
  98334. * @param shape shape vertex array
  98335. * @param meshInd shape indices array
  98336. * @param meshUV shape uv array
  98337. * @param meshCol shape color array
  98338. * @param meshNor shape normals array
  98339. * @param bbInfo shape bounding info
  98340. * @param storage target particle storage
  98341. * @options addShape() passed options
  98342. * @hidden
  98343. */
  98344. private _insertNewParticle;
  98345. /**
  98346. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  98347. * This method calls `updateParticle()` for each particle of the SPS.
  98348. * For an animated SPS, it is usually called within the render loop.
  98349. * 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.
  98350. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  98351. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  98352. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  98353. * @returns the SPS.
  98354. */
  98355. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  98356. /**
  98357. * Disposes the SPS.
  98358. */
  98359. dispose(): void;
  98360. /**
  98361. * Returns a SolidParticle object from its identifier : particle.id
  98362. * @param id (integer) the particle Id
  98363. * @returns the searched particle or null if not found in the SPS.
  98364. */
  98365. getParticleById(id: number): Nullable<SolidParticle>;
  98366. /**
  98367. * Returns a new array populated with the particles having the passed shapeId.
  98368. * @param shapeId (integer) the shape identifier
  98369. * @returns a new solid particle array
  98370. */
  98371. getParticlesByShapeId(shapeId: number): SolidParticle[];
  98372. /**
  98373. * Populates the passed array "ref" with the particles having the passed shapeId.
  98374. * @param shapeId the shape identifier
  98375. * @returns the SPS
  98376. * @param ref
  98377. */
  98378. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  98379. /**
  98380. * Computes the required SubMeshes according the materials assigned to the particles.
  98381. * @returns the solid particle system.
  98382. * Does nothing if called before the SPS mesh is built.
  98383. */
  98384. computeSubMeshes(): SolidParticleSystem;
  98385. /**
  98386. * Sorts the solid particles by material when MultiMaterial is enabled.
  98387. * Updates the indices32 array.
  98388. * Updates the indicesByMaterial array.
  98389. * Updates the mesh indices array.
  98390. * @returns the SPS
  98391. * @hidden
  98392. */
  98393. private _sortParticlesByMaterial;
  98394. /**
  98395. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  98396. * @hidden
  98397. */
  98398. private _setMaterialIndexesById;
  98399. /**
  98400. * Returns an array with unique values of Materials from the passed array
  98401. * @param array the material array to be checked and filtered
  98402. * @hidden
  98403. */
  98404. private _filterUniqueMaterialId;
  98405. /**
  98406. * Sets a new Standard Material as _defaultMaterial if not already set.
  98407. * @hidden
  98408. */
  98409. private _setDefaultMaterial;
  98410. /**
  98411. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  98412. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98413. * @returns the SPS.
  98414. */
  98415. refreshVisibleSize(): SolidParticleSystem;
  98416. /**
  98417. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  98418. * @param size the size (float) of the visibility box
  98419. * note : this doesn't lock the SPS mesh bounding box.
  98420. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98421. */
  98422. setVisibilityBox(size: number): void;
  98423. /**
  98424. * Gets whether the SPS as always visible or not
  98425. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98426. */
  98427. get isAlwaysVisible(): boolean;
  98428. /**
  98429. * Sets the SPS as always visible or not
  98430. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98431. */
  98432. set isAlwaysVisible(val: boolean);
  98433. /**
  98434. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  98435. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98436. */
  98437. set isVisibilityBoxLocked(val: boolean);
  98438. /**
  98439. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  98440. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98441. */
  98442. get isVisibilityBoxLocked(): boolean;
  98443. /**
  98444. * Tells to `setParticles()` to compute the particle rotations or not.
  98445. * Default value : true. The SPS is faster when it's set to false.
  98446. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  98447. */
  98448. set computeParticleRotation(val: boolean);
  98449. /**
  98450. * Tells to `setParticles()` to compute the particle colors or not.
  98451. * Default value : true. The SPS is faster when it's set to false.
  98452. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  98453. */
  98454. set computeParticleColor(val: boolean);
  98455. set computeParticleTexture(val: boolean);
  98456. /**
  98457. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  98458. * Default value : false. The SPS is faster when it's set to false.
  98459. * Note : the particle custom vertex positions aren't stored values.
  98460. */
  98461. set computeParticleVertex(val: boolean);
  98462. /**
  98463. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  98464. */
  98465. set computeBoundingBox(val: boolean);
  98466. /**
  98467. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  98468. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  98469. * Default : `true`
  98470. */
  98471. set depthSortParticles(val: boolean);
  98472. /**
  98473. * Gets if `setParticles()` computes the particle rotations or not.
  98474. * Default value : true. The SPS is faster when it's set to false.
  98475. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  98476. */
  98477. get computeParticleRotation(): boolean;
  98478. /**
  98479. * Gets if `setParticles()` computes the particle colors or not.
  98480. * Default value : true. The SPS is faster when it's set to false.
  98481. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  98482. */
  98483. get computeParticleColor(): boolean;
  98484. /**
  98485. * Gets if `setParticles()` computes the particle textures or not.
  98486. * Default value : true. The SPS is faster when it's set to false.
  98487. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  98488. */
  98489. get computeParticleTexture(): boolean;
  98490. /**
  98491. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  98492. * Default value : false. The SPS is faster when it's set to false.
  98493. * Note : the particle custom vertex positions aren't stored values.
  98494. */
  98495. get computeParticleVertex(): boolean;
  98496. /**
  98497. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  98498. */
  98499. get computeBoundingBox(): boolean;
  98500. /**
  98501. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  98502. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  98503. * Default : `true`
  98504. */
  98505. get depthSortParticles(): boolean;
  98506. /**
  98507. * Gets if the SPS is created as expandable at construction time.
  98508. * Default : `false`
  98509. */
  98510. get expandable(): boolean;
  98511. /**
  98512. * Gets if the SPS supports the Multi Materials
  98513. */
  98514. get multimaterialEnabled(): boolean;
  98515. /**
  98516. * Gets if the SPS uses the model materials for its own multimaterial.
  98517. */
  98518. get useModelMaterial(): boolean;
  98519. /**
  98520. * The SPS used material array.
  98521. */
  98522. get materials(): Material[];
  98523. /**
  98524. * Sets the SPS MultiMaterial from the passed materials.
  98525. * Note : the passed array is internally copied and not used then by reference.
  98526. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  98527. */
  98528. setMultiMaterial(materials: Material[]): void;
  98529. /**
  98530. * The SPS computed multimaterial object
  98531. */
  98532. get multimaterial(): MultiMaterial;
  98533. set multimaterial(mm: MultiMaterial);
  98534. /**
  98535. * If the subMeshes must be updated on the next call to setParticles()
  98536. */
  98537. get autoUpdateSubMeshes(): boolean;
  98538. set autoUpdateSubMeshes(val: boolean);
  98539. /**
  98540. * This function does nothing. It may be overwritten to set all the particle first values.
  98541. * The SPS doesn't call this function, you may have to call it by your own.
  98542. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  98543. */
  98544. initParticles(): void;
  98545. /**
  98546. * This function does nothing. It may be overwritten to recycle a particle.
  98547. * The SPS doesn't call this function, you may have to call it by your own.
  98548. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  98549. * @param particle The particle to recycle
  98550. * @returns the recycled particle
  98551. */
  98552. recycleParticle(particle: SolidParticle): SolidParticle;
  98553. /**
  98554. * Updates a particle : this function should be overwritten by the user.
  98555. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  98556. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  98557. * @example : just set a particle position or velocity and recycle conditions
  98558. * @param particle The particle to update
  98559. * @returns the updated particle
  98560. */
  98561. updateParticle(particle: SolidParticle): SolidParticle;
  98562. /**
  98563. * Updates a vertex of a particle : it can be overwritten by the user.
  98564. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  98565. * @param particle the current particle
  98566. * @param vertex the current index of the current particle
  98567. * @param pt the index of the current vertex in the particle shape
  98568. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  98569. * @example : just set a vertex particle position
  98570. * @returns the updated vertex
  98571. */
  98572. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  98573. /**
  98574. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  98575. * This does nothing and may be overwritten by the user.
  98576. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98577. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98578. * @param update the boolean update value actually passed to setParticles()
  98579. */
  98580. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  98581. /**
  98582. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  98583. * This will be passed three parameters.
  98584. * This does nothing and may be overwritten by the user.
  98585. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98586. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98587. * @param update the boolean update value actually passed to setParticles()
  98588. */
  98589. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  98590. }
  98591. }
  98592. declare module BABYLON {
  98593. /**
  98594. * Represents one particle of a solid particle system.
  98595. */
  98596. export class SolidParticle {
  98597. /**
  98598. * particle global index
  98599. */
  98600. idx: number;
  98601. /**
  98602. * particle identifier
  98603. */
  98604. id: number;
  98605. /**
  98606. * The color of the particle
  98607. */
  98608. color: Nullable<Color4>;
  98609. /**
  98610. * The world space position of the particle.
  98611. */
  98612. position: Vector3;
  98613. /**
  98614. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  98615. */
  98616. rotation: Vector3;
  98617. /**
  98618. * The world space rotation quaternion of the particle.
  98619. */
  98620. rotationQuaternion: Nullable<Quaternion>;
  98621. /**
  98622. * The scaling of the particle.
  98623. */
  98624. scaling: Vector3;
  98625. /**
  98626. * The uvs of the particle.
  98627. */
  98628. uvs: Vector4;
  98629. /**
  98630. * The current speed of the particle.
  98631. */
  98632. velocity: Vector3;
  98633. /**
  98634. * The pivot point in the particle local space.
  98635. */
  98636. pivot: Vector3;
  98637. /**
  98638. * Must the particle be translated from its pivot point in its local space ?
  98639. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  98640. * Default : false
  98641. */
  98642. translateFromPivot: boolean;
  98643. /**
  98644. * Is the particle active or not ?
  98645. */
  98646. alive: boolean;
  98647. /**
  98648. * Is the particle visible or not ?
  98649. */
  98650. isVisible: boolean;
  98651. /**
  98652. * Index of this particle in the global "positions" array (Internal use)
  98653. * @hidden
  98654. */
  98655. _pos: number;
  98656. /**
  98657. * @hidden Index of this particle in the global "indices" array (Internal use)
  98658. */
  98659. _ind: number;
  98660. /**
  98661. * @hidden ModelShape of this particle (Internal use)
  98662. */
  98663. _model: ModelShape;
  98664. /**
  98665. * ModelShape id of this particle
  98666. */
  98667. shapeId: number;
  98668. /**
  98669. * Index of the particle in its shape id
  98670. */
  98671. idxInShape: number;
  98672. /**
  98673. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  98674. */
  98675. _modelBoundingInfo: BoundingInfo;
  98676. /**
  98677. * @hidden Particle BoundingInfo object (Internal use)
  98678. */
  98679. _boundingInfo: BoundingInfo;
  98680. /**
  98681. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  98682. */
  98683. _sps: SolidParticleSystem;
  98684. /**
  98685. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  98686. */
  98687. _stillInvisible: boolean;
  98688. /**
  98689. * @hidden Last computed particle rotation matrix
  98690. */
  98691. _rotationMatrix: number[];
  98692. /**
  98693. * Parent particle Id, if any.
  98694. * Default null.
  98695. */
  98696. parentId: Nullable<number>;
  98697. /**
  98698. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  98699. */
  98700. materialIndex: Nullable<number>;
  98701. /**
  98702. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  98703. * The possible values are :
  98704. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98705. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98706. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98707. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98708. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98709. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  98710. * */
  98711. cullingStrategy: number;
  98712. /**
  98713. * @hidden Internal global position in the SPS.
  98714. */
  98715. _globalPosition: Vector3;
  98716. /**
  98717. * Creates a Solid Particle object.
  98718. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  98719. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  98720. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  98721. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  98722. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  98723. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  98724. * @param shapeId (integer) is the model shape identifier in the SPS.
  98725. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  98726. * @param sps defines the sps it is associated to
  98727. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  98728. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  98729. */
  98730. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  98731. /**
  98732. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  98733. * @param target the particle target
  98734. * @returns the current particle
  98735. */
  98736. copyToRef(target: SolidParticle): SolidParticle;
  98737. /**
  98738. * Legacy support, changed scale to scaling
  98739. */
  98740. get scale(): Vector3;
  98741. /**
  98742. * Legacy support, changed scale to scaling
  98743. */
  98744. set scale(scale: Vector3);
  98745. /**
  98746. * Legacy support, changed quaternion to rotationQuaternion
  98747. */
  98748. get quaternion(): Nullable<Quaternion>;
  98749. /**
  98750. * Legacy support, changed quaternion to rotationQuaternion
  98751. */
  98752. set quaternion(q: Nullable<Quaternion>);
  98753. /**
  98754. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  98755. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  98756. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  98757. * @returns true if it intersects
  98758. */
  98759. intersectsMesh(target: Mesh | SolidParticle): boolean;
  98760. /**
  98761. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  98762. * A particle is in the frustum if its bounding box intersects the frustum
  98763. * @param frustumPlanes defines the frustum to test
  98764. * @returns true if the particle is in the frustum planes
  98765. */
  98766. isInFrustum(frustumPlanes: Plane[]): boolean;
  98767. /**
  98768. * get the rotation matrix of the particle
  98769. * @hidden
  98770. */
  98771. getRotationMatrix(m: Matrix): void;
  98772. }
  98773. /**
  98774. * Represents the shape of the model used by one particle of a solid particle system.
  98775. * SPS internal tool, don't use it manually.
  98776. */
  98777. export class ModelShape {
  98778. /**
  98779. * The shape id
  98780. * @hidden
  98781. */
  98782. shapeID: number;
  98783. /**
  98784. * flat array of model positions (internal use)
  98785. * @hidden
  98786. */
  98787. _shape: Vector3[];
  98788. /**
  98789. * flat array of model UVs (internal use)
  98790. * @hidden
  98791. */
  98792. _shapeUV: number[];
  98793. /**
  98794. * color array of the model
  98795. * @hidden
  98796. */
  98797. _shapeColors: number[];
  98798. /**
  98799. * indices array of the model
  98800. * @hidden
  98801. */
  98802. _indices: number[];
  98803. /**
  98804. * normals array of the model
  98805. * @hidden
  98806. */
  98807. _normals: number[];
  98808. /**
  98809. * length of the shape in the model indices array (internal use)
  98810. * @hidden
  98811. */
  98812. _indicesLength: number;
  98813. /**
  98814. * Custom position function (internal use)
  98815. * @hidden
  98816. */
  98817. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  98818. /**
  98819. * Custom vertex function (internal use)
  98820. * @hidden
  98821. */
  98822. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  98823. /**
  98824. * Model material (internal use)
  98825. * @hidden
  98826. */
  98827. _material: Nullable<Material>;
  98828. /**
  98829. * 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.
  98830. * SPS internal tool, don't use it manually.
  98831. * @hidden
  98832. */
  98833. 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>);
  98834. }
  98835. /**
  98836. * Represents a Depth Sorted Particle in the solid particle system.
  98837. * @hidden
  98838. */
  98839. export class DepthSortedParticle {
  98840. /**
  98841. * Index of the particle in the "indices" array
  98842. */
  98843. ind: number;
  98844. /**
  98845. * Length of the particle shape in the "indices" array
  98846. */
  98847. indicesLength: number;
  98848. /**
  98849. * Squared distance from the particle to the camera
  98850. */
  98851. sqDistance: number;
  98852. /**
  98853. * Material index when used with MultiMaterials
  98854. */
  98855. materialIndex: number;
  98856. /**
  98857. * Creates a new sorted particle
  98858. * @param materialIndex
  98859. */
  98860. constructor(ind: number, indLength: number, materialIndex: number);
  98861. }
  98862. }
  98863. declare module BABYLON {
  98864. /**
  98865. * @hidden
  98866. */
  98867. export class _MeshCollisionData {
  98868. _checkCollisions: boolean;
  98869. _collisionMask: number;
  98870. _collisionGroup: number;
  98871. _collider: Nullable<Collider>;
  98872. _oldPositionForCollisions: Vector3;
  98873. _diffPositionForCollisions: Vector3;
  98874. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98875. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98876. }
  98877. }
  98878. declare module BABYLON {
  98879. /** @hidden */
  98880. class _FacetDataStorage {
  98881. facetPositions: Vector3[];
  98882. facetNormals: Vector3[];
  98883. facetPartitioning: number[][];
  98884. facetNb: number;
  98885. partitioningSubdivisions: number;
  98886. partitioningBBoxRatio: number;
  98887. facetDataEnabled: boolean;
  98888. facetParameters: any;
  98889. bbSize: Vector3;
  98890. subDiv: {
  98891. max: number;
  98892. X: number;
  98893. Y: number;
  98894. Z: number;
  98895. };
  98896. facetDepthSort: boolean;
  98897. facetDepthSortEnabled: boolean;
  98898. depthSortedIndices: IndicesArray;
  98899. depthSortedFacets: {
  98900. ind: number;
  98901. sqDistance: number;
  98902. }[];
  98903. facetDepthSortFunction: (f1: {
  98904. ind: number;
  98905. sqDistance: number;
  98906. }, f2: {
  98907. ind: number;
  98908. sqDistance: number;
  98909. }) => number;
  98910. facetDepthSortFrom: Vector3;
  98911. facetDepthSortOrigin: Vector3;
  98912. invertedMatrix: Matrix;
  98913. }
  98914. /**
  98915. * @hidden
  98916. **/
  98917. class _InternalAbstractMeshDataInfo {
  98918. _hasVertexAlpha: boolean;
  98919. _useVertexColors: boolean;
  98920. _numBoneInfluencers: number;
  98921. _applyFog: boolean;
  98922. _receiveShadows: boolean;
  98923. _facetData: _FacetDataStorage;
  98924. _visibility: number;
  98925. _skeleton: Nullable<Skeleton>;
  98926. _layerMask: number;
  98927. _computeBonesUsingShaders: boolean;
  98928. _isActive: boolean;
  98929. _onlyForInstances: boolean;
  98930. _isActiveIntermediate: boolean;
  98931. _onlyForInstancesIntermediate: boolean;
  98932. _actAsRegularMesh: boolean;
  98933. }
  98934. /**
  98935. * Class used to store all common mesh properties
  98936. */
  98937. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98938. /** No occlusion */
  98939. static OCCLUSION_TYPE_NONE: number;
  98940. /** Occlusion set to optimisitic */
  98941. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98942. /** Occlusion set to strict */
  98943. static OCCLUSION_TYPE_STRICT: number;
  98944. /** Use an accurante occlusion algorithm */
  98945. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98946. /** Use a conservative occlusion algorithm */
  98947. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98948. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98949. * Test order :
  98950. * Is the bounding sphere outside the frustum ?
  98951. * If not, are the bounding box vertices outside the frustum ?
  98952. * It not, then the cullable object is in the frustum.
  98953. */
  98954. static readonly CULLINGSTRATEGY_STANDARD: number;
  98955. /** Culling strategy : Bounding Sphere Only.
  98956. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98957. * It's also less accurate than the standard because some not visible objects can still be selected.
  98958. * Test : is the bounding sphere outside the frustum ?
  98959. * If not, then the cullable object is in the frustum.
  98960. */
  98961. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98962. /** Culling strategy : Optimistic Inclusion.
  98963. * This in an inclusion test first, then the standard exclusion test.
  98964. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98965. * 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.
  98966. * Anyway, it's as accurate as the standard strategy.
  98967. * Test :
  98968. * Is the cullable object bounding sphere center in the frustum ?
  98969. * If not, apply the default culling strategy.
  98970. */
  98971. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98972. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98973. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98974. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98975. * 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.
  98976. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98977. * Test :
  98978. * Is the cullable object bounding sphere center in the frustum ?
  98979. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98980. */
  98981. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98982. /**
  98983. * No billboard
  98984. */
  98985. static get BILLBOARDMODE_NONE(): number;
  98986. /** Billboard on X axis */
  98987. static get BILLBOARDMODE_X(): number;
  98988. /** Billboard on Y axis */
  98989. static get BILLBOARDMODE_Y(): number;
  98990. /** Billboard on Z axis */
  98991. static get BILLBOARDMODE_Z(): number;
  98992. /** Billboard on all axes */
  98993. static get BILLBOARDMODE_ALL(): number;
  98994. /** Billboard on using position instead of orientation */
  98995. static get BILLBOARDMODE_USE_POSITION(): number;
  98996. /** @hidden */
  98997. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  98998. /**
  98999. * The culling strategy to use to check whether the mesh must be rendered or not.
  99000. * This value can be changed at any time and will be used on the next render mesh selection.
  99001. * The possible values are :
  99002. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  99003. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  99004. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  99005. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  99006. * Please read each static variable documentation to get details about the culling process.
  99007. * */
  99008. cullingStrategy: number;
  99009. /**
  99010. * Gets the number of facets in the mesh
  99011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  99012. */
  99013. get facetNb(): number;
  99014. /**
  99015. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  99016. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  99017. */
  99018. get partitioningSubdivisions(): number;
  99019. set partitioningSubdivisions(nb: number);
  99020. /**
  99021. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  99022. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  99023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  99024. */
  99025. get partitioningBBoxRatio(): number;
  99026. set partitioningBBoxRatio(ratio: number);
  99027. /**
  99028. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  99029. * Works only for updatable meshes.
  99030. * Doesn't work with multi-materials
  99031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  99032. */
  99033. get mustDepthSortFacets(): boolean;
  99034. set mustDepthSortFacets(sort: boolean);
  99035. /**
  99036. * The location (Vector3) where the facet depth sort must be computed from.
  99037. * By default, the active camera position.
  99038. * Used only when facet depth sort is enabled
  99039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  99040. */
  99041. get facetDepthSortFrom(): Vector3;
  99042. set facetDepthSortFrom(location: Vector3);
  99043. /**
  99044. * gets a boolean indicating if facetData is enabled
  99045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  99046. */
  99047. get isFacetDataEnabled(): boolean;
  99048. /** @hidden */
  99049. _updateNonUniformScalingState(value: boolean): boolean;
  99050. /**
  99051. * An event triggered when this mesh collides with another one
  99052. */
  99053. onCollideObservable: Observable<AbstractMesh>;
  99054. /** Set a function to call when this mesh collides with another one */
  99055. set onCollide(callback: () => void);
  99056. /**
  99057. * An event triggered when the collision's position changes
  99058. */
  99059. onCollisionPositionChangeObservable: Observable<Vector3>;
  99060. /** Set a function to call when the collision's position changes */
  99061. set onCollisionPositionChange(callback: () => void);
  99062. /**
  99063. * An event triggered when material is changed
  99064. */
  99065. onMaterialChangedObservable: Observable<AbstractMesh>;
  99066. /**
  99067. * Gets or sets the orientation for POV movement & rotation
  99068. */
  99069. definedFacingForward: boolean;
  99070. /** @hidden */
  99071. _occlusionQuery: Nullable<WebGLQuery>;
  99072. /** @hidden */
  99073. _renderingGroup: Nullable<RenderingGroup>;
  99074. /**
  99075. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  99076. */
  99077. get visibility(): number;
  99078. /**
  99079. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  99080. */
  99081. set visibility(value: number);
  99082. /** Gets or sets the alpha index used to sort transparent meshes
  99083. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  99084. */
  99085. alphaIndex: number;
  99086. /**
  99087. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  99088. */
  99089. isVisible: boolean;
  99090. /**
  99091. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  99092. */
  99093. isPickable: boolean;
  99094. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  99095. showSubMeshesBoundingBox: boolean;
  99096. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  99097. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  99098. */
  99099. isBlocker: boolean;
  99100. /**
  99101. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  99102. */
  99103. enablePointerMoveEvents: boolean;
  99104. /**
  99105. * Specifies the rendering group id for this mesh (0 by default)
  99106. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  99107. */
  99108. renderingGroupId: number;
  99109. private _material;
  99110. /** Gets or sets current material */
  99111. get material(): Nullable<Material>;
  99112. set material(value: Nullable<Material>);
  99113. /**
  99114. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  99115. * @see http://doc.babylonjs.com/babylon101/shadows
  99116. */
  99117. get receiveShadows(): boolean;
  99118. set receiveShadows(value: boolean);
  99119. /** Defines color to use when rendering outline */
  99120. outlineColor: Color3;
  99121. /** Define width to use when rendering outline */
  99122. outlineWidth: number;
  99123. /** Defines color to use when rendering overlay */
  99124. overlayColor: Color3;
  99125. /** Defines alpha to use when rendering overlay */
  99126. overlayAlpha: number;
  99127. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  99128. get hasVertexAlpha(): boolean;
  99129. set hasVertexAlpha(value: boolean);
  99130. /** 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) */
  99131. get useVertexColors(): boolean;
  99132. set useVertexColors(value: boolean);
  99133. /**
  99134. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  99135. */
  99136. get computeBonesUsingShaders(): boolean;
  99137. set computeBonesUsingShaders(value: boolean);
  99138. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  99139. get numBoneInfluencers(): number;
  99140. set numBoneInfluencers(value: number);
  99141. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  99142. get applyFog(): boolean;
  99143. set applyFog(value: boolean);
  99144. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  99145. useOctreeForRenderingSelection: boolean;
  99146. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  99147. useOctreeForPicking: boolean;
  99148. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  99149. useOctreeForCollisions: boolean;
  99150. /**
  99151. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  99152. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  99153. */
  99154. get layerMask(): number;
  99155. set layerMask(value: number);
  99156. /**
  99157. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  99158. */
  99159. alwaysSelectAsActiveMesh: boolean;
  99160. /**
  99161. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  99162. */
  99163. doNotSyncBoundingInfo: boolean;
  99164. /**
  99165. * Gets or sets the current action manager
  99166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99167. */
  99168. actionManager: Nullable<AbstractActionManager>;
  99169. private _meshCollisionData;
  99170. /**
  99171. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  99172. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99173. */
  99174. ellipsoid: Vector3;
  99175. /**
  99176. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  99177. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99178. */
  99179. ellipsoidOffset: Vector3;
  99180. /**
  99181. * Gets or sets a collision mask used to mask collisions (default is -1).
  99182. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  99183. */
  99184. get collisionMask(): number;
  99185. set collisionMask(mask: number);
  99186. /**
  99187. * Gets or sets the current collision group mask (-1 by default).
  99188. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  99189. */
  99190. get collisionGroup(): number;
  99191. set collisionGroup(mask: number);
  99192. /**
  99193. * Defines edge width used when edgesRenderer is enabled
  99194. * @see https://www.babylonjs-playground.com/#10OJSG#13
  99195. */
  99196. edgesWidth: number;
  99197. /**
  99198. * Defines edge color used when edgesRenderer is enabled
  99199. * @see https://www.babylonjs-playground.com/#10OJSG#13
  99200. */
  99201. edgesColor: Color4;
  99202. /** @hidden */
  99203. _edgesRenderer: Nullable<IEdgesRenderer>;
  99204. /** @hidden */
  99205. _masterMesh: Nullable<AbstractMesh>;
  99206. /** @hidden */
  99207. _boundingInfo: Nullable<BoundingInfo>;
  99208. /** @hidden */
  99209. _renderId: number;
  99210. /**
  99211. * Gets or sets the list of subMeshes
  99212. * @see http://doc.babylonjs.com/how_to/multi_materials
  99213. */
  99214. subMeshes: SubMesh[];
  99215. /** @hidden */
  99216. _intersectionsInProgress: AbstractMesh[];
  99217. /** @hidden */
  99218. _unIndexed: boolean;
  99219. /** @hidden */
  99220. _lightSources: Light[];
  99221. /** Gets the list of lights affecting that mesh */
  99222. get lightSources(): Light[];
  99223. /** @hidden */
  99224. get _positions(): Nullable<Vector3[]>;
  99225. /** @hidden */
  99226. _waitingData: {
  99227. lods: Nullable<any>;
  99228. actions: Nullable<any>;
  99229. freezeWorldMatrix: Nullable<boolean>;
  99230. };
  99231. /** @hidden */
  99232. _bonesTransformMatrices: Nullable<Float32Array>;
  99233. /** @hidden */
  99234. _transformMatrixTexture: Nullable<RawTexture>;
  99235. /**
  99236. * Gets or sets a skeleton to apply skining transformations
  99237. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99238. */
  99239. set skeleton(value: Nullable<Skeleton>);
  99240. get skeleton(): Nullable<Skeleton>;
  99241. /**
  99242. * An event triggered when the mesh is rebuilt.
  99243. */
  99244. onRebuildObservable: Observable<AbstractMesh>;
  99245. /**
  99246. * Creates a new AbstractMesh
  99247. * @param name defines the name of the mesh
  99248. * @param scene defines the hosting scene
  99249. */
  99250. constructor(name: string, scene?: Nullable<Scene>);
  99251. /**
  99252. * Returns the string "AbstractMesh"
  99253. * @returns "AbstractMesh"
  99254. */
  99255. getClassName(): string;
  99256. /**
  99257. * Gets a string representation of the current mesh
  99258. * @param fullDetails defines a boolean indicating if full details must be included
  99259. * @returns a string representation of the current mesh
  99260. */
  99261. toString(fullDetails?: boolean): string;
  99262. /**
  99263. * @hidden
  99264. */
  99265. protected _getEffectiveParent(): Nullable<Node>;
  99266. /** @hidden */
  99267. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99268. /** @hidden */
  99269. _rebuild(): void;
  99270. /** @hidden */
  99271. _resyncLightSources(): void;
  99272. /** @hidden */
  99273. _resyncLightSource(light: Light): void;
  99274. /** @hidden */
  99275. _unBindEffect(): void;
  99276. /** @hidden */
  99277. _removeLightSource(light: Light, dispose: boolean): void;
  99278. private _markSubMeshesAsDirty;
  99279. /** @hidden */
  99280. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  99281. /** @hidden */
  99282. _markSubMeshesAsAttributesDirty(): void;
  99283. /** @hidden */
  99284. _markSubMeshesAsMiscDirty(): void;
  99285. /**
  99286. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  99287. */
  99288. get scaling(): Vector3;
  99289. set scaling(newScaling: Vector3);
  99290. /**
  99291. * Returns true if the mesh is blocked. Implemented by child classes
  99292. */
  99293. get isBlocked(): boolean;
  99294. /**
  99295. * Returns the mesh itself by default. Implemented by child classes
  99296. * @param camera defines the camera to use to pick the right LOD level
  99297. * @returns the currentAbstractMesh
  99298. */
  99299. getLOD(camera: Camera): Nullable<AbstractMesh>;
  99300. /**
  99301. * Returns 0 by default. Implemented by child classes
  99302. * @returns an integer
  99303. */
  99304. getTotalVertices(): number;
  99305. /**
  99306. * Returns a positive integer : the total number of indices in this mesh geometry.
  99307. * @returns the numner of indices or zero if the mesh has no geometry.
  99308. */
  99309. getTotalIndices(): number;
  99310. /**
  99311. * Returns null by default. Implemented by child classes
  99312. * @returns null
  99313. */
  99314. getIndices(): Nullable<IndicesArray>;
  99315. /**
  99316. * Returns the array of the requested vertex data kind. Implemented by child classes
  99317. * @param kind defines the vertex data kind to use
  99318. * @returns null
  99319. */
  99320. getVerticesData(kind: string): Nullable<FloatArray>;
  99321. /**
  99322. * Sets the vertex data of the mesh geometry for the requested `kind`.
  99323. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  99324. * Note that a new underlying VertexBuffer object is created each call.
  99325. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  99326. * @param kind defines vertex data kind:
  99327. * * VertexBuffer.PositionKind
  99328. * * VertexBuffer.UVKind
  99329. * * VertexBuffer.UV2Kind
  99330. * * VertexBuffer.UV3Kind
  99331. * * VertexBuffer.UV4Kind
  99332. * * VertexBuffer.UV5Kind
  99333. * * VertexBuffer.UV6Kind
  99334. * * VertexBuffer.ColorKind
  99335. * * VertexBuffer.MatricesIndicesKind
  99336. * * VertexBuffer.MatricesIndicesExtraKind
  99337. * * VertexBuffer.MatricesWeightsKind
  99338. * * VertexBuffer.MatricesWeightsExtraKind
  99339. * @param data defines the data source
  99340. * @param updatable defines if the data must be flagged as updatable (or static)
  99341. * @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
  99342. * @returns the current mesh
  99343. */
  99344. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99345. /**
  99346. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  99347. * If the mesh has no geometry, it is simply returned as it is.
  99348. * @param kind defines vertex data kind:
  99349. * * VertexBuffer.PositionKind
  99350. * * VertexBuffer.UVKind
  99351. * * VertexBuffer.UV2Kind
  99352. * * VertexBuffer.UV3Kind
  99353. * * VertexBuffer.UV4Kind
  99354. * * VertexBuffer.UV5Kind
  99355. * * VertexBuffer.UV6Kind
  99356. * * VertexBuffer.ColorKind
  99357. * * VertexBuffer.MatricesIndicesKind
  99358. * * VertexBuffer.MatricesIndicesExtraKind
  99359. * * VertexBuffer.MatricesWeightsKind
  99360. * * VertexBuffer.MatricesWeightsExtraKind
  99361. * @param data defines the data source
  99362. * @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
  99363. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  99364. * @returns the current mesh
  99365. */
  99366. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99367. /**
  99368. * Sets the mesh indices,
  99369. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  99370. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  99371. * @param totalVertices Defines the total number of vertices
  99372. * @returns the current mesh
  99373. */
  99374. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  99375. /**
  99376. * Gets a boolean indicating if specific vertex data is present
  99377. * @param kind defines the vertex data kind to use
  99378. * @returns true is data kind is present
  99379. */
  99380. isVerticesDataPresent(kind: string): boolean;
  99381. /**
  99382. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  99383. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  99384. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  99385. * @returns a BoundingInfo
  99386. */
  99387. getBoundingInfo(): BoundingInfo;
  99388. /**
  99389. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  99390. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  99391. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  99392. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  99393. * @returns the current mesh
  99394. */
  99395. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  99396. /**
  99397. * Overwrite the current bounding info
  99398. * @param boundingInfo defines the new bounding info
  99399. * @returns the current mesh
  99400. */
  99401. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  99402. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  99403. get useBones(): boolean;
  99404. /** @hidden */
  99405. _preActivate(): void;
  99406. /** @hidden */
  99407. _preActivateForIntermediateRendering(renderId: number): void;
  99408. /** @hidden */
  99409. _activate(renderId: number, intermediateRendering: boolean): boolean;
  99410. /** @hidden */
  99411. _postActivate(): void;
  99412. /** @hidden */
  99413. _freeze(): void;
  99414. /** @hidden */
  99415. _unFreeze(): void;
  99416. /**
  99417. * Gets the current world matrix
  99418. * @returns a Matrix
  99419. */
  99420. getWorldMatrix(): Matrix;
  99421. /** @hidden */
  99422. _getWorldMatrixDeterminant(): number;
  99423. /**
  99424. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  99425. */
  99426. get isAnInstance(): boolean;
  99427. /**
  99428. * Gets a boolean indicating if this mesh has instances
  99429. */
  99430. get hasInstances(): boolean;
  99431. /**
  99432. * Perform relative position change from the point of view of behind the front of the mesh.
  99433. * This is performed taking into account the meshes current rotation, so you do not have to care.
  99434. * Supports definition of mesh facing forward or backward
  99435. * @param amountRight defines the distance on the right axis
  99436. * @param amountUp defines the distance on the up axis
  99437. * @param amountForward defines the distance on the forward axis
  99438. * @returns the current mesh
  99439. */
  99440. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  99441. /**
  99442. * Calculate relative position change from the point of view of behind the front of the mesh.
  99443. * This is performed taking into account the meshes current rotation, so you do not have to care.
  99444. * Supports definition of mesh facing forward or backward
  99445. * @param amountRight defines the distance on the right axis
  99446. * @param amountUp defines the distance on the up axis
  99447. * @param amountForward defines the distance on the forward axis
  99448. * @returns the new displacement vector
  99449. */
  99450. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  99451. /**
  99452. * Perform relative rotation change from the point of view of behind the front of the mesh.
  99453. * Supports definition of mesh facing forward or backward
  99454. * @param flipBack defines the flip
  99455. * @param twirlClockwise defines the twirl
  99456. * @param tiltRight defines the tilt
  99457. * @returns the current mesh
  99458. */
  99459. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  99460. /**
  99461. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  99462. * Supports definition of mesh facing forward or backward.
  99463. * @param flipBack defines the flip
  99464. * @param twirlClockwise defines the twirl
  99465. * @param tiltRight defines the tilt
  99466. * @returns the new rotation vector
  99467. */
  99468. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  99469. /**
  99470. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99471. * This means the mesh underlying bounding box and sphere are recomputed.
  99472. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99473. * @returns the current mesh
  99474. */
  99475. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  99476. /** @hidden */
  99477. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  99478. /** @hidden */
  99479. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  99480. /** @hidden */
  99481. _updateBoundingInfo(): AbstractMesh;
  99482. /** @hidden */
  99483. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  99484. /** @hidden */
  99485. protected _afterComputeWorldMatrix(): void;
  99486. /** @hidden */
  99487. get _effectiveMesh(): AbstractMesh;
  99488. /**
  99489. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99490. * A mesh is in the frustum if its bounding box intersects the frustum
  99491. * @param frustumPlanes defines the frustum to test
  99492. * @returns true if the mesh is in the frustum planes
  99493. */
  99494. isInFrustum(frustumPlanes: Plane[]): boolean;
  99495. /**
  99496. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  99497. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  99498. * @param frustumPlanes defines the frustum to test
  99499. * @returns true if the mesh is completely in the frustum planes
  99500. */
  99501. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  99502. /**
  99503. * True if the mesh intersects another mesh or a SolidParticle object
  99504. * @param mesh defines a target mesh or SolidParticle to test
  99505. * @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)
  99506. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  99507. * @returns true if there is an intersection
  99508. */
  99509. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  99510. /**
  99511. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  99512. * @param point defines the point to test
  99513. * @returns true if there is an intersection
  99514. */
  99515. intersectsPoint(point: Vector3): boolean;
  99516. /**
  99517. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  99518. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99519. */
  99520. get checkCollisions(): boolean;
  99521. set checkCollisions(collisionEnabled: boolean);
  99522. /**
  99523. * Gets Collider object used to compute collisions (not physics)
  99524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99525. */
  99526. get collider(): Nullable<Collider>;
  99527. /**
  99528. * Move the mesh using collision engine
  99529. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99530. * @param displacement defines the requested displacement vector
  99531. * @returns the current mesh
  99532. */
  99533. moveWithCollisions(displacement: Vector3): AbstractMesh;
  99534. private _onCollisionPositionChange;
  99535. /** @hidden */
  99536. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  99537. /** @hidden */
  99538. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  99539. /** @hidden */
  99540. _checkCollision(collider: Collider): AbstractMesh;
  99541. /** @hidden */
  99542. _generatePointsArray(): boolean;
  99543. /**
  99544. * Checks if the passed Ray intersects with the mesh
  99545. * @param ray defines the ray to use
  99546. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  99547. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99548. * @returns the picking info
  99549. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  99550. */
  99551. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  99552. /**
  99553. * Clones the current mesh
  99554. * @param name defines the mesh name
  99555. * @param newParent defines the new mesh parent
  99556. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  99557. * @returns the new mesh
  99558. */
  99559. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  99560. /**
  99561. * Disposes all the submeshes of the current meshnp
  99562. * @returns the current mesh
  99563. */
  99564. releaseSubMeshes(): AbstractMesh;
  99565. /**
  99566. * Releases resources associated with this abstract mesh.
  99567. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99568. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99569. */
  99570. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99571. /**
  99572. * Adds the passed mesh as a child to the current mesh
  99573. * @param mesh defines the child mesh
  99574. * @returns the current mesh
  99575. */
  99576. addChild(mesh: AbstractMesh): AbstractMesh;
  99577. /**
  99578. * Removes the passed mesh from the current mesh children list
  99579. * @param mesh defines the child mesh
  99580. * @returns the current mesh
  99581. */
  99582. removeChild(mesh: AbstractMesh): AbstractMesh;
  99583. /** @hidden */
  99584. private _initFacetData;
  99585. /**
  99586. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  99587. * This method can be called within the render loop.
  99588. * 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
  99589. * @returns the current mesh
  99590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99591. */
  99592. updateFacetData(): AbstractMesh;
  99593. /**
  99594. * Returns the facetLocalNormals array.
  99595. * The normals are expressed in the mesh local spac
  99596. * @returns an array of Vector3
  99597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99598. */
  99599. getFacetLocalNormals(): Vector3[];
  99600. /**
  99601. * Returns the facetLocalPositions array.
  99602. * The facet positions are expressed in the mesh local space
  99603. * @returns an array of Vector3
  99604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99605. */
  99606. getFacetLocalPositions(): Vector3[];
  99607. /**
  99608. * Returns the facetLocalPartioning array
  99609. * @returns an array of array of numbers
  99610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99611. */
  99612. getFacetLocalPartitioning(): number[][];
  99613. /**
  99614. * Returns the i-th facet position in the world system.
  99615. * This method allocates a new Vector3 per call
  99616. * @param i defines the facet index
  99617. * @returns a new Vector3
  99618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99619. */
  99620. getFacetPosition(i: number): Vector3;
  99621. /**
  99622. * Sets the reference Vector3 with the i-th facet position in the world system
  99623. * @param i defines the facet index
  99624. * @param ref defines the target vector
  99625. * @returns the current mesh
  99626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99627. */
  99628. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  99629. /**
  99630. * Returns the i-th facet normal in the world system.
  99631. * This method allocates a new Vector3 per call
  99632. * @param i defines the facet index
  99633. * @returns a new Vector3
  99634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99635. */
  99636. getFacetNormal(i: number): Vector3;
  99637. /**
  99638. * Sets the reference Vector3 with the i-th facet normal in the world system
  99639. * @param i defines the facet index
  99640. * @param ref defines the target vector
  99641. * @returns the current mesh
  99642. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99643. */
  99644. getFacetNormalToRef(i: number, ref: Vector3): this;
  99645. /**
  99646. * 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)
  99647. * @param x defines x coordinate
  99648. * @param y defines y coordinate
  99649. * @param z defines z coordinate
  99650. * @returns the array of facet indexes
  99651. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99652. */
  99653. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  99654. /**
  99655. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  99656. * @param projected sets as the (x,y,z) world projection on the facet
  99657. * @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
  99658. * @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
  99659. * @param x defines x coordinate
  99660. * @param y defines y coordinate
  99661. * @param z defines z coordinate
  99662. * @returns the face index if found (or null instead)
  99663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99664. */
  99665. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  99666. /**
  99667. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  99668. * @param projected sets as the (x,y,z) local projection on the facet
  99669. * @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
  99670. * @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
  99671. * @param x defines x coordinate
  99672. * @param y defines y coordinate
  99673. * @param z defines z coordinate
  99674. * @returns the face index if found (or null instead)
  99675. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99676. */
  99677. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  99678. /**
  99679. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  99680. * @returns the parameters
  99681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99682. */
  99683. getFacetDataParameters(): any;
  99684. /**
  99685. * Disables the feature FacetData and frees the related memory
  99686. * @returns the current mesh
  99687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99688. */
  99689. disableFacetData(): AbstractMesh;
  99690. /**
  99691. * Updates the AbstractMesh indices array
  99692. * @param indices defines the data source
  99693. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99694. * @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)
  99695. * @returns the current mesh
  99696. */
  99697. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99698. /**
  99699. * Creates new normals data for the mesh
  99700. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  99701. * @returns the current mesh
  99702. */
  99703. createNormals(updatable: boolean): AbstractMesh;
  99704. /**
  99705. * Align the mesh with a normal
  99706. * @param normal defines the normal to use
  99707. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  99708. * @returns the current mesh
  99709. */
  99710. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  99711. /** @hidden */
  99712. _checkOcclusionQuery(): boolean;
  99713. /**
  99714. * Disables the mesh edge rendering mode
  99715. * @returns the currentAbstractMesh
  99716. */
  99717. disableEdgesRendering(): AbstractMesh;
  99718. /**
  99719. * Enables the edge rendering mode on the mesh.
  99720. * This mode makes the mesh edges visible
  99721. * @param epsilon defines the maximal distance between two angles to detect a face
  99722. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  99723. * @returns the currentAbstractMesh
  99724. * @see https://www.babylonjs-playground.com/#19O9TU#0
  99725. */
  99726. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  99727. }
  99728. }
  99729. declare module BABYLON {
  99730. /**
  99731. * Interface used to define ActionEvent
  99732. */
  99733. export interface IActionEvent {
  99734. /** The mesh or sprite that triggered the action */
  99735. source: any;
  99736. /** The X mouse cursor position at the time of the event */
  99737. pointerX: number;
  99738. /** The Y mouse cursor position at the time of the event */
  99739. pointerY: number;
  99740. /** The mesh that is currently pointed at (can be null) */
  99741. meshUnderPointer: Nullable<AbstractMesh>;
  99742. /** the original (browser) event that triggered the ActionEvent */
  99743. sourceEvent?: any;
  99744. /** additional data for the event */
  99745. additionalData?: any;
  99746. }
  99747. /**
  99748. * ActionEvent is the event being sent when an action is triggered.
  99749. */
  99750. export class ActionEvent implements IActionEvent {
  99751. /** The mesh or sprite that triggered the action */
  99752. source: any;
  99753. /** The X mouse cursor position at the time of the event */
  99754. pointerX: number;
  99755. /** The Y mouse cursor position at the time of the event */
  99756. pointerY: number;
  99757. /** The mesh that is currently pointed at (can be null) */
  99758. meshUnderPointer: Nullable<AbstractMesh>;
  99759. /** the original (browser) event that triggered the ActionEvent */
  99760. sourceEvent?: any;
  99761. /** additional data for the event */
  99762. additionalData?: any;
  99763. /**
  99764. * Creates a new ActionEvent
  99765. * @param source The mesh or sprite that triggered the action
  99766. * @param pointerX The X mouse cursor position at the time of the event
  99767. * @param pointerY The Y mouse cursor position at the time of the event
  99768. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  99769. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  99770. * @param additionalData additional data for the event
  99771. */
  99772. constructor(
  99773. /** The mesh or sprite that triggered the action */
  99774. source: any,
  99775. /** The X mouse cursor position at the time of the event */
  99776. pointerX: number,
  99777. /** The Y mouse cursor position at the time of the event */
  99778. pointerY: number,
  99779. /** The mesh that is currently pointed at (can be null) */
  99780. meshUnderPointer: Nullable<AbstractMesh>,
  99781. /** the original (browser) event that triggered the ActionEvent */
  99782. sourceEvent?: any,
  99783. /** additional data for the event */
  99784. additionalData?: any);
  99785. /**
  99786. * Helper function to auto-create an ActionEvent from a source mesh.
  99787. * @param source The source mesh that triggered the event
  99788. * @param evt The original (browser) event
  99789. * @param additionalData additional data for the event
  99790. * @returns the new ActionEvent
  99791. */
  99792. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  99793. /**
  99794. * Helper function to auto-create an ActionEvent from a source sprite
  99795. * @param source The source sprite that triggered the event
  99796. * @param scene Scene associated with the sprite
  99797. * @param evt The original (browser) event
  99798. * @param additionalData additional data for the event
  99799. * @returns the new ActionEvent
  99800. */
  99801. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  99802. /**
  99803. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  99804. * @param scene the scene where the event occurred
  99805. * @param evt The original (browser) event
  99806. * @returns the new ActionEvent
  99807. */
  99808. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  99809. /**
  99810. * Helper function to auto-create an ActionEvent from a primitive
  99811. * @param prim defines the target primitive
  99812. * @param pointerPos defines the pointer position
  99813. * @param evt The original (browser) event
  99814. * @param additionalData additional data for the event
  99815. * @returns the new ActionEvent
  99816. */
  99817. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  99818. }
  99819. }
  99820. declare module BABYLON {
  99821. /**
  99822. * Abstract class used to decouple action Manager from scene and meshes.
  99823. * Do not instantiate.
  99824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99825. */
  99826. export abstract class AbstractActionManager implements IDisposable {
  99827. /** Gets the list of active triggers */
  99828. static Triggers: {
  99829. [key: string]: number;
  99830. };
  99831. /** Gets the cursor to use when hovering items */
  99832. hoverCursor: string;
  99833. /** Gets the list of actions */
  99834. actions: IAction[];
  99835. /**
  99836. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  99837. */
  99838. isRecursive: boolean;
  99839. /**
  99840. * Releases all associated resources
  99841. */
  99842. abstract dispose(): void;
  99843. /**
  99844. * Does this action manager has pointer triggers
  99845. */
  99846. abstract get hasPointerTriggers(): boolean;
  99847. /**
  99848. * Does this action manager has pick triggers
  99849. */
  99850. abstract get hasPickTriggers(): boolean;
  99851. /**
  99852. * Process a specific trigger
  99853. * @param trigger defines the trigger to process
  99854. * @param evt defines the event details to be processed
  99855. */
  99856. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99857. /**
  99858. * Does this action manager handles actions of any of the given triggers
  99859. * @param triggers defines the triggers to be tested
  99860. * @return a boolean indicating whether one (or more) of the triggers is handled
  99861. */
  99862. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99863. /**
  99864. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99865. * speed.
  99866. * @param triggerA defines the trigger to be tested
  99867. * @param triggerB defines the trigger to be tested
  99868. * @return a boolean indicating whether one (or more) of the triggers is handled
  99869. */
  99870. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99871. /**
  99872. * Does this action manager handles actions of a given trigger
  99873. * @param trigger defines the trigger to be tested
  99874. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99875. * @return whether the trigger is handled
  99876. */
  99877. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99878. /**
  99879. * Serialize this manager to a JSON object
  99880. * @param name defines the property name to store this manager
  99881. * @returns a JSON representation of this manager
  99882. */
  99883. abstract serialize(name: string): any;
  99884. /**
  99885. * Registers an action to this action manager
  99886. * @param action defines the action to be registered
  99887. * @return the action amended (prepared) after registration
  99888. */
  99889. abstract registerAction(action: IAction): Nullable<IAction>;
  99890. /**
  99891. * Unregisters an action to this action manager
  99892. * @param action defines the action to be unregistered
  99893. * @return a boolean indicating whether the action has been unregistered
  99894. */
  99895. abstract unregisterAction(action: IAction): Boolean;
  99896. /**
  99897. * Does exist one action manager with at least one trigger
  99898. **/
  99899. static get HasTriggers(): boolean;
  99900. /**
  99901. * Does exist one action manager with at least one pick trigger
  99902. **/
  99903. static get HasPickTriggers(): boolean;
  99904. /**
  99905. * Does exist one action manager that handles actions of a given trigger
  99906. * @param trigger defines the trigger to be tested
  99907. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99908. **/
  99909. static HasSpecificTrigger(trigger: number): boolean;
  99910. }
  99911. }
  99912. declare module BABYLON {
  99913. /**
  99914. * Defines how a node can be built from a string name.
  99915. */
  99916. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99917. /**
  99918. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99919. */
  99920. export class Node implements IBehaviorAware<Node> {
  99921. /** @hidden */
  99922. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99923. private static _NodeConstructors;
  99924. /**
  99925. * Add a new node constructor
  99926. * @param type defines the type name of the node to construct
  99927. * @param constructorFunc defines the constructor function
  99928. */
  99929. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99930. /**
  99931. * Returns a node constructor based on type name
  99932. * @param type defines the type name
  99933. * @param name defines the new node name
  99934. * @param scene defines the hosting scene
  99935. * @param options defines optional options to transmit to constructors
  99936. * @returns the new constructor or null
  99937. */
  99938. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99939. /**
  99940. * Gets or sets the name of the node
  99941. */
  99942. name: string;
  99943. /**
  99944. * Gets or sets the id of the node
  99945. */
  99946. id: string;
  99947. /**
  99948. * Gets or sets the unique id of the node
  99949. */
  99950. uniqueId: number;
  99951. /**
  99952. * Gets or sets a string used to store user defined state for the node
  99953. */
  99954. state: string;
  99955. /**
  99956. * Gets or sets an object used to store user defined information for the node
  99957. */
  99958. metadata: any;
  99959. /**
  99960. * For internal use only. Please do not use.
  99961. */
  99962. reservedDataStore: any;
  99963. /**
  99964. * List of inspectable custom properties (used by the Inspector)
  99965. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99966. */
  99967. inspectableCustomProperties: IInspectable[];
  99968. private _doNotSerialize;
  99969. /**
  99970. * Gets or sets a boolean used to define if the node must be serialized
  99971. */
  99972. get doNotSerialize(): boolean;
  99973. set doNotSerialize(value: boolean);
  99974. /** @hidden */
  99975. _isDisposed: boolean;
  99976. /**
  99977. * Gets a list of Animations associated with the node
  99978. */
  99979. animations: Animation[];
  99980. protected _ranges: {
  99981. [name: string]: Nullable<AnimationRange>;
  99982. };
  99983. /**
  99984. * Callback raised when the node is ready to be used
  99985. */
  99986. onReady: Nullable<(node: Node) => void>;
  99987. private _isEnabled;
  99988. private _isParentEnabled;
  99989. private _isReady;
  99990. /** @hidden */
  99991. _currentRenderId: number;
  99992. private _parentUpdateId;
  99993. /** @hidden */
  99994. _childUpdateId: number;
  99995. /** @hidden */
  99996. _waitingParentId: Nullable<string>;
  99997. /** @hidden */
  99998. _scene: Scene;
  99999. /** @hidden */
  100000. _cache: any;
  100001. private _parentNode;
  100002. private _children;
  100003. /** @hidden */
  100004. _worldMatrix: Matrix;
  100005. /** @hidden */
  100006. _worldMatrixDeterminant: number;
  100007. /** @hidden */
  100008. _worldMatrixDeterminantIsDirty: boolean;
  100009. /** @hidden */
  100010. private _sceneRootNodesIndex;
  100011. /**
  100012. * Gets a boolean indicating if the node has been disposed
  100013. * @returns true if the node was disposed
  100014. */
  100015. isDisposed(): boolean;
  100016. /**
  100017. * Gets or sets the parent of the node (without keeping the current position in the scene)
  100018. * @see https://doc.babylonjs.com/how_to/parenting
  100019. */
  100020. set parent(parent: Nullable<Node>);
  100021. get parent(): Nullable<Node>;
  100022. /** @hidden */
  100023. _addToSceneRootNodes(): void;
  100024. /** @hidden */
  100025. _removeFromSceneRootNodes(): void;
  100026. private _animationPropertiesOverride;
  100027. /**
  100028. * Gets or sets the animation properties override
  100029. */
  100030. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  100031. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  100032. /**
  100033. * Gets a string idenfifying the name of the class
  100034. * @returns "Node" string
  100035. */
  100036. getClassName(): string;
  100037. /** @hidden */
  100038. readonly _isNode: boolean;
  100039. /**
  100040. * An event triggered when the mesh is disposed
  100041. */
  100042. onDisposeObservable: Observable<Node>;
  100043. private _onDisposeObserver;
  100044. /**
  100045. * Sets a callback that will be raised when the node will be disposed
  100046. */
  100047. set onDispose(callback: () => void);
  100048. /**
  100049. * Creates a new Node
  100050. * @param name the name and id to be given to this node
  100051. * @param scene the scene this node will be added to
  100052. */
  100053. constructor(name: string, scene?: Nullable<Scene>);
  100054. /**
  100055. * Gets the scene of the node
  100056. * @returns a scene
  100057. */
  100058. getScene(): Scene;
  100059. /**
  100060. * Gets the engine of the node
  100061. * @returns a Engine
  100062. */
  100063. getEngine(): Engine;
  100064. private _behaviors;
  100065. /**
  100066. * Attach a behavior to the node
  100067. * @see http://doc.babylonjs.com/features/behaviour
  100068. * @param behavior defines the behavior to attach
  100069. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  100070. * @returns the current Node
  100071. */
  100072. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  100073. /**
  100074. * Remove an attached behavior
  100075. * @see http://doc.babylonjs.com/features/behaviour
  100076. * @param behavior defines the behavior to attach
  100077. * @returns the current Node
  100078. */
  100079. removeBehavior(behavior: Behavior<Node>): Node;
  100080. /**
  100081. * Gets the list of attached behaviors
  100082. * @see http://doc.babylonjs.com/features/behaviour
  100083. */
  100084. get behaviors(): Behavior<Node>[];
  100085. /**
  100086. * Gets an attached behavior by name
  100087. * @param name defines the name of the behavior to look for
  100088. * @see http://doc.babylonjs.com/features/behaviour
  100089. * @returns null if behavior was not found else the requested behavior
  100090. */
  100091. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  100092. /**
  100093. * Returns the latest update of the World matrix
  100094. * @returns a Matrix
  100095. */
  100096. getWorldMatrix(): Matrix;
  100097. /** @hidden */
  100098. _getWorldMatrixDeterminant(): number;
  100099. /**
  100100. * Returns directly the latest state of the mesh World matrix.
  100101. * A Matrix is returned.
  100102. */
  100103. get worldMatrixFromCache(): Matrix;
  100104. /** @hidden */
  100105. _initCache(): void;
  100106. /** @hidden */
  100107. updateCache(force?: boolean): void;
  100108. /** @hidden */
  100109. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  100110. /** @hidden */
  100111. _updateCache(ignoreParentClass?: boolean): void;
  100112. /** @hidden */
  100113. _isSynchronized(): boolean;
  100114. /** @hidden */
  100115. _markSyncedWithParent(): void;
  100116. /** @hidden */
  100117. isSynchronizedWithParent(): boolean;
  100118. /** @hidden */
  100119. isSynchronized(): boolean;
  100120. /**
  100121. * Is this node ready to be used/rendered
  100122. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  100123. * @return true if the node is ready
  100124. */
  100125. isReady(completeCheck?: boolean): boolean;
  100126. /**
  100127. * Is this node enabled?
  100128. * 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
  100129. * @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
  100130. * @return whether this node (and its parent) is enabled
  100131. */
  100132. isEnabled(checkAncestors?: boolean): boolean;
  100133. /** @hidden */
  100134. protected _syncParentEnabledState(): void;
  100135. /**
  100136. * Set the enabled state of this node
  100137. * @param value defines the new enabled state
  100138. */
  100139. setEnabled(value: boolean): void;
  100140. /**
  100141. * Is this node a descendant of the given node?
  100142. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  100143. * @param ancestor defines the parent node to inspect
  100144. * @returns a boolean indicating if this node is a descendant of the given node
  100145. */
  100146. isDescendantOf(ancestor: Node): boolean;
  100147. /** @hidden */
  100148. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  100149. /**
  100150. * Will return all nodes that have this node as ascendant
  100151. * @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
  100152. * @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
  100153. * @return all children nodes of all types
  100154. */
  100155. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  100156. /**
  100157. * Get all child-meshes of this node
  100158. * @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)
  100159. * @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
  100160. * @returns an array of AbstractMesh
  100161. */
  100162. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  100163. /**
  100164. * Get all direct children of this node
  100165. * @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
  100166. * @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)
  100167. * @returns an array of Node
  100168. */
  100169. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  100170. /** @hidden */
  100171. _setReady(state: boolean): void;
  100172. /**
  100173. * Get an animation by name
  100174. * @param name defines the name of the animation to look for
  100175. * @returns null if not found else the requested animation
  100176. */
  100177. getAnimationByName(name: string): Nullable<Animation>;
  100178. /**
  100179. * Creates an animation range for this node
  100180. * @param name defines the name of the range
  100181. * @param from defines the starting key
  100182. * @param to defines the end key
  100183. */
  100184. createAnimationRange(name: string, from: number, to: number): void;
  100185. /**
  100186. * Delete a specific animation range
  100187. * @param name defines the name of the range to delete
  100188. * @param deleteFrames defines if animation frames from the range must be deleted as well
  100189. */
  100190. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  100191. /**
  100192. * Get an animation range by name
  100193. * @param name defines the name of the animation range to look for
  100194. * @returns null if not found else the requested animation range
  100195. */
  100196. getAnimationRange(name: string): Nullable<AnimationRange>;
  100197. /**
  100198. * Gets the list of all animation ranges defined on this node
  100199. * @returns an array
  100200. */
  100201. getAnimationRanges(): Nullable<AnimationRange>[];
  100202. /**
  100203. * Will start the animation sequence
  100204. * @param name defines the range frames for animation sequence
  100205. * @param loop defines if the animation should loop (false by default)
  100206. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  100207. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  100208. * @returns the object created for this animation. If range does not exist, it will return null
  100209. */
  100210. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  100211. /**
  100212. * Serialize animation ranges into a JSON compatible object
  100213. * @returns serialization object
  100214. */
  100215. serializeAnimationRanges(): any;
  100216. /**
  100217. * Computes the world matrix of the node
  100218. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100219. * @returns the world matrix
  100220. */
  100221. computeWorldMatrix(force?: boolean): Matrix;
  100222. /**
  100223. * Releases resources associated with this node.
  100224. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100225. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100226. */
  100227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100228. /**
  100229. * Parse animation range data from a serialization object and store them into a given node
  100230. * @param node defines where to store the animation ranges
  100231. * @param parsedNode defines the serialization object to read data from
  100232. * @param scene defines the hosting scene
  100233. */
  100234. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  100235. /**
  100236. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  100237. * @param includeDescendants Include bounding info from descendants as well (true by default)
  100238. * @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
  100239. * @returns the new bounding vectors
  100240. */
  100241. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  100242. min: Vector3;
  100243. max: Vector3;
  100244. };
  100245. }
  100246. }
  100247. declare module BABYLON {
  100248. /**
  100249. * @hidden
  100250. */
  100251. export class _IAnimationState {
  100252. key: number;
  100253. repeatCount: number;
  100254. workValue?: any;
  100255. loopMode?: number;
  100256. offsetValue?: any;
  100257. highLimitValue?: any;
  100258. }
  100259. /**
  100260. * Class used to store any kind of animation
  100261. */
  100262. export class Animation {
  100263. /**Name of the animation */
  100264. name: string;
  100265. /**Property to animate */
  100266. targetProperty: string;
  100267. /**The frames per second of the animation */
  100268. framePerSecond: number;
  100269. /**The data type of the animation */
  100270. dataType: number;
  100271. /**The loop mode of the animation */
  100272. loopMode?: number | undefined;
  100273. /**Specifies if blending should be enabled */
  100274. enableBlending?: boolean | undefined;
  100275. /**
  100276. * Use matrix interpolation instead of using direct key value when animating matrices
  100277. */
  100278. static AllowMatricesInterpolation: boolean;
  100279. /**
  100280. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  100281. */
  100282. static AllowMatrixDecomposeForInterpolation: boolean;
  100283. /**
  100284. * Stores the key frames of the animation
  100285. */
  100286. private _keys;
  100287. /**
  100288. * Stores the easing function of the animation
  100289. */
  100290. private _easingFunction;
  100291. /**
  100292. * @hidden Internal use only
  100293. */
  100294. _runtimeAnimations: RuntimeAnimation[];
  100295. /**
  100296. * The set of event that will be linked to this animation
  100297. */
  100298. private _events;
  100299. /**
  100300. * Stores an array of target property paths
  100301. */
  100302. targetPropertyPath: string[];
  100303. /**
  100304. * Stores the blending speed of the animation
  100305. */
  100306. blendingSpeed: number;
  100307. /**
  100308. * Stores the animation ranges for the animation
  100309. */
  100310. private _ranges;
  100311. /**
  100312. * @hidden Internal use
  100313. */
  100314. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  100315. /**
  100316. * Sets up an animation
  100317. * @param property The property to animate
  100318. * @param animationType The animation type to apply
  100319. * @param framePerSecond The frames per second of the animation
  100320. * @param easingFunction The easing function used in the animation
  100321. * @returns The created animation
  100322. */
  100323. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  100324. /**
  100325. * Create and start an animation on a node
  100326. * @param name defines the name of the global animation that will be run on all nodes
  100327. * @param node defines the root node where the animation will take place
  100328. * @param targetProperty defines property to animate
  100329. * @param framePerSecond defines the number of frame per second yo use
  100330. * @param totalFrame defines the number of frames in total
  100331. * @param from defines the initial value
  100332. * @param to defines the final value
  100333. * @param loopMode defines which loop mode you want to use (off by default)
  100334. * @param easingFunction defines the easing function to use (linear by default)
  100335. * @param onAnimationEnd defines the callback to call when animation end
  100336. * @returns the animatable created for this animation
  100337. */
  100338. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  100339. /**
  100340. * Create and start an animation on a node and its descendants
  100341. * @param name defines the name of the global animation that will be run on all nodes
  100342. * @param node defines the root node where the animation will take place
  100343. * @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
  100344. * @param targetProperty defines property to animate
  100345. * @param framePerSecond defines the number of frame per second to use
  100346. * @param totalFrame defines the number of frames in total
  100347. * @param from defines the initial value
  100348. * @param to defines the final value
  100349. * @param loopMode defines which loop mode you want to use (off by default)
  100350. * @param easingFunction defines the easing function to use (linear by default)
  100351. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  100352. * @returns the list of animatables created for all nodes
  100353. * @example https://www.babylonjs-playground.com/#MH0VLI
  100354. */
  100355. 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[]>;
  100356. /**
  100357. * Creates a new animation, merges it with the existing animations and starts it
  100358. * @param name Name of the animation
  100359. * @param node Node which contains the scene that begins the animations
  100360. * @param targetProperty Specifies which property to animate
  100361. * @param framePerSecond The frames per second of the animation
  100362. * @param totalFrame The total number of frames
  100363. * @param from The frame at the beginning of the animation
  100364. * @param to The frame at the end of the animation
  100365. * @param loopMode Specifies the loop mode of the animation
  100366. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  100367. * @param onAnimationEnd Callback to run once the animation is complete
  100368. * @returns Nullable animation
  100369. */
  100370. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  100371. /**
  100372. * Transition property of an host to the target Value
  100373. * @param property The property to transition
  100374. * @param targetValue The target Value of the property
  100375. * @param host The object where the property to animate belongs
  100376. * @param scene Scene used to run the animation
  100377. * @param frameRate Framerate (in frame/s) to use
  100378. * @param transition The transition type we want to use
  100379. * @param duration The duration of the animation, in milliseconds
  100380. * @param onAnimationEnd Callback trigger at the end of the animation
  100381. * @returns Nullable animation
  100382. */
  100383. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  100384. /**
  100385. * Return the array of runtime animations currently using this animation
  100386. */
  100387. get runtimeAnimations(): RuntimeAnimation[];
  100388. /**
  100389. * Specifies if any of the runtime animations are currently running
  100390. */
  100391. get hasRunningRuntimeAnimations(): boolean;
  100392. /**
  100393. * Initializes the animation
  100394. * @param name Name of the animation
  100395. * @param targetProperty Property to animate
  100396. * @param framePerSecond The frames per second of the animation
  100397. * @param dataType The data type of the animation
  100398. * @param loopMode The loop mode of the animation
  100399. * @param enableBlending Specifies if blending should be enabled
  100400. */
  100401. constructor(
  100402. /**Name of the animation */
  100403. name: string,
  100404. /**Property to animate */
  100405. targetProperty: string,
  100406. /**The frames per second of the animation */
  100407. framePerSecond: number,
  100408. /**The data type of the animation */
  100409. dataType: number,
  100410. /**The loop mode of the animation */
  100411. loopMode?: number | undefined,
  100412. /**Specifies if blending should be enabled */
  100413. enableBlending?: boolean | undefined);
  100414. /**
  100415. * Converts the animation to a string
  100416. * @param fullDetails support for multiple levels of logging within scene loading
  100417. * @returns String form of the animation
  100418. */
  100419. toString(fullDetails?: boolean): string;
  100420. /**
  100421. * Add an event to this animation
  100422. * @param event Event to add
  100423. */
  100424. addEvent(event: AnimationEvent): void;
  100425. /**
  100426. * Remove all events found at the given frame
  100427. * @param frame The frame to remove events from
  100428. */
  100429. removeEvents(frame: number): void;
  100430. /**
  100431. * Retrieves all the events from the animation
  100432. * @returns Events from the animation
  100433. */
  100434. getEvents(): AnimationEvent[];
  100435. /**
  100436. * Creates an animation range
  100437. * @param name Name of the animation range
  100438. * @param from Starting frame of the animation range
  100439. * @param to Ending frame of the animation
  100440. */
  100441. createRange(name: string, from: number, to: number): void;
  100442. /**
  100443. * Deletes an animation range by name
  100444. * @param name Name of the animation range to delete
  100445. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  100446. */
  100447. deleteRange(name: string, deleteFrames?: boolean): void;
  100448. /**
  100449. * Gets the animation range by name, or null if not defined
  100450. * @param name Name of the animation range
  100451. * @returns Nullable animation range
  100452. */
  100453. getRange(name: string): Nullable<AnimationRange>;
  100454. /**
  100455. * Gets the key frames from the animation
  100456. * @returns The key frames of the animation
  100457. */
  100458. getKeys(): Array<IAnimationKey>;
  100459. /**
  100460. * Gets the highest frame rate of the animation
  100461. * @returns Highest frame rate of the animation
  100462. */
  100463. getHighestFrame(): number;
  100464. /**
  100465. * Gets the easing function of the animation
  100466. * @returns Easing function of the animation
  100467. */
  100468. getEasingFunction(): IEasingFunction;
  100469. /**
  100470. * Sets the easing function of the animation
  100471. * @param easingFunction A custom mathematical formula for animation
  100472. */
  100473. setEasingFunction(easingFunction: EasingFunction): void;
  100474. /**
  100475. * Interpolates a scalar linearly
  100476. * @param startValue Start value of the animation curve
  100477. * @param endValue End value of the animation curve
  100478. * @param gradient Scalar amount to interpolate
  100479. * @returns Interpolated scalar value
  100480. */
  100481. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  100482. /**
  100483. * Interpolates a scalar cubically
  100484. * @param startValue Start value of the animation curve
  100485. * @param outTangent End tangent of the animation
  100486. * @param endValue End value of the animation curve
  100487. * @param inTangent Start tangent of the animation curve
  100488. * @param gradient Scalar amount to interpolate
  100489. * @returns Interpolated scalar value
  100490. */
  100491. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  100492. /**
  100493. * Interpolates a quaternion using a spherical linear interpolation
  100494. * @param startValue Start value of the animation curve
  100495. * @param endValue End value of the animation curve
  100496. * @param gradient Scalar amount to interpolate
  100497. * @returns Interpolated quaternion value
  100498. */
  100499. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  100500. /**
  100501. * Interpolates a quaternion cubically
  100502. * @param startValue Start value of the animation curve
  100503. * @param outTangent End tangent of the animation curve
  100504. * @param endValue End value of the animation curve
  100505. * @param inTangent Start tangent of the animation curve
  100506. * @param gradient Scalar amount to interpolate
  100507. * @returns Interpolated quaternion value
  100508. */
  100509. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  100510. /**
  100511. * Interpolates a Vector3 linearl
  100512. * @param startValue Start value of the animation curve
  100513. * @param endValue End value of the animation curve
  100514. * @param gradient Scalar amount to interpolate
  100515. * @returns Interpolated scalar value
  100516. */
  100517. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  100518. /**
  100519. * Interpolates a Vector3 cubically
  100520. * @param startValue Start value of the animation curve
  100521. * @param outTangent End tangent of the animation
  100522. * @param endValue End value of the animation curve
  100523. * @param inTangent Start tangent of the animation curve
  100524. * @param gradient Scalar amount to interpolate
  100525. * @returns InterpolatedVector3 value
  100526. */
  100527. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  100528. /**
  100529. * Interpolates a Vector2 linearly
  100530. * @param startValue Start value of the animation curve
  100531. * @param endValue End value of the animation curve
  100532. * @param gradient Scalar amount to interpolate
  100533. * @returns Interpolated Vector2 value
  100534. */
  100535. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  100536. /**
  100537. * Interpolates a Vector2 cubically
  100538. * @param startValue Start value of the animation curve
  100539. * @param outTangent End tangent of the animation
  100540. * @param endValue End value of the animation curve
  100541. * @param inTangent Start tangent of the animation curve
  100542. * @param gradient Scalar amount to interpolate
  100543. * @returns Interpolated Vector2 value
  100544. */
  100545. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  100546. /**
  100547. * Interpolates a size linearly
  100548. * @param startValue Start value of the animation curve
  100549. * @param endValue End value of the animation curve
  100550. * @param gradient Scalar amount to interpolate
  100551. * @returns Interpolated Size value
  100552. */
  100553. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  100554. /**
  100555. * Interpolates a Color3 linearly
  100556. * @param startValue Start value of the animation curve
  100557. * @param endValue End value of the animation curve
  100558. * @param gradient Scalar amount to interpolate
  100559. * @returns Interpolated Color3 value
  100560. */
  100561. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  100562. /**
  100563. * Interpolates a Color4 linearly
  100564. * @param startValue Start value of the animation curve
  100565. * @param endValue End value of the animation curve
  100566. * @param gradient Scalar amount to interpolate
  100567. * @returns Interpolated Color3 value
  100568. */
  100569. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  100570. /**
  100571. * @hidden Internal use only
  100572. */
  100573. _getKeyValue(value: any): any;
  100574. /**
  100575. * @hidden Internal use only
  100576. */
  100577. _interpolate(currentFrame: number, state: _IAnimationState): any;
  100578. /**
  100579. * Defines the function to use to interpolate matrices
  100580. * @param startValue defines the start matrix
  100581. * @param endValue defines the end matrix
  100582. * @param gradient defines the gradient between both matrices
  100583. * @param result defines an optional target matrix where to store the interpolation
  100584. * @returns the interpolated matrix
  100585. */
  100586. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  100587. /**
  100588. * Makes a copy of the animation
  100589. * @returns Cloned animation
  100590. */
  100591. clone(): Animation;
  100592. /**
  100593. * Sets the key frames of the animation
  100594. * @param values The animation key frames to set
  100595. */
  100596. setKeys(values: Array<IAnimationKey>): void;
  100597. /**
  100598. * Serializes the animation to an object
  100599. * @returns Serialized object
  100600. */
  100601. serialize(): any;
  100602. /**
  100603. * Float animation type
  100604. */
  100605. static readonly ANIMATIONTYPE_FLOAT: number;
  100606. /**
  100607. * Vector3 animation type
  100608. */
  100609. static readonly ANIMATIONTYPE_VECTOR3: number;
  100610. /**
  100611. * Quaternion animation type
  100612. */
  100613. static readonly ANIMATIONTYPE_QUATERNION: number;
  100614. /**
  100615. * Matrix animation type
  100616. */
  100617. static readonly ANIMATIONTYPE_MATRIX: number;
  100618. /**
  100619. * Color3 animation type
  100620. */
  100621. static readonly ANIMATIONTYPE_COLOR3: number;
  100622. /**
  100623. * Color3 animation type
  100624. */
  100625. static readonly ANIMATIONTYPE_COLOR4: number;
  100626. /**
  100627. * Vector2 animation type
  100628. */
  100629. static readonly ANIMATIONTYPE_VECTOR2: number;
  100630. /**
  100631. * Size animation type
  100632. */
  100633. static readonly ANIMATIONTYPE_SIZE: number;
  100634. /**
  100635. * Relative Loop Mode
  100636. */
  100637. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  100638. /**
  100639. * Cycle Loop Mode
  100640. */
  100641. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  100642. /**
  100643. * Constant Loop Mode
  100644. */
  100645. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  100646. /** @hidden */
  100647. static _UniversalLerp(left: any, right: any, amount: number): any;
  100648. /**
  100649. * Parses an animation object and creates an animation
  100650. * @param parsedAnimation Parsed animation object
  100651. * @returns Animation object
  100652. */
  100653. static Parse(parsedAnimation: any): Animation;
  100654. /**
  100655. * Appends the serialized animations from the source animations
  100656. * @param source Source containing the animations
  100657. * @param destination Target to store the animations
  100658. */
  100659. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  100660. }
  100661. }
  100662. declare module BABYLON {
  100663. /**
  100664. * Interface containing an array of animations
  100665. */
  100666. export interface IAnimatable {
  100667. /**
  100668. * Array of animations
  100669. */
  100670. animations: Nullable<Array<Animation>>;
  100671. }
  100672. }
  100673. declare module BABYLON {
  100674. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  100675. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100676. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100677. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100678. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100679. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100680. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100681. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100682. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100683. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100684. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100685. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100686. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100687. /**
  100688. * Decorator used to define property that can be serialized as reference to a camera
  100689. * @param sourceName defines the name of the property to decorate
  100690. */
  100691. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100692. /**
  100693. * Class used to help serialization objects
  100694. */
  100695. export class SerializationHelper {
  100696. /** @hidden */
  100697. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  100698. /** @hidden */
  100699. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  100700. /** @hidden */
  100701. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  100702. /** @hidden */
  100703. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  100704. /**
  100705. * Appends the serialized animations from the source animations
  100706. * @param source Source containing the animations
  100707. * @param destination Target to store the animations
  100708. */
  100709. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  100710. /**
  100711. * Static function used to serialized a specific entity
  100712. * @param entity defines the entity to serialize
  100713. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  100714. * @returns a JSON compatible object representing the serialization of the entity
  100715. */
  100716. static Serialize<T>(entity: T, serializationObject?: any): any;
  100717. /**
  100718. * Creates a new entity from a serialization data object
  100719. * @param creationFunction defines a function used to instanciated the new entity
  100720. * @param source defines the source serialization data
  100721. * @param scene defines the hosting scene
  100722. * @param rootUrl defines the root url for resources
  100723. * @returns a new entity
  100724. */
  100725. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  100726. /**
  100727. * Clones an object
  100728. * @param creationFunction defines the function used to instanciate the new object
  100729. * @param source defines the source object
  100730. * @returns the cloned object
  100731. */
  100732. static Clone<T>(creationFunction: () => T, source: T): T;
  100733. /**
  100734. * Instanciates a new object based on a source one (some data will be shared between both object)
  100735. * @param creationFunction defines the function used to instanciate the new object
  100736. * @param source defines the source object
  100737. * @returns the new object
  100738. */
  100739. static Instanciate<T>(creationFunction: () => T, source: T): T;
  100740. }
  100741. }
  100742. declare module BABYLON {
  100743. /**
  100744. * Class used to manipulate GUIDs
  100745. */
  100746. export class GUID {
  100747. /**
  100748. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100749. * Be aware Math.random() could cause collisions, but:
  100750. * "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"
  100751. * @returns a pseudo random id
  100752. */
  100753. static RandomId(): string;
  100754. }
  100755. }
  100756. declare module BABYLON {
  100757. /**
  100758. * Base class of all the textures in babylon.
  100759. * It groups all the common properties the materials, post process, lights... might need
  100760. * in order to make a correct use of the texture.
  100761. */
  100762. export class BaseTexture implements IAnimatable {
  100763. /**
  100764. * Default anisotropic filtering level for the application.
  100765. * It is set to 4 as a good tradeoff between perf and quality.
  100766. */
  100767. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  100768. /**
  100769. * Gets or sets the unique id of the texture
  100770. */
  100771. uniqueId: number;
  100772. /**
  100773. * Define the name of the texture.
  100774. */
  100775. name: string;
  100776. /**
  100777. * Gets or sets an object used to store user defined information.
  100778. */
  100779. metadata: any;
  100780. /**
  100781. * For internal use only. Please do not use.
  100782. */
  100783. reservedDataStore: any;
  100784. private _hasAlpha;
  100785. /**
  100786. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  100787. */
  100788. set hasAlpha(value: boolean);
  100789. get hasAlpha(): boolean;
  100790. /**
  100791. * Defines if the alpha value should be determined via the rgb values.
  100792. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  100793. */
  100794. getAlphaFromRGB: boolean;
  100795. /**
  100796. * Intensity or strength of the texture.
  100797. * It is commonly used by materials to fine tune the intensity of the texture
  100798. */
  100799. level: number;
  100800. /**
  100801. * Define the UV chanel to use starting from 0 and defaulting to 0.
  100802. * This is part of the texture as textures usually maps to one uv set.
  100803. */
  100804. coordinatesIndex: number;
  100805. private _coordinatesMode;
  100806. /**
  100807. * How a texture is mapped.
  100808. *
  100809. * | Value | Type | Description |
  100810. * | ----- | ----------------------------------- | ----------- |
  100811. * | 0 | EXPLICIT_MODE | |
  100812. * | 1 | SPHERICAL_MODE | |
  100813. * | 2 | PLANAR_MODE | |
  100814. * | 3 | CUBIC_MODE | |
  100815. * | 4 | PROJECTION_MODE | |
  100816. * | 5 | SKYBOX_MODE | |
  100817. * | 6 | INVCUBIC_MODE | |
  100818. * | 7 | EQUIRECTANGULAR_MODE | |
  100819. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  100820. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  100821. */
  100822. set coordinatesMode(value: number);
  100823. get coordinatesMode(): number;
  100824. /**
  100825. * | Value | Type | Description |
  100826. * | ----- | ------------------ | ----------- |
  100827. * | 0 | CLAMP_ADDRESSMODE | |
  100828. * | 1 | WRAP_ADDRESSMODE | |
  100829. * | 2 | MIRROR_ADDRESSMODE | |
  100830. */
  100831. wrapU: number;
  100832. /**
  100833. * | Value | Type | Description |
  100834. * | ----- | ------------------ | ----------- |
  100835. * | 0 | CLAMP_ADDRESSMODE | |
  100836. * | 1 | WRAP_ADDRESSMODE | |
  100837. * | 2 | MIRROR_ADDRESSMODE | |
  100838. */
  100839. wrapV: number;
  100840. /**
  100841. * | Value | Type | Description |
  100842. * | ----- | ------------------ | ----------- |
  100843. * | 0 | CLAMP_ADDRESSMODE | |
  100844. * | 1 | WRAP_ADDRESSMODE | |
  100845. * | 2 | MIRROR_ADDRESSMODE | |
  100846. */
  100847. wrapR: number;
  100848. /**
  100849. * With compliant hardware and browser (supporting anisotropic filtering)
  100850. * this defines the level of anisotropic filtering in the texture.
  100851. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100852. */
  100853. anisotropicFilteringLevel: number;
  100854. /**
  100855. * Define if the texture is a cube texture or if false a 2d texture.
  100856. */
  100857. get isCube(): boolean;
  100858. set isCube(value: boolean);
  100859. /**
  100860. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100861. */
  100862. get is3D(): boolean;
  100863. set is3D(value: boolean);
  100864. /**
  100865. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100866. */
  100867. get is2DArray(): boolean;
  100868. set is2DArray(value: boolean);
  100869. /**
  100870. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100871. * HDR texture are usually stored in linear space.
  100872. * This only impacts the PBR and Background materials
  100873. */
  100874. gammaSpace: boolean;
  100875. /**
  100876. * Gets or sets whether or not the texture contains RGBD data.
  100877. */
  100878. get isRGBD(): boolean;
  100879. set isRGBD(value: boolean);
  100880. /**
  100881. * Is Z inverted in the texture (useful in a cube texture).
  100882. */
  100883. invertZ: boolean;
  100884. /**
  100885. * Are mip maps generated for this texture or not.
  100886. */
  100887. get noMipmap(): boolean;
  100888. /**
  100889. * @hidden
  100890. */
  100891. lodLevelInAlpha: boolean;
  100892. /**
  100893. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100894. */
  100895. get lodGenerationOffset(): number;
  100896. set lodGenerationOffset(value: number);
  100897. /**
  100898. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100899. */
  100900. get lodGenerationScale(): number;
  100901. set lodGenerationScale(value: number);
  100902. /**
  100903. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100904. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100905. * average roughness values.
  100906. */
  100907. get linearSpecularLOD(): boolean;
  100908. set linearSpecularLOD(value: boolean);
  100909. /**
  100910. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100911. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100912. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100913. */
  100914. get irradianceTexture(): Nullable<BaseTexture>;
  100915. set irradianceTexture(value: Nullable<BaseTexture>);
  100916. /**
  100917. * Define if the texture is a render target.
  100918. */
  100919. isRenderTarget: boolean;
  100920. /**
  100921. * Define the unique id of the texture in the scene.
  100922. */
  100923. get uid(): string;
  100924. /**
  100925. * Return a string representation of the texture.
  100926. * @returns the texture as a string
  100927. */
  100928. toString(): string;
  100929. /**
  100930. * Get the class name of the texture.
  100931. * @returns "BaseTexture"
  100932. */
  100933. getClassName(): string;
  100934. /**
  100935. * Define the list of animation attached to the texture.
  100936. */
  100937. animations: Animation[];
  100938. /**
  100939. * An event triggered when the texture is disposed.
  100940. */
  100941. onDisposeObservable: Observable<BaseTexture>;
  100942. private _onDisposeObserver;
  100943. /**
  100944. * Callback triggered when the texture has been disposed.
  100945. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100946. */
  100947. set onDispose(callback: () => void);
  100948. /**
  100949. * Define the current state of the loading sequence when in delayed load mode.
  100950. */
  100951. delayLoadState: number;
  100952. private _scene;
  100953. /** @hidden */
  100954. _texture: Nullable<InternalTexture>;
  100955. private _uid;
  100956. /**
  100957. * Define if the texture is preventinga material to render or not.
  100958. * If not and the texture is not ready, the engine will use a default black texture instead.
  100959. */
  100960. get isBlocking(): boolean;
  100961. /**
  100962. * Instantiates a new BaseTexture.
  100963. * Base class of all the textures in babylon.
  100964. * It groups all the common properties the materials, post process, lights... might need
  100965. * in order to make a correct use of the texture.
  100966. * @param scene Define the scene the texture blongs to
  100967. */
  100968. constructor(scene: Nullable<Scene>);
  100969. /**
  100970. * Get the scene the texture belongs to.
  100971. * @returns the scene or null if undefined
  100972. */
  100973. getScene(): Nullable<Scene>;
  100974. /**
  100975. * Get the texture transform matrix used to offset tile the texture for istance.
  100976. * @returns the transformation matrix
  100977. */
  100978. getTextureMatrix(): Matrix;
  100979. /**
  100980. * Get the texture reflection matrix used to rotate/transform the reflection.
  100981. * @returns the reflection matrix
  100982. */
  100983. getReflectionTextureMatrix(): Matrix;
  100984. /**
  100985. * Get the underlying lower level texture from Babylon.
  100986. * @returns the insternal texture
  100987. */
  100988. getInternalTexture(): Nullable<InternalTexture>;
  100989. /**
  100990. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100991. * @returns true if ready or not blocking
  100992. */
  100993. isReadyOrNotBlocking(): boolean;
  100994. /**
  100995. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  100996. * @returns true if fully ready
  100997. */
  100998. isReady(): boolean;
  100999. private _cachedSize;
  101000. /**
  101001. * Get the size of the texture.
  101002. * @returns the texture size.
  101003. */
  101004. getSize(): ISize;
  101005. /**
  101006. * Get the base size of the texture.
  101007. * It can be different from the size if the texture has been resized for POT for instance
  101008. * @returns the base size
  101009. */
  101010. getBaseSize(): ISize;
  101011. /**
  101012. * Update the sampling mode of the texture.
  101013. * Default is Trilinear mode.
  101014. *
  101015. * | Value | Type | Description |
  101016. * | ----- | ------------------ | ----------- |
  101017. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  101018. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  101019. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  101020. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  101021. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  101022. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  101023. * | 7 | NEAREST_LINEAR | |
  101024. * | 8 | NEAREST_NEAREST | |
  101025. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  101026. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  101027. * | 11 | LINEAR_LINEAR | |
  101028. * | 12 | LINEAR_NEAREST | |
  101029. *
  101030. * > _mag_: magnification filter (close to the viewer)
  101031. * > _min_: minification filter (far from the viewer)
  101032. * > _mip_: filter used between mip map levels
  101033. *@param samplingMode Define the new sampling mode of the texture
  101034. */
  101035. updateSamplingMode(samplingMode: number): void;
  101036. /**
  101037. * Scales the texture if is `canRescale()`
  101038. * @param ratio the resize factor we want to use to rescale
  101039. */
  101040. scale(ratio: number): void;
  101041. /**
  101042. * Get if the texture can rescale.
  101043. */
  101044. get canRescale(): boolean;
  101045. /** @hidden */
  101046. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  101047. /** @hidden */
  101048. _rebuild(): void;
  101049. /**
  101050. * Triggers the load sequence in delayed load mode.
  101051. */
  101052. delayLoad(): void;
  101053. /**
  101054. * Clones the texture.
  101055. * @returns the cloned texture
  101056. */
  101057. clone(): Nullable<BaseTexture>;
  101058. /**
  101059. * Get the texture underlying type (INT, FLOAT...)
  101060. */
  101061. get textureType(): number;
  101062. /**
  101063. * Get the texture underlying format (RGB, RGBA...)
  101064. */
  101065. get textureFormat(): number;
  101066. /**
  101067. * Indicates that textures need to be re-calculated for all materials
  101068. */
  101069. protected _markAllSubMeshesAsTexturesDirty(): void;
  101070. /**
  101071. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  101072. * This will returns an RGBA array buffer containing either in values (0-255) or
  101073. * float values (0-1) depending of the underlying buffer type.
  101074. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  101075. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  101076. * @param buffer defines a user defined buffer to fill with data (can be null)
  101077. * @returns The Array buffer containing the pixels data.
  101078. */
  101079. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  101080. /**
  101081. * Release and destroy the underlying lower level texture aka internalTexture.
  101082. */
  101083. releaseInternalTexture(): void;
  101084. /** @hidden */
  101085. get _lodTextureHigh(): Nullable<BaseTexture>;
  101086. /** @hidden */
  101087. get _lodTextureMid(): Nullable<BaseTexture>;
  101088. /** @hidden */
  101089. get _lodTextureLow(): Nullable<BaseTexture>;
  101090. /**
  101091. * Dispose the texture and release its associated resources.
  101092. */
  101093. dispose(): void;
  101094. /**
  101095. * Serialize the texture into a JSON representation that can be parsed later on.
  101096. * @returns the JSON representation of the texture
  101097. */
  101098. serialize(): any;
  101099. /**
  101100. * Helper function to be called back once a list of texture contains only ready textures.
  101101. * @param textures Define the list of textures to wait for
  101102. * @param callback Define the callback triggered once the entire list will be ready
  101103. */
  101104. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  101105. }
  101106. }
  101107. declare module BABYLON {
  101108. /**
  101109. * Options to be used when creating an effect.
  101110. */
  101111. export interface IEffectCreationOptions {
  101112. /**
  101113. * Atrributes that will be used in the shader.
  101114. */
  101115. attributes: string[];
  101116. /**
  101117. * Uniform varible names that will be set in the shader.
  101118. */
  101119. uniformsNames: string[];
  101120. /**
  101121. * Uniform buffer variable names that will be set in the shader.
  101122. */
  101123. uniformBuffersNames: string[];
  101124. /**
  101125. * Sampler texture variable names that will be set in the shader.
  101126. */
  101127. samplers: string[];
  101128. /**
  101129. * Define statements that will be set in the shader.
  101130. */
  101131. defines: any;
  101132. /**
  101133. * Possible fallbacks for this effect to improve performance when needed.
  101134. */
  101135. fallbacks: Nullable<IEffectFallbacks>;
  101136. /**
  101137. * Callback that will be called when the shader is compiled.
  101138. */
  101139. onCompiled: Nullable<(effect: Effect) => void>;
  101140. /**
  101141. * Callback that will be called if an error occurs during shader compilation.
  101142. */
  101143. onError: Nullable<(effect: Effect, errors: string) => void>;
  101144. /**
  101145. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  101146. */
  101147. indexParameters?: any;
  101148. /**
  101149. * Max number of lights that can be used in the shader.
  101150. */
  101151. maxSimultaneousLights?: number;
  101152. /**
  101153. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  101154. */
  101155. transformFeedbackVaryings?: Nullable<string[]>;
  101156. }
  101157. /**
  101158. * Effect containing vertex and fragment shader that can be executed on an object.
  101159. */
  101160. export class Effect implements IDisposable {
  101161. /**
  101162. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101163. */
  101164. static ShadersRepository: string;
  101165. /**
  101166. * Name of the effect.
  101167. */
  101168. name: any;
  101169. /**
  101170. * String container all the define statements that should be set on the shader.
  101171. */
  101172. defines: string;
  101173. /**
  101174. * Callback that will be called when the shader is compiled.
  101175. */
  101176. onCompiled: Nullable<(effect: Effect) => void>;
  101177. /**
  101178. * Callback that will be called if an error occurs during shader compilation.
  101179. */
  101180. onError: Nullable<(effect: Effect, errors: string) => void>;
  101181. /**
  101182. * Callback that will be called when effect is bound.
  101183. */
  101184. onBind: Nullable<(effect: Effect) => void>;
  101185. /**
  101186. * Unique ID of the effect.
  101187. */
  101188. uniqueId: number;
  101189. /**
  101190. * Observable that will be called when the shader is compiled.
  101191. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  101192. */
  101193. onCompileObservable: Observable<Effect>;
  101194. /**
  101195. * Observable that will be called if an error occurs during shader compilation.
  101196. */
  101197. onErrorObservable: Observable<Effect>;
  101198. /** @hidden */
  101199. _onBindObservable: Nullable<Observable<Effect>>;
  101200. /**
  101201. * @hidden
  101202. * Specifies if the effect was previously ready
  101203. */
  101204. _wasPreviouslyReady: boolean;
  101205. /**
  101206. * Observable that will be called when effect is bound.
  101207. */
  101208. get onBindObservable(): Observable<Effect>;
  101209. /** @hidden */
  101210. _bonesComputationForcedToCPU: boolean;
  101211. private static _uniqueIdSeed;
  101212. private _engine;
  101213. private _uniformBuffersNames;
  101214. private _uniformsNames;
  101215. private _samplerList;
  101216. private _samplers;
  101217. private _isReady;
  101218. private _compilationError;
  101219. private _allFallbacksProcessed;
  101220. private _attributesNames;
  101221. private _attributes;
  101222. private _attributeLocationByName;
  101223. private _uniforms;
  101224. /**
  101225. * Key for the effect.
  101226. * @hidden
  101227. */
  101228. _key: string;
  101229. private _indexParameters;
  101230. private _fallbacks;
  101231. private _vertexSourceCode;
  101232. private _fragmentSourceCode;
  101233. private _vertexSourceCodeOverride;
  101234. private _fragmentSourceCodeOverride;
  101235. private _transformFeedbackVaryings;
  101236. /**
  101237. * Compiled shader to webGL program.
  101238. * @hidden
  101239. */
  101240. _pipelineContext: Nullable<IPipelineContext>;
  101241. private _valueCache;
  101242. private static _baseCache;
  101243. /**
  101244. * Instantiates an effect.
  101245. * An effect can be used to create/manage/execute vertex and fragment shaders.
  101246. * @param baseName Name of the effect.
  101247. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  101248. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  101249. * @param samplers List of sampler variables that will be passed to the shader.
  101250. * @param engine Engine to be used to render the effect
  101251. * @param defines Define statements to be added to the shader.
  101252. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  101253. * @param onCompiled Callback that will be called when the shader is compiled.
  101254. * @param onError Callback that will be called if an error occurs during shader compilation.
  101255. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  101256. */
  101257. 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);
  101258. private _useFinalCode;
  101259. /**
  101260. * Unique key for this effect
  101261. */
  101262. get key(): string;
  101263. /**
  101264. * If the effect has been compiled and prepared.
  101265. * @returns if the effect is compiled and prepared.
  101266. */
  101267. isReady(): boolean;
  101268. private _isReadyInternal;
  101269. /**
  101270. * The engine the effect was initialized with.
  101271. * @returns the engine.
  101272. */
  101273. getEngine(): Engine;
  101274. /**
  101275. * The pipeline context for this effect
  101276. * @returns the associated pipeline context
  101277. */
  101278. getPipelineContext(): Nullable<IPipelineContext>;
  101279. /**
  101280. * The set of names of attribute variables for the shader.
  101281. * @returns An array of attribute names.
  101282. */
  101283. getAttributesNames(): string[];
  101284. /**
  101285. * Returns the attribute at the given index.
  101286. * @param index The index of the attribute.
  101287. * @returns The location of the attribute.
  101288. */
  101289. getAttributeLocation(index: number): number;
  101290. /**
  101291. * Returns the attribute based on the name of the variable.
  101292. * @param name of the attribute to look up.
  101293. * @returns the attribute location.
  101294. */
  101295. getAttributeLocationByName(name: string): number;
  101296. /**
  101297. * The number of attributes.
  101298. * @returns the numnber of attributes.
  101299. */
  101300. getAttributesCount(): number;
  101301. /**
  101302. * Gets the index of a uniform variable.
  101303. * @param uniformName of the uniform to look up.
  101304. * @returns the index.
  101305. */
  101306. getUniformIndex(uniformName: string): number;
  101307. /**
  101308. * Returns the attribute based on the name of the variable.
  101309. * @param uniformName of the uniform to look up.
  101310. * @returns the location of the uniform.
  101311. */
  101312. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  101313. /**
  101314. * Returns an array of sampler variable names
  101315. * @returns The array of sampler variable neames.
  101316. */
  101317. getSamplers(): string[];
  101318. /**
  101319. * The error from the last compilation.
  101320. * @returns the error string.
  101321. */
  101322. getCompilationError(): string;
  101323. /**
  101324. * Gets a boolean indicating that all fallbacks were used during compilation
  101325. * @returns true if all fallbacks were used
  101326. */
  101327. allFallbacksProcessed(): boolean;
  101328. /**
  101329. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  101330. * @param func The callback to be used.
  101331. */
  101332. executeWhenCompiled(func: (effect: Effect) => void): void;
  101333. private _checkIsReady;
  101334. private _loadShader;
  101335. /**
  101336. * Recompiles the webGL program
  101337. * @param vertexSourceCode The source code for the vertex shader.
  101338. * @param fragmentSourceCode The source code for the fragment shader.
  101339. * @param onCompiled Callback called when completed.
  101340. * @param onError Callback called on error.
  101341. * @hidden
  101342. */
  101343. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  101344. /**
  101345. * Prepares the effect
  101346. * @hidden
  101347. */
  101348. _prepareEffect(): void;
  101349. private _processCompilationErrors;
  101350. /**
  101351. * Checks if the effect is supported. (Must be called after compilation)
  101352. */
  101353. get isSupported(): boolean;
  101354. /**
  101355. * Binds a texture to the engine to be used as output of the shader.
  101356. * @param channel Name of the output variable.
  101357. * @param texture Texture to bind.
  101358. * @hidden
  101359. */
  101360. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  101361. /**
  101362. * Sets a texture on the engine to be used in the shader.
  101363. * @param channel Name of the sampler variable.
  101364. * @param texture Texture to set.
  101365. */
  101366. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  101367. /**
  101368. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  101369. * @param channel Name of the sampler variable.
  101370. * @param texture Texture to set.
  101371. */
  101372. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  101373. /**
  101374. * Sets an array of textures on the engine to be used in the shader.
  101375. * @param channel Name of the variable.
  101376. * @param textures Textures to set.
  101377. */
  101378. setTextureArray(channel: string, textures: BaseTexture[]): void;
  101379. /**
  101380. * 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)
  101381. * @param channel Name of the sampler variable.
  101382. * @param postProcess Post process to get the input texture from.
  101383. */
  101384. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  101385. /**
  101386. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  101387. * 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)
  101388. * @param channel Name of the sampler variable.
  101389. * @param postProcess Post process to get the output texture from.
  101390. */
  101391. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  101392. /** @hidden */
  101393. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  101394. /** @hidden */
  101395. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  101396. /** @hidden */
  101397. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  101398. /** @hidden */
  101399. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  101400. /**
  101401. * Binds a buffer to a uniform.
  101402. * @param buffer Buffer to bind.
  101403. * @param name Name of the uniform variable to bind to.
  101404. */
  101405. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  101406. /**
  101407. * Binds block to a uniform.
  101408. * @param blockName Name of the block to bind.
  101409. * @param index Index to bind.
  101410. */
  101411. bindUniformBlock(blockName: string, index: number): void;
  101412. /**
  101413. * Sets an interger value on a uniform variable.
  101414. * @param uniformName Name of the variable.
  101415. * @param value Value to be set.
  101416. * @returns this effect.
  101417. */
  101418. setInt(uniformName: string, value: number): Effect;
  101419. /**
  101420. * Sets an int array on a uniform variable.
  101421. * @param uniformName Name of the variable.
  101422. * @param array array to be set.
  101423. * @returns this effect.
  101424. */
  101425. setIntArray(uniformName: string, array: Int32Array): Effect;
  101426. /**
  101427. * 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)
  101428. * @param uniformName Name of the variable.
  101429. * @param array array to be set.
  101430. * @returns this effect.
  101431. */
  101432. setIntArray2(uniformName: string, array: Int32Array): Effect;
  101433. /**
  101434. * 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)
  101435. * @param uniformName Name of the variable.
  101436. * @param array array to be set.
  101437. * @returns this effect.
  101438. */
  101439. setIntArray3(uniformName: string, array: Int32Array): Effect;
  101440. /**
  101441. * 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)
  101442. * @param uniformName Name of the variable.
  101443. * @param array array to be set.
  101444. * @returns this effect.
  101445. */
  101446. setIntArray4(uniformName: string, array: Int32Array): Effect;
  101447. /**
  101448. * Sets an float array on a uniform variable.
  101449. * @param uniformName Name of the variable.
  101450. * @param array array to be set.
  101451. * @returns this effect.
  101452. */
  101453. setFloatArray(uniformName: string, array: Float32Array): Effect;
  101454. /**
  101455. * 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)
  101456. * @param uniformName Name of the variable.
  101457. * @param array array to be set.
  101458. * @returns this effect.
  101459. */
  101460. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  101461. /**
  101462. * 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)
  101463. * @param uniformName Name of the variable.
  101464. * @param array array to be set.
  101465. * @returns this effect.
  101466. */
  101467. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  101468. /**
  101469. * 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)
  101470. * @param uniformName Name of the variable.
  101471. * @param array array to be set.
  101472. * @returns this effect.
  101473. */
  101474. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  101475. /**
  101476. * Sets an array on a uniform variable.
  101477. * @param uniformName Name of the variable.
  101478. * @param array array to be set.
  101479. * @returns this effect.
  101480. */
  101481. setArray(uniformName: string, array: number[]): Effect;
  101482. /**
  101483. * 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)
  101484. * @param uniformName Name of the variable.
  101485. * @param array array to be set.
  101486. * @returns this effect.
  101487. */
  101488. setArray2(uniformName: string, array: number[]): Effect;
  101489. /**
  101490. * 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)
  101491. * @param uniformName Name of the variable.
  101492. * @param array array to be set.
  101493. * @returns this effect.
  101494. */
  101495. setArray3(uniformName: string, array: number[]): Effect;
  101496. /**
  101497. * 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)
  101498. * @param uniformName Name of the variable.
  101499. * @param array array to be set.
  101500. * @returns this effect.
  101501. */
  101502. setArray4(uniformName: string, array: number[]): Effect;
  101503. /**
  101504. * Sets matrices on a uniform variable.
  101505. * @param uniformName Name of the variable.
  101506. * @param matrices matrices to be set.
  101507. * @returns this effect.
  101508. */
  101509. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  101510. /**
  101511. * Sets matrix on a uniform variable.
  101512. * @param uniformName Name of the variable.
  101513. * @param matrix matrix to be set.
  101514. * @returns this effect.
  101515. */
  101516. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  101517. /**
  101518. * 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)
  101519. * @param uniformName Name of the variable.
  101520. * @param matrix matrix to be set.
  101521. * @returns this effect.
  101522. */
  101523. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  101524. /**
  101525. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  101526. * @param uniformName Name of the variable.
  101527. * @param matrix matrix to be set.
  101528. * @returns this effect.
  101529. */
  101530. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  101531. /**
  101532. * Sets a float on a uniform variable.
  101533. * @param uniformName Name of the variable.
  101534. * @param value value to be set.
  101535. * @returns this effect.
  101536. */
  101537. setFloat(uniformName: string, value: number): Effect;
  101538. /**
  101539. * Sets a boolean on a uniform variable.
  101540. * @param uniformName Name of the variable.
  101541. * @param bool value to be set.
  101542. * @returns this effect.
  101543. */
  101544. setBool(uniformName: string, bool: boolean): Effect;
  101545. /**
  101546. * Sets a Vector2 on a uniform variable.
  101547. * @param uniformName Name of the variable.
  101548. * @param vector2 vector2 to be set.
  101549. * @returns this effect.
  101550. */
  101551. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  101552. /**
  101553. * Sets a float2 on a uniform variable.
  101554. * @param uniformName Name of the variable.
  101555. * @param x First float in float2.
  101556. * @param y Second float in float2.
  101557. * @returns this effect.
  101558. */
  101559. setFloat2(uniformName: string, x: number, y: number): Effect;
  101560. /**
  101561. * Sets a Vector3 on a uniform variable.
  101562. * @param uniformName Name of the variable.
  101563. * @param vector3 Value to be set.
  101564. * @returns this effect.
  101565. */
  101566. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  101567. /**
  101568. * Sets a float3 on a uniform variable.
  101569. * @param uniformName Name of the variable.
  101570. * @param x First float in float3.
  101571. * @param y Second float in float3.
  101572. * @param z Third float in float3.
  101573. * @returns this effect.
  101574. */
  101575. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  101576. /**
  101577. * Sets a Vector4 on a uniform variable.
  101578. * @param uniformName Name of the variable.
  101579. * @param vector4 Value to be set.
  101580. * @returns this effect.
  101581. */
  101582. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  101583. /**
  101584. * Sets a float4 on a uniform variable.
  101585. * @param uniformName Name of the variable.
  101586. * @param x First float in float4.
  101587. * @param y Second float in float4.
  101588. * @param z Third float in float4.
  101589. * @param w Fourth float in float4.
  101590. * @returns this effect.
  101591. */
  101592. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  101593. /**
  101594. * Sets a Color3 on a uniform variable.
  101595. * @param uniformName Name of the variable.
  101596. * @param color3 Value to be set.
  101597. * @returns this effect.
  101598. */
  101599. setColor3(uniformName: string, color3: IColor3Like): Effect;
  101600. /**
  101601. * Sets a Color4 on a uniform variable.
  101602. * @param uniformName Name of the variable.
  101603. * @param color3 Value to be set.
  101604. * @param alpha Alpha value to be set.
  101605. * @returns this effect.
  101606. */
  101607. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  101608. /**
  101609. * Sets a Color4 on a uniform variable
  101610. * @param uniformName defines the name of the variable
  101611. * @param color4 defines the value to be set
  101612. * @returns this effect.
  101613. */
  101614. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  101615. /** Release all associated resources */
  101616. dispose(): void;
  101617. /**
  101618. * This function will add a new shader to the shader store
  101619. * @param name the name of the shader
  101620. * @param pixelShader optional pixel shader content
  101621. * @param vertexShader optional vertex shader content
  101622. */
  101623. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  101624. /**
  101625. * Store of each shader (The can be looked up using effect.key)
  101626. */
  101627. static ShadersStore: {
  101628. [key: string]: string;
  101629. };
  101630. /**
  101631. * Store of each included file for a shader (The can be looked up using effect.key)
  101632. */
  101633. static IncludesShadersStore: {
  101634. [key: string]: string;
  101635. };
  101636. /**
  101637. * Resets the cache of effects.
  101638. */
  101639. static ResetCache(): void;
  101640. }
  101641. }
  101642. declare module BABYLON {
  101643. /**
  101644. * Interface used to describe the capabilities of the engine relatively to the current browser
  101645. */
  101646. export interface EngineCapabilities {
  101647. /** Maximum textures units per fragment shader */
  101648. maxTexturesImageUnits: number;
  101649. /** Maximum texture units per vertex shader */
  101650. maxVertexTextureImageUnits: number;
  101651. /** Maximum textures units in the entire pipeline */
  101652. maxCombinedTexturesImageUnits: number;
  101653. /** Maximum texture size */
  101654. maxTextureSize: number;
  101655. /** Maximum texture samples */
  101656. maxSamples?: number;
  101657. /** Maximum cube texture size */
  101658. maxCubemapTextureSize: number;
  101659. /** Maximum render texture size */
  101660. maxRenderTextureSize: number;
  101661. /** Maximum number of vertex attributes */
  101662. maxVertexAttribs: number;
  101663. /** Maximum number of varyings */
  101664. maxVaryingVectors: number;
  101665. /** Maximum number of uniforms per vertex shader */
  101666. maxVertexUniformVectors: number;
  101667. /** Maximum number of uniforms per fragment shader */
  101668. maxFragmentUniformVectors: number;
  101669. /** Defines if standard derivates (dx/dy) are supported */
  101670. standardDerivatives: boolean;
  101671. /** Defines if s3tc texture compression is supported */
  101672. s3tc?: WEBGL_compressed_texture_s3tc;
  101673. /** Defines if pvrtc texture compression is supported */
  101674. pvrtc: any;
  101675. /** Defines if etc1 texture compression is supported */
  101676. etc1: any;
  101677. /** Defines if etc2 texture compression is supported */
  101678. etc2: any;
  101679. /** Defines if astc texture compression is supported */
  101680. astc: any;
  101681. /** Defines if float textures are supported */
  101682. textureFloat: boolean;
  101683. /** Defines if vertex array objects are supported */
  101684. vertexArrayObject: boolean;
  101685. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  101686. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  101687. /** Gets the maximum level of anisotropy supported */
  101688. maxAnisotropy: number;
  101689. /** Defines if instancing is supported */
  101690. instancedArrays: boolean;
  101691. /** Defines if 32 bits indices are supported */
  101692. uintIndices: boolean;
  101693. /** Defines if high precision shaders are supported */
  101694. highPrecisionShaderSupported: boolean;
  101695. /** Defines if depth reading in the fragment shader is supported */
  101696. fragmentDepthSupported: boolean;
  101697. /** Defines if float texture linear filtering is supported*/
  101698. textureFloatLinearFiltering: boolean;
  101699. /** Defines if rendering to float textures is supported */
  101700. textureFloatRender: boolean;
  101701. /** Defines if half float textures are supported*/
  101702. textureHalfFloat: boolean;
  101703. /** Defines if half float texture linear filtering is supported*/
  101704. textureHalfFloatLinearFiltering: boolean;
  101705. /** Defines if rendering to half float textures is supported */
  101706. textureHalfFloatRender: boolean;
  101707. /** Defines if textureLOD shader command is supported */
  101708. textureLOD: boolean;
  101709. /** Defines if draw buffers extension is supported */
  101710. drawBuffersExtension: boolean;
  101711. /** Defines if depth textures are supported */
  101712. depthTextureExtension: boolean;
  101713. /** Defines if float color buffer are supported */
  101714. colorBufferFloat: boolean;
  101715. /** Gets disjoint timer query extension (null if not supported) */
  101716. timerQuery?: EXT_disjoint_timer_query;
  101717. /** Defines if timestamp can be used with timer query */
  101718. canUseTimestampForTimerQuery: boolean;
  101719. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  101720. multiview?: any;
  101721. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  101722. oculusMultiview?: any;
  101723. /** Function used to let the system compiles shaders in background */
  101724. parallelShaderCompile?: {
  101725. COMPLETION_STATUS_KHR: number;
  101726. };
  101727. /** Max number of texture samples for MSAA */
  101728. maxMSAASamples: number;
  101729. /** Defines if the blend min max extension is supported */
  101730. blendMinMax: boolean;
  101731. }
  101732. }
  101733. declare module BABYLON {
  101734. /**
  101735. * @hidden
  101736. **/
  101737. export class DepthCullingState {
  101738. private _isDepthTestDirty;
  101739. private _isDepthMaskDirty;
  101740. private _isDepthFuncDirty;
  101741. private _isCullFaceDirty;
  101742. private _isCullDirty;
  101743. private _isZOffsetDirty;
  101744. private _isFrontFaceDirty;
  101745. private _depthTest;
  101746. private _depthMask;
  101747. private _depthFunc;
  101748. private _cull;
  101749. private _cullFace;
  101750. private _zOffset;
  101751. private _frontFace;
  101752. /**
  101753. * Initializes the state.
  101754. */
  101755. constructor();
  101756. get isDirty(): boolean;
  101757. get zOffset(): number;
  101758. set zOffset(value: number);
  101759. get cullFace(): Nullable<number>;
  101760. set cullFace(value: Nullable<number>);
  101761. get cull(): Nullable<boolean>;
  101762. set cull(value: Nullable<boolean>);
  101763. get depthFunc(): Nullable<number>;
  101764. set depthFunc(value: Nullable<number>);
  101765. get depthMask(): boolean;
  101766. set depthMask(value: boolean);
  101767. get depthTest(): boolean;
  101768. set depthTest(value: boolean);
  101769. get frontFace(): Nullable<number>;
  101770. set frontFace(value: Nullable<number>);
  101771. reset(): void;
  101772. apply(gl: WebGLRenderingContext): void;
  101773. }
  101774. }
  101775. declare module BABYLON {
  101776. /**
  101777. * @hidden
  101778. **/
  101779. export class StencilState {
  101780. /** 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 */
  101781. static readonly ALWAYS: number;
  101782. /** Passed to stencilOperation to specify that stencil value must be kept */
  101783. static readonly KEEP: number;
  101784. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101785. static readonly REPLACE: number;
  101786. private _isStencilTestDirty;
  101787. private _isStencilMaskDirty;
  101788. private _isStencilFuncDirty;
  101789. private _isStencilOpDirty;
  101790. private _stencilTest;
  101791. private _stencilMask;
  101792. private _stencilFunc;
  101793. private _stencilFuncRef;
  101794. private _stencilFuncMask;
  101795. private _stencilOpStencilFail;
  101796. private _stencilOpDepthFail;
  101797. private _stencilOpStencilDepthPass;
  101798. get isDirty(): boolean;
  101799. get stencilFunc(): number;
  101800. set stencilFunc(value: number);
  101801. get stencilFuncRef(): number;
  101802. set stencilFuncRef(value: number);
  101803. get stencilFuncMask(): number;
  101804. set stencilFuncMask(value: number);
  101805. get stencilOpStencilFail(): number;
  101806. set stencilOpStencilFail(value: number);
  101807. get stencilOpDepthFail(): number;
  101808. set stencilOpDepthFail(value: number);
  101809. get stencilOpStencilDepthPass(): number;
  101810. set stencilOpStencilDepthPass(value: number);
  101811. get stencilMask(): number;
  101812. set stencilMask(value: number);
  101813. get stencilTest(): boolean;
  101814. set stencilTest(value: boolean);
  101815. constructor();
  101816. reset(): void;
  101817. apply(gl: WebGLRenderingContext): void;
  101818. }
  101819. }
  101820. declare module BABYLON {
  101821. /**
  101822. * @hidden
  101823. **/
  101824. export class AlphaState {
  101825. private _isAlphaBlendDirty;
  101826. private _isBlendFunctionParametersDirty;
  101827. private _isBlendEquationParametersDirty;
  101828. private _isBlendConstantsDirty;
  101829. private _alphaBlend;
  101830. private _blendFunctionParameters;
  101831. private _blendEquationParameters;
  101832. private _blendConstants;
  101833. /**
  101834. * Initializes the state.
  101835. */
  101836. constructor();
  101837. get isDirty(): boolean;
  101838. get alphaBlend(): boolean;
  101839. set alphaBlend(value: boolean);
  101840. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  101841. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  101842. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101843. reset(): void;
  101844. apply(gl: WebGLRenderingContext): void;
  101845. }
  101846. }
  101847. declare module BABYLON {
  101848. /** @hidden */
  101849. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101850. attributeProcessor(attribute: string): string;
  101851. varyingProcessor(varying: string, isFragment: boolean): string;
  101852. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101853. }
  101854. }
  101855. declare module BABYLON {
  101856. /**
  101857. * Interface for attribute information associated with buffer instanciation
  101858. */
  101859. export interface InstancingAttributeInfo {
  101860. /**
  101861. * Name of the GLSL attribute
  101862. * if attribute index is not specified, this is used to retrieve the index from the effect
  101863. */
  101864. attributeName: string;
  101865. /**
  101866. * Index/offset of the attribute in the vertex shader
  101867. * if not specified, this will be computes from the name.
  101868. */
  101869. index?: number;
  101870. /**
  101871. * size of the attribute, 1, 2, 3 or 4
  101872. */
  101873. attributeSize: number;
  101874. /**
  101875. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101876. */
  101877. offset: number;
  101878. /**
  101879. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101880. * default to 1
  101881. */
  101882. divisor?: number;
  101883. /**
  101884. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101885. * default is FLOAT
  101886. */
  101887. attributeType?: number;
  101888. /**
  101889. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101890. */
  101891. normalized?: boolean;
  101892. }
  101893. }
  101894. declare module BABYLON {
  101895. interface ThinEngine {
  101896. /**
  101897. * Update a video texture
  101898. * @param texture defines the texture to update
  101899. * @param video defines the video element to use
  101900. * @param invertY defines if data must be stored with Y axis inverted
  101901. */
  101902. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101903. }
  101904. }
  101905. declare module BABYLON {
  101906. /**
  101907. * Settings for finer control over video usage
  101908. */
  101909. export interface VideoTextureSettings {
  101910. /**
  101911. * Applies `autoplay` to video, if specified
  101912. */
  101913. autoPlay?: boolean;
  101914. /**
  101915. * Applies `loop` to video, if specified
  101916. */
  101917. loop?: boolean;
  101918. /**
  101919. * Automatically updates internal texture from video at every frame in the render loop
  101920. */
  101921. autoUpdateTexture: boolean;
  101922. /**
  101923. * Image src displayed during the video loading or until the user interacts with the video.
  101924. */
  101925. poster?: string;
  101926. }
  101927. /**
  101928. * If you want to display a video in your scene, this is the special texture for that.
  101929. * This special texture works similar to other textures, with the exception of a few parameters.
  101930. * @see https://doc.babylonjs.com/how_to/video_texture
  101931. */
  101932. export class VideoTexture extends Texture {
  101933. /**
  101934. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101935. */
  101936. readonly autoUpdateTexture: boolean;
  101937. /**
  101938. * The video instance used by the texture internally
  101939. */
  101940. readonly video: HTMLVideoElement;
  101941. private _onUserActionRequestedObservable;
  101942. /**
  101943. * Event triggerd when a dom action is required by the user to play the video.
  101944. * This happens due to recent changes in browser policies preventing video to auto start.
  101945. */
  101946. get onUserActionRequestedObservable(): Observable<Texture>;
  101947. private _generateMipMaps;
  101948. private _engine;
  101949. private _stillImageCaptured;
  101950. private _displayingPosterTexture;
  101951. private _settings;
  101952. private _createInternalTextureOnEvent;
  101953. private _frameId;
  101954. /**
  101955. * Creates a video texture.
  101956. * If you want to display a video in your scene, this is the special texture for that.
  101957. * This special texture works similar to other textures, with the exception of a few parameters.
  101958. * @see https://doc.babylonjs.com/how_to/video_texture
  101959. * @param name optional name, will detect from video source, if not defined
  101960. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101961. * @param scene is obviously the current scene.
  101962. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101963. * @param invertY is false by default but can be used to invert video on Y axis
  101964. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101965. * @param settings allows finer control over video usage
  101966. */
  101967. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101968. private _getName;
  101969. private _getVideo;
  101970. private _createInternalTexture;
  101971. private reset;
  101972. /**
  101973. * @hidden Internal method to initiate `update`.
  101974. */
  101975. _rebuild(): void;
  101976. /**
  101977. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101978. */
  101979. update(): void;
  101980. /**
  101981. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101982. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101983. */
  101984. updateTexture(isVisible: boolean): void;
  101985. protected _updateInternalTexture: () => void;
  101986. /**
  101987. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101988. * @param url New url.
  101989. */
  101990. updateURL(url: string): void;
  101991. /**
  101992. * Dispose the texture and release its associated resources.
  101993. */
  101994. dispose(): void;
  101995. /**
  101996. * Creates a video texture straight from a stream.
  101997. * @param scene Define the scene the texture should be created in
  101998. * @param stream Define the stream the texture should be created from
  101999. * @returns The created video texture as a promise
  102000. */
  102001. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  102002. /**
  102003. * Creates a video texture straight from your WebCam video feed.
  102004. * @param scene Define the scene the texture should be created in
  102005. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  102006. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  102007. * @returns The created video texture as a promise
  102008. */
  102009. static CreateFromWebCamAsync(scene: Scene, constraints: {
  102010. minWidth: number;
  102011. maxWidth: number;
  102012. minHeight: number;
  102013. maxHeight: number;
  102014. deviceId: string;
  102015. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  102016. /**
  102017. * Creates a video texture straight from your WebCam video feed.
  102018. * @param scene Define the scene the texture should be created in
  102019. * @param onReady Define a callback to triggered once the texture will be ready
  102020. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  102021. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  102022. */
  102023. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  102024. minWidth: number;
  102025. maxWidth: number;
  102026. minHeight: number;
  102027. maxHeight: number;
  102028. deviceId: string;
  102029. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  102030. }
  102031. }
  102032. declare module BABYLON {
  102033. /**
  102034. * Defines the interface used by objects working like Scene
  102035. * @hidden
  102036. */
  102037. interface ISceneLike {
  102038. _addPendingData(data: any): void;
  102039. _removePendingData(data: any): void;
  102040. offlineProvider: IOfflineProvider;
  102041. }
  102042. /** Interface defining initialization parameters for Engine class */
  102043. export interface EngineOptions extends WebGLContextAttributes {
  102044. /**
  102045. * Defines if the engine should no exceed a specified device ratio
  102046. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  102047. */
  102048. limitDeviceRatio?: number;
  102049. /**
  102050. * Defines if webvr should be enabled automatically
  102051. * @see http://doc.babylonjs.com/how_to/webvr_camera
  102052. */
  102053. autoEnableWebVR?: boolean;
  102054. /**
  102055. * Defines if webgl2 should be turned off even if supported
  102056. * @see http://doc.babylonjs.com/features/webgl2
  102057. */
  102058. disableWebGL2Support?: boolean;
  102059. /**
  102060. * Defines if webaudio should be initialized as well
  102061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102062. */
  102063. audioEngine?: boolean;
  102064. /**
  102065. * Defines if animations should run using a deterministic lock step
  102066. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102067. */
  102068. deterministicLockstep?: boolean;
  102069. /** Defines the maximum steps to use with deterministic lock step mode */
  102070. lockstepMaxSteps?: number;
  102071. /** Defines the seconds between each deterministic lock step */
  102072. timeStep?: number;
  102073. /**
  102074. * Defines that engine should ignore context lost events
  102075. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  102076. */
  102077. doNotHandleContextLost?: boolean;
  102078. /**
  102079. * Defines that engine should ignore modifying touch action attribute and style
  102080. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  102081. */
  102082. doNotHandleTouchAction?: boolean;
  102083. /**
  102084. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  102085. */
  102086. useHighPrecisionFloats?: boolean;
  102087. }
  102088. /**
  102089. * The base engine class (root of all engines)
  102090. */
  102091. export class ThinEngine {
  102092. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  102093. static ExceptionList: ({
  102094. key: string;
  102095. capture: string;
  102096. captureConstraint: number;
  102097. targets: string[];
  102098. } | {
  102099. key: string;
  102100. capture: null;
  102101. captureConstraint: null;
  102102. targets: string[];
  102103. })[];
  102104. /** @hidden */
  102105. static _TextureLoaders: IInternalTextureLoader[];
  102106. /**
  102107. * Returns the current npm package of the sdk
  102108. */
  102109. static get NpmPackage(): string;
  102110. /**
  102111. * Returns the current version of the framework
  102112. */
  102113. static get Version(): string;
  102114. /**
  102115. * Returns a string describing the current engine
  102116. */
  102117. get description(): string;
  102118. /**
  102119. * Gets or sets the epsilon value used by collision engine
  102120. */
  102121. static CollisionsEpsilon: number;
  102122. /**
  102123. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  102124. */
  102125. static get ShadersRepository(): string;
  102126. static set ShadersRepository(value: string);
  102127. /**
  102128. * Gets or sets the textures that the engine should not attempt to load as compressed
  102129. */
  102130. protected _excludedCompressedTextures: string[];
  102131. /**
  102132. * Filters the compressed texture formats to only include
  102133. * files that are not included in the skippable list
  102134. *
  102135. * @param url the current extension
  102136. * @param textureFormatInUse the current compressed texture format
  102137. * @returns "format" string
  102138. */
  102139. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  102140. /** @hidden */
  102141. _shaderProcessor: IShaderProcessor;
  102142. /**
  102143. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  102144. */
  102145. forcePOTTextures: boolean;
  102146. /**
  102147. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  102148. */
  102149. isFullscreen: boolean;
  102150. /**
  102151. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  102152. */
  102153. cullBackFaces: boolean;
  102154. /**
  102155. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  102156. */
  102157. renderEvenInBackground: boolean;
  102158. /**
  102159. * Gets or sets a boolean indicating that cache can be kept between frames
  102160. */
  102161. preventCacheWipeBetweenFrames: boolean;
  102162. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  102163. validateShaderPrograms: boolean;
  102164. /**
  102165. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  102166. * This can provide greater z depth for distant objects.
  102167. */
  102168. useReverseDepthBuffer: boolean;
  102169. /**
  102170. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  102171. */
  102172. disableUniformBuffers: boolean;
  102173. /** @hidden */
  102174. _uniformBuffers: UniformBuffer[];
  102175. /**
  102176. * Gets a boolean indicating that the engine supports uniform buffers
  102177. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  102178. */
  102179. get supportsUniformBuffers(): boolean;
  102180. /** @hidden */
  102181. _gl: WebGLRenderingContext;
  102182. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  102183. protected _windowIsBackground: boolean;
  102184. protected _webGLVersion: number;
  102185. protected _creationOptions: EngineOptions;
  102186. protected _highPrecisionShadersAllowed: boolean;
  102187. /** @hidden */
  102188. get _shouldUseHighPrecisionShader(): boolean;
  102189. /**
  102190. * Gets a boolean indicating that only power of 2 textures are supported
  102191. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  102192. */
  102193. get needPOTTextures(): boolean;
  102194. /** @hidden */
  102195. _badOS: boolean;
  102196. /** @hidden */
  102197. _badDesktopOS: boolean;
  102198. private _hardwareScalingLevel;
  102199. /** @hidden */
  102200. _caps: EngineCapabilities;
  102201. private _isStencilEnable;
  102202. private _glVersion;
  102203. private _glRenderer;
  102204. private _glVendor;
  102205. /** @hidden */
  102206. _videoTextureSupported: boolean;
  102207. protected _renderingQueueLaunched: boolean;
  102208. protected _activeRenderLoops: (() => void)[];
  102209. /**
  102210. * Observable signaled when a context lost event is raised
  102211. */
  102212. onContextLostObservable: Observable<ThinEngine>;
  102213. /**
  102214. * Observable signaled when a context restored event is raised
  102215. */
  102216. onContextRestoredObservable: Observable<ThinEngine>;
  102217. private _onContextLost;
  102218. private _onContextRestored;
  102219. protected _contextWasLost: boolean;
  102220. /** @hidden */
  102221. _doNotHandleContextLost: boolean;
  102222. /**
  102223. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  102224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  102225. */
  102226. get doNotHandleContextLost(): boolean;
  102227. set doNotHandleContextLost(value: boolean);
  102228. /**
  102229. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  102230. */
  102231. disableVertexArrayObjects: boolean;
  102232. /** @hidden */
  102233. protected _colorWrite: boolean;
  102234. /** @hidden */
  102235. protected _colorWriteChanged: boolean;
  102236. /** @hidden */
  102237. protected _depthCullingState: DepthCullingState;
  102238. /** @hidden */
  102239. protected _stencilState: StencilState;
  102240. /** @hidden */
  102241. _alphaState: AlphaState;
  102242. /** @hidden */
  102243. _alphaMode: number;
  102244. /** @hidden */
  102245. _alphaEquation: number;
  102246. /** @hidden */
  102247. _internalTexturesCache: InternalTexture[];
  102248. /** @hidden */
  102249. protected _activeChannel: number;
  102250. private _currentTextureChannel;
  102251. /** @hidden */
  102252. protected _boundTexturesCache: {
  102253. [key: string]: Nullable<InternalTexture>;
  102254. };
  102255. /** @hidden */
  102256. protected _currentEffect: Nullable<Effect>;
  102257. /** @hidden */
  102258. protected _currentProgram: Nullable<WebGLProgram>;
  102259. private _compiledEffects;
  102260. private _vertexAttribArraysEnabled;
  102261. /** @hidden */
  102262. protected _cachedViewport: Nullable<IViewportLike>;
  102263. private _cachedVertexArrayObject;
  102264. /** @hidden */
  102265. protected _cachedVertexBuffers: any;
  102266. /** @hidden */
  102267. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  102268. /** @hidden */
  102269. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  102270. /** @hidden */
  102271. _currentRenderTarget: Nullable<InternalTexture>;
  102272. private _uintIndicesCurrentlySet;
  102273. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  102274. /** @hidden */
  102275. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  102276. private _currentBufferPointers;
  102277. private _currentInstanceLocations;
  102278. private _currentInstanceBuffers;
  102279. private _textureUnits;
  102280. /** @hidden */
  102281. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102282. /** @hidden */
  102283. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102284. /** @hidden */
  102285. _boundRenderFunction: any;
  102286. private _vaoRecordInProgress;
  102287. private _mustWipeVertexAttributes;
  102288. private _emptyTexture;
  102289. private _emptyCubeTexture;
  102290. private _emptyTexture3D;
  102291. private _emptyTexture2DArray;
  102292. /** @hidden */
  102293. _frameHandler: number;
  102294. private _nextFreeTextureSlots;
  102295. private _maxSimultaneousTextures;
  102296. private _activeRequests;
  102297. protected _texturesSupported: string[];
  102298. /** @hidden */
  102299. _textureFormatInUse: Nullable<string>;
  102300. protected get _supportsHardwareTextureRescaling(): boolean;
  102301. /**
  102302. * Gets the list of texture formats supported
  102303. */
  102304. get texturesSupported(): Array<string>;
  102305. /**
  102306. * Gets the list of texture formats in use
  102307. */
  102308. get textureFormatInUse(): Nullable<string>;
  102309. /**
  102310. * Gets the current viewport
  102311. */
  102312. get currentViewport(): Nullable<IViewportLike>;
  102313. /**
  102314. * Gets the default empty texture
  102315. */
  102316. get emptyTexture(): InternalTexture;
  102317. /**
  102318. * Gets the default empty 3D texture
  102319. */
  102320. get emptyTexture3D(): InternalTexture;
  102321. /**
  102322. * Gets the default empty 2D array texture
  102323. */
  102324. get emptyTexture2DArray(): InternalTexture;
  102325. /**
  102326. * Gets the default empty cube texture
  102327. */
  102328. get emptyCubeTexture(): InternalTexture;
  102329. /**
  102330. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  102331. */
  102332. readonly premultipliedAlpha: boolean;
  102333. /**
  102334. * Observable event triggered before each texture is initialized
  102335. */
  102336. onBeforeTextureInitObservable: Observable<Texture>;
  102337. /**
  102338. * Creates a new engine
  102339. * @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
  102340. * @param antialias defines enable antialiasing (default: false)
  102341. * @param options defines further options to be sent to the getContext() function
  102342. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  102343. */
  102344. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  102345. private _rebuildInternalTextures;
  102346. private _rebuildEffects;
  102347. /**
  102348. * Gets a boolean indicating if all created effects are ready
  102349. * @returns true if all effects are ready
  102350. */
  102351. areAllEffectsReady(): boolean;
  102352. protected _rebuildBuffers(): void;
  102353. private _initGLContext;
  102354. /**
  102355. * Gets version of the current webGL context
  102356. */
  102357. get webGLVersion(): number;
  102358. /**
  102359. * Gets a string idenfifying the name of the class
  102360. * @returns "Engine" string
  102361. */
  102362. getClassName(): string;
  102363. /**
  102364. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  102365. */
  102366. get isStencilEnable(): boolean;
  102367. /** @hidden */
  102368. _prepareWorkingCanvas(): void;
  102369. /**
  102370. * Reset the texture cache to empty state
  102371. */
  102372. resetTextureCache(): void;
  102373. /**
  102374. * Gets an object containing information about the current webGL context
  102375. * @returns an object containing the vender, the renderer and the version of the current webGL context
  102376. */
  102377. getGlInfo(): {
  102378. vendor: string;
  102379. renderer: string;
  102380. version: string;
  102381. };
  102382. /**
  102383. * Defines the hardware scaling level.
  102384. * By default the hardware scaling level is computed from the window device ratio.
  102385. * 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.
  102386. * @param level defines the level to use
  102387. */
  102388. setHardwareScalingLevel(level: number): void;
  102389. /**
  102390. * Gets the current hardware scaling level.
  102391. * By default the hardware scaling level is computed from the window device ratio.
  102392. * 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.
  102393. * @returns a number indicating the current hardware scaling level
  102394. */
  102395. getHardwareScalingLevel(): number;
  102396. /**
  102397. * Gets the list of loaded textures
  102398. * @returns an array containing all loaded textures
  102399. */
  102400. getLoadedTexturesCache(): InternalTexture[];
  102401. /**
  102402. * Gets the object containing all engine capabilities
  102403. * @returns the EngineCapabilities object
  102404. */
  102405. getCaps(): EngineCapabilities;
  102406. /**
  102407. * stop executing a render loop function and remove it from the execution array
  102408. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  102409. */
  102410. stopRenderLoop(renderFunction?: () => void): void;
  102411. /** @hidden */
  102412. _renderLoop(): void;
  102413. /**
  102414. * Gets the HTML canvas attached with the current webGL context
  102415. * @returns a HTML canvas
  102416. */
  102417. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  102418. /**
  102419. * Gets host window
  102420. * @returns the host window object
  102421. */
  102422. getHostWindow(): Nullable<Window>;
  102423. /**
  102424. * Gets the current render width
  102425. * @param useScreen defines if screen size must be used (or the current render target if any)
  102426. * @returns a number defining the current render width
  102427. */
  102428. getRenderWidth(useScreen?: boolean): number;
  102429. /**
  102430. * Gets the current render height
  102431. * @param useScreen defines if screen size must be used (or the current render target if any)
  102432. * @returns a number defining the current render height
  102433. */
  102434. getRenderHeight(useScreen?: boolean): number;
  102435. /**
  102436. * Can be used to override the current requestAnimationFrame requester.
  102437. * @hidden
  102438. */
  102439. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  102440. /**
  102441. * Register and execute a render loop. The engine can have more than one render function
  102442. * @param renderFunction defines the function to continuously execute
  102443. */
  102444. runRenderLoop(renderFunction: () => void): void;
  102445. /**
  102446. * Clear the current render buffer or the current render target (if any is set up)
  102447. * @param color defines the color to use
  102448. * @param backBuffer defines if the back buffer must be cleared
  102449. * @param depth defines if the depth buffer must be cleared
  102450. * @param stencil defines if the stencil buffer must be cleared
  102451. */
  102452. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  102453. private _viewportCached;
  102454. /** @hidden */
  102455. _viewport(x: number, y: number, width: number, height: number): void;
  102456. /**
  102457. * Set the WebGL's viewport
  102458. * @param viewport defines the viewport element to be used
  102459. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  102460. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  102461. */
  102462. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  102463. /**
  102464. * Begin a new frame
  102465. */
  102466. beginFrame(): void;
  102467. /**
  102468. * Enf the current frame
  102469. */
  102470. endFrame(): void;
  102471. /**
  102472. * Resize the view according to the canvas' size
  102473. */
  102474. resize(): void;
  102475. /**
  102476. * Force a specific size of the canvas
  102477. * @param width defines the new canvas' width
  102478. * @param height defines the new canvas' height
  102479. */
  102480. setSize(width: number, height: number): void;
  102481. /**
  102482. * Binds the frame buffer to the specified texture.
  102483. * @param texture The texture to render to or null for the default canvas
  102484. * @param faceIndex The face of the texture to render to in case of cube texture
  102485. * @param requiredWidth The width of the target to render to
  102486. * @param requiredHeight The height of the target to render to
  102487. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  102488. * @param depthStencilTexture The depth stencil texture to use to render
  102489. * @param lodLevel defines le lod level to bind to the frame buffer
  102490. */
  102491. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  102492. /** @hidden */
  102493. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  102494. /**
  102495. * Unbind the current render target texture from the webGL context
  102496. * @param texture defines the render target texture to unbind
  102497. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102498. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102499. */
  102500. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  102501. /**
  102502. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  102503. */
  102504. flushFramebuffer(): void;
  102505. /**
  102506. * Unbind the current render target and bind the default framebuffer
  102507. */
  102508. restoreDefaultFramebuffer(): void;
  102509. /** @hidden */
  102510. protected _resetVertexBufferBinding(): void;
  102511. /**
  102512. * Creates a vertex buffer
  102513. * @param data the data for the vertex buffer
  102514. * @returns the new WebGL static buffer
  102515. */
  102516. createVertexBuffer(data: DataArray): DataBuffer;
  102517. private _createVertexBuffer;
  102518. /**
  102519. * Creates a dynamic vertex buffer
  102520. * @param data the data for the dynamic vertex buffer
  102521. * @returns the new WebGL dynamic buffer
  102522. */
  102523. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  102524. protected _resetIndexBufferBinding(): void;
  102525. /**
  102526. * Creates a new index buffer
  102527. * @param indices defines the content of the index buffer
  102528. * @param updatable defines if the index buffer must be updatable
  102529. * @returns a new webGL buffer
  102530. */
  102531. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  102532. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  102533. /**
  102534. * Bind a webGL buffer to the webGL context
  102535. * @param buffer defines the buffer to bind
  102536. */
  102537. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  102538. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  102539. private bindBuffer;
  102540. /**
  102541. * update the bound buffer with the given data
  102542. * @param data defines the data to update
  102543. */
  102544. updateArrayBuffer(data: Float32Array): void;
  102545. private _vertexAttribPointer;
  102546. private _bindIndexBufferWithCache;
  102547. private _bindVertexBuffersAttributes;
  102548. /**
  102549. * Records a vertex array object
  102550. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  102551. * @param vertexBuffers defines the list of vertex buffers to store
  102552. * @param indexBuffer defines the index buffer to store
  102553. * @param effect defines the effect to store
  102554. * @returns the new vertex array object
  102555. */
  102556. recordVertexArrayObject(vertexBuffers: {
  102557. [key: string]: VertexBuffer;
  102558. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  102559. /**
  102560. * Bind a specific vertex array object
  102561. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  102562. * @param vertexArrayObject defines the vertex array object to bind
  102563. * @param indexBuffer defines the index buffer to bind
  102564. */
  102565. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  102566. /**
  102567. * Bind webGl buffers directly to the webGL context
  102568. * @param vertexBuffer defines the vertex buffer to bind
  102569. * @param indexBuffer defines the index buffer to bind
  102570. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  102571. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  102572. * @param effect defines the effect associated with the vertex buffer
  102573. */
  102574. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  102575. private _unbindVertexArrayObject;
  102576. /**
  102577. * Bind a list of vertex buffers to the webGL context
  102578. * @param vertexBuffers defines the list of vertex buffers to bind
  102579. * @param indexBuffer defines the index buffer to bind
  102580. * @param effect defines the effect associated with the vertex buffers
  102581. */
  102582. bindBuffers(vertexBuffers: {
  102583. [key: string]: Nullable<VertexBuffer>;
  102584. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  102585. /**
  102586. * Unbind all instance attributes
  102587. */
  102588. unbindInstanceAttributes(): void;
  102589. /**
  102590. * Release and free the memory of a vertex array object
  102591. * @param vao defines the vertex array object to delete
  102592. */
  102593. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  102594. /** @hidden */
  102595. _releaseBuffer(buffer: DataBuffer): boolean;
  102596. protected _deleteBuffer(buffer: DataBuffer): void;
  102597. /**
  102598. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  102599. * @param instancesBuffer defines the webGL buffer to update and bind
  102600. * @param data defines the data to store in the buffer
  102601. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  102602. */
  102603. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  102604. /**
  102605. * Bind the content of a webGL buffer used with instanciation
  102606. * @param instancesBuffer defines the webGL buffer to bind
  102607. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  102608. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  102609. */
  102610. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  102611. /**
  102612. * Disable the instance attribute corresponding to the name in parameter
  102613. * @param name defines the name of the attribute to disable
  102614. */
  102615. disableInstanceAttributeByName(name: string): void;
  102616. /**
  102617. * Disable the instance attribute corresponding to the location in parameter
  102618. * @param attributeLocation defines the attribute location of the attribute to disable
  102619. */
  102620. disableInstanceAttribute(attributeLocation: number): void;
  102621. /**
  102622. * Disable the attribute corresponding to the location in parameter
  102623. * @param attributeLocation defines the attribute location of the attribute to disable
  102624. */
  102625. disableAttributeByIndex(attributeLocation: number): void;
  102626. /**
  102627. * Send a draw order
  102628. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  102629. * @param indexStart defines the starting index
  102630. * @param indexCount defines the number of index to draw
  102631. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102632. */
  102633. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  102634. /**
  102635. * Draw a list of points
  102636. * @param verticesStart defines the index of first vertex to draw
  102637. * @param verticesCount defines the count of vertices to draw
  102638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102639. */
  102640. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  102641. /**
  102642. * Draw a list of unindexed primitives
  102643. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  102644. * @param verticesStart defines the index of first vertex to draw
  102645. * @param verticesCount defines the count of vertices to draw
  102646. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102647. */
  102648. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  102649. /**
  102650. * Draw a list of indexed primitives
  102651. * @param fillMode defines the primitive to use
  102652. * @param indexStart defines the starting index
  102653. * @param indexCount defines the number of index to draw
  102654. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102655. */
  102656. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  102657. /**
  102658. * Draw a list of unindexed primitives
  102659. * @param fillMode defines the primitive to use
  102660. * @param verticesStart defines the index of first vertex to draw
  102661. * @param verticesCount defines the count of vertices to draw
  102662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102663. */
  102664. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  102665. private _drawMode;
  102666. /** @hidden */
  102667. protected _reportDrawCall(): void;
  102668. /** @hidden */
  102669. _releaseEffect(effect: Effect): void;
  102670. /** @hidden */
  102671. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102672. /**
  102673. * Create a new effect (used to store vertex/fragment shaders)
  102674. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  102675. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  102676. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  102677. * @param samplers defines an array of string used to represent textures
  102678. * @param defines defines the string containing the defines to use to compile the shaders
  102679. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  102680. * @param onCompiled defines a function to call when the effect creation is successful
  102681. * @param onError defines a function to call when the effect creation has failed
  102682. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  102683. * @returns the new Effect
  102684. */
  102685. 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;
  102686. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  102687. private _compileShader;
  102688. private _compileRawShader;
  102689. /**
  102690. * Directly creates a webGL program
  102691. * @param pipelineContext defines the pipeline context to attach to
  102692. * @param vertexCode defines the vertex shader code to use
  102693. * @param fragmentCode defines the fragment shader code to use
  102694. * @param context defines the webGL context to use (if not set, the current one will be used)
  102695. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  102696. * @returns the new webGL program
  102697. */
  102698. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102699. /**
  102700. * Creates a webGL program
  102701. * @param pipelineContext defines the pipeline context to attach to
  102702. * @param vertexCode defines the vertex shader code to use
  102703. * @param fragmentCode defines the fragment shader code to use
  102704. * @param defines defines the string containing the defines to use to compile the shaders
  102705. * @param context defines the webGL context to use (if not set, the current one will be used)
  102706. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  102707. * @returns the new webGL program
  102708. */
  102709. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102710. /**
  102711. * Creates a new pipeline context
  102712. * @returns the new pipeline
  102713. */
  102714. createPipelineContext(): IPipelineContext;
  102715. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102716. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  102717. /** @hidden */
  102718. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  102719. /** @hidden */
  102720. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  102721. /** @hidden */
  102722. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  102723. /**
  102724. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  102725. * @param pipelineContext defines the pipeline context to use
  102726. * @param uniformsNames defines the list of uniform names
  102727. * @returns an array of webGL uniform locations
  102728. */
  102729. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  102730. /**
  102731. * Gets the lsit of active attributes for a given webGL program
  102732. * @param pipelineContext defines the pipeline context to use
  102733. * @param attributesNames defines the list of attribute names to get
  102734. * @returns an array of indices indicating the offset of each attribute
  102735. */
  102736. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  102737. /**
  102738. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  102739. * @param effect defines the effect to activate
  102740. */
  102741. enableEffect(effect: Nullable<Effect>): void;
  102742. /**
  102743. * Set the value of an uniform to a number (int)
  102744. * @param uniform defines the webGL uniform location where to store the value
  102745. * @param value defines the int number to store
  102746. */
  102747. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102748. /**
  102749. * Set the value of an uniform to an array of int32
  102750. * @param uniform defines the webGL uniform location where to store the value
  102751. * @param array defines the array of int32 to store
  102752. */
  102753. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102754. /**
  102755. * Set the value of an uniform to an array of int32 (stored as vec2)
  102756. * @param uniform defines the webGL uniform location where to store the value
  102757. * @param array defines the array of int32 to store
  102758. */
  102759. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102760. /**
  102761. * Set the value of an uniform to an array of int32 (stored as vec3)
  102762. * @param uniform defines the webGL uniform location where to store the value
  102763. * @param array defines the array of int32 to store
  102764. */
  102765. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102766. /**
  102767. * Set the value of an uniform to an array of int32 (stored as vec4)
  102768. * @param uniform defines the webGL uniform location where to store the value
  102769. * @param array defines the array of int32 to store
  102770. */
  102771. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102772. /**
  102773. * Set the value of an uniform to an array of number
  102774. * @param uniform defines the webGL uniform location where to store the value
  102775. * @param array defines the array of number to store
  102776. */
  102777. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102778. /**
  102779. * Set the value of an uniform to an array of number (stored as vec2)
  102780. * @param uniform defines the webGL uniform location where to store the value
  102781. * @param array defines the array of number to store
  102782. */
  102783. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102784. /**
  102785. * Set the value of an uniform to an array of number (stored as vec3)
  102786. * @param uniform defines the webGL uniform location where to store the value
  102787. * @param array defines the array of number to store
  102788. */
  102789. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102790. /**
  102791. * Set the value of an uniform to an array of number (stored as vec4)
  102792. * @param uniform defines the webGL uniform location where to store the value
  102793. * @param array defines the array of number to store
  102794. */
  102795. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102796. /**
  102797. * Set the value of an uniform to an array of float32 (stored as matrices)
  102798. * @param uniform defines the webGL uniform location where to store the value
  102799. * @param matrices defines the array of float32 to store
  102800. */
  102801. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  102802. /**
  102803. * Set the value of an uniform to a matrix (3x3)
  102804. * @param uniform defines the webGL uniform location where to store the value
  102805. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  102806. */
  102807. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102808. /**
  102809. * Set the value of an uniform to a matrix (2x2)
  102810. * @param uniform defines the webGL uniform location where to store the value
  102811. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  102812. */
  102813. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102814. /**
  102815. * Set the value of an uniform to a number (float)
  102816. * @param uniform defines the webGL uniform location where to store the value
  102817. * @param value defines the float number to store
  102818. */
  102819. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102820. /**
  102821. * Set the value of an uniform to a vec2
  102822. * @param uniform defines the webGL uniform location where to store the value
  102823. * @param x defines the 1st component of the value
  102824. * @param y defines the 2nd component of the value
  102825. */
  102826. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  102827. /**
  102828. * Set the value of an uniform to a vec3
  102829. * @param uniform defines the webGL uniform location where to store the value
  102830. * @param x defines the 1st component of the value
  102831. * @param y defines the 2nd component of the value
  102832. * @param z defines the 3rd component of the value
  102833. */
  102834. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  102835. /**
  102836. * Set the value of an uniform to a vec4
  102837. * @param uniform defines the webGL uniform location where to store the value
  102838. * @param x defines the 1st component of the value
  102839. * @param y defines the 2nd component of the value
  102840. * @param z defines the 3rd component of the value
  102841. * @param w defines the 4th component of the value
  102842. */
  102843. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102844. /**
  102845. * Apply all cached states (depth, culling, stencil and alpha)
  102846. */
  102847. applyStates(): void;
  102848. /**
  102849. * Enable or disable color writing
  102850. * @param enable defines the state to set
  102851. */
  102852. setColorWrite(enable: boolean): void;
  102853. /**
  102854. * Gets a boolean indicating if color writing is enabled
  102855. * @returns the current color writing state
  102856. */
  102857. getColorWrite(): boolean;
  102858. /**
  102859. * Gets the depth culling state manager
  102860. */
  102861. get depthCullingState(): DepthCullingState;
  102862. /**
  102863. * Gets the alpha state manager
  102864. */
  102865. get alphaState(): AlphaState;
  102866. /**
  102867. * Gets the stencil state manager
  102868. */
  102869. get stencilState(): StencilState;
  102870. /**
  102871. * Clears the list of texture accessible through engine.
  102872. * This can help preventing texture load conflict due to name collision.
  102873. */
  102874. clearInternalTexturesCache(): void;
  102875. /**
  102876. * Force the entire cache to be cleared
  102877. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102878. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102879. */
  102880. wipeCaches(bruteForce?: boolean): void;
  102881. /** @hidden */
  102882. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102883. min: number;
  102884. mag: number;
  102885. };
  102886. /** @hidden */
  102887. _createTexture(): WebGLTexture;
  102888. /**
  102889. * Usually called from Texture.ts.
  102890. * Passed information to create a WebGLTexture
  102891. * @param urlArg defines a value which contains one of the following:
  102892. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102893. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102894. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102895. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102896. * @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)
  102897. * @param scene needed for loading to the correct scene
  102898. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102899. * @param onLoad optional callback to be called upon successful completion
  102900. * @param onError optional callback to be called upon failure
  102901. * @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
  102902. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102903. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102904. * @param forcedExtension defines the extension to use to pick the right loader
  102905. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102906. * @param mimeType defines an optional mime type
  102907. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102908. */
  102909. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  102910. /**
  102911. * Loads an image as an HTMLImageElement.
  102912. * @param input url string, ArrayBuffer, or Blob to load
  102913. * @param onLoad callback called when the image successfully loads
  102914. * @param onError callback called when the image fails to load
  102915. * @param offlineProvider offline provider for caching
  102916. * @param mimeType optional mime type
  102917. * @returns the HTMLImageElement of the loaded image
  102918. * @hidden
  102919. */
  102920. 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>;
  102921. /**
  102922. * @hidden
  102923. */
  102924. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102925. /**
  102926. * Creates a raw texture
  102927. * @param data defines the data to store in the texture
  102928. * @param width defines the width of the texture
  102929. * @param height defines the height of the texture
  102930. * @param format defines the format of the data
  102931. * @param generateMipMaps defines if the engine should generate the mip levels
  102932. * @param invertY defines if data must be stored with Y axis inverted
  102933. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102934. * @param compression defines the compression used (null by default)
  102935. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102936. * @returns the raw texture inside an InternalTexture
  102937. */
  102938. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102939. /**
  102940. * Creates a new raw cube texture
  102941. * @param data defines the array of data to use to create each face
  102942. * @param size defines the size of the textures
  102943. * @param format defines the format of the data
  102944. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102945. * @param generateMipMaps defines if the engine should generate the mip levels
  102946. * @param invertY defines if data must be stored with Y axis inverted
  102947. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102948. * @param compression defines the compression used (null by default)
  102949. * @returns the cube texture as an InternalTexture
  102950. */
  102951. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102952. /**
  102953. * Creates a new raw 3D texture
  102954. * @param data defines the data used to create the texture
  102955. * @param width defines the width of the texture
  102956. * @param height defines the height of the texture
  102957. * @param depth defines the depth of the texture
  102958. * @param format defines the format of the texture
  102959. * @param generateMipMaps defines if the engine must generate mip levels
  102960. * @param invertY defines if data must be stored with Y axis inverted
  102961. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102962. * @param compression defines the compressed used (can be null)
  102963. * @param textureType defines the compressed used (can be null)
  102964. * @returns a new raw 3D texture (stored in an InternalTexture)
  102965. */
  102966. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102967. /**
  102968. * Creates a new raw 2D array texture
  102969. * @param data defines the data used to create the texture
  102970. * @param width defines the width of the texture
  102971. * @param height defines the height of the texture
  102972. * @param depth defines the number of layers of the texture
  102973. * @param format defines the format of the texture
  102974. * @param generateMipMaps defines if the engine must generate mip levels
  102975. * @param invertY defines if data must be stored with Y axis inverted
  102976. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102977. * @param compression defines the compressed used (can be null)
  102978. * @param textureType defines the compressed used (can be null)
  102979. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102980. */
  102981. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102982. private _unpackFlipYCached;
  102983. /**
  102984. * In case you are sharing the context with other applications, it might
  102985. * be interested to not cache the unpack flip y state to ensure a consistent
  102986. * value would be set.
  102987. */
  102988. enableUnpackFlipYCached: boolean;
  102989. /** @hidden */
  102990. _unpackFlipY(value: boolean): void;
  102991. /** @hidden */
  102992. _getUnpackAlignement(): number;
  102993. private _getTextureTarget;
  102994. /**
  102995. * Update the sampling mode of a given texture
  102996. * @param samplingMode defines the required sampling mode
  102997. * @param texture defines the texture to update
  102998. * @param generateMipMaps defines whether to generate mipmaps for the texture
  102999. */
  103000. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  103001. /**
  103002. * Update the sampling mode of a given texture
  103003. * @param texture defines the texture to update
  103004. * @param wrapU defines the texture wrap mode of the u coordinates
  103005. * @param wrapV defines the texture wrap mode of the v coordinates
  103006. * @param wrapR defines the texture wrap mode of the r coordinates
  103007. */
  103008. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  103009. /** @hidden */
  103010. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  103011. width: number;
  103012. height: number;
  103013. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  103014. /** @hidden */
  103015. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103016. /** @hidden */
  103017. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  103018. /** @hidden */
  103019. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103020. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  103021. private _prepareWebGLTexture;
  103022. /** @hidden */
  103023. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  103024. private _getDepthStencilBuffer;
  103025. /** @hidden */
  103026. _releaseFramebufferObjects(texture: InternalTexture): void;
  103027. /** @hidden */
  103028. _releaseTexture(texture: InternalTexture): void;
  103029. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  103030. protected _setProgram(program: WebGLProgram): void;
  103031. protected _boundUniforms: {
  103032. [key: number]: WebGLUniformLocation;
  103033. };
  103034. /**
  103035. * Binds an effect to the webGL context
  103036. * @param effect defines the effect to bind
  103037. */
  103038. bindSamplers(effect: Effect): void;
  103039. private _activateCurrentTexture;
  103040. /** @hidden */
  103041. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  103042. /** @hidden */
  103043. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  103044. /**
  103045. * Unbind all textures from the webGL context
  103046. */
  103047. unbindAllTextures(): void;
  103048. /**
  103049. * Sets a texture to the according uniform.
  103050. * @param channel The texture channel
  103051. * @param uniform The uniform to set
  103052. * @param texture The texture to apply
  103053. */
  103054. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  103055. private _bindSamplerUniformToChannel;
  103056. private _getTextureWrapMode;
  103057. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  103058. /**
  103059. * Sets an array of texture to the webGL context
  103060. * @param channel defines the channel where the texture array must be set
  103061. * @param uniform defines the associated uniform location
  103062. * @param textures defines the array of textures to bind
  103063. */
  103064. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  103065. /** @hidden */
  103066. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  103067. private _setTextureParameterFloat;
  103068. private _setTextureParameterInteger;
  103069. /**
  103070. * Unbind all vertex attributes from the webGL context
  103071. */
  103072. unbindAllAttributes(): void;
  103073. /**
  103074. * 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
  103075. */
  103076. releaseEffects(): void;
  103077. /**
  103078. * Dispose and release all associated resources
  103079. */
  103080. dispose(): void;
  103081. /**
  103082. * Attach a new callback raised when context lost event is fired
  103083. * @param callback defines the callback to call
  103084. */
  103085. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  103086. /**
  103087. * Attach a new callback raised when context restored event is fired
  103088. * @param callback defines the callback to call
  103089. */
  103090. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  103091. /**
  103092. * Get the current error code of the webGL context
  103093. * @returns the error code
  103094. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  103095. */
  103096. getError(): number;
  103097. private _canRenderToFloatFramebuffer;
  103098. private _canRenderToHalfFloatFramebuffer;
  103099. private _canRenderToFramebuffer;
  103100. /** @hidden */
  103101. _getWebGLTextureType(type: number): number;
  103102. /** @hidden */
  103103. _getInternalFormat(format: number): number;
  103104. /** @hidden */
  103105. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  103106. /** @hidden */
  103107. _getRGBAMultiSampleBufferFormat(type: number): number;
  103108. /** @hidden */
  103109. _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;
  103110. /**
  103111. * Loads a file from a url
  103112. * @param url url to load
  103113. * @param onSuccess callback called when the file successfully loads
  103114. * @param onProgress callback called while file is loading (if the server supports this mode)
  103115. * @param offlineProvider defines the offline provider for caching
  103116. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  103117. * @param onError callback called when the file fails to load
  103118. * @returns a file request object
  103119. * @hidden
  103120. */
  103121. 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;
  103122. /**
  103123. * Reads pixels from the current frame buffer. Please note that this function can be slow
  103124. * @param x defines the x coordinate of the rectangle where pixels must be read
  103125. * @param y defines the y coordinate of the rectangle where pixels must be read
  103126. * @param width defines the width of the rectangle where pixels must be read
  103127. * @param height defines the height of the rectangle where pixels must be read
  103128. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  103129. * @returns a Uint8Array containing RGBA colors
  103130. */
  103131. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  103132. private static _isSupported;
  103133. /**
  103134. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  103135. * @returns true if the engine can be created
  103136. * @ignorenaming
  103137. */
  103138. static isSupported(): boolean;
  103139. /**
  103140. * Find the next highest power of two.
  103141. * @param x Number to start search from.
  103142. * @return Next highest power of two.
  103143. */
  103144. static CeilingPOT(x: number): number;
  103145. /**
  103146. * Find the next lowest power of two.
  103147. * @param x Number to start search from.
  103148. * @return Next lowest power of two.
  103149. */
  103150. static FloorPOT(x: number): number;
  103151. /**
  103152. * Find the nearest power of two.
  103153. * @param x Number to start search from.
  103154. * @return Next nearest power of two.
  103155. */
  103156. static NearestPOT(x: number): number;
  103157. /**
  103158. * Get the closest exponent of two
  103159. * @param value defines the value to approximate
  103160. * @param max defines the maximum value to return
  103161. * @param mode defines how to define the closest value
  103162. * @returns closest exponent of two of the given value
  103163. */
  103164. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  103165. /**
  103166. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  103167. * @param func - the function to be called
  103168. * @param requester - the object that will request the next frame. Falls back to window.
  103169. * @returns frame number
  103170. */
  103171. static QueueNewFrame(func: () => void, requester?: any): number;
  103172. /**
  103173. * Gets host document
  103174. * @returns the host document object
  103175. */
  103176. getHostDocument(): Nullable<Document>;
  103177. }
  103178. }
  103179. declare module BABYLON {
  103180. /**
  103181. * Class representing spherical harmonics coefficients to the 3rd degree
  103182. */
  103183. export class SphericalHarmonics {
  103184. /**
  103185. * Defines whether or not the harmonics have been prescaled for rendering.
  103186. */
  103187. preScaled: boolean;
  103188. /**
  103189. * The l0,0 coefficients of the spherical harmonics
  103190. */
  103191. l00: Vector3;
  103192. /**
  103193. * The l1,-1 coefficients of the spherical harmonics
  103194. */
  103195. l1_1: Vector3;
  103196. /**
  103197. * The l1,0 coefficients of the spherical harmonics
  103198. */
  103199. l10: Vector3;
  103200. /**
  103201. * The l1,1 coefficients of the spherical harmonics
  103202. */
  103203. l11: Vector3;
  103204. /**
  103205. * The l2,-2 coefficients of the spherical harmonics
  103206. */
  103207. l2_2: Vector3;
  103208. /**
  103209. * The l2,-1 coefficients of the spherical harmonics
  103210. */
  103211. l2_1: Vector3;
  103212. /**
  103213. * The l2,0 coefficients of the spherical harmonics
  103214. */
  103215. l20: Vector3;
  103216. /**
  103217. * The l2,1 coefficients of the spherical harmonics
  103218. */
  103219. l21: Vector3;
  103220. /**
  103221. * The l2,2 coefficients of the spherical harmonics
  103222. */
  103223. l22: Vector3;
  103224. /**
  103225. * Adds a light to the spherical harmonics
  103226. * @param direction the direction of the light
  103227. * @param color the color of the light
  103228. * @param deltaSolidAngle the delta solid angle of the light
  103229. */
  103230. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  103231. /**
  103232. * Scales the spherical harmonics by the given amount
  103233. * @param scale the amount to scale
  103234. */
  103235. scaleInPlace(scale: number): void;
  103236. /**
  103237. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  103238. *
  103239. * ```
  103240. * E_lm = A_l * L_lm
  103241. * ```
  103242. *
  103243. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  103244. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  103245. * the scaling factors are given in equation 9.
  103246. */
  103247. convertIncidentRadianceToIrradiance(): void;
  103248. /**
  103249. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  103250. *
  103251. * ```
  103252. * L = (1/pi) * E * rho
  103253. * ```
  103254. *
  103255. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  103256. */
  103257. convertIrradianceToLambertianRadiance(): void;
  103258. /**
  103259. * Integrates the reconstruction coefficients directly in to the SH preventing further
  103260. * required operations at run time.
  103261. *
  103262. * This is simply done by scaling back the SH with Ylm constants parameter.
  103263. * The trigonometric part being applied by the shader at run time.
  103264. */
  103265. preScaleForRendering(): void;
  103266. /**
  103267. * Constructs a spherical harmonics from an array.
  103268. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  103269. * @returns the spherical harmonics
  103270. */
  103271. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  103272. /**
  103273. * Gets the spherical harmonics from polynomial
  103274. * @param polynomial the spherical polynomial
  103275. * @returns the spherical harmonics
  103276. */
  103277. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  103278. }
  103279. /**
  103280. * Class representing spherical polynomial coefficients to the 3rd degree
  103281. */
  103282. export class SphericalPolynomial {
  103283. private _harmonics;
  103284. /**
  103285. * The spherical harmonics used to create the polynomials.
  103286. */
  103287. get preScaledHarmonics(): SphericalHarmonics;
  103288. /**
  103289. * The x coefficients of the spherical polynomial
  103290. */
  103291. x: Vector3;
  103292. /**
  103293. * The y coefficients of the spherical polynomial
  103294. */
  103295. y: Vector3;
  103296. /**
  103297. * The z coefficients of the spherical polynomial
  103298. */
  103299. z: Vector3;
  103300. /**
  103301. * The xx coefficients of the spherical polynomial
  103302. */
  103303. xx: Vector3;
  103304. /**
  103305. * The yy coefficients of the spherical polynomial
  103306. */
  103307. yy: Vector3;
  103308. /**
  103309. * The zz coefficients of the spherical polynomial
  103310. */
  103311. zz: Vector3;
  103312. /**
  103313. * The xy coefficients of the spherical polynomial
  103314. */
  103315. xy: Vector3;
  103316. /**
  103317. * The yz coefficients of the spherical polynomial
  103318. */
  103319. yz: Vector3;
  103320. /**
  103321. * The zx coefficients of the spherical polynomial
  103322. */
  103323. zx: Vector3;
  103324. /**
  103325. * Adds an ambient color to the spherical polynomial
  103326. * @param color the color to add
  103327. */
  103328. addAmbient(color: Color3): void;
  103329. /**
  103330. * Scales the spherical polynomial by the given amount
  103331. * @param scale the amount to scale
  103332. */
  103333. scaleInPlace(scale: number): void;
  103334. /**
  103335. * Gets the spherical polynomial from harmonics
  103336. * @param harmonics the spherical harmonics
  103337. * @returns the spherical polynomial
  103338. */
  103339. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  103340. /**
  103341. * Constructs a spherical polynomial from an array.
  103342. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  103343. * @returns the spherical polynomial
  103344. */
  103345. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  103346. }
  103347. }
  103348. declare module BABYLON {
  103349. /**
  103350. * Defines the source of the internal texture
  103351. */
  103352. export enum InternalTextureSource {
  103353. /**
  103354. * The source of the texture data is unknown
  103355. */
  103356. Unknown = 0,
  103357. /**
  103358. * Texture data comes from an URL
  103359. */
  103360. Url = 1,
  103361. /**
  103362. * Texture data is only used for temporary storage
  103363. */
  103364. Temp = 2,
  103365. /**
  103366. * Texture data comes from raw data (ArrayBuffer)
  103367. */
  103368. Raw = 3,
  103369. /**
  103370. * Texture content is dynamic (video or dynamic texture)
  103371. */
  103372. Dynamic = 4,
  103373. /**
  103374. * Texture content is generated by rendering to it
  103375. */
  103376. RenderTarget = 5,
  103377. /**
  103378. * Texture content is part of a multi render target process
  103379. */
  103380. MultiRenderTarget = 6,
  103381. /**
  103382. * Texture data comes from a cube data file
  103383. */
  103384. Cube = 7,
  103385. /**
  103386. * Texture data comes from a raw cube data
  103387. */
  103388. CubeRaw = 8,
  103389. /**
  103390. * Texture data come from a prefiltered cube data file
  103391. */
  103392. CubePrefiltered = 9,
  103393. /**
  103394. * Texture content is raw 3D data
  103395. */
  103396. Raw3D = 10,
  103397. /**
  103398. * Texture content is raw 2D array data
  103399. */
  103400. Raw2DArray = 11,
  103401. /**
  103402. * Texture content is a depth texture
  103403. */
  103404. Depth = 12,
  103405. /**
  103406. * Texture data comes from a raw cube data encoded with RGBD
  103407. */
  103408. CubeRawRGBD = 13
  103409. }
  103410. /**
  103411. * Class used to store data associated with WebGL texture data for the engine
  103412. * This class should not be used directly
  103413. */
  103414. export class InternalTexture {
  103415. /** @hidden */
  103416. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  103417. /**
  103418. * Defines if the texture is ready
  103419. */
  103420. isReady: boolean;
  103421. /**
  103422. * Defines if the texture is a cube texture
  103423. */
  103424. isCube: boolean;
  103425. /**
  103426. * Defines if the texture contains 3D data
  103427. */
  103428. is3D: boolean;
  103429. /**
  103430. * Defines if the texture contains 2D array data
  103431. */
  103432. is2DArray: boolean;
  103433. /**
  103434. * Defines if the texture contains multiview data
  103435. */
  103436. isMultiview: boolean;
  103437. /**
  103438. * Gets the URL used to load this texture
  103439. */
  103440. url: string;
  103441. /**
  103442. * Gets the sampling mode of the texture
  103443. */
  103444. samplingMode: number;
  103445. /**
  103446. * Gets a boolean indicating if the texture needs mipmaps generation
  103447. */
  103448. generateMipMaps: boolean;
  103449. /**
  103450. * Gets the number of samples used by the texture (WebGL2+ only)
  103451. */
  103452. samples: number;
  103453. /**
  103454. * Gets the type of the texture (int, float...)
  103455. */
  103456. type: number;
  103457. /**
  103458. * Gets the format of the texture (RGB, RGBA...)
  103459. */
  103460. format: number;
  103461. /**
  103462. * Observable called when the texture is loaded
  103463. */
  103464. onLoadedObservable: Observable<InternalTexture>;
  103465. /**
  103466. * Gets the width of the texture
  103467. */
  103468. width: number;
  103469. /**
  103470. * Gets the height of the texture
  103471. */
  103472. height: number;
  103473. /**
  103474. * Gets the depth of the texture
  103475. */
  103476. depth: number;
  103477. /**
  103478. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  103479. */
  103480. baseWidth: number;
  103481. /**
  103482. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  103483. */
  103484. baseHeight: number;
  103485. /**
  103486. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  103487. */
  103488. baseDepth: number;
  103489. /**
  103490. * Gets a boolean indicating if the texture is inverted on Y axis
  103491. */
  103492. invertY: boolean;
  103493. /** @hidden */
  103494. _invertVScale: boolean;
  103495. /** @hidden */
  103496. _associatedChannel: number;
  103497. /** @hidden */
  103498. _source: InternalTextureSource;
  103499. /** @hidden */
  103500. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103501. /** @hidden */
  103502. _bufferView: Nullable<ArrayBufferView>;
  103503. /** @hidden */
  103504. _bufferViewArray: Nullable<ArrayBufferView[]>;
  103505. /** @hidden */
  103506. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  103507. /** @hidden */
  103508. _size: number;
  103509. /** @hidden */
  103510. _extension: string;
  103511. /** @hidden */
  103512. _files: Nullable<string[]>;
  103513. /** @hidden */
  103514. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  103515. /** @hidden */
  103516. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  103517. /** @hidden */
  103518. _framebuffer: Nullable<WebGLFramebuffer>;
  103519. /** @hidden */
  103520. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  103521. /** @hidden */
  103522. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  103523. /** @hidden */
  103524. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  103525. /** @hidden */
  103526. _attachments: Nullable<number[]>;
  103527. /** @hidden */
  103528. _cachedCoordinatesMode: Nullable<number>;
  103529. /** @hidden */
  103530. _cachedWrapU: Nullable<number>;
  103531. /** @hidden */
  103532. _cachedWrapV: Nullable<number>;
  103533. /** @hidden */
  103534. _cachedWrapR: Nullable<number>;
  103535. /** @hidden */
  103536. _cachedAnisotropicFilteringLevel: Nullable<number>;
  103537. /** @hidden */
  103538. _isDisabled: boolean;
  103539. /** @hidden */
  103540. _compression: Nullable<string>;
  103541. /** @hidden */
  103542. _generateStencilBuffer: boolean;
  103543. /** @hidden */
  103544. _generateDepthBuffer: boolean;
  103545. /** @hidden */
  103546. _comparisonFunction: number;
  103547. /** @hidden */
  103548. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  103549. /** @hidden */
  103550. _lodGenerationScale: number;
  103551. /** @hidden */
  103552. _lodGenerationOffset: number;
  103553. /** @hidden */
  103554. _colorTextureArray: Nullable<WebGLTexture>;
  103555. /** @hidden */
  103556. _depthStencilTextureArray: Nullable<WebGLTexture>;
  103557. /** @hidden */
  103558. _lodTextureHigh: Nullable<BaseTexture>;
  103559. /** @hidden */
  103560. _lodTextureMid: Nullable<BaseTexture>;
  103561. /** @hidden */
  103562. _lodTextureLow: Nullable<BaseTexture>;
  103563. /** @hidden */
  103564. _isRGBD: boolean;
  103565. /** @hidden */
  103566. _linearSpecularLOD: boolean;
  103567. /** @hidden */
  103568. _irradianceTexture: Nullable<BaseTexture>;
  103569. /** @hidden */
  103570. _webGLTexture: Nullable<WebGLTexture>;
  103571. /** @hidden */
  103572. _references: number;
  103573. private _engine;
  103574. /**
  103575. * Gets the Engine the texture belongs to.
  103576. * @returns The babylon engine
  103577. */
  103578. getEngine(): ThinEngine;
  103579. /**
  103580. * Gets the data source type of the texture
  103581. */
  103582. get source(): InternalTextureSource;
  103583. /**
  103584. * Creates a new InternalTexture
  103585. * @param engine defines the engine to use
  103586. * @param source defines the type of data that will be used
  103587. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103588. */
  103589. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  103590. /**
  103591. * Increments the number of references (ie. the number of Texture that point to it)
  103592. */
  103593. incrementReferences(): void;
  103594. /**
  103595. * Change the size of the texture (not the size of the content)
  103596. * @param width defines the new width
  103597. * @param height defines the new height
  103598. * @param depth defines the new depth (1 by default)
  103599. */
  103600. updateSize(width: int, height: int, depth?: int): void;
  103601. /** @hidden */
  103602. _rebuild(): void;
  103603. /** @hidden */
  103604. _swapAndDie(target: InternalTexture): void;
  103605. /**
  103606. * Dispose the current allocated resources
  103607. */
  103608. dispose(): void;
  103609. }
  103610. }
  103611. declare module BABYLON {
  103612. /**
  103613. * Class used to work with sound analyzer using fast fourier transform (FFT)
  103614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103615. */
  103616. export class Analyser {
  103617. /**
  103618. * Gets or sets the smoothing
  103619. * @ignorenaming
  103620. */
  103621. SMOOTHING: number;
  103622. /**
  103623. * Gets or sets the FFT table size
  103624. * @ignorenaming
  103625. */
  103626. FFT_SIZE: number;
  103627. /**
  103628. * Gets or sets the bar graph amplitude
  103629. * @ignorenaming
  103630. */
  103631. BARGRAPHAMPLITUDE: number;
  103632. /**
  103633. * Gets or sets the position of the debug canvas
  103634. * @ignorenaming
  103635. */
  103636. DEBUGCANVASPOS: {
  103637. x: number;
  103638. y: number;
  103639. };
  103640. /**
  103641. * Gets or sets the debug canvas size
  103642. * @ignorenaming
  103643. */
  103644. DEBUGCANVASSIZE: {
  103645. width: number;
  103646. height: number;
  103647. };
  103648. private _byteFreqs;
  103649. private _byteTime;
  103650. private _floatFreqs;
  103651. private _webAudioAnalyser;
  103652. private _debugCanvas;
  103653. private _debugCanvasContext;
  103654. private _scene;
  103655. private _registerFunc;
  103656. private _audioEngine;
  103657. /**
  103658. * Creates a new analyser
  103659. * @param scene defines hosting scene
  103660. */
  103661. constructor(scene: Scene);
  103662. /**
  103663. * Get the number of data values you will have to play with for the visualization
  103664. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  103665. * @returns a number
  103666. */
  103667. getFrequencyBinCount(): number;
  103668. /**
  103669. * Gets the current frequency data as a byte array
  103670. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  103671. * @returns a Uint8Array
  103672. */
  103673. getByteFrequencyData(): Uint8Array;
  103674. /**
  103675. * Gets the current waveform as a byte array
  103676. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  103677. * @returns a Uint8Array
  103678. */
  103679. getByteTimeDomainData(): Uint8Array;
  103680. /**
  103681. * Gets the current frequency data as a float array
  103682. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  103683. * @returns a Float32Array
  103684. */
  103685. getFloatFrequencyData(): Float32Array;
  103686. /**
  103687. * Renders the debug canvas
  103688. */
  103689. drawDebugCanvas(): void;
  103690. /**
  103691. * Stops rendering the debug canvas and removes it
  103692. */
  103693. stopDebugCanvas(): void;
  103694. /**
  103695. * Connects two audio nodes
  103696. * @param inputAudioNode defines first node to connect
  103697. * @param outputAudioNode defines second node to connect
  103698. */
  103699. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  103700. /**
  103701. * Releases all associated resources
  103702. */
  103703. dispose(): void;
  103704. }
  103705. }
  103706. declare module BABYLON {
  103707. /**
  103708. * This represents an audio engine and it is responsible
  103709. * to play, synchronize and analyse sounds throughout the application.
  103710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103711. */
  103712. export interface IAudioEngine extends IDisposable {
  103713. /**
  103714. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103715. */
  103716. readonly canUseWebAudio: boolean;
  103717. /**
  103718. * Gets the current AudioContext if available.
  103719. */
  103720. readonly audioContext: Nullable<AudioContext>;
  103721. /**
  103722. * The master gain node defines the global audio volume of your audio engine.
  103723. */
  103724. readonly masterGain: GainNode;
  103725. /**
  103726. * Gets whether or not mp3 are supported by your browser.
  103727. */
  103728. readonly isMP3supported: boolean;
  103729. /**
  103730. * Gets whether or not ogg are supported by your browser.
  103731. */
  103732. readonly isOGGsupported: boolean;
  103733. /**
  103734. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103735. * @ignoreNaming
  103736. */
  103737. WarnedWebAudioUnsupported: boolean;
  103738. /**
  103739. * Defines if the audio engine relies on a custom unlocked button.
  103740. * In this case, the embedded button will not be displayed.
  103741. */
  103742. useCustomUnlockedButton: boolean;
  103743. /**
  103744. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  103745. */
  103746. readonly unlocked: boolean;
  103747. /**
  103748. * Event raised when audio has been unlocked on the browser.
  103749. */
  103750. onAudioUnlockedObservable: Observable<AudioEngine>;
  103751. /**
  103752. * Event raised when audio has been locked on the browser.
  103753. */
  103754. onAudioLockedObservable: Observable<AudioEngine>;
  103755. /**
  103756. * Flags the audio engine in Locked state.
  103757. * This happens due to new browser policies preventing audio to autoplay.
  103758. */
  103759. lock(): void;
  103760. /**
  103761. * Unlocks the audio engine once a user action has been done on the dom.
  103762. * This is helpful to resume play once browser policies have been satisfied.
  103763. */
  103764. unlock(): void;
  103765. }
  103766. /**
  103767. * This represents the default audio engine used in babylon.
  103768. * It is responsible to play, synchronize and analyse sounds throughout the application.
  103769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103770. */
  103771. export class AudioEngine implements IAudioEngine {
  103772. private _audioContext;
  103773. private _audioContextInitialized;
  103774. private _muteButton;
  103775. private _hostElement;
  103776. /**
  103777. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103778. */
  103779. canUseWebAudio: boolean;
  103780. /**
  103781. * The master gain node defines the global audio volume of your audio engine.
  103782. */
  103783. masterGain: GainNode;
  103784. /**
  103785. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103786. * @ignoreNaming
  103787. */
  103788. WarnedWebAudioUnsupported: boolean;
  103789. /**
  103790. * Gets whether or not mp3 are supported by your browser.
  103791. */
  103792. isMP3supported: boolean;
  103793. /**
  103794. * Gets whether or not ogg are supported by your browser.
  103795. */
  103796. isOGGsupported: boolean;
  103797. /**
  103798. * Gets whether audio has been unlocked on the device.
  103799. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  103800. * a user interaction has happened.
  103801. */
  103802. unlocked: boolean;
  103803. /**
  103804. * Defines if the audio engine relies on a custom unlocked button.
  103805. * In this case, the embedded button will not be displayed.
  103806. */
  103807. useCustomUnlockedButton: boolean;
  103808. /**
  103809. * Event raised when audio has been unlocked on the browser.
  103810. */
  103811. onAudioUnlockedObservable: Observable<AudioEngine>;
  103812. /**
  103813. * Event raised when audio has been locked on the browser.
  103814. */
  103815. onAudioLockedObservable: Observable<AudioEngine>;
  103816. /**
  103817. * Gets the current AudioContext if available.
  103818. */
  103819. get audioContext(): Nullable<AudioContext>;
  103820. private _connectedAnalyser;
  103821. /**
  103822. * Instantiates a new audio engine.
  103823. *
  103824. * There should be only one per page as some browsers restrict the number
  103825. * of audio contexts you can create.
  103826. * @param hostElement defines the host element where to display the mute icon if necessary
  103827. */
  103828. constructor(hostElement?: Nullable<HTMLElement>);
  103829. /**
  103830. * Flags the audio engine in Locked state.
  103831. * This happens due to new browser policies preventing audio to autoplay.
  103832. */
  103833. lock(): void;
  103834. /**
  103835. * Unlocks the audio engine once a user action has been done on the dom.
  103836. * This is helpful to resume play once browser policies have been satisfied.
  103837. */
  103838. unlock(): void;
  103839. private _resumeAudioContext;
  103840. private _initializeAudioContext;
  103841. private _tryToRun;
  103842. private _triggerRunningState;
  103843. private _triggerSuspendedState;
  103844. private _displayMuteButton;
  103845. private _moveButtonToTopLeft;
  103846. private _onResize;
  103847. private _hideMuteButton;
  103848. /**
  103849. * Destroy and release the resources associated with the audio ccontext.
  103850. */
  103851. dispose(): void;
  103852. /**
  103853. * Gets the global volume sets on the master gain.
  103854. * @returns the global volume if set or -1 otherwise
  103855. */
  103856. getGlobalVolume(): number;
  103857. /**
  103858. * Sets the global volume of your experience (sets on the master gain).
  103859. * @param newVolume Defines the new global volume of the application
  103860. */
  103861. setGlobalVolume(newVolume: number): void;
  103862. /**
  103863. * Connect the audio engine to an audio analyser allowing some amazing
  103864. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103866. * @param analyser The analyser to connect to the engine
  103867. */
  103868. connectToAnalyser(analyser: Analyser): void;
  103869. }
  103870. }
  103871. declare module BABYLON {
  103872. /**
  103873. * Interface used to present a loading screen while loading a scene
  103874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103875. */
  103876. export interface ILoadingScreen {
  103877. /**
  103878. * Function called to display the loading screen
  103879. */
  103880. displayLoadingUI: () => void;
  103881. /**
  103882. * Function called to hide the loading screen
  103883. */
  103884. hideLoadingUI: () => void;
  103885. /**
  103886. * Gets or sets the color to use for the background
  103887. */
  103888. loadingUIBackgroundColor: string;
  103889. /**
  103890. * Gets or sets the text to display while loading
  103891. */
  103892. loadingUIText: string;
  103893. }
  103894. /**
  103895. * Class used for the default loading screen
  103896. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103897. */
  103898. export class DefaultLoadingScreen implements ILoadingScreen {
  103899. private _renderingCanvas;
  103900. private _loadingText;
  103901. private _loadingDivBackgroundColor;
  103902. private _loadingDiv;
  103903. private _loadingTextDiv;
  103904. /** Gets or sets the logo url to use for the default loading screen */
  103905. static DefaultLogoUrl: string;
  103906. /** Gets or sets the spinner url to use for the default loading screen */
  103907. static DefaultSpinnerUrl: string;
  103908. /**
  103909. * Creates a new default loading screen
  103910. * @param _renderingCanvas defines the canvas used to render the scene
  103911. * @param _loadingText defines the default text to display
  103912. * @param _loadingDivBackgroundColor defines the default background color
  103913. */
  103914. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103915. /**
  103916. * Function called to display the loading screen
  103917. */
  103918. displayLoadingUI(): void;
  103919. /**
  103920. * Function called to hide the loading screen
  103921. */
  103922. hideLoadingUI(): void;
  103923. /**
  103924. * Gets or sets the text to display while loading
  103925. */
  103926. set loadingUIText(text: string);
  103927. get loadingUIText(): string;
  103928. /**
  103929. * Gets or sets the color to use for the background
  103930. */
  103931. get loadingUIBackgroundColor(): string;
  103932. set loadingUIBackgroundColor(color: string);
  103933. private _resizeLoadingUI;
  103934. }
  103935. }
  103936. declare module BABYLON {
  103937. /**
  103938. * Interface for any object that can request an animation frame
  103939. */
  103940. export interface ICustomAnimationFrameRequester {
  103941. /**
  103942. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103943. */
  103944. renderFunction?: Function;
  103945. /**
  103946. * Called to request the next frame to render to
  103947. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103948. */
  103949. requestAnimationFrame: Function;
  103950. /**
  103951. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103952. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103953. */
  103954. requestID?: number;
  103955. }
  103956. }
  103957. declare module BABYLON {
  103958. /**
  103959. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103960. */
  103961. export class PerformanceMonitor {
  103962. private _enabled;
  103963. private _rollingFrameTime;
  103964. private _lastFrameTimeMs;
  103965. /**
  103966. * constructor
  103967. * @param frameSampleSize The number of samples required to saturate the sliding window
  103968. */
  103969. constructor(frameSampleSize?: number);
  103970. /**
  103971. * Samples current frame
  103972. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103973. */
  103974. sampleFrame(timeMs?: number): void;
  103975. /**
  103976. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103977. */
  103978. get averageFrameTime(): number;
  103979. /**
  103980. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103981. */
  103982. get averageFrameTimeVariance(): number;
  103983. /**
  103984. * Returns the frame time of the most recent frame
  103985. */
  103986. get instantaneousFrameTime(): number;
  103987. /**
  103988. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  103989. */
  103990. get averageFPS(): number;
  103991. /**
  103992. * Returns the average framerate in frames per second using the most recent frame time
  103993. */
  103994. get instantaneousFPS(): number;
  103995. /**
  103996. * Returns true if enough samples have been taken to completely fill the sliding window
  103997. */
  103998. get isSaturated(): boolean;
  103999. /**
  104000. * Enables contributions to the sliding window sample set
  104001. */
  104002. enable(): void;
  104003. /**
  104004. * Disables contributions to the sliding window sample set
  104005. * Samples will not be interpolated over the disabled period
  104006. */
  104007. disable(): void;
  104008. /**
  104009. * Returns true if sampling is enabled
  104010. */
  104011. get isEnabled(): boolean;
  104012. /**
  104013. * Resets performance monitor
  104014. */
  104015. reset(): void;
  104016. }
  104017. /**
  104018. * RollingAverage
  104019. *
  104020. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  104021. */
  104022. export class RollingAverage {
  104023. /**
  104024. * Current average
  104025. */
  104026. average: number;
  104027. /**
  104028. * Current variance
  104029. */
  104030. variance: number;
  104031. protected _samples: Array<number>;
  104032. protected _sampleCount: number;
  104033. protected _pos: number;
  104034. protected _m2: number;
  104035. /**
  104036. * constructor
  104037. * @param length The number of samples required to saturate the sliding window
  104038. */
  104039. constructor(length: number);
  104040. /**
  104041. * Adds a sample to the sample set
  104042. * @param v The sample value
  104043. */
  104044. add(v: number): void;
  104045. /**
  104046. * Returns previously added values or null if outside of history or outside the sliding window domain
  104047. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  104048. * @return Value previously recorded with add() or null if outside of range
  104049. */
  104050. history(i: number): number;
  104051. /**
  104052. * Returns true if enough samples have been taken to completely fill the sliding window
  104053. * @return true if sample-set saturated
  104054. */
  104055. isSaturated(): boolean;
  104056. /**
  104057. * Resets the rolling average (equivalent to 0 samples taken so far)
  104058. */
  104059. reset(): void;
  104060. /**
  104061. * Wraps a value around the sample range boundaries
  104062. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  104063. * @return Wrapped position in sample range
  104064. */
  104065. protected _wrapPosition(i: number): number;
  104066. }
  104067. }
  104068. declare module BABYLON {
  104069. /**
  104070. * This class is used to track a performance counter which is number based.
  104071. * The user has access to many properties which give statistics of different nature.
  104072. *
  104073. * The implementer can track two kinds of Performance Counter: time and count.
  104074. * 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.
  104075. * 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.
  104076. */
  104077. export class PerfCounter {
  104078. /**
  104079. * Gets or sets a global boolean to turn on and off all the counters
  104080. */
  104081. static Enabled: boolean;
  104082. /**
  104083. * Returns the smallest value ever
  104084. */
  104085. get min(): number;
  104086. /**
  104087. * Returns the biggest value ever
  104088. */
  104089. get max(): number;
  104090. /**
  104091. * Returns the average value since the performance counter is running
  104092. */
  104093. get average(): number;
  104094. /**
  104095. * Returns the average value of the last second the counter was monitored
  104096. */
  104097. get lastSecAverage(): number;
  104098. /**
  104099. * Returns the current value
  104100. */
  104101. get current(): number;
  104102. /**
  104103. * Gets the accumulated total
  104104. */
  104105. get total(): number;
  104106. /**
  104107. * Gets the total value count
  104108. */
  104109. get count(): number;
  104110. /**
  104111. * Creates a new counter
  104112. */
  104113. constructor();
  104114. /**
  104115. * Call this method to start monitoring a new frame.
  104116. * 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.
  104117. */
  104118. fetchNewFrame(): void;
  104119. /**
  104120. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  104121. * @param newCount the count value to add to the monitored count
  104122. * @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.
  104123. */
  104124. addCount(newCount: number, fetchResult: boolean): void;
  104125. /**
  104126. * Start monitoring this performance counter
  104127. */
  104128. beginMonitoring(): void;
  104129. /**
  104130. * Compute the time lapsed since the previous beginMonitoring() call.
  104131. * @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
  104132. */
  104133. endMonitoring(newFrame?: boolean): void;
  104134. private _fetchResult;
  104135. private _startMonitoringTime;
  104136. private _min;
  104137. private _max;
  104138. private _average;
  104139. private _current;
  104140. private _totalValueCount;
  104141. private _totalAccumulated;
  104142. private _lastSecAverage;
  104143. private _lastSecAccumulated;
  104144. private _lastSecTime;
  104145. private _lastSecValueCount;
  104146. }
  104147. }
  104148. declare module BABYLON {
  104149. interface ThinEngine {
  104150. /**
  104151. * Sets alpha constants used by some alpha blending modes
  104152. * @param r defines the red component
  104153. * @param g defines the green component
  104154. * @param b defines the blue component
  104155. * @param a defines the alpha component
  104156. */
  104157. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  104158. /**
  104159. * Sets the current alpha mode
  104160. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  104161. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  104162. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  104163. */
  104164. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104165. /**
  104166. * Gets the current alpha mode
  104167. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  104168. * @returns the current alpha mode
  104169. */
  104170. getAlphaMode(): number;
  104171. /**
  104172. * Sets the current alpha equation
  104173. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  104174. */
  104175. setAlphaEquation(equation: number): void;
  104176. /**
  104177. * Gets the current alpha equation.
  104178. * @returns the current alpha equation
  104179. */
  104180. getAlphaEquation(): number;
  104181. }
  104182. }
  104183. declare module BABYLON {
  104184. /**
  104185. * Defines the interface used by display changed events
  104186. */
  104187. export interface IDisplayChangedEventArgs {
  104188. /** Gets the vrDisplay object (if any) */
  104189. vrDisplay: Nullable<any>;
  104190. /** Gets a boolean indicating if webVR is supported */
  104191. vrSupported: boolean;
  104192. }
  104193. /**
  104194. * Defines the interface used by objects containing a viewport (like a camera)
  104195. */
  104196. interface IViewportOwnerLike {
  104197. /**
  104198. * Gets or sets the viewport
  104199. */
  104200. viewport: IViewportLike;
  104201. }
  104202. /**
  104203. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  104204. */
  104205. export class Engine extends ThinEngine {
  104206. /** Defines that alpha blending is disabled */
  104207. static readonly ALPHA_DISABLE: number;
  104208. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  104209. static readonly ALPHA_ADD: number;
  104210. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  104211. static readonly ALPHA_COMBINE: number;
  104212. /** Defines that alpha blending to DEST - SRC * DEST */
  104213. static readonly ALPHA_SUBTRACT: number;
  104214. /** Defines that alpha blending to SRC * DEST */
  104215. static readonly ALPHA_MULTIPLY: number;
  104216. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  104217. static readonly ALPHA_MAXIMIZED: number;
  104218. /** Defines that alpha blending to SRC + DEST */
  104219. static readonly ALPHA_ONEONE: number;
  104220. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  104221. static readonly ALPHA_PREMULTIPLIED: number;
  104222. /**
  104223. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  104224. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  104225. */
  104226. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  104227. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  104228. static readonly ALPHA_INTERPOLATE: number;
  104229. /**
  104230. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  104231. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  104232. */
  104233. static readonly ALPHA_SCREENMODE: number;
  104234. /** Defines that the ressource is not delayed*/
  104235. static readonly DELAYLOADSTATE_NONE: number;
  104236. /** Defines that the ressource was successfully delay loaded */
  104237. static readonly DELAYLOADSTATE_LOADED: number;
  104238. /** Defines that the ressource is currently delay loading */
  104239. static readonly DELAYLOADSTATE_LOADING: number;
  104240. /** Defines that the ressource is delayed and has not started loading */
  104241. static readonly DELAYLOADSTATE_NOTLOADED: number;
  104242. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  104243. static readonly NEVER: number;
  104244. /** 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 */
  104245. static readonly ALWAYS: number;
  104246. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  104247. static readonly LESS: number;
  104248. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  104249. static readonly EQUAL: number;
  104250. /** 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 */
  104251. static readonly LEQUAL: number;
  104252. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  104253. static readonly GREATER: number;
  104254. /** 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 */
  104255. static readonly GEQUAL: number;
  104256. /** 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 */
  104257. static readonly NOTEQUAL: number;
  104258. /** Passed to stencilOperation to specify that stencil value must be kept */
  104259. static readonly KEEP: number;
  104260. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104261. static readonly REPLACE: number;
  104262. /** Passed to stencilOperation to specify that stencil value must be incremented */
  104263. static readonly INCR: number;
  104264. /** Passed to stencilOperation to specify that stencil value must be decremented */
  104265. static readonly DECR: number;
  104266. /** Passed to stencilOperation to specify that stencil value must be inverted */
  104267. static readonly INVERT: number;
  104268. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  104269. static readonly INCR_WRAP: number;
  104270. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  104271. static readonly DECR_WRAP: number;
  104272. /** Texture is not repeating outside of 0..1 UVs */
  104273. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  104274. /** Texture is repeating outside of 0..1 UVs */
  104275. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  104276. /** Texture is repeating and mirrored */
  104277. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  104278. /** ALPHA */
  104279. static readonly TEXTUREFORMAT_ALPHA: number;
  104280. /** LUMINANCE */
  104281. static readonly TEXTUREFORMAT_LUMINANCE: number;
  104282. /** LUMINANCE_ALPHA */
  104283. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  104284. /** RGB */
  104285. static readonly TEXTUREFORMAT_RGB: number;
  104286. /** RGBA */
  104287. static readonly TEXTUREFORMAT_RGBA: number;
  104288. /** RED */
  104289. static readonly TEXTUREFORMAT_RED: number;
  104290. /** RED (2nd reference) */
  104291. static readonly TEXTUREFORMAT_R: number;
  104292. /** RG */
  104293. static readonly TEXTUREFORMAT_RG: number;
  104294. /** RED_INTEGER */
  104295. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  104296. /** RED_INTEGER (2nd reference) */
  104297. static readonly TEXTUREFORMAT_R_INTEGER: number;
  104298. /** RG_INTEGER */
  104299. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  104300. /** RGB_INTEGER */
  104301. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  104302. /** RGBA_INTEGER */
  104303. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  104304. /** UNSIGNED_BYTE */
  104305. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  104306. /** UNSIGNED_BYTE (2nd reference) */
  104307. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  104308. /** FLOAT */
  104309. static readonly TEXTURETYPE_FLOAT: number;
  104310. /** HALF_FLOAT */
  104311. static readonly TEXTURETYPE_HALF_FLOAT: number;
  104312. /** BYTE */
  104313. static readonly TEXTURETYPE_BYTE: number;
  104314. /** SHORT */
  104315. static readonly TEXTURETYPE_SHORT: number;
  104316. /** UNSIGNED_SHORT */
  104317. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  104318. /** INT */
  104319. static readonly TEXTURETYPE_INT: number;
  104320. /** UNSIGNED_INT */
  104321. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  104322. /** UNSIGNED_SHORT_4_4_4_4 */
  104323. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  104324. /** UNSIGNED_SHORT_5_5_5_1 */
  104325. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  104326. /** UNSIGNED_SHORT_5_6_5 */
  104327. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  104328. /** UNSIGNED_INT_2_10_10_10_REV */
  104329. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  104330. /** UNSIGNED_INT_24_8 */
  104331. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  104332. /** UNSIGNED_INT_10F_11F_11F_REV */
  104333. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  104334. /** UNSIGNED_INT_5_9_9_9_REV */
  104335. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  104336. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  104337. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  104338. /** nearest is mag = nearest and min = nearest and mip = linear */
  104339. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  104340. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104341. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  104342. /** Trilinear is mag = linear and min = linear and mip = linear */
  104343. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  104344. /** nearest is mag = nearest and min = nearest and mip = linear */
  104345. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  104346. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104347. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  104348. /** Trilinear is mag = linear and min = linear and mip = linear */
  104349. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  104350. /** mag = nearest and min = nearest and mip = nearest */
  104351. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  104352. /** mag = nearest and min = linear and mip = nearest */
  104353. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  104354. /** mag = nearest and min = linear and mip = linear */
  104355. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  104356. /** mag = nearest and min = linear and mip = none */
  104357. static readonly TEXTURE_NEAREST_LINEAR: number;
  104358. /** mag = nearest and min = nearest and mip = none */
  104359. static readonly TEXTURE_NEAREST_NEAREST: number;
  104360. /** mag = linear and min = nearest and mip = nearest */
  104361. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  104362. /** mag = linear and min = nearest and mip = linear */
  104363. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  104364. /** mag = linear and min = linear and mip = none */
  104365. static readonly TEXTURE_LINEAR_LINEAR: number;
  104366. /** mag = linear and min = nearest and mip = none */
  104367. static readonly TEXTURE_LINEAR_NEAREST: number;
  104368. /** Explicit coordinates mode */
  104369. static readonly TEXTURE_EXPLICIT_MODE: number;
  104370. /** Spherical coordinates mode */
  104371. static readonly TEXTURE_SPHERICAL_MODE: number;
  104372. /** Planar coordinates mode */
  104373. static readonly TEXTURE_PLANAR_MODE: number;
  104374. /** Cubic coordinates mode */
  104375. static readonly TEXTURE_CUBIC_MODE: number;
  104376. /** Projection coordinates mode */
  104377. static readonly TEXTURE_PROJECTION_MODE: number;
  104378. /** Skybox coordinates mode */
  104379. static readonly TEXTURE_SKYBOX_MODE: number;
  104380. /** Inverse Cubic coordinates mode */
  104381. static readonly TEXTURE_INVCUBIC_MODE: number;
  104382. /** Equirectangular coordinates mode */
  104383. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  104384. /** Equirectangular Fixed coordinates mode */
  104385. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  104386. /** Equirectangular Fixed Mirrored coordinates mode */
  104387. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104388. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  104389. static readonly SCALEMODE_FLOOR: number;
  104390. /** Defines that texture rescaling will look for the nearest power of 2 size */
  104391. static readonly SCALEMODE_NEAREST: number;
  104392. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  104393. static readonly SCALEMODE_CEILING: number;
  104394. /**
  104395. * Returns the current npm package of the sdk
  104396. */
  104397. static get NpmPackage(): string;
  104398. /**
  104399. * Returns the current version of the framework
  104400. */
  104401. static get Version(): string;
  104402. /** Gets the list of created engines */
  104403. static get Instances(): Engine[];
  104404. /**
  104405. * Gets the latest created engine
  104406. */
  104407. static get LastCreatedEngine(): Nullable<Engine>;
  104408. /**
  104409. * Gets the latest created scene
  104410. */
  104411. static get LastCreatedScene(): Nullable<Scene>;
  104412. /**
  104413. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  104414. * @param flag defines which part of the materials must be marked as dirty
  104415. * @param predicate defines a predicate used to filter which materials should be affected
  104416. */
  104417. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  104418. /**
  104419. * Method called to create the default loading screen.
  104420. * This can be overriden in your own app.
  104421. * @param canvas The rendering canvas element
  104422. * @returns The loading screen
  104423. */
  104424. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  104425. /**
  104426. * Method called to create the default rescale post process on each engine.
  104427. */
  104428. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  104429. /**
  104430. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  104431. **/
  104432. enableOfflineSupport: boolean;
  104433. /**
  104434. * 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)
  104435. **/
  104436. disableManifestCheck: boolean;
  104437. /**
  104438. * Gets the list of created scenes
  104439. */
  104440. scenes: Scene[];
  104441. /**
  104442. * Event raised when a new scene is created
  104443. */
  104444. onNewSceneAddedObservable: Observable<Scene>;
  104445. /**
  104446. * Gets the list of created postprocesses
  104447. */
  104448. postProcesses: PostProcess[];
  104449. /**
  104450. * Gets a boolean indicating if the pointer is currently locked
  104451. */
  104452. isPointerLock: boolean;
  104453. /**
  104454. * Observable event triggered each time the rendering canvas is resized
  104455. */
  104456. onResizeObservable: Observable<Engine>;
  104457. /**
  104458. * Observable event triggered each time the canvas loses focus
  104459. */
  104460. onCanvasBlurObservable: Observable<Engine>;
  104461. /**
  104462. * Observable event triggered each time the canvas gains focus
  104463. */
  104464. onCanvasFocusObservable: Observable<Engine>;
  104465. /**
  104466. * Observable event triggered each time the canvas receives pointerout event
  104467. */
  104468. onCanvasPointerOutObservable: Observable<PointerEvent>;
  104469. /**
  104470. * Observable raised when the engine begins a new frame
  104471. */
  104472. onBeginFrameObservable: Observable<Engine>;
  104473. /**
  104474. * If set, will be used to request the next animation frame for the render loop
  104475. */
  104476. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  104477. /**
  104478. * Observable raised when the engine ends the current frame
  104479. */
  104480. onEndFrameObservable: Observable<Engine>;
  104481. /**
  104482. * Observable raised when the engine is about to compile a shader
  104483. */
  104484. onBeforeShaderCompilationObservable: Observable<Engine>;
  104485. /**
  104486. * Observable raised when the engine has jsut compiled a shader
  104487. */
  104488. onAfterShaderCompilationObservable: Observable<Engine>;
  104489. /**
  104490. * Gets the audio engine
  104491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104492. * @ignorenaming
  104493. */
  104494. static audioEngine: IAudioEngine;
  104495. /**
  104496. * Default AudioEngine factory responsible of creating the Audio Engine.
  104497. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  104498. */
  104499. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  104500. /**
  104501. * Default offline support factory responsible of creating a tool used to store data locally.
  104502. * By default, this will create a Database object if the workload has been embedded.
  104503. */
  104504. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  104505. private _loadingScreen;
  104506. private _pointerLockRequested;
  104507. private _dummyFramebuffer;
  104508. private _rescalePostProcess;
  104509. private _deterministicLockstep;
  104510. private _lockstepMaxSteps;
  104511. private _timeStep;
  104512. protected get _supportsHardwareTextureRescaling(): boolean;
  104513. private _fps;
  104514. private _deltaTime;
  104515. /** @hidden */
  104516. _drawCalls: PerfCounter;
  104517. /**
  104518. * Turn this value on if you want to pause FPS computation when in background
  104519. */
  104520. disablePerformanceMonitorInBackground: boolean;
  104521. private _performanceMonitor;
  104522. /**
  104523. * Gets the performance monitor attached to this engine
  104524. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  104525. */
  104526. get performanceMonitor(): PerformanceMonitor;
  104527. private _onFocus;
  104528. private _onBlur;
  104529. private _onCanvasPointerOut;
  104530. private _onCanvasBlur;
  104531. private _onCanvasFocus;
  104532. private _onFullscreenChange;
  104533. private _onPointerLockChange;
  104534. /**
  104535. * Gets the HTML element used to attach event listeners
  104536. * @returns a HTML element
  104537. */
  104538. getInputElement(): Nullable<HTMLElement>;
  104539. /**
  104540. * Creates a new engine
  104541. * @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
  104542. * @param antialias defines enable antialiasing (default: false)
  104543. * @param options defines further options to be sent to the getContext() function
  104544. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104545. */
  104546. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104547. /**
  104548. * Gets current aspect ratio
  104549. * @param viewportOwner defines the camera to use to get the aspect ratio
  104550. * @param useScreen defines if screen size must be used (or the current render target if any)
  104551. * @returns a number defining the aspect ratio
  104552. */
  104553. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  104554. /**
  104555. * Gets current screen aspect ratio
  104556. * @returns a number defining the aspect ratio
  104557. */
  104558. getScreenAspectRatio(): number;
  104559. /**
  104560. * Gets the client rect of the HTML canvas attached with the current webGL context
  104561. * @returns a client rectanglee
  104562. */
  104563. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  104564. /**
  104565. * Gets the client rect of the HTML element used for events
  104566. * @returns a client rectanglee
  104567. */
  104568. getInputElementClientRect(): Nullable<ClientRect>;
  104569. /**
  104570. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  104571. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104572. * @returns true if engine is in deterministic lock step mode
  104573. */
  104574. isDeterministicLockStep(): boolean;
  104575. /**
  104576. * Gets the max steps when engine is running in deterministic lock step
  104577. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104578. * @returns the max steps
  104579. */
  104580. getLockstepMaxSteps(): number;
  104581. /**
  104582. * Returns the time in ms between steps when using deterministic lock step.
  104583. * @returns time step in (ms)
  104584. */
  104585. getTimeStep(): number;
  104586. /**
  104587. * Force the mipmap generation for the given render target texture
  104588. * @param texture defines the render target texture to use
  104589. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  104590. */
  104591. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  104592. /** States */
  104593. /**
  104594. * Set various states to the webGL context
  104595. * @param culling defines backface culling state
  104596. * @param zOffset defines the value to apply to zOffset (0 by default)
  104597. * @param force defines if states must be applied even if cache is up to date
  104598. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  104599. */
  104600. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104601. /**
  104602. * Set the z offset to apply to current rendering
  104603. * @param value defines the offset to apply
  104604. */
  104605. setZOffset(value: number): void;
  104606. /**
  104607. * Gets the current value of the zOffset
  104608. * @returns the current zOffset state
  104609. */
  104610. getZOffset(): number;
  104611. /**
  104612. * Enable or disable depth buffering
  104613. * @param enable defines the state to set
  104614. */
  104615. setDepthBuffer(enable: boolean): void;
  104616. /**
  104617. * Gets a boolean indicating if depth writing is enabled
  104618. * @returns the current depth writing state
  104619. */
  104620. getDepthWrite(): boolean;
  104621. /**
  104622. * Enable or disable depth writing
  104623. * @param enable defines the state to set
  104624. */
  104625. setDepthWrite(enable: boolean): void;
  104626. /**
  104627. * Gets a boolean indicating if stencil buffer is enabled
  104628. * @returns the current stencil buffer state
  104629. */
  104630. getStencilBuffer(): boolean;
  104631. /**
  104632. * Enable or disable the stencil buffer
  104633. * @param enable defines if the stencil buffer must be enabled or disabled
  104634. */
  104635. setStencilBuffer(enable: boolean): void;
  104636. /**
  104637. * Gets the current stencil mask
  104638. * @returns a number defining the new stencil mask to use
  104639. */
  104640. getStencilMask(): number;
  104641. /**
  104642. * Sets the current stencil mask
  104643. * @param mask defines the new stencil mask to use
  104644. */
  104645. setStencilMask(mask: number): void;
  104646. /**
  104647. * Gets the current stencil function
  104648. * @returns a number defining the stencil function to use
  104649. */
  104650. getStencilFunction(): number;
  104651. /**
  104652. * Gets the current stencil reference value
  104653. * @returns a number defining the stencil reference value to use
  104654. */
  104655. getStencilFunctionReference(): number;
  104656. /**
  104657. * Gets the current stencil mask
  104658. * @returns a number defining the stencil mask to use
  104659. */
  104660. getStencilFunctionMask(): number;
  104661. /**
  104662. * Sets the current stencil function
  104663. * @param stencilFunc defines the new stencil function to use
  104664. */
  104665. setStencilFunction(stencilFunc: number): void;
  104666. /**
  104667. * Sets the current stencil reference
  104668. * @param reference defines the new stencil reference to use
  104669. */
  104670. setStencilFunctionReference(reference: number): void;
  104671. /**
  104672. * Sets the current stencil mask
  104673. * @param mask defines the new stencil mask to use
  104674. */
  104675. setStencilFunctionMask(mask: number): void;
  104676. /**
  104677. * Gets the current stencil operation when stencil fails
  104678. * @returns a number defining stencil operation to use when stencil fails
  104679. */
  104680. getStencilOperationFail(): number;
  104681. /**
  104682. * Gets the current stencil operation when depth fails
  104683. * @returns a number defining stencil operation to use when depth fails
  104684. */
  104685. getStencilOperationDepthFail(): number;
  104686. /**
  104687. * Gets the current stencil operation when stencil passes
  104688. * @returns a number defining stencil operation to use when stencil passes
  104689. */
  104690. getStencilOperationPass(): number;
  104691. /**
  104692. * Sets the stencil operation to use when stencil fails
  104693. * @param operation defines the stencil operation to use when stencil fails
  104694. */
  104695. setStencilOperationFail(operation: number): void;
  104696. /**
  104697. * Sets the stencil operation to use when depth fails
  104698. * @param operation defines the stencil operation to use when depth fails
  104699. */
  104700. setStencilOperationDepthFail(operation: number): void;
  104701. /**
  104702. * Sets the stencil operation to use when stencil passes
  104703. * @param operation defines the stencil operation to use when stencil passes
  104704. */
  104705. setStencilOperationPass(operation: number): void;
  104706. /**
  104707. * Sets a boolean indicating if the dithering state is enabled or disabled
  104708. * @param value defines the dithering state
  104709. */
  104710. setDitheringState(value: boolean): void;
  104711. /**
  104712. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  104713. * @param value defines the rasterizer state
  104714. */
  104715. setRasterizerState(value: boolean): void;
  104716. /**
  104717. * Gets the current depth function
  104718. * @returns a number defining the depth function
  104719. */
  104720. getDepthFunction(): Nullable<number>;
  104721. /**
  104722. * Sets the current depth function
  104723. * @param depthFunc defines the function to use
  104724. */
  104725. setDepthFunction(depthFunc: number): void;
  104726. /**
  104727. * Sets the current depth function to GREATER
  104728. */
  104729. setDepthFunctionToGreater(): void;
  104730. /**
  104731. * Sets the current depth function to GEQUAL
  104732. */
  104733. setDepthFunctionToGreaterOrEqual(): void;
  104734. /**
  104735. * Sets the current depth function to LESS
  104736. */
  104737. setDepthFunctionToLess(): void;
  104738. /**
  104739. * Sets the current depth function to LEQUAL
  104740. */
  104741. setDepthFunctionToLessOrEqual(): void;
  104742. private _cachedStencilBuffer;
  104743. private _cachedStencilFunction;
  104744. private _cachedStencilMask;
  104745. private _cachedStencilOperationPass;
  104746. private _cachedStencilOperationFail;
  104747. private _cachedStencilOperationDepthFail;
  104748. private _cachedStencilReference;
  104749. /**
  104750. * Caches the the state of the stencil buffer
  104751. */
  104752. cacheStencilState(): void;
  104753. /**
  104754. * Restores the state of the stencil buffer
  104755. */
  104756. restoreStencilState(): void;
  104757. /**
  104758. * Directly set the WebGL Viewport
  104759. * @param x defines the x coordinate of the viewport (in screen space)
  104760. * @param y defines the y coordinate of the viewport (in screen space)
  104761. * @param width defines the width of the viewport (in screen space)
  104762. * @param height defines the height of the viewport (in screen space)
  104763. * @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
  104764. */
  104765. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  104766. /**
  104767. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  104768. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104769. * @param y defines the y-coordinate of the corner of the clear rectangle
  104770. * @param width defines the width of the clear rectangle
  104771. * @param height defines the height of the clear rectangle
  104772. * @param clearColor defines the clear color
  104773. */
  104774. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  104775. /**
  104776. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  104777. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104778. * @param y defines the y-coordinate of the corner of the clear rectangle
  104779. * @param width defines the width of the clear rectangle
  104780. * @param height defines the height of the clear rectangle
  104781. */
  104782. enableScissor(x: number, y: number, width: number, height: number): void;
  104783. /**
  104784. * Disable previously set scissor test rectangle
  104785. */
  104786. disableScissor(): void;
  104787. protected _reportDrawCall(): void;
  104788. /**
  104789. * Initializes a webVR display and starts listening to display change events
  104790. * The onVRDisplayChangedObservable will be notified upon these changes
  104791. * @returns The onVRDisplayChangedObservable
  104792. */
  104793. initWebVR(): Observable<IDisplayChangedEventArgs>;
  104794. /** @hidden */
  104795. _prepareVRComponent(): void;
  104796. /** @hidden */
  104797. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  104798. /** @hidden */
  104799. _submitVRFrame(): void;
  104800. /**
  104801. * Call this function to leave webVR mode
  104802. * Will do nothing if webVR is not supported or if there is no webVR device
  104803. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104804. */
  104805. disableVR(): void;
  104806. /**
  104807. * Gets a boolean indicating that the system is in VR mode and is presenting
  104808. * @returns true if VR mode is engaged
  104809. */
  104810. isVRPresenting(): boolean;
  104811. /** @hidden */
  104812. _requestVRFrame(): void;
  104813. /** @hidden */
  104814. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  104815. /**
  104816. * Gets the source code of the vertex shader associated with a specific webGL program
  104817. * @param program defines the program to use
  104818. * @returns a string containing the source code of the vertex shader associated with the program
  104819. */
  104820. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  104821. /**
  104822. * Gets the source code of the fragment shader associated with a specific webGL program
  104823. * @param program defines the program to use
  104824. * @returns a string containing the source code of the fragment shader associated with the program
  104825. */
  104826. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  104827. /**
  104828. * Sets a depth stencil texture from a render target to the according uniform.
  104829. * @param channel The texture channel
  104830. * @param uniform The uniform to set
  104831. * @param texture The render target texture containing the depth stencil texture to apply
  104832. */
  104833. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  104834. /**
  104835. * Sets a texture to the webGL context from a postprocess
  104836. * @param channel defines the channel to use
  104837. * @param postProcess defines the source postprocess
  104838. */
  104839. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  104840. /**
  104841. * Binds the output of the passed in post process to the texture channel specified
  104842. * @param channel The channel the texture should be bound to
  104843. * @param postProcess The post process which's output should be bound
  104844. */
  104845. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  104846. /** @hidden */
  104847. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  104848. protected _rebuildBuffers(): void;
  104849. /** @hidden */
  104850. _renderFrame(): void;
  104851. _renderLoop(): void;
  104852. /** @hidden */
  104853. _renderViews(): boolean;
  104854. /**
  104855. * Toggle full screen mode
  104856. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104857. */
  104858. switchFullscreen(requestPointerLock: boolean): void;
  104859. /**
  104860. * Enters full screen mode
  104861. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104862. */
  104863. enterFullscreen(requestPointerLock: boolean): void;
  104864. /**
  104865. * Exits full screen mode
  104866. */
  104867. exitFullscreen(): void;
  104868. /**
  104869. * Enters Pointerlock mode
  104870. */
  104871. enterPointerlock(): void;
  104872. /**
  104873. * Exits Pointerlock mode
  104874. */
  104875. exitPointerlock(): void;
  104876. /**
  104877. * Begin a new frame
  104878. */
  104879. beginFrame(): void;
  104880. /**
  104881. * Enf the current frame
  104882. */
  104883. endFrame(): void;
  104884. resize(): void;
  104885. /**
  104886. * Set the compressed texture format to use, based on the formats you have, and the formats
  104887. * supported by the hardware / browser.
  104888. *
  104889. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104890. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104891. * to API arguments needed to compressed textures. This puts the burden on the container
  104892. * generator to house the arcane code for determining these for current & future formats.
  104893. *
  104894. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104895. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104896. *
  104897. * Note: The result of this call is not taken into account when a texture is base64.
  104898. *
  104899. * @param formatsAvailable defines the list of those format families you have created
  104900. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104901. *
  104902. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104903. * @returns The extension selected.
  104904. */
  104905. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104906. /**
  104907. * Set the compressed texture extensions or file names to skip.
  104908. *
  104909. * @param skippedFiles defines the list of those texture files you want to skip
  104910. * Example: [".dds", ".env", "myfile.png"]
  104911. */
  104912. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104913. /**
  104914. * Force a specific size of the canvas
  104915. * @param width defines the new canvas' width
  104916. * @param height defines the new canvas' height
  104917. */
  104918. setSize(width: number, height: number): void;
  104919. /**
  104920. * Updates a dynamic vertex buffer.
  104921. * @param vertexBuffer the vertex buffer to update
  104922. * @param data the data used to update the vertex buffer
  104923. * @param byteOffset the byte offset of the data
  104924. * @param byteLength the byte length of the data
  104925. */
  104926. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104927. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104928. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104929. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104930. _releaseTexture(texture: InternalTexture): void;
  104931. /**
  104932. * @hidden
  104933. * Rescales a texture
  104934. * @param source input texutre
  104935. * @param destination destination texture
  104936. * @param scene scene to use to render the resize
  104937. * @param internalFormat format to use when resizing
  104938. * @param onComplete callback to be called when resize has completed
  104939. */
  104940. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104941. /**
  104942. * Gets the current framerate
  104943. * @returns a number representing the framerate
  104944. */
  104945. getFps(): number;
  104946. /**
  104947. * Gets the time spent between current and previous frame
  104948. * @returns a number representing the delta time in ms
  104949. */
  104950. getDeltaTime(): number;
  104951. private _measureFps;
  104952. /** @hidden */
  104953. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104954. /**
  104955. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104956. * @param renderTarget The render target to set the frame buffer for
  104957. */
  104958. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104959. /**
  104960. * Update a dynamic index buffer
  104961. * @param indexBuffer defines the target index buffer
  104962. * @param indices defines the data to update
  104963. * @param offset defines the offset in the target index buffer where update should start
  104964. */
  104965. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104966. /**
  104967. * Updates the sample count of a render target texture
  104968. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104969. * @param texture defines the texture to update
  104970. * @param samples defines the sample count to set
  104971. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104972. */
  104973. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104974. /**
  104975. * Updates a depth texture Comparison Mode and Function.
  104976. * If the comparison Function is equal to 0, the mode will be set to none.
  104977. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104978. * @param texture The texture to set the comparison function for
  104979. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104980. */
  104981. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104982. /**
  104983. * Creates a webGL buffer to use with instanciation
  104984. * @param capacity defines the size of the buffer
  104985. * @returns the webGL buffer
  104986. */
  104987. createInstancesBuffer(capacity: number): DataBuffer;
  104988. /**
  104989. * Delete a webGL buffer used with instanciation
  104990. * @param buffer defines the webGL buffer to delete
  104991. */
  104992. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  104993. /** @hidden */
  104994. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  104995. dispose(): void;
  104996. private _disableTouchAction;
  104997. /**
  104998. * Display the loading screen
  104999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105000. */
  105001. displayLoadingUI(): void;
  105002. /**
  105003. * Hide the loading screen
  105004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105005. */
  105006. hideLoadingUI(): void;
  105007. /**
  105008. * Gets the current loading screen object
  105009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105010. */
  105011. get loadingScreen(): ILoadingScreen;
  105012. /**
  105013. * Sets the current loading screen object
  105014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105015. */
  105016. set loadingScreen(loadingScreen: ILoadingScreen);
  105017. /**
  105018. * Sets the current loading screen text
  105019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105020. */
  105021. set loadingUIText(text: string);
  105022. /**
  105023. * Sets the current loading screen background color
  105024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105025. */
  105026. set loadingUIBackgroundColor(color: string);
  105027. /** Pointerlock and fullscreen */
  105028. /**
  105029. * Ask the browser to promote the current element to pointerlock mode
  105030. * @param element defines the DOM element to promote
  105031. */
  105032. static _RequestPointerlock(element: HTMLElement): void;
  105033. /**
  105034. * Asks the browser to exit pointerlock mode
  105035. */
  105036. static _ExitPointerlock(): void;
  105037. /**
  105038. * Ask the browser to promote the current element to fullscreen rendering mode
  105039. * @param element defines the DOM element to promote
  105040. */
  105041. static _RequestFullscreen(element: HTMLElement): void;
  105042. /**
  105043. * Asks the browser to exit fullscreen mode
  105044. */
  105045. static _ExitFullscreen(): void;
  105046. }
  105047. }
  105048. declare module BABYLON {
  105049. /**
  105050. * The engine store class is responsible to hold all the instances of Engine and Scene created
  105051. * during the life time of the application.
  105052. */
  105053. export class EngineStore {
  105054. /** Gets the list of created engines */
  105055. static Instances: Engine[];
  105056. /** @hidden */
  105057. static _LastCreatedScene: Nullable<Scene>;
  105058. /**
  105059. * Gets the latest created engine
  105060. */
  105061. static get LastCreatedEngine(): Nullable<Engine>;
  105062. /**
  105063. * Gets the latest created scene
  105064. */
  105065. static get LastCreatedScene(): Nullable<Scene>;
  105066. /**
  105067. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  105068. * @ignorenaming
  105069. */
  105070. static UseFallbackTexture: boolean;
  105071. /**
  105072. * Texture content used if a texture cannot loaded
  105073. * @ignorenaming
  105074. */
  105075. static FallbackTexture: string;
  105076. }
  105077. }
  105078. declare module BABYLON {
  105079. /**
  105080. * Helper class that provides a small promise polyfill
  105081. */
  105082. export class PromisePolyfill {
  105083. /**
  105084. * Static function used to check if the polyfill is required
  105085. * If this is the case then the function will inject the polyfill to window.Promise
  105086. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  105087. */
  105088. static Apply(force?: boolean): void;
  105089. }
  105090. }
  105091. declare module BABYLON {
  105092. /**
  105093. * Interface for screenshot methods with describe argument called `size` as object with options
  105094. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  105095. */
  105096. export interface IScreenshotSize {
  105097. /**
  105098. * number in pixels for canvas height
  105099. */
  105100. height?: number;
  105101. /**
  105102. * multiplier allowing render at a higher or lower resolution
  105103. * If value is defined then height and width will be ignored and taken from camera
  105104. */
  105105. precision?: number;
  105106. /**
  105107. * number in pixels for canvas width
  105108. */
  105109. width?: number;
  105110. }
  105111. }
  105112. declare module BABYLON {
  105113. interface IColor4Like {
  105114. r: float;
  105115. g: float;
  105116. b: float;
  105117. a: float;
  105118. }
  105119. /**
  105120. * Class containing a set of static utilities functions
  105121. */
  105122. export class Tools {
  105123. /**
  105124. * Gets or sets the base URL to use to load assets
  105125. */
  105126. static get BaseUrl(): string;
  105127. static set BaseUrl(value: string);
  105128. /**
  105129. * Enable/Disable Custom HTTP Request Headers globally.
  105130. * default = false
  105131. * @see CustomRequestHeaders
  105132. */
  105133. static UseCustomRequestHeaders: boolean;
  105134. /**
  105135. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  105136. * i.e. when loading files, where the server/service expects an Authorization header
  105137. */
  105138. static CustomRequestHeaders: {
  105139. [key: string]: string;
  105140. };
  105141. /**
  105142. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  105143. */
  105144. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  105145. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  105146. /**
  105147. * Default behaviour for cors in the application.
  105148. * It can be a string if the expected behavior is identical in the entire app.
  105149. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  105150. */
  105151. static CorsBehavior: string | ((url: string | string[]) => string);
  105152. /**
  105153. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  105154. * @ignorenaming
  105155. */
  105156. static get UseFallbackTexture(): boolean;
  105157. static set UseFallbackTexture(value: boolean);
  105158. /**
  105159. * Use this object to register external classes like custom textures or material
  105160. * to allow the laoders to instantiate them
  105161. */
  105162. static get RegisteredExternalClasses(): {
  105163. [key: string]: Object;
  105164. };
  105165. static set RegisteredExternalClasses(classes: {
  105166. [key: string]: Object;
  105167. });
  105168. /**
  105169. * Texture content used if a texture cannot loaded
  105170. * @ignorenaming
  105171. */
  105172. static get fallbackTexture(): string;
  105173. static set fallbackTexture(value: string);
  105174. /**
  105175. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  105176. * @param u defines the coordinate on X axis
  105177. * @param v defines the coordinate on Y axis
  105178. * @param width defines the width of the source data
  105179. * @param height defines the height of the source data
  105180. * @param pixels defines the source byte array
  105181. * @param color defines the output color
  105182. */
  105183. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  105184. /**
  105185. * Interpolates between a and b via alpha
  105186. * @param a The lower value (returned when alpha = 0)
  105187. * @param b The upper value (returned when alpha = 1)
  105188. * @param alpha The interpolation-factor
  105189. * @return The mixed value
  105190. */
  105191. static Mix(a: number, b: number, alpha: number): number;
  105192. /**
  105193. * Tries to instantiate a new object from a given class name
  105194. * @param className defines the class name to instantiate
  105195. * @returns the new object or null if the system was not able to do the instantiation
  105196. */
  105197. static Instantiate(className: string): any;
  105198. /**
  105199. * Provides a slice function that will work even on IE
  105200. * @param data defines the array to slice
  105201. * @param start defines the start of the data (optional)
  105202. * @param end defines the end of the data (optional)
  105203. * @returns the new sliced array
  105204. */
  105205. static Slice<T>(data: T, start?: number, end?: number): T;
  105206. /**
  105207. * Polyfill for setImmediate
  105208. * @param action defines the action to execute after the current execution block
  105209. */
  105210. static SetImmediate(action: () => void): void;
  105211. /**
  105212. * Function indicating if a number is an exponent of 2
  105213. * @param value defines the value to test
  105214. * @returns true if the value is an exponent of 2
  105215. */
  105216. static IsExponentOfTwo(value: number): boolean;
  105217. private static _tmpFloatArray;
  105218. /**
  105219. * Returns the nearest 32-bit single precision float representation of a Number
  105220. * @param value A Number. If the parameter is of a different type, it will get converted
  105221. * to a number or to NaN if it cannot be converted
  105222. * @returns number
  105223. */
  105224. static FloatRound(value: number): number;
  105225. /**
  105226. * Extracts the filename from a path
  105227. * @param path defines the path to use
  105228. * @returns the filename
  105229. */
  105230. static GetFilename(path: string): string;
  105231. /**
  105232. * Extracts the "folder" part of a path (everything before the filename).
  105233. * @param uri The URI to extract the info from
  105234. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  105235. * @returns The "folder" part of the path
  105236. */
  105237. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  105238. /**
  105239. * Extracts text content from a DOM element hierarchy
  105240. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  105241. */
  105242. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  105243. /**
  105244. * Convert an angle in radians to degrees
  105245. * @param angle defines the angle to convert
  105246. * @returns the angle in degrees
  105247. */
  105248. static ToDegrees(angle: number): number;
  105249. /**
  105250. * Convert an angle in degrees to radians
  105251. * @param angle defines the angle to convert
  105252. * @returns the angle in radians
  105253. */
  105254. static ToRadians(angle: number): number;
  105255. /**
  105256. * Returns an array if obj is not an array
  105257. * @param obj defines the object to evaluate as an array
  105258. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  105259. * @returns either obj directly if obj is an array or a new array containing obj
  105260. */
  105261. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  105262. /**
  105263. * Gets the pointer prefix to use
  105264. * @returns "pointer" if touch is enabled. Else returns "mouse"
  105265. */
  105266. static GetPointerPrefix(): string;
  105267. /**
  105268. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  105269. * @param url define the url we are trying
  105270. * @param element define the dom element where to configure the cors policy
  105271. */
  105272. static SetCorsBehavior(url: string | string[], element: {
  105273. crossOrigin: string | null;
  105274. }): void;
  105275. /**
  105276. * Removes unwanted characters from an url
  105277. * @param url defines the url to clean
  105278. * @returns the cleaned url
  105279. */
  105280. static CleanUrl(url: string): string;
  105281. /**
  105282. * Gets or sets a function used to pre-process url before using them to load assets
  105283. */
  105284. static get PreprocessUrl(): (url: string) => string;
  105285. static set PreprocessUrl(processor: (url: string) => string);
  105286. /**
  105287. * Loads an image as an HTMLImageElement.
  105288. * @param input url string, ArrayBuffer, or Blob to load
  105289. * @param onLoad callback called when the image successfully loads
  105290. * @param onError callback called when the image fails to load
  105291. * @param offlineProvider offline provider for caching
  105292. * @param mimeType optional mime type
  105293. * @returns the HTMLImageElement of the loaded image
  105294. */
  105295. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  105296. /**
  105297. * Loads a file from a url
  105298. * @param url url string, ArrayBuffer, or Blob to load
  105299. * @param onSuccess callback called when the file successfully loads
  105300. * @param onProgress callback called while file is loading (if the server supports this mode)
  105301. * @param offlineProvider defines the offline provider for caching
  105302. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105303. * @param onError callback called when the file fails to load
  105304. * @returns a file request object
  105305. */
  105306. 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;
  105307. /**
  105308. * Loads a file from a url
  105309. * @param url the file url to load
  105310. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  105311. */
  105312. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  105313. /**
  105314. * Load a script (identified by an url). When the url returns, the
  105315. * content of this file is added into a new script element, attached to the DOM (body element)
  105316. * @param scriptUrl defines the url of the script to laod
  105317. * @param onSuccess defines the callback called when the script is loaded
  105318. * @param onError defines the callback to call if an error occurs
  105319. * @param scriptId defines the id of the script element
  105320. */
  105321. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  105322. /**
  105323. * Load an asynchronous script (identified by an url). When the url returns, the
  105324. * content of this file is added into a new script element, attached to the DOM (body element)
  105325. * @param scriptUrl defines the url of the script to laod
  105326. * @param scriptId defines the id of the script element
  105327. * @returns a promise request object
  105328. */
  105329. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  105330. /**
  105331. * Loads a file from a blob
  105332. * @param fileToLoad defines the blob to use
  105333. * @param callback defines the callback to call when data is loaded
  105334. * @param progressCallback defines the callback to call during loading process
  105335. * @returns a file request object
  105336. */
  105337. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  105338. /**
  105339. * Reads a file from a File object
  105340. * @param file defines the file to load
  105341. * @param onSuccess defines the callback to call when data is loaded
  105342. * @param onProgress defines the callback to call during loading process
  105343. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  105344. * @param onError defines the callback to call when an error occurs
  105345. * @returns a file request object
  105346. */
  105347. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105348. /**
  105349. * Creates a data url from a given string content
  105350. * @param content defines the content to convert
  105351. * @returns the new data url link
  105352. */
  105353. static FileAsURL(content: string): string;
  105354. /**
  105355. * Format the given number to a specific decimal format
  105356. * @param value defines the number to format
  105357. * @param decimals defines the number of decimals to use
  105358. * @returns the formatted string
  105359. */
  105360. static Format(value: number, decimals?: number): string;
  105361. /**
  105362. * Tries to copy an object by duplicating every property
  105363. * @param source defines the source object
  105364. * @param destination defines the target object
  105365. * @param doNotCopyList defines a list of properties to avoid
  105366. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  105367. */
  105368. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  105369. /**
  105370. * Gets a boolean indicating if the given object has no own property
  105371. * @param obj defines the object to test
  105372. * @returns true if object has no own property
  105373. */
  105374. static IsEmpty(obj: any): boolean;
  105375. /**
  105376. * Function used to register events at window level
  105377. * @param windowElement defines the Window object to use
  105378. * @param events defines the events to register
  105379. */
  105380. static RegisterTopRootEvents(windowElement: Window, events: {
  105381. name: string;
  105382. handler: Nullable<(e: FocusEvent) => any>;
  105383. }[]): void;
  105384. /**
  105385. * Function used to unregister events from window level
  105386. * @param windowElement defines the Window object to use
  105387. * @param events defines the events to unregister
  105388. */
  105389. static UnregisterTopRootEvents(windowElement: Window, events: {
  105390. name: string;
  105391. handler: Nullable<(e: FocusEvent) => any>;
  105392. }[]): void;
  105393. /**
  105394. * @ignore
  105395. */
  105396. static _ScreenshotCanvas: HTMLCanvasElement;
  105397. /**
  105398. * Dumps the current bound framebuffer
  105399. * @param width defines the rendering width
  105400. * @param height defines the rendering height
  105401. * @param engine defines the hosting engine
  105402. * @param successCallback defines the callback triggered once the data are available
  105403. * @param mimeType defines the mime type of the result
  105404. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  105405. */
  105406. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  105407. /**
  105408. * Converts the canvas data to blob.
  105409. * This acts as a polyfill for browsers not supporting the to blob function.
  105410. * @param canvas Defines the canvas to extract the data from
  105411. * @param successCallback Defines the callback triggered once the data are available
  105412. * @param mimeType Defines the mime type of the result
  105413. */
  105414. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  105415. /**
  105416. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  105417. * @param successCallback defines the callback triggered once the data are available
  105418. * @param mimeType defines the mime type of the result
  105419. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  105420. */
  105421. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  105422. /**
  105423. * Downloads a blob in the browser
  105424. * @param blob defines the blob to download
  105425. * @param fileName defines the name of the downloaded file
  105426. */
  105427. static Download(blob: Blob, fileName: string): void;
  105428. /**
  105429. * Captures a screenshot of the current rendering
  105430. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105431. * @param engine defines the rendering engine
  105432. * @param camera defines the source camera
  105433. * @param size This parameter can be set to a single number or to an object with the
  105434. * following (optional) properties: precision, width, height. If a single number is passed,
  105435. * it will be used for both width and height. If an object is passed, the screenshot size
  105436. * will be derived from the parameters. The precision property is a multiplier allowing
  105437. * rendering at a higher or lower resolution
  105438. * @param successCallback defines the callback receives a single parameter which contains the
  105439. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  105440. * src parameter of an <img> to display it
  105441. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  105442. * Check your browser for supported MIME types
  105443. */
  105444. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  105445. /**
  105446. * Captures a screenshot of the current rendering
  105447. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105448. * @param engine defines the rendering engine
  105449. * @param camera defines the source camera
  105450. * @param size This parameter can be set to a single number or to an object with the
  105451. * following (optional) properties: precision, width, height. If a single number is passed,
  105452. * it will be used for both width and height. If an object is passed, the screenshot size
  105453. * will be derived from the parameters. The precision property is a multiplier allowing
  105454. * rendering at a higher or lower resolution
  105455. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  105456. * Check your browser for supported MIME types
  105457. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  105458. * to the src parameter of an <img> to display it
  105459. */
  105460. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  105461. /**
  105462. * Generates an image screenshot from the specified camera.
  105463. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105464. * @param engine The engine to use for rendering
  105465. * @param camera The camera to use for rendering
  105466. * @param size This parameter can be set to a single number or to an object with the
  105467. * following (optional) properties: precision, width, height. If a single number is passed,
  105468. * it will be used for both width and height. If an object is passed, the screenshot size
  105469. * will be derived from the parameters. The precision property is a multiplier allowing
  105470. * rendering at a higher or lower resolution
  105471. * @param successCallback The callback receives a single parameter which contains the
  105472. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  105473. * src parameter of an <img> to display it
  105474. * @param mimeType The MIME type of the screenshot image (default: image/png).
  105475. * Check your browser for supported MIME types
  105476. * @param samples Texture samples (default: 1)
  105477. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  105478. * @param fileName A name for for the downloaded file.
  105479. */
  105480. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  105481. /**
  105482. * Generates an image screenshot from the specified camera.
  105483. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105484. * @param engine The engine to use for rendering
  105485. * @param camera The camera to use for rendering
  105486. * @param size This parameter can be set to a single number or to an object with the
  105487. * following (optional) properties: precision, width, height. If a single number is passed,
  105488. * it will be used for both width and height. If an object is passed, the screenshot size
  105489. * will be derived from the parameters. The precision property is a multiplier allowing
  105490. * rendering at a higher or lower resolution
  105491. * @param mimeType The MIME type of the screenshot image (default: image/png).
  105492. * Check your browser for supported MIME types
  105493. * @param samples Texture samples (default: 1)
  105494. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  105495. * @param fileName A name for for the downloaded file.
  105496. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  105497. * to the src parameter of an <img> to display it
  105498. */
  105499. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  105500. /**
  105501. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105502. * Be aware Math.random() could cause collisions, but:
  105503. * "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"
  105504. * @returns a pseudo random id
  105505. */
  105506. static RandomId(): string;
  105507. /**
  105508. * Test if the given uri is a base64 string
  105509. * @param uri The uri to test
  105510. * @return True if the uri is a base64 string or false otherwise
  105511. */
  105512. static IsBase64(uri: string): boolean;
  105513. /**
  105514. * Decode the given base64 uri.
  105515. * @param uri The uri to decode
  105516. * @return The decoded base64 data.
  105517. */
  105518. static DecodeBase64(uri: string): ArrayBuffer;
  105519. /**
  105520. * Gets the absolute url.
  105521. * @param url the input url
  105522. * @return the absolute url
  105523. */
  105524. static GetAbsoluteUrl(url: string): string;
  105525. /**
  105526. * No log
  105527. */
  105528. static readonly NoneLogLevel: number;
  105529. /**
  105530. * Only message logs
  105531. */
  105532. static readonly MessageLogLevel: number;
  105533. /**
  105534. * Only warning logs
  105535. */
  105536. static readonly WarningLogLevel: number;
  105537. /**
  105538. * Only error logs
  105539. */
  105540. static readonly ErrorLogLevel: number;
  105541. /**
  105542. * All logs
  105543. */
  105544. static readonly AllLogLevel: number;
  105545. /**
  105546. * Gets a value indicating the number of loading errors
  105547. * @ignorenaming
  105548. */
  105549. static get errorsCount(): number;
  105550. /**
  105551. * Callback called when a new log is added
  105552. */
  105553. static OnNewCacheEntry: (entry: string) => void;
  105554. /**
  105555. * Log a message to the console
  105556. * @param message defines the message to log
  105557. */
  105558. static Log(message: string): void;
  105559. /**
  105560. * Write a warning message to the console
  105561. * @param message defines the message to log
  105562. */
  105563. static Warn(message: string): void;
  105564. /**
  105565. * Write an error message to the console
  105566. * @param message defines the message to log
  105567. */
  105568. static Error(message: string): void;
  105569. /**
  105570. * Gets current log cache (list of logs)
  105571. */
  105572. static get LogCache(): string;
  105573. /**
  105574. * Clears the log cache
  105575. */
  105576. static ClearLogCache(): void;
  105577. /**
  105578. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  105579. */
  105580. static set LogLevels(level: number);
  105581. /**
  105582. * Checks if the window object exists
  105583. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  105584. */
  105585. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  105586. /**
  105587. * No performance log
  105588. */
  105589. static readonly PerformanceNoneLogLevel: number;
  105590. /**
  105591. * Use user marks to log performance
  105592. */
  105593. static readonly PerformanceUserMarkLogLevel: number;
  105594. /**
  105595. * Log performance to the console
  105596. */
  105597. static readonly PerformanceConsoleLogLevel: number;
  105598. private static _performance;
  105599. /**
  105600. * Sets the current performance log level
  105601. */
  105602. static set PerformanceLogLevel(level: number);
  105603. private static _StartPerformanceCounterDisabled;
  105604. private static _EndPerformanceCounterDisabled;
  105605. private static _StartUserMark;
  105606. private static _EndUserMark;
  105607. private static _StartPerformanceConsole;
  105608. private static _EndPerformanceConsole;
  105609. /**
  105610. * Starts a performance counter
  105611. */
  105612. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  105613. /**
  105614. * Ends a specific performance coutner
  105615. */
  105616. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  105617. /**
  105618. * Gets either window.performance.now() if supported or Date.now() else
  105619. */
  105620. static get Now(): number;
  105621. /**
  105622. * This method will return the name of the class used to create the instance of the given object.
  105623. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  105624. * @param object the object to get the class name from
  105625. * @param isType defines if the object is actually a type
  105626. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  105627. */
  105628. static GetClassName(object: any, isType?: boolean): string;
  105629. /**
  105630. * Gets the first element of an array satisfying a given predicate
  105631. * @param array defines the array to browse
  105632. * @param predicate defines the predicate to use
  105633. * @returns null if not found or the element
  105634. */
  105635. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  105636. /**
  105637. * This method will return the name of the full name of the class, including its owning module (if any).
  105638. * 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).
  105639. * @param object the object to get the class name from
  105640. * @param isType defines if the object is actually a type
  105641. * @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.
  105642. * @ignorenaming
  105643. */
  105644. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  105645. /**
  105646. * Returns a promise that resolves after the given amount of time.
  105647. * @param delay Number of milliseconds to delay
  105648. * @returns Promise that resolves after the given amount of time
  105649. */
  105650. static DelayAsync(delay: number): Promise<void>;
  105651. /**
  105652. * Utility function to detect if the current user agent is Safari
  105653. * @returns whether or not the current user agent is safari
  105654. */
  105655. static IsSafari(): boolean;
  105656. }
  105657. /**
  105658. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  105659. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  105660. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  105661. * @param name The name of the class, case should be preserved
  105662. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  105663. */
  105664. export function className(name: string, module?: string): (target: Object) => void;
  105665. /**
  105666. * An implementation of a loop for asynchronous functions.
  105667. */
  105668. export class AsyncLoop {
  105669. /**
  105670. * Defines the number of iterations for the loop
  105671. */
  105672. iterations: number;
  105673. /**
  105674. * Defines the current index of the loop.
  105675. */
  105676. index: number;
  105677. private _done;
  105678. private _fn;
  105679. private _successCallback;
  105680. /**
  105681. * Constructor.
  105682. * @param iterations the number of iterations.
  105683. * @param func the function to run each iteration
  105684. * @param successCallback the callback that will be called upon succesful execution
  105685. * @param offset starting offset.
  105686. */
  105687. constructor(
  105688. /**
  105689. * Defines the number of iterations for the loop
  105690. */
  105691. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  105692. /**
  105693. * Execute the next iteration. Must be called after the last iteration was finished.
  105694. */
  105695. executeNext(): void;
  105696. /**
  105697. * Break the loop and run the success callback.
  105698. */
  105699. breakLoop(): void;
  105700. /**
  105701. * Create and run an async loop.
  105702. * @param iterations the number of iterations.
  105703. * @param fn the function to run each iteration
  105704. * @param successCallback the callback that will be called upon succesful execution
  105705. * @param offset starting offset.
  105706. * @returns the created async loop object
  105707. */
  105708. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  105709. /**
  105710. * A for-loop that will run a given number of iterations synchronous and the rest async.
  105711. * @param iterations total number of iterations
  105712. * @param syncedIterations number of synchronous iterations in each async iteration.
  105713. * @param fn the function to call each iteration.
  105714. * @param callback a success call back that will be called when iterating stops.
  105715. * @param breakFunction a break condition (optional)
  105716. * @param timeout timeout settings for the setTimeout function. default - 0.
  105717. * @returns the created async loop object
  105718. */
  105719. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  105720. }
  105721. }
  105722. declare module BABYLON {
  105723. /**
  105724. * This class implement a typical dictionary using a string as key and the generic type T as value.
  105725. * The underlying implementation relies on an associative array to ensure the best performances.
  105726. * The value can be anything including 'null' but except 'undefined'
  105727. */
  105728. export class StringDictionary<T> {
  105729. /**
  105730. * This will clear this dictionary and copy the content from the 'source' one.
  105731. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  105732. * @param source the dictionary to take the content from and copy to this dictionary
  105733. */
  105734. copyFrom(source: StringDictionary<T>): void;
  105735. /**
  105736. * Get a value based from its key
  105737. * @param key the given key to get the matching value from
  105738. * @return the value if found, otherwise undefined is returned
  105739. */
  105740. get(key: string): T | undefined;
  105741. /**
  105742. * Get a value from its key or add it if it doesn't exist.
  105743. * This method will ensure you that a given key/data will be present in the dictionary.
  105744. * @param key the given key to get the matching value from
  105745. * @param factory the factory that will create the value if the key is not present in the dictionary.
  105746. * The factory will only be invoked if there's no data for the given key.
  105747. * @return the value corresponding to the key.
  105748. */
  105749. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  105750. /**
  105751. * Get a value from its key if present in the dictionary otherwise add it
  105752. * @param key the key to get the value from
  105753. * @param val if there's no such key/value pair in the dictionary add it with this value
  105754. * @return the value corresponding to the key
  105755. */
  105756. getOrAdd(key: string, val: T): T;
  105757. /**
  105758. * Check if there's a given key in the dictionary
  105759. * @param key the key to check for
  105760. * @return true if the key is present, false otherwise
  105761. */
  105762. contains(key: string): boolean;
  105763. /**
  105764. * Add a new key and its corresponding value
  105765. * @param key the key to add
  105766. * @param value the value corresponding to the key
  105767. * @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
  105768. */
  105769. add(key: string, value: T): boolean;
  105770. /**
  105771. * Update a specific value associated to a key
  105772. * @param key defines the key to use
  105773. * @param value defines the value to store
  105774. * @returns true if the value was updated (or false if the key was not found)
  105775. */
  105776. set(key: string, value: T): boolean;
  105777. /**
  105778. * Get the element of the given key and remove it from the dictionary
  105779. * @param key defines the key to search
  105780. * @returns the value associated with the key or null if not found
  105781. */
  105782. getAndRemove(key: string): Nullable<T>;
  105783. /**
  105784. * Remove a key/value from the dictionary.
  105785. * @param key the key to remove
  105786. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  105787. */
  105788. remove(key: string): boolean;
  105789. /**
  105790. * Clear the whole content of the dictionary
  105791. */
  105792. clear(): void;
  105793. /**
  105794. * Gets the current count
  105795. */
  105796. get count(): number;
  105797. /**
  105798. * Execute a callback on each key/val of the dictionary.
  105799. * Note that you can remove any element in this dictionary in the callback implementation
  105800. * @param callback the callback to execute on a given key/value pair
  105801. */
  105802. forEach(callback: (key: string, val: T) => void): void;
  105803. /**
  105804. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  105805. * If the callback returns null or undefined the method will iterate to the next key/value pair
  105806. * Note that you can remove any element in this dictionary in the callback implementation
  105807. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  105808. * @returns the first item
  105809. */
  105810. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  105811. private _count;
  105812. private _data;
  105813. }
  105814. }
  105815. declare module BABYLON {
  105816. /** @hidden */
  105817. export interface ICollisionCoordinator {
  105818. createCollider(): Collider;
  105819. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105820. init(scene: Scene): void;
  105821. }
  105822. /** @hidden */
  105823. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  105824. private _scene;
  105825. private _scaledPosition;
  105826. private _scaledVelocity;
  105827. private _finalPosition;
  105828. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105829. createCollider(): Collider;
  105830. init(scene: Scene): void;
  105831. private _collideWithWorld;
  105832. }
  105833. }
  105834. declare module BABYLON {
  105835. /**
  105836. * Class used to manage all inputs for the scene.
  105837. */
  105838. export class InputManager {
  105839. /** The distance in pixel that you have to move to prevent some events */
  105840. static DragMovementThreshold: number;
  105841. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  105842. static LongPressDelay: number;
  105843. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  105844. static DoubleClickDelay: number;
  105845. /** If you need to check double click without raising a single click at first click, enable this flag */
  105846. static ExclusiveDoubleClickMode: boolean;
  105847. private _wheelEventName;
  105848. private _onPointerMove;
  105849. private _onPointerDown;
  105850. private _onPointerUp;
  105851. private _initClickEvent;
  105852. private _initActionManager;
  105853. private _delayedSimpleClick;
  105854. private _delayedSimpleClickTimeout;
  105855. private _previousDelayedSimpleClickTimeout;
  105856. private _meshPickProceed;
  105857. private _previousButtonPressed;
  105858. private _currentPickResult;
  105859. private _previousPickResult;
  105860. private _totalPointersPressed;
  105861. private _doubleClickOccured;
  105862. private _pointerOverMesh;
  105863. private _pickedDownMesh;
  105864. private _pickedUpMesh;
  105865. private _pointerX;
  105866. private _pointerY;
  105867. private _unTranslatedPointerX;
  105868. private _unTranslatedPointerY;
  105869. private _startingPointerPosition;
  105870. private _previousStartingPointerPosition;
  105871. private _startingPointerTime;
  105872. private _previousStartingPointerTime;
  105873. private _pointerCaptures;
  105874. private _onKeyDown;
  105875. private _onKeyUp;
  105876. private _onCanvasFocusObserver;
  105877. private _onCanvasBlurObserver;
  105878. private _scene;
  105879. /**
  105880. * Creates a new InputManager
  105881. * @param scene defines the hosting scene
  105882. */
  105883. constructor(scene: Scene);
  105884. /**
  105885. * Gets the mesh that is currently under the pointer
  105886. */
  105887. get meshUnderPointer(): Nullable<AbstractMesh>;
  105888. /**
  105889. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105890. */
  105891. get unTranslatedPointer(): Vector2;
  105892. /**
  105893. * Gets or sets the current on-screen X position of the pointer
  105894. */
  105895. get pointerX(): number;
  105896. set pointerX(value: number);
  105897. /**
  105898. * Gets or sets the current on-screen Y position of the pointer
  105899. */
  105900. get pointerY(): number;
  105901. set pointerY(value: number);
  105902. private _updatePointerPosition;
  105903. private _processPointerMove;
  105904. private _setRayOnPointerInfo;
  105905. private _checkPrePointerObservable;
  105906. /**
  105907. * Use this method to simulate a pointer move on a mesh
  105908. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105909. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105910. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105911. */
  105912. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105913. /**
  105914. * Use this method to simulate a pointer down on a mesh
  105915. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105916. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105917. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105918. */
  105919. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105920. private _processPointerDown;
  105921. /** @hidden */
  105922. _isPointerSwiping(): boolean;
  105923. /**
  105924. * Use this method to simulate a pointer up on a mesh
  105925. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105926. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105927. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105928. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105929. */
  105930. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105931. private _processPointerUp;
  105932. /**
  105933. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105934. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105935. * @returns true if the pointer was captured
  105936. */
  105937. isPointerCaptured(pointerId?: number): boolean;
  105938. /**
  105939. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105940. * @param attachUp defines if you want to attach events to pointerup
  105941. * @param attachDown defines if you want to attach events to pointerdown
  105942. * @param attachMove defines if you want to attach events to pointermove
  105943. */
  105944. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105945. /**
  105946. * Detaches all event handlers
  105947. */
  105948. detachControl(): void;
  105949. /**
  105950. * Force the value of meshUnderPointer
  105951. * @param mesh defines the mesh to use
  105952. */
  105953. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105954. /**
  105955. * Gets the mesh under the pointer
  105956. * @returns a Mesh or null if no mesh is under the pointer
  105957. */
  105958. getPointerOverMesh(): Nullable<AbstractMesh>;
  105959. }
  105960. }
  105961. declare module BABYLON {
  105962. /**
  105963. * Helper class used to generate session unique ID
  105964. */
  105965. export class UniqueIdGenerator {
  105966. private static _UniqueIdCounter;
  105967. /**
  105968. * Gets an unique (relatively to the current scene) Id
  105969. */
  105970. static get UniqueId(): number;
  105971. }
  105972. }
  105973. declare module BABYLON {
  105974. /**
  105975. * This class defines the direct association between an animation and a target
  105976. */
  105977. export class TargetedAnimation {
  105978. /**
  105979. * Animation to perform
  105980. */
  105981. animation: Animation;
  105982. /**
  105983. * Target to animate
  105984. */
  105985. target: any;
  105986. /**
  105987. * Serialize the object
  105988. * @returns the JSON object representing the current entity
  105989. */
  105990. serialize(): any;
  105991. }
  105992. /**
  105993. * Use this class to create coordinated animations on multiple targets
  105994. */
  105995. export class AnimationGroup implements IDisposable {
  105996. /** The name of the animation group */
  105997. name: string;
  105998. private _scene;
  105999. private _targetedAnimations;
  106000. private _animatables;
  106001. private _from;
  106002. private _to;
  106003. private _isStarted;
  106004. private _isPaused;
  106005. private _speedRatio;
  106006. private _loopAnimation;
  106007. /**
  106008. * Gets or sets the unique id of the node
  106009. */
  106010. uniqueId: number;
  106011. /**
  106012. * This observable will notify when one animation have ended
  106013. */
  106014. onAnimationEndObservable: Observable<TargetedAnimation>;
  106015. /**
  106016. * Observer raised when one animation loops
  106017. */
  106018. onAnimationLoopObservable: Observable<TargetedAnimation>;
  106019. /**
  106020. * Observer raised when all animations have looped
  106021. */
  106022. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  106023. /**
  106024. * This observable will notify when all animations have ended.
  106025. */
  106026. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  106027. /**
  106028. * This observable will notify when all animations have paused.
  106029. */
  106030. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  106031. /**
  106032. * This observable will notify when all animations are playing.
  106033. */
  106034. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  106035. /**
  106036. * Gets the first frame
  106037. */
  106038. get from(): number;
  106039. /**
  106040. * Gets the last frame
  106041. */
  106042. get to(): number;
  106043. /**
  106044. * Define if the animations are started
  106045. */
  106046. get isStarted(): boolean;
  106047. /**
  106048. * Gets a value indicating that the current group is playing
  106049. */
  106050. get isPlaying(): boolean;
  106051. /**
  106052. * Gets or sets the speed ratio to use for all animations
  106053. */
  106054. get speedRatio(): number;
  106055. /**
  106056. * Gets or sets the speed ratio to use for all animations
  106057. */
  106058. set speedRatio(value: number);
  106059. /**
  106060. * Gets or sets if all animations should loop or not
  106061. */
  106062. get loopAnimation(): boolean;
  106063. set loopAnimation(value: boolean);
  106064. /**
  106065. * Gets the targeted animations for this animation group
  106066. */
  106067. get targetedAnimations(): Array<TargetedAnimation>;
  106068. /**
  106069. * returning the list of animatables controlled by this animation group.
  106070. */
  106071. get animatables(): Array<Animatable>;
  106072. /**
  106073. * Instantiates a new Animation Group.
  106074. * This helps managing several animations at once.
  106075. * @see http://doc.babylonjs.com/how_to/group
  106076. * @param name Defines the name of the group
  106077. * @param scene Defines the scene the group belongs to
  106078. */
  106079. constructor(
  106080. /** The name of the animation group */
  106081. name: string, scene?: Nullable<Scene>);
  106082. /**
  106083. * Add an animation (with its target) in the group
  106084. * @param animation defines the animation we want to add
  106085. * @param target defines the target of the animation
  106086. * @returns the TargetedAnimation object
  106087. */
  106088. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  106089. /**
  106090. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  106091. * It can add constant keys at begin or end
  106092. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  106093. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  106094. * @returns the animation group
  106095. */
  106096. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  106097. private _animationLoopCount;
  106098. private _animationLoopFlags;
  106099. private _processLoop;
  106100. /**
  106101. * Start all animations on given targets
  106102. * @param loop defines if animations must loop
  106103. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  106104. * @param from defines the from key (optional)
  106105. * @param to defines the to key (optional)
  106106. * @returns the current animation group
  106107. */
  106108. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  106109. /**
  106110. * Pause all animations
  106111. * @returns the animation group
  106112. */
  106113. pause(): AnimationGroup;
  106114. /**
  106115. * Play all animations to initial state
  106116. * This function will start() the animations if they were not started or will restart() them if they were paused
  106117. * @param loop defines if animations must loop
  106118. * @returns the animation group
  106119. */
  106120. play(loop?: boolean): AnimationGroup;
  106121. /**
  106122. * Reset all animations to initial state
  106123. * @returns the animation group
  106124. */
  106125. reset(): AnimationGroup;
  106126. /**
  106127. * Restart animations from key 0
  106128. * @returns the animation group
  106129. */
  106130. restart(): AnimationGroup;
  106131. /**
  106132. * Stop all animations
  106133. * @returns the animation group
  106134. */
  106135. stop(): AnimationGroup;
  106136. /**
  106137. * Set animation weight for all animatables
  106138. * @param weight defines the weight to use
  106139. * @return the animationGroup
  106140. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  106141. */
  106142. setWeightForAllAnimatables(weight: number): AnimationGroup;
  106143. /**
  106144. * Synchronize and normalize all animatables with a source animatable
  106145. * @param root defines the root animatable to synchronize with
  106146. * @return the animationGroup
  106147. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  106148. */
  106149. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  106150. /**
  106151. * Goes to a specific frame in this animation group
  106152. * @param frame the frame number to go to
  106153. * @return the animationGroup
  106154. */
  106155. goToFrame(frame: number): AnimationGroup;
  106156. /**
  106157. * Dispose all associated resources
  106158. */
  106159. dispose(): void;
  106160. private _checkAnimationGroupEnded;
  106161. /**
  106162. * Clone the current animation group and returns a copy
  106163. * @param newName defines the name of the new group
  106164. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  106165. * @returns the new aniamtion group
  106166. */
  106167. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  106168. /**
  106169. * Serializes the animationGroup to an object
  106170. * @returns Serialized object
  106171. */
  106172. serialize(): any;
  106173. /**
  106174. * Returns a new AnimationGroup object parsed from the source provided.
  106175. * @param parsedAnimationGroup defines the source
  106176. * @param scene defines the scene that will receive the animationGroup
  106177. * @returns a new AnimationGroup
  106178. */
  106179. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  106180. /**
  106181. * Returns the string "AnimationGroup"
  106182. * @returns "AnimationGroup"
  106183. */
  106184. getClassName(): string;
  106185. /**
  106186. * Creates a detailled string about the object
  106187. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  106188. * @returns a string representing the object
  106189. */
  106190. toString(fullDetails?: boolean): string;
  106191. }
  106192. }
  106193. declare module BABYLON {
  106194. /**
  106195. * Define an interface for all classes that will hold resources
  106196. */
  106197. export interface IDisposable {
  106198. /**
  106199. * Releases all held resources
  106200. */
  106201. dispose(): void;
  106202. }
  106203. /** Interface defining initialization parameters for Scene class */
  106204. export interface SceneOptions {
  106205. /**
  106206. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  106207. * It will improve performance when the number of geometries becomes important.
  106208. */
  106209. useGeometryUniqueIdsMap?: boolean;
  106210. /**
  106211. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  106212. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  106213. */
  106214. useMaterialMeshMap?: boolean;
  106215. /**
  106216. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  106217. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  106218. */
  106219. useClonedMeshMap?: boolean;
  106220. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  106221. virtual?: boolean;
  106222. }
  106223. /**
  106224. * Represents a scene to be rendered by the engine.
  106225. * @see http://doc.babylonjs.com/features/scene
  106226. */
  106227. export class Scene extends AbstractScene implements IAnimatable {
  106228. /** The fog is deactivated */
  106229. static readonly FOGMODE_NONE: number;
  106230. /** The fog density is following an exponential function */
  106231. static readonly FOGMODE_EXP: number;
  106232. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  106233. static readonly FOGMODE_EXP2: number;
  106234. /** The fog density is following a linear function. */
  106235. static readonly FOGMODE_LINEAR: number;
  106236. /**
  106237. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  106238. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106239. */
  106240. static MinDeltaTime: number;
  106241. /**
  106242. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  106243. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106244. */
  106245. static MaxDeltaTime: number;
  106246. /**
  106247. * Factory used to create the default material.
  106248. * @param name The name of the material to create
  106249. * @param scene The scene to create the material for
  106250. * @returns The default material
  106251. */
  106252. static DefaultMaterialFactory(scene: Scene): Material;
  106253. /**
  106254. * Factory used to create the a collision coordinator.
  106255. * @returns The collision coordinator
  106256. */
  106257. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  106258. /** @hidden */
  106259. _inputManager: InputManager;
  106260. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  106261. cameraToUseForPointers: Nullable<Camera>;
  106262. /** @hidden */
  106263. readonly _isScene: boolean;
  106264. /**
  106265. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  106266. */
  106267. autoClear: boolean;
  106268. /**
  106269. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  106270. */
  106271. autoClearDepthAndStencil: boolean;
  106272. /**
  106273. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  106274. */
  106275. clearColor: Color4;
  106276. /**
  106277. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  106278. */
  106279. ambientColor: Color3;
  106280. /**
  106281. * This is use to store the default BRDF lookup for PBR materials in your scene.
  106282. * It should only be one of the following (if not the default embedded one):
  106283. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  106284. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  106285. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  106286. * The material properties need to be setup according to the type of texture in use.
  106287. */
  106288. environmentBRDFTexture: BaseTexture;
  106289. /** @hidden */
  106290. protected _environmentTexture: Nullable<BaseTexture>;
  106291. /**
  106292. * Texture used in all pbr material as the reflection texture.
  106293. * As in the majority of the scene they are the same (exception for multi room and so on),
  106294. * this is easier to reference from here than from all the materials.
  106295. */
  106296. get environmentTexture(): Nullable<BaseTexture>;
  106297. /**
  106298. * Texture used in all pbr material as the reflection texture.
  106299. * As in the majority of the scene they are the same (exception for multi room and so on),
  106300. * this is easier to set here than in all the materials.
  106301. */
  106302. set environmentTexture(value: Nullable<BaseTexture>);
  106303. /** @hidden */
  106304. protected _environmentIntensity: number;
  106305. /**
  106306. * Intensity of the environment in all pbr material.
  106307. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  106308. * As in the majority of the scene they are the same (exception for multi room and so on),
  106309. * this is easier to reference from here than from all the materials.
  106310. */
  106311. get environmentIntensity(): number;
  106312. /**
  106313. * Intensity of the environment in all pbr material.
  106314. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  106315. * As in the majority of the scene they are the same (exception for multi room and so on),
  106316. * this is easier to set here than in all the materials.
  106317. */
  106318. set environmentIntensity(value: number);
  106319. /** @hidden */
  106320. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106321. /**
  106322. * Default image processing configuration used either in the rendering
  106323. * Forward main pass or through the imageProcessingPostProcess if present.
  106324. * As in the majority of the scene they are the same (exception for multi camera),
  106325. * this is easier to reference from here than from all the materials and post process.
  106326. *
  106327. * No setter as we it is a shared configuration, you can set the values instead.
  106328. */
  106329. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  106330. private _forceWireframe;
  106331. /**
  106332. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  106333. */
  106334. set forceWireframe(value: boolean);
  106335. get forceWireframe(): boolean;
  106336. private _skipFrustumClipping;
  106337. /**
  106338. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  106339. */
  106340. set skipFrustumClipping(value: boolean);
  106341. get skipFrustumClipping(): boolean;
  106342. private _forcePointsCloud;
  106343. /**
  106344. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  106345. */
  106346. set forcePointsCloud(value: boolean);
  106347. get forcePointsCloud(): boolean;
  106348. /**
  106349. * Gets or sets the active clipplane 1
  106350. */
  106351. clipPlane: Nullable<Plane>;
  106352. /**
  106353. * Gets or sets the active clipplane 2
  106354. */
  106355. clipPlane2: Nullable<Plane>;
  106356. /**
  106357. * Gets or sets the active clipplane 3
  106358. */
  106359. clipPlane3: Nullable<Plane>;
  106360. /**
  106361. * Gets or sets the active clipplane 4
  106362. */
  106363. clipPlane4: Nullable<Plane>;
  106364. /**
  106365. * Gets or sets the active clipplane 5
  106366. */
  106367. clipPlane5: Nullable<Plane>;
  106368. /**
  106369. * Gets or sets the active clipplane 6
  106370. */
  106371. clipPlane6: Nullable<Plane>;
  106372. /**
  106373. * Gets or sets a boolean indicating if animations are enabled
  106374. */
  106375. animationsEnabled: boolean;
  106376. private _animationPropertiesOverride;
  106377. /**
  106378. * Gets or sets the animation properties override
  106379. */
  106380. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106381. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106382. /**
  106383. * Gets or sets a boolean indicating if a constant deltatime has to be used
  106384. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  106385. */
  106386. useConstantAnimationDeltaTime: boolean;
  106387. /**
  106388. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  106389. * Please note that it requires to run a ray cast through the scene on every frame
  106390. */
  106391. constantlyUpdateMeshUnderPointer: boolean;
  106392. /**
  106393. * Defines the HTML cursor to use when hovering over interactive elements
  106394. */
  106395. hoverCursor: string;
  106396. /**
  106397. * Defines the HTML default cursor to use (empty by default)
  106398. */
  106399. defaultCursor: string;
  106400. /**
  106401. * Defines wether cursors are handled by the scene.
  106402. */
  106403. doNotHandleCursors: boolean;
  106404. /**
  106405. * This is used to call preventDefault() on pointer down
  106406. * in order to block unwanted artifacts like system double clicks
  106407. */
  106408. preventDefaultOnPointerDown: boolean;
  106409. /**
  106410. * This is used to call preventDefault() on pointer up
  106411. * in order to block unwanted artifacts like system double clicks
  106412. */
  106413. preventDefaultOnPointerUp: boolean;
  106414. /**
  106415. * Gets or sets user defined metadata
  106416. */
  106417. metadata: any;
  106418. /**
  106419. * For internal use only. Please do not use.
  106420. */
  106421. reservedDataStore: any;
  106422. /**
  106423. * Gets the name of the plugin used to load this scene (null by default)
  106424. */
  106425. loadingPluginName: string;
  106426. /**
  106427. * Use this array to add regular expressions used to disable offline support for specific urls
  106428. */
  106429. disableOfflineSupportExceptionRules: RegExp[];
  106430. /**
  106431. * An event triggered when the scene is disposed.
  106432. */
  106433. onDisposeObservable: Observable<Scene>;
  106434. private _onDisposeObserver;
  106435. /** Sets a function to be executed when this scene is disposed. */
  106436. set onDispose(callback: () => void);
  106437. /**
  106438. * An event triggered before rendering the scene (right after animations and physics)
  106439. */
  106440. onBeforeRenderObservable: Observable<Scene>;
  106441. private _onBeforeRenderObserver;
  106442. /** Sets a function to be executed before rendering this scene */
  106443. set beforeRender(callback: Nullable<() => void>);
  106444. /**
  106445. * An event triggered after rendering the scene
  106446. */
  106447. onAfterRenderObservable: Observable<Scene>;
  106448. /**
  106449. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  106450. */
  106451. onAfterRenderCameraObservable: Observable<Camera>;
  106452. private _onAfterRenderObserver;
  106453. /** Sets a function to be executed after rendering this scene */
  106454. set afterRender(callback: Nullable<() => void>);
  106455. /**
  106456. * An event triggered before animating the scene
  106457. */
  106458. onBeforeAnimationsObservable: Observable<Scene>;
  106459. /**
  106460. * An event triggered after animations processing
  106461. */
  106462. onAfterAnimationsObservable: Observable<Scene>;
  106463. /**
  106464. * An event triggered before draw calls are ready to be sent
  106465. */
  106466. onBeforeDrawPhaseObservable: Observable<Scene>;
  106467. /**
  106468. * An event triggered after draw calls have been sent
  106469. */
  106470. onAfterDrawPhaseObservable: Observable<Scene>;
  106471. /**
  106472. * An event triggered when the scene is ready
  106473. */
  106474. onReadyObservable: Observable<Scene>;
  106475. /**
  106476. * An event triggered before rendering a camera
  106477. */
  106478. onBeforeCameraRenderObservable: Observable<Camera>;
  106479. private _onBeforeCameraRenderObserver;
  106480. /** Sets a function to be executed before rendering a camera*/
  106481. set beforeCameraRender(callback: () => void);
  106482. /**
  106483. * An event triggered after rendering a camera
  106484. */
  106485. onAfterCameraRenderObservable: Observable<Camera>;
  106486. private _onAfterCameraRenderObserver;
  106487. /** Sets a function to be executed after rendering a camera*/
  106488. set afterCameraRender(callback: () => void);
  106489. /**
  106490. * An event triggered when active meshes evaluation is about to start
  106491. */
  106492. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  106493. /**
  106494. * An event triggered when active meshes evaluation is done
  106495. */
  106496. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  106497. /**
  106498. * An event triggered when particles rendering is about to start
  106499. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  106500. */
  106501. onBeforeParticlesRenderingObservable: Observable<Scene>;
  106502. /**
  106503. * An event triggered when particles rendering is done
  106504. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  106505. */
  106506. onAfterParticlesRenderingObservable: Observable<Scene>;
  106507. /**
  106508. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  106509. */
  106510. onDataLoadedObservable: Observable<Scene>;
  106511. /**
  106512. * An event triggered when a camera is created
  106513. */
  106514. onNewCameraAddedObservable: Observable<Camera>;
  106515. /**
  106516. * An event triggered when a camera is removed
  106517. */
  106518. onCameraRemovedObservable: Observable<Camera>;
  106519. /**
  106520. * An event triggered when a light is created
  106521. */
  106522. onNewLightAddedObservable: Observable<Light>;
  106523. /**
  106524. * An event triggered when a light is removed
  106525. */
  106526. onLightRemovedObservable: Observable<Light>;
  106527. /**
  106528. * An event triggered when a geometry is created
  106529. */
  106530. onNewGeometryAddedObservable: Observable<Geometry>;
  106531. /**
  106532. * An event triggered when a geometry is removed
  106533. */
  106534. onGeometryRemovedObservable: Observable<Geometry>;
  106535. /**
  106536. * An event triggered when a transform node is created
  106537. */
  106538. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  106539. /**
  106540. * An event triggered when a transform node is removed
  106541. */
  106542. onTransformNodeRemovedObservable: Observable<TransformNode>;
  106543. /**
  106544. * An event triggered when a mesh is created
  106545. */
  106546. onNewMeshAddedObservable: Observable<AbstractMesh>;
  106547. /**
  106548. * An event triggered when a mesh is removed
  106549. */
  106550. onMeshRemovedObservable: Observable<AbstractMesh>;
  106551. /**
  106552. * An event triggered when a skeleton is created
  106553. */
  106554. onNewSkeletonAddedObservable: Observable<Skeleton>;
  106555. /**
  106556. * An event triggered when a skeleton is removed
  106557. */
  106558. onSkeletonRemovedObservable: Observable<Skeleton>;
  106559. /**
  106560. * An event triggered when a material is created
  106561. */
  106562. onNewMaterialAddedObservable: Observable<Material>;
  106563. /**
  106564. * An event triggered when a material is removed
  106565. */
  106566. onMaterialRemovedObservable: Observable<Material>;
  106567. /**
  106568. * An event triggered when a texture is created
  106569. */
  106570. onNewTextureAddedObservable: Observable<BaseTexture>;
  106571. /**
  106572. * An event triggered when a texture is removed
  106573. */
  106574. onTextureRemovedObservable: Observable<BaseTexture>;
  106575. /**
  106576. * An event triggered when render targets are about to be rendered
  106577. * Can happen multiple times per frame.
  106578. */
  106579. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  106580. /**
  106581. * An event triggered when render targets were rendered.
  106582. * Can happen multiple times per frame.
  106583. */
  106584. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  106585. /**
  106586. * An event triggered before calculating deterministic simulation step
  106587. */
  106588. onBeforeStepObservable: Observable<Scene>;
  106589. /**
  106590. * An event triggered after calculating deterministic simulation step
  106591. */
  106592. onAfterStepObservable: Observable<Scene>;
  106593. /**
  106594. * An event triggered when the activeCamera property is updated
  106595. */
  106596. onActiveCameraChanged: Observable<Scene>;
  106597. /**
  106598. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  106599. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  106600. * 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)
  106601. */
  106602. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  106603. /**
  106604. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  106605. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  106606. * 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)
  106607. */
  106608. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  106609. /**
  106610. * This Observable will when a mesh has been imported into the scene.
  106611. */
  106612. onMeshImportedObservable: Observable<AbstractMesh>;
  106613. /**
  106614. * This Observable will when an animation file has been imported into the scene.
  106615. */
  106616. onAnimationFileImportedObservable: Observable<Scene>;
  106617. /**
  106618. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  106619. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  106620. */
  106621. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  106622. /** @hidden */
  106623. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  106624. /**
  106625. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  106626. */
  106627. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  106628. /**
  106629. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  106630. */
  106631. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  106632. /**
  106633. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  106634. */
  106635. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  106636. /** Callback called when a pointer move is detected */
  106637. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  106638. /** Callback called when a pointer down is detected */
  106639. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  106640. /** Callback called when a pointer up is detected */
  106641. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  106642. /** Callback called when a pointer pick is detected */
  106643. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  106644. /**
  106645. * 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).
  106646. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  106647. */
  106648. onPrePointerObservable: Observable<PointerInfoPre>;
  106649. /**
  106650. * Observable event triggered each time an input event is received from the rendering canvas
  106651. */
  106652. onPointerObservable: Observable<PointerInfo>;
  106653. /**
  106654. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  106655. */
  106656. get unTranslatedPointer(): Vector2;
  106657. /**
  106658. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  106659. */
  106660. static get DragMovementThreshold(): number;
  106661. static set DragMovementThreshold(value: number);
  106662. /**
  106663. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  106664. */
  106665. static get LongPressDelay(): number;
  106666. static set LongPressDelay(value: number);
  106667. /**
  106668. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  106669. */
  106670. static get DoubleClickDelay(): number;
  106671. static set DoubleClickDelay(value: number);
  106672. /** If you need to check double click without raising a single click at first click, enable this flag */
  106673. static get ExclusiveDoubleClickMode(): boolean;
  106674. static set ExclusiveDoubleClickMode(value: boolean);
  106675. /** @hidden */
  106676. _mirroredCameraPosition: Nullable<Vector3>;
  106677. /**
  106678. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  106679. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  106680. */
  106681. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  106682. /**
  106683. * Observable event triggered each time an keyboard event is received from the hosting window
  106684. */
  106685. onKeyboardObservable: Observable<KeyboardInfo>;
  106686. private _useRightHandedSystem;
  106687. /**
  106688. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  106689. */
  106690. set useRightHandedSystem(value: boolean);
  106691. get useRightHandedSystem(): boolean;
  106692. private _timeAccumulator;
  106693. private _currentStepId;
  106694. private _currentInternalStep;
  106695. /**
  106696. * Sets the step Id used by deterministic lock step
  106697. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106698. * @param newStepId defines the step Id
  106699. */
  106700. setStepId(newStepId: number): void;
  106701. /**
  106702. * Gets the step Id used by deterministic lock step
  106703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106704. * @returns the step Id
  106705. */
  106706. getStepId(): number;
  106707. /**
  106708. * Gets the internal step used by deterministic lock step
  106709. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106710. * @returns the internal step
  106711. */
  106712. getInternalStep(): number;
  106713. private _fogEnabled;
  106714. /**
  106715. * Gets or sets a boolean indicating if fog is enabled on this scene
  106716. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106717. * (Default is true)
  106718. */
  106719. set fogEnabled(value: boolean);
  106720. get fogEnabled(): boolean;
  106721. private _fogMode;
  106722. /**
  106723. * Gets or sets the fog mode to use
  106724. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106725. * | mode | value |
  106726. * | --- | --- |
  106727. * | FOGMODE_NONE | 0 |
  106728. * | FOGMODE_EXP | 1 |
  106729. * | FOGMODE_EXP2 | 2 |
  106730. * | FOGMODE_LINEAR | 3 |
  106731. */
  106732. set fogMode(value: number);
  106733. get fogMode(): number;
  106734. /**
  106735. * Gets or sets the fog color to use
  106736. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106737. * (Default is Color3(0.2, 0.2, 0.3))
  106738. */
  106739. fogColor: Color3;
  106740. /**
  106741. * Gets or sets the fog density to use
  106742. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106743. * (Default is 0.1)
  106744. */
  106745. fogDensity: number;
  106746. /**
  106747. * Gets or sets the fog start distance to use
  106748. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106749. * (Default is 0)
  106750. */
  106751. fogStart: number;
  106752. /**
  106753. * Gets or sets the fog end distance to use
  106754. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106755. * (Default is 1000)
  106756. */
  106757. fogEnd: number;
  106758. private _shadowsEnabled;
  106759. /**
  106760. * Gets or sets a boolean indicating if shadows are enabled on this scene
  106761. */
  106762. set shadowsEnabled(value: boolean);
  106763. get shadowsEnabled(): boolean;
  106764. private _lightsEnabled;
  106765. /**
  106766. * Gets or sets a boolean indicating if lights are enabled on this scene
  106767. */
  106768. set lightsEnabled(value: boolean);
  106769. get lightsEnabled(): boolean;
  106770. /** All of the active cameras added to this scene. */
  106771. activeCameras: Camera[];
  106772. /** @hidden */
  106773. _activeCamera: Nullable<Camera>;
  106774. /** Gets or sets the current active camera */
  106775. get activeCamera(): Nullable<Camera>;
  106776. set activeCamera(value: Nullable<Camera>);
  106777. private _defaultMaterial;
  106778. /** The default material used on meshes when no material is affected */
  106779. get defaultMaterial(): Material;
  106780. /** The default material used on meshes when no material is affected */
  106781. set defaultMaterial(value: Material);
  106782. private _texturesEnabled;
  106783. /**
  106784. * Gets or sets a boolean indicating if textures are enabled on this scene
  106785. */
  106786. set texturesEnabled(value: boolean);
  106787. get texturesEnabled(): boolean;
  106788. /**
  106789. * Gets or sets a boolean indicating if particles are enabled on this scene
  106790. */
  106791. particlesEnabled: boolean;
  106792. /**
  106793. * Gets or sets a boolean indicating if sprites are enabled on this scene
  106794. */
  106795. spritesEnabled: boolean;
  106796. private _skeletonsEnabled;
  106797. /**
  106798. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  106799. */
  106800. set skeletonsEnabled(value: boolean);
  106801. get skeletonsEnabled(): boolean;
  106802. /**
  106803. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  106804. */
  106805. lensFlaresEnabled: boolean;
  106806. /**
  106807. * Gets or sets a boolean indicating if collisions are enabled on this scene
  106808. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106809. */
  106810. collisionsEnabled: boolean;
  106811. private _collisionCoordinator;
  106812. /** @hidden */
  106813. get collisionCoordinator(): ICollisionCoordinator;
  106814. /**
  106815. * Defines the gravity applied to this scene (used only for collisions)
  106816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106817. */
  106818. gravity: Vector3;
  106819. /**
  106820. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  106821. */
  106822. postProcessesEnabled: boolean;
  106823. /**
  106824. * The list of postprocesses added to the scene
  106825. */
  106826. postProcesses: PostProcess[];
  106827. /**
  106828. * Gets the current postprocess manager
  106829. */
  106830. postProcessManager: PostProcessManager;
  106831. /**
  106832. * Gets or sets a boolean indicating if render targets are enabled on this scene
  106833. */
  106834. renderTargetsEnabled: boolean;
  106835. /**
  106836. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  106837. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  106838. */
  106839. dumpNextRenderTargets: boolean;
  106840. /**
  106841. * The list of user defined render targets added to the scene
  106842. */
  106843. customRenderTargets: RenderTargetTexture[];
  106844. /**
  106845. * Defines if texture loading must be delayed
  106846. * If true, textures will only be loaded when they need to be rendered
  106847. */
  106848. useDelayedTextureLoading: boolean;
  106849. /**
  106850. * Gets the list of meshes imported to the scene through SceneLoader
  106851. */
  106852. importedMeshesFiles: String[];
  106853. /**
  106854. * Gets or sets a boolean indicating if probes are enabled on this scene
  106855. */
  106856. probesEnabled: boolean;
  106857. /**
  106858. * Gets or sets the current offline provider to use to store scene data
  106859. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106860. */
  106861. offlineProvider: IOfflineProvider;
  106862. /**
  106863. * Gets or sets the action manager associated with the scene
  106864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106865. */
  106866. actionManager: AbstractActionManager;
  106867. private _meshesForIntersections;
  106868. /**
  106869. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  106870. */
  106871. proceduralTexturesEnabled: boolean;
  106872. private _engine;
  106873. private _totalVertices;
  106874. /** @hidden */
  106875. _activeIndices: PerfCounter;
  106876. /** @hidden */
  106877. _activeParticles: PerfCounter;
  106878. /** @hidden */
  106879. _activeBones: PerfCounter;
  106880. private _animationRatio;
  106881. /** @hidden */
  106882. _animationTimeLast: number;
  106883. /** @hidden */
  106884. _animationTime: number;
  106885. /**
  106886. * Gets or sets a general scale for animation speed
  106887. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106888. */
  106889. animationTimeScale: number;
  106890. /** @hidden */
  106891. _cachedMaterial: Nullable<Material>;
  106892. /** @hidden */
  106893. _cachedEffect: Nullable<Effect>;
  106894. /** @hidden */
  106895. _cachedVisibility: Nullable<number>;
  106896. private _renderId;
  106897. private _frameId;
  106898. private _executeWhenReadyTimeoutId;
  106899. private _intermediateRendering;
  106900. private _viewUpdateFlag;
  106901. private _projectionUpdateFlag;
  106902. /** @hidden */
  106903. _toBeDisposed: Nullable<IDisposable>[];
  106904. private _activeRequests;
  106905. /** @hidden */
  106906. _pendingData: any[];
  106907. private _isDisposed;
  106908. /**
  106909. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106910. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106911. */
  106912. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106913. private _activeMeshes;
  106914. private _processedMaterials;
  106915. private _renderTargets;
  106916. /** @hidden */
  106917. _activeParticleSystems: SmartArray<IParticleSystem>;
  106918. private _activeSkeletons;
  106919. private _softwareSkinnedMeshes;
  106920. private _renderingManager;
  106921. /** @hidden */
  106922. _activeAnimatables: Animatable[];
  106923. private _transformMatrix;
  106924. private _sceneUbo;
  106925. /** @hidden */
  106926. _viewMatrix: Matrix;
  106927. private _projectionMatrix;
  106928. /** @hidden */
  106929. _forcedViewPosition: Nullable<Vector3>;
  106930. /** @hidden */
  106931. _frustumPlanes: Plane[];
  106932. /**
  106933. * Gets the list of frustum planes (built from the active camera)
  106934. */
  106935. get frustumPlanes(): Plane[];
  106936. /**
  106937. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106938. * This is useful if there are more lights that the maximum simulteanous authorized
  106939. */
  106940. requireLightSorting: boolean;
  106941. /** @hidden */
  106942. readonly useMaterialMeshMap: boolean;
  106943. /** @hidden */
  106944. readonly useClonedMeshMap: boolean;
  106945. private _externalData;
  106946. private _uid;
  106947. /**
  106948. * @hidden
  106949. * Backing store of defined scene components.
  106950. */
  106951. _components: ISceneComponent[];
  106952. /**
  106953. * @hidden
  106954. * Backing store of defined scene components.
  106955. */
  106956. _serializableComponents: ISceneSerializableComponent[];
  106957. /**
  106958. * List of components to register on the next registration step.
  106959. */
  106960. private _transientComponents;
  106961. /**
  106962. * Registers the transient components if needed.
  106963. */
  106964. private _registerTransientComponents;
  106965. /**
  106966. * @hidden
  106967. * Add a component to the scene.
  106968. * Note that the ccomponent could be registered on th next frame if this is called after
  106969. * the register component stage.
  106970. * @param component Defines the component to add to the scene
  106971. */
  106972. _addComponent(component: ISceneComponent): void;
  106973. /**
  106974. * @hidden
  106975. * Gets a component from the scene.
  106976. * @param name defines the name of the component to retrieve
  106977. * @returns the component or null if not present
  106978. */
  106979. _getComponent(name: string): Nullable<ISceneComponent>;
  106980. /**
  106981. * @hidden
  106982. * Defines the actions happening before camera updates.
  106983. */
  106984. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106985. /**
  106986. * @hidden
  106987. * Defines the actions happening before clear the canvas.
  106988. */
  106989. _beforeClearStage: Stage<SimpleStageAction>;
  106990. /**
  106991. * @hidden
  106992. * Defines the actions when collecting render targets for the frame.
  106993. */
  106994. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106995. /**
  106996. * @hidden
  106997. * Defines the actions happening for one camera in the frame.
  106998. */
  106999. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  107000. /**
  107001. * @hidden
  107002. * Defines the actions happening during the per mesh ready checks.
  107003. */
  107004. _isReadyForMeshStage: Stage<MeshStageAction>;
  107005. /**
  107006. * @hidden
  107007. * Defines the actions happening before evaluate active mesh checks.
  107008. */
  107009. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  107010. /**
  107011. * @hidden
  107012. * Defines the actions happening during the evaluate sub mesh checks.
  107013. */
  107014. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  107015. /**
  107016. * @hidden
  107017. * Defines the actions happening during the active mesh stage.
  107018. */
  107019. _activeMeshStage: Stage<ActiveMeshStageAction>;
  107020. /**
  107021. * @hidden
  107022. * Defines the actions happening during the per camera render target step.
  107023. */
  107024. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  107025. /**
  107026. * @hidden
  107027. * Defines the actions happening just before the active camera is drawing.
  107028. */
  107029. _beforeCameraDrawStage: Stage<CameraStageAction>;
  107030. /**
  107031. * @hidden
  107032. * Defines the actions happening just before a render target is drawing.
  107033. */
  107034. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  107035. /**
  107036. * @hidden
  107037. * Defines the actions happening just before a rendering group is drawing.
  107038. */
  107039. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  107040. /**
  107041. * @hidden
  107042. * Defines the actions happening just before a mesh is drawing.
  107043. */
  107044. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  107045. /**
  107046. * @hidden
  107047. * Defines the actions happening just after a mesh has been drawn.
  107048. */
  107049. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  107050. /**
  107051. * @hidden
  107052. * Defines the actions happening just after a rendering group has been drawn.
  107053. */
  107054. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  107055. /**
  107056. * @hidden
  107057. * Defines the actions happening just after the active camera has been drawn.
  107058. */
  107059. _afterCameraDrawStage: Stage<CameraStageAction>;
  107060. /**
  107061. * @hidden
  107062. * Defines the actions happening just after a render target has been drawn.
  107063. */
  107064. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  107065. /**
  107066. * @hidden
  107067. * Defines the actions happening just after rendering all cameras and computing intersections.
  107068. */
  107069. _afterRenderStage: Stage<SimpleStageAction>;
  107070. /**
  107071. * @hidden
  107072. * Defines the actions happening when a pointer move event happens.
  107073. */
  107074. _pointerMoveStage: Stage<PointerMoveStageAction>;
  107075. /**
  107076. * @hidden
  107077. * Defines the actions happening when a pointer down event happens.
  107078. */
  107079. _pointerDownStage: Stage<PointerUpDownStageAction>;
  107080. /**
  107081. * @hidden
  107082. * Defines the actions happening when a pointer up event happens.
  107083. */
  107084. _pointerUpStage: Stage<PointerUpDownStageAction>;
  107085. /**
  107086. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  107087. */
  107088. private geometriesByUniqueId;
  107089. /**
  107090. * Creates a new Scene
  107091. * @param engine defines the engine to use to render this scene
  107092. * @param options defines the scene options
  107093. */
  107094. constructor(engine: Engine, options?: SceneOptions);
  107095. /**
  107096. * Gets a string idenfifying the name of the class
  107097. * @returns "Scene" string
  107098. */
  107099. getClassName(): string;
  107100. private _defaultMeshCandidates;
  107101. /**
  107102. * @hidden
  107103. */
  107104. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107105. private _defaultSubMeshCandidates;
  107106. /**
  107107. * @hidden
  107108. */
  107109. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107110. /**
  107111. * Sets the default candidate providers for the scene.
  107112. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  107113. * and getCollidingSubMeshCandidates to their default function
  107114. */
  107115. setDefaultCandidateProviders(): void;
  107116. /**
  107117. * Gets the mesh that is currently under the pointer
  107118. */
  107119. get meshUnderPointer(): Nullable<AbstractMesh>;
  107120. /**
  107121. * Gets or sets the current on-screen X position of the pointer
  107122. */
  107123. get pointerX(): number;
  107124. set pointerX(value: number);
  107125. /**
  107126. * Gets or sets the current on-screen Y position of the pointer
  107127. */
  107128. get pointerY(): number;
  107129. set pointerY(value: number);
  107130. /**
  107131. * Gets the cached material (ie. the latest rendered one)
  107132. * @returns the cached material
  107133. */
  107134. getCachedMaterial(): Nullable<Material>;
  107135. /**
  107136. * Gets the cached effect (ie. the latest rendered one)
  107137. * @returns the cached effect
  107138. */
  107139. getCachedEffect(): Nullable<Effect>;
  107140. /**
  107141. * Gets the cached visibility state (ie. the latest rendered one)
  107142. * @returns the cached visibility state
  107143. */
  107144. getCachedVisibility(): Nullable<number>;
  107145. /**
  107146. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  107147. * @param material defines the current material
  107148. * @param effect defines the current effect
  107149. * @param visibility defines the current visibility state
  107150. * @returns true if one parameter is not cached
  107151. */
  107152. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  107153. /**
  107154. * Gets the engine associated with the scene
  107155. * @returns an Engine
  107156. */
  107157. getEngine(): Engine;
  107158. /**
  107159. * Gets the total number of vertices rendered per frame
  107160. * @returns the total number of vertices rendered per frame
  107161. */
  107162. getTotalVertices(): number;
  107163. /**
  107164. * Gets the performance counter for total vertices
  107165. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107166. */
  107167. get totalVerticesPerfCounter(): PerfCounter;
  107168. /**
  107169. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  107170. * @returns the total number of active indices rendered per frame
  107171. */
  107172. getActiveIndices(): number;
  107173. /**
  107174. * Gets the performance counter for active indices
  107175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107176. */
  107177. get totalActiveIndicesPerfCounter(): PerfCounter;
  107178. /**
  107179. * Gets the total number of active particles rendered per frame
  107180. * @returns the total number of active particles rendered per frame
  107181. */
  107182. getActiveParticles(): number;
  107183. /**
  107184. * Gets the performance counter for active particles
  107185. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107186. */
  107187. get activeParticlesPerfCounter(): PerfCounter;
  107188. /**
  107189. * Gets the total number of active bones rendered per frame
  107190. * @returns the total number of active bones rendered per frame
  107191. */
  107192. getActiveBones(): number;
  107193. /**
  107194. * Gets the performance counter for active bones
  107195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107196. */
  107197. get activeBonesPerfCounter(): PerfCounter;
  107198. /**
  107199. * Gets the array of active meshes
  107200. * @returns an array of AbstractMesh
  107201. */
  107202. getActiveMeshes(): SmartArray<AbstractMesh>;
  107203. /**
  107204. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  107205. * @returns a number
  107206. */
  107207. getAnimationRatio(): number;
  107208. /**
  107209. * Gets an unique Id for the current render phase
  107210. * @returns a number
  107211. */
  107212. getRenderId(): number;
  107213. /**
  107214. * Gets an unique Id for the current frame
  107215. * @returns a number
  107216. */
  107217. getFrameId(): number;
  107218. /** Call this function if you want to manually increment the render Id*/
  107219. incrementRenderId(): void;
  107220. private _createUbo;
  107221. /**
  107222. * Use this method to simulate a pointer move on a mesh
  107223. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107224. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107225. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107226. * @returns the current scene
  107227. */
  107228. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  107229. /**
  107230. * Use this method to simulate a pointer down on a mesh
  107231. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107232. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107233. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107234. * @returns the current scene
  107235. */
  107236. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  107237. /**
  107238. * Use this method to simulate a pointer up on a mesh
  107239. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107240. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107241. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107242. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107243. * @returns the current scene
  107244. */
  107245. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  107246. /**
  107247. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107248. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107249. * @returns true if the pointer was captured
  107250. */
  107251. isPointerCaptured(pointerId?: number): boolean;
  107252. /**
  107253. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107254. * @param attachUp defines if you want to attach events to pointerup
  107255. * @param attachDown defines if you want to attach events to pointerdown
  107256. * @param attachMove defines if you want to attach events to pointermove
  107257. */
  107258. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  107259. /** Detaches all event handlers*/
  107260. detachControl(): void;
  107261. /**
  107262. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  107263. * Delay loaded resources are not taking in account
  107264. * @return true if all required resources are ready
  107265. */
  107266. isReady(): boolean;
  107267. /** Resets all cached information relative to material (including effect and visibility) */
  107268. resetCachedMaterial(): void;
  107269. /**
  107270. * Registers a function to be called before every frame render
  107271. * @param func defines the function to register
  107272. */
  107273. registerBeforeRender(func: () => void): void;
  107274. /**
  107275. * Unregisters a function called before every frame render
  107276. * @param func defines the function to unregister
  107277. */
  107278. unregisterBeforeRender(func: () => void): void;
  107279. /**
  107280. * Registers a function to be called after every frame render
  107281. * @param func defines the function to register
  107282. */
  107283. registerAfterRender(func: () => void): void;
  107284. /**
  107285. * Unregisters a function called after every frame render
  107286. * @param func defines the function to unregister
  107287. */
  107288. unregisterAfterRender(func: () => void): void;
  107289. private _executeOnceBeforeRender;
  107290. /**
  107291. * The provided function will run before render once and will be disposed afterwards.
  107292. * A timeout delay can be provided so that the function will be executed in N ms.
  107293. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  107294. * @param func The function to be executed.
  107295. * @param timeout optional delay in ms
  107296. */
  107297. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  107298. /** @hidden */
  107299. _addPendingData(data: any): void;
  107300. /** @hidden */
  107301. _removePendingData(data: any): void;
  107302. /**
  107303. * Returns the number of items waiting to be loaded
  107304. * @returns the number of items waiting to be loaded
  107305. */
  107306. getWaitingItemsCount(): number;
  107307. /**
  107308. * Returns a boolean indicating if the scene is still loading data
  107309. */
  107310. get isLoading(): boolean;
  107311. /**
  107312. * Registers a function to be executed when the scene is ready
  107313. * @param {Function} func - the function to be executed
  107314. */
  107315. executeWhenReady(func: () => void): void;
  107316. /**
  107317. * Returns a promise that resolves when the scene is ready
  107318. * @returns A promise that resolves when the scene is ready
  107319. */
  107320. whenReadyAsync(): Promise<void>;
  107321. /** @hidden */
  107322. _checkIsReady(): void;
  107323. /**
  107324. * Gets all animatable attached to the scene
  107325. */
  107326. get animatables(): Animatable[];
  107327. /**
  107328. * Resets the last animation time frame.
  107329. * Useful to override when animations start running when loading a scene for the first time.
  107330. */
  107331. resetLastAnimationTimeFrame(): void;
  107332. /**
  107333. * Gets the current view matrix
  107334. * @returns a Matrix
  107335. */
  107336. getViewMatrix(): Matrix;
  107337. /**
  107338. * Gets the current projection matrix
  107339. * @returns a Matrix
  107340. */
  107341. getProjectionMatrix(): Matrix;
  107342. /**
  107343. * Gets the current transform matrix
  107344. * @returns a Matrix made of View * Projection
  107345. */
  107346. getTransformMatrix(): Matrix;
  107347. /**
  107348. * Sets the current transform matrix
  107349. * @param viewL defines the View matrix to use
  107350. * @param projectionL defines the Projection matrix to use
  107351. * @param viewR defines the right View matrix to use (if provided)
  107352. * @param projectionR defines the right Projection matrix to use (if provided)
  107353. */
  107354. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  107355. /**
  107356. * Gets the uniform buffer used to store scene data
  107357. * @returns a UniformBuffer
  107358. */
  107359. getSceneUniformBuffer(): UniformBuffer;
  107360. /**
  107361. * Gets an unique (relatively to the current scene) Id
  107362. * @returns an unique number for the scene
  107363. */
  107364. getUniqueId(): number;
  107365. /**
  107366. * Add a mesh to the list of scene's meshes
  107367. * @param newMesh defines the mesh to add
  107368. * @param recursive if all child meshes should also be added to the scene
  107369. */
  107370. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  107371. /**
  107372. * Remove a mesh for the list of scene's meshes
  107373. * @param toRemove defines the mesh to remove
  107374. * @param recursive if all child meshes should also be removed from the scene
  107375. * @returns the index where the mesh was in the mesh list
  107376. */
  107377. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  107378. /**
  107379. * Add a transform node to the list of scene's transform nodes
  107380. * @param newTransformNode defines the transform node to add
  107381. */
  107382. addTransformNode(newTransformNode: TransformNode): void;
  107383. /**
  107384. * Remove a transform node for the list of scene's transform nodes
  107385. * @param toRemove defines the transform node to remove
  107386. * @returns the index where the transform node was in the transform node list
  107387. */
  107388. removeTransformNode(toRemove: TransformNode): number;
  107389. /**
  107390. * Remove a skeleton for the list of scene's skeletons
  107391. * @param toRemove defines the skeleton to remove
  107392. * @returns the index where the skeleton was in the skeleton list
  107393. */
  107394. removeSkeleton(toRemove: Skeleton): number;
  107395. /**
  107396. * Remove a morph target for the list of scene's morph targets
  107397. * @param toRemove defines the morph target to remove
  107398. * @returns the index where the morph target was in the morph target list
  107399. */
  107400. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  107401. /**
  107402. * Remove a light for the list of scene's lights
  107403. * @param toRemove defines the light to remove
  107404. * @returns the index where the light was in the light list
  107405. */
  107406. removeLight(toRemove: Light): number;
  107407. /**
  107408. * Remove a camera for the list of scene's cameras
  107409. * @param toRemove defines the camera to remove
  107410. * @returns the index where the camera was in the camera list
  107411. */
  107412. removeCamera(toRemove: Camera): number;
  107413. /**
  107414. * Remove a particle system for the list of scene's particle systems
  107415. * @param toRemove defines the particle system to remove
  107416. * @returns the index where the particle system was in the particle system list
  107417. */
  107418. removeParticleSystem(toRemove: IParticleSystem): number;
  107419. /**
  107420. * Remove a animation for the list of scene's animations
  107421. * @param toRemove defines the animation to remove
  107422. * @returns the index where the animation was in the animation list
  107423. */
  107424. removeAnimation(toRemove: Animation): number;
  107425. /**
  107426. * Will stop the animation of the given target
  107427. * @param target - the target
  107428. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  107429. * @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)
  107430. */
  107431. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  107432. /**
  107433. * Removes the given animation group from this scene.
  107434. * @param toRemove The animation group to remove
  107435. * @returns The index of the removed animation group
  107436. */
  107437. removeAnimationGroup(toRemove: AnimationGroup): number;
  107438. /**
  107439. * Removes the given multi-material from this scene.
  107440. * @param toRemove The multi-material to remove
  107441. * @returns The index of the removed multi-material
  107442. */
  107443. removeMultiMaterial(toRemove: MultiMaterial): number;
  107444. /**
  107445. * Removes the given material from this scene.
  107446. * @param toRemove The material to remove
  107447. * @returns The index of the removed material
  107448. */
  107449. removeMaterial(toRemove: Material): number;
  107450. /**
  107451. * Removes the given action manager from this scene.
  107452. * @param toRemove The action manager to remove
  107453. * @returns The index of the removed action manager
  107454. */
  107455. removeActionManager(toRemove: AbstractActionManager): number;
  107456. /**
  107457. * Removes the given texture from this scene.
  107458. * @param toRemove The texture to remove
  107459. * @returns The index of the removed texture
  107460. */
  107461. removeTexture(toRemove: BaseTexture): number;
  107462. /**
  107463. * Adds the given light to this scene
  107464. * @param newLight The light to add
  107465. */
  107466. addLight(newLight: Light): void;
  107467. /**
  107468. * Sorts the list list based on light priorities
  107469. */
  107470. sortLightsByPriority(): void;
  107471. /**
  107472. * Adds the given camera to this scene
  107473. * @param newCamera The camera to add
  107474. */
  107475. addCamera(newCamera: Camera): void;
  107476. /**
  107477. * Adds the given skeleton to this scene
  107478. * @param newSkeleton The skeleton to add
  107479. */
  107480. addSkeleton(newSkeleton: Skeleton): void;
  107481. /**
  107482. * Adds the given particle system to this scene
  107483. * @param newParticleSystem The particle system to add
  107484. */
  107485. addParticleSystem(newParticleSystem: IParticleSystem): void;
  107486. /**
  107487. * Adds the given animation to this scene
  107488. * @param newAnimation The animation to add
  107489. */
  107490. addAnimation(newAnimation: Animation): void;
  107491. /**
  107492. * Adds the given animation group to this scene.
  107493. * @param newAnimationGroup The animation group to add
  107494. */
  107495. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  107496. /**
  107497. * Adds the given multi-material to this scene
  107498. * @param newMultiMaterial The multi-material to add
  107499. */
  107500. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  107501. /**
  107502. * Adds the given material to this scene
  107503. * @param newMaterial The material to add
  107504. */
  107505. addMaterial(newMaterial: Material): void;
  107506. /**
  107507. * Adds the given morph target to this scene
  107508. * @param newMorphTargetManager The morph target to add
  107509. */
  107510. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  107511. /**
  107512. * Adds the given geometry to this scene
  107513. * @param newGeometry The geometry to add
  107514. */
  107515. addGeometry(newGeometry: Geometry): void;
  107516. /**
  107517. * Adds the given action manager to this scene
  107518. * @param newActionManager The action manager to add
  107519. */
  107520. addActionManager(newActionManager: AbstractActionManager): void;
  107521. /**
  107522. * Adds the given texture to this scene.
  107523. * @param newTexture The texture to add
  107524. */
  107525. addTexture(newTexture: BaseTexture): void;
  107526. /**
  107527. * Switch active camera
  107528. * @param newCamera defines the new active camera
  107529. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  107530. */
  107531. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  107532. /**
  107533. * sets the active camera of the scene using its ID
  107534. * @param id defines the camera's ID
  107535. * @return the new active camera or null if none found.
  107536. */
  107537. setActiveCameraByID(id: string): Nullable<Camera>;
  107538. /**
  107539. * sets the active camera of the scene using its name
  107540. * @param name defines the camera's name
  107541. * @returns the new active camera or null if none found.
  107542. */
  107543. setActiveCameraByName(name: string): Nullable<Camera>;
  107544. /**
  107545. * get an animation group using its name
  107546. * @param name defines the material's name
  107547. * @return the animation group or null if none found.
  107548. */
  107549. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  107550. /**
  107551. * Get a material using its unique id
  107552. * @param uniqueId defines the material's unique id
  107553. * @return the material or null if none found.
  107554. */
  107555. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  107556. /**
  107557. * get a material using its id
  107558. * @param id defines the material's ID
  107559. * @return the material or null if none found.
  107560. */
  107561. getMaterialByID(id: string): Nullable<Material>;
  107562. /**
  107563. * Gets a the last added material using a given id
  107564. * @param id defines the material's ID
  107565. * @return the last material with the given id or null if none found.
  107566. */
  107567. getLastMaterialByID(id: string): Nullable<Material>;
  107568. /**
  107569. * Gets a material using its name
  107570. * @param name defines the material's name
  107571. * @return the material or null if none found.
  107572. */
  107573. getMaterialByName(name: string): Nullable<Material>;
  107574. /**
  107575. * Get a texture using its unique id
  107576. * @param uniqueId defines the texture's unique id
  107577. * @return the texture or null if none found.
  107578. */
  107579. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  107580. /**
  107581. * Gets a camera using its id
  107582. * @param id defines the id to look for
  107583. * @returns the camera or null if not found
  107584. */
  107585. getCameraByID(id: string): Nullable<Camera>;
  107586. /**
  107587. * Gets a camera using its unique id
  107588. * @param uniqueId defines the unique id to look for
  107589. * @returns the camera or null if not found
  107590. */
  107591. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  107592. /**
  107593. * Gets a camera using its name
  107594. * @param name defines the camera's name
  107595. * @return the camera or null if none found.
  107596. */
  107597. getCameraByName(name: string): Nullable<Camera>;
  107598. /**
  107599. * Gets a bone using its id
  107600. * @param id defines the bone's id
  107601. * @return the bone or null if not found
  107602. */
  107603. getBoneByID(id: string): Nullable<Bone>;
  107604. /**
  107605. * Gets a bone using its id
  107606. * @param name defines the bone's name
  107607. * @return the bone or null if not found
  107608. */
  107609. getBoneByName(name: string): Nullable<Bone>;
  107610. /**
  107611. * Gets a light node using its name
  107612. * @param name defines the the light's name
  107613. * @return the light or null if none found.
  107614. */
  107615. getLightByName(name: string): Nullable<Light>;
  107616. /**
  107617. * Gets a light node using its id
  107618. * @param id defines the light's id
  107619. * @return the light or null if none found.
  107620. */
  107621. getLightByID(id: string): Nullable<Light>;
  107622. /**
  107623. * Gets a light node using its scene-generated unique ID
  107624. * @param uniqueId defines the light's unique id
  107625. * @return the light or null if none found.
  107626. */
  107627. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  107628. /**
  107629. * Gets a particle system by id
  107630. * @param id defines the particle system id
  107631. * @return the corresponding system or null if none found
  107632. */
  107633. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  107634. /**
  107635. * Gets a geometry using its ID
  107636. * @param id defines the geometry's id
  107637. * @return the geometry or null if none found.
  107638. */
  107639. getGeometryByID(id: string): Nullable<Geometry>;
  107640. private _getGeometryByUniqueID;
  107641. /**
  107642. * Add a new geometry to this scene
  107643. * @param geometry defines the geometry to be added to the scene.
  107644. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  107645. * @return a boolean defining if the geometry was added or not
  107646. */
  107647. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  107648. /**
  107649. * Removes an existing geometry
  107650. * @param geometry defines the geometry to be removed from the scene
  107651. * @return a boolean defining if the geometry was removed or not
  107652. */
  107653. removeGeometry(geometry: Geometry): boolean;
  107654. /**
  107655. * Gets the list of geometries attached to the scene
  107656. * @returns an array of Geometry
  107657. */
  107658. getGeometries(): Geometry[];
  107659. /**
  107660. * Gets the first added mesh found of a given ID
  107661. * @param id defines the id to search for
  107662. * @return the mesh found or null if not found at all
  107663. */
  107664. getMeshByID(id: string): Nullable<AbstractMesh>;
  107665. /**
  107666. * Gets a list of meshes using their id
  107667. * @param id defines the id to search for
  107668. * @returns a list of meshes
  107669. */
  107670. getMeshesByID(id: string): Array<AbstractMesh>;
  107671. /**
  107672. * Gets the first added transform node found of a given ID
  107673. * @param id defines the id to search for
  107674. * @return the found transform node or null if not found at all.
  107675. */
  107676. getTransformNodeByID(id: string): Nullable<TransformNode>;
  107677. /**
  107678. * Gets a transform node with its auto-generated unique id
  107679. * @param uniqueId efines the unique id to search for
  107680. * @return the found transform node or null if not found at all.
  107681. */
  107682. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  107683. /**
  107684. * Gets a list of transform nodes using their id
  107685. * @param id defines the id to search for
  107686. * @returns a list of transform nodes
  107687. */
  107688. getTransformNodesByID(id: string): Array<TransformNode>;
  107689. /**
  107690. * Gets a mesh with its auto-generated unique id
  107691. * @param uniqueId defines the unique id to search for
  107692. * @return the found mesh or null if not found at all.
  107693. */
  107694. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  107695. /**
  107696. * Gets a the last added mesh using a given id
  107697. * @param id defines the id to search for
  107698. * @return the found mesh or null if not found at all.
  107699. */
  107700. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  107701. /**
  107702. * Gets a the last added node (Mesh, Camera, Light) using a given id
  107703. * @param id defines the id to search for
  107704. * @return the found node or null if not found at all
  107705. */
  107706. getLastEntryByID(id: string): Nullable<Node>;
  107707. /**
  107708. * Gets a node (Mesh, Camera, Light) using a given id
  107709. * @param id defines the id to search for
  107710. * @return the found node or null if not found at all
  107711. */
  107712. getNodeByID(id: string): Nullable<Node>;
  107713. /**
  107714. * Gets a node (Mesh, Camera, Light) using a given name
  107715. * @param name defines the name to search for
  107716. * @return the found node or null if not found at all.
  107717. */
  107718. getNodeByName(name: string): Nullable<Node>;
  107719. /**
  107720. * Gets a mesh using a given name
  107721. * @param name defines the name to search for
  107722. * @return the found mesh or null if not found at all.
  107723. */
  107724. getMeshByName(name: string): Nullable<AbstractMesh>;
  107725. /**
  107726. * Gets a transform node using a given name
  107727. * @param name defines the name to search for
  107728. * @return the found transform node or null if not found at all.
  107729. */
  107730. getTransformNodeByName(name: string): Nullable<TransformNode>;
  107731. /**
  107732. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  107733. * @param id defines the id to search for
  107734. * @return the found skeleton or null if not found at all.
  107735. */
  107736. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  107737. /**
  107738. * Gets a skeleton using a given auto generated unique id
  107739. * @param uniqueId defines the unique id to search for
  107740. * @return the found skeleton or null if not found at all.
  107741. */
  107742. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  107743. /**
  107744. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  107745. * @param id defines the id to search for
  107746. * @return the found skeleton or null if not found at all.
  107747. */
  107748. getSkeletonById(id: string): Nullable<Skeleton>;
  107749. /**
  107750. * Gets a skeleton using a given name
  107751. * @param name defines the name to search for
  107752. * @return the found skeleton or null if not found at all.
  107753. */
  107754. getSkeletonByName(name: string): Nullable<Skeleton>;
  107755. /**
  107756. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  107757. * @param id defines the id to search for
  107758. * @return the found morph target manager or null if not found at all.
  107759. */
  107760. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  107761. /**
  107762. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  107763. * @param id defines the id to search for
  107764. * @return the found morph target or null if not found at all.
  107765. */
  107766. getMorphTargetById(id: string): Nullable<MorphTarget>;
  107767. /**
  107768. * Gets a boolean indicating if the given mesh is active
  107769. * @param mesh defines the mesh to look for
  107770. * @returns true if the mesh is in the active list
  107771. */
  107772. isActiveMesh(mesh: AbstractMesh): boolean;
  107773. /**
  107774. * Return a unique id as a string which can serve as an identifier for the scene
  107775. */
  107776. get uid(): string;
  107777. /**
  107778. * Add an externaly attached data from its key.
  107779. * This method call will fail and return false, if such key already exists.
  107780. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  107781. * @param key the unique key that identifies the data
  107782. * @param data the data object to associate to the key for this Engine instance
  107783. * @return true if no such key were already present and the data was added successfully, false otherwise
  107784. */
  107785. addExternalData<T>(key: string, data: T): boolean;
  107786. /**
  107787. * Get an externaly attached data from its key
  107788. * @param key the unique key that identifies the data
  107789. * @return the associated data, if present (can be null), or undefined if not present
  107790. */
  107791. getExternalData<T>(key: string): Nullable<T>;
  107792. /**
  107793. * Get an externaly attached data from its key, create it using a factory if it's not already present
  107794. * @param key the unique key that identifies the data
  107795. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  107796. * @return the associated data, can be null if the factory returned null.
  107797. */
  107798. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  107799. /**
  107800. * Remove an externaly attached data from the Engine instance
  107801. * @param key the unique key that identifies the data
  107802. * @return true if the data was successfully removed, false if it doesn't exist
  107803. */
  107804. removeExternalData(key: string): boolean;
  107805. private _evaluateSubMesh;
  107806. /**
  107807. * Clear the processed materials smart array preventing retention point in material dispose.
  107808. */
  107809. freeProcessedMaterials(): void;
  107810. private _preventFreeActiveMeshesAndRenderingGroups;
  107811. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  107812. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  107813. * when disposing several meshes in a row or a hierarchy of meshes.
  107814. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  107815. */
  107816. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  107817. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  107818. /**
  107819. * Clear the active meshes smart array preventing retention point in mesh dispose.
  107820. */
  107821. freeActiveMeshes(): void;
  107822. /**
  107823. * Clear the info related to rendering groups preventing retention points during dispose.
  107824. */
  107825. freeRenderingGroups(): void;
  107826. /** @hidden */
  107827. _isInIntermediateRendering(): boolean;
  107828. /**
  107829. * Lambda returning the list of potentially active meshes.
  107830. */
  107831. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  107832. /**
  107833. * Lambda returning the list of potentially active sub meshes.
  107834. */
  107835. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  107836. /**
  107837. * Lambda returning the list of potentially intersecting sub meshes.
  107838. */
  107839. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  107840. /**
  107841. * Lambda returning the list of potentially colliding sub meshes.
  107842. */
  107843. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  107844. private _activeMeshesFrozen;
  107845. private _skipEvaluateActiveMeshesCompletely;
  107846. /**
  107847. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  107848. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  107849. * @returns the current scene
  107850. */
  107851. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  107852. /**
  107853. * Use this function to restart evaluating active meshes on every frame
  107854. * @returns the current scene
  107855. */
  107856. unfreezeActiveMeshes(): Scene;
  107857. private _evaluateActiveMeshes;
  107858. private _activeMesh;
  107859. /**
  107860. * Update the transform matrix to update from the current active camera
  107861. * @param force defines a boolean used to force the update even if cache is up to date
  107862. */
  107863. updateTransformMatrix(force?: boolean): void;
  107864. private _bindFrameBuffer;
  107865. /** @hidden */
  107866. _allowPostProcessClearColor: boolean;
  107867. /** @hidden */
  107868. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  107869. private _processSubCameras;
  107870. private _checkIntersections;
  107871. /** @hidden */
  107872. _advancePhysicsEngineStep(step: number): void;
  107873. /**
  107874. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  107875. */
  107876. getDeterministicFrameTime: () => number;
  107877. /** @hidden */
  107878. _animate(): void;
  107879. /** Execute all animations (for a frame) */
  107880. animate(): void;
  107881. /**
  107882. * Render the scene
  107883. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  107884. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107885. */
  107886. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107887. /**
  107888. * Freeze all materials
  107889. * A frozen material will not be updatable but should be faster to render
  107890. */
  107891. freezeMaterials(): void;
  107892. /**
  107893. * Unfreeze all materials
  107894. * A frozen material will not be updatable but should be faster to render
  107895. */
  107896. unfreezeMaterials(): void;
  107897. /**
  107898. * Releases all held ressources
  107899. */
  107900. dispose(): void;
  107901. /**
  107902. * Gets if the scene is already disposed
  107903. */
  107904. get isDisposed(): boolean;
  107905. /**
  107906. * Call this function to reduce memory footprint of the scene.
  107907. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107908. */
  107909. clearCachedVertexData(): void;
  107910. /**
  107911. * This function will remove the local cached buffer data from texture.
  107912. * It will save memory but will prevent the texture from being rebuilt
  107913. */
  107914. cleanCachedTextureBuffer(): void;
  107915. /**
  107916. * Get the world extend vectors with an optional filter
  107917. *
  107918. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107919. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107920. */
  107921. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107922. min: Vector3;
  107923. max: Vector3;
  107924. };
  107925. /**
  107926. * Creates a ray that can be used to pick in the scene
  107927. * @param x defines the x coordinate of the origin (on-screen)
  107928. * @param y defines the y coordinate of the origin (on-screen)
  107929. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107930. * @param camera defines the camera to use for the picking
  107931. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107932. * @returns a Ray
  107933. */
  107934. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107935. /**
  107936. * Creates a ray that can be used to pick in the scene
  107937. * @param x defines the x coordinate of the origin (on-screen)
  107938. * @param y defines the y coordinate of the origin (on-screen)
  107939. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107940. * @param result defines the ray where to store the picking ray
  107941. * @param camera defines the camera to use for the picking
  107942. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107943. * @returns the current scene
  107944. */
  107945. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107946. /**
  107947. * Creates a ray that can be used to pick in the scene
  107948. * @param x defines the x coordinate of the origin (on-screen)
  107949. * @param y defines the y coordinate of the origin (on-screen)
  107950. * @param camera defines the camera to use for the picking
  107951. * @returns a Ray
  107952. */
  107953. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107954. /**
  107955. * Creates a ray that can be used to pick in the scene
  107956. * @param x defines the x coordinate of the origin (on-screen)
  107957. * @param y defines the y coordinate of the origin (on-screen)
  107958. * @param result defines the ray where to store the picking ray
  107959. * @param camera defines the camera to use for the picking
  107960. * @returns the current scene
  107961. */
  107962. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107963. /** Launch a ray to try to pick a mesh in the scene
  107964. * @param x position on screen
  107965. * @param y position on screen
  107966. * @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
  107967. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107968. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107969. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107970. * @returns a PickingInfo
  107971. */
  107972. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107973. /** Use the given ray to pick a mesh in the scene
  107974. * @param ray The ray to use to pick meshes
  107975. * @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
  107976. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107977. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107978. * @returns a PickingInfo
  107979. */
  107980. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107981. /**
  107982. * Launch a ray to try to pick a mesh in the scene
  107983. * @param x X position on screen
  107984. * @param y Y position on screen
  107985. * @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
  107986. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107987. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107988. * @returns an array of PickingInfo
  107989. */
  107990. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107991. /**
  107992. * Launch a ray to try to pick a mesh in the scene
  107993. * @param ray Ray to use
  107994. * @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
  107995. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107996. * @returns an array of PickingInfo
  107997. */
  107998. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107999. /**
  108000. * Force the value of meshUnderPointer
  108001. * @param mesh defines the mesh to use
  108002. */
  108003. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108004. /**
  108005. * Gets the mesh under the pointer
  108006. * @returns a Mesh or null if no mesh is under the pointer
  108007. */
  108008. getPointerOverMesh(): Nullable<AbstractMesh>;
  108009. /** @hidden */
  108010. _rebuildGeometries(): void;
  108011. /** @hidden */
  108012. _rebuildTextures(): void;
  108013. private _getByTags;
  108014. /**
  108015. * Get a list of meshes by tags
  108016. * @param tagsQuery defines the tags query to use
  108017. * @param forEach defines a predicate used to filter results
  108018. * @returns an array of Mesh
  108019. */
  108020. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  108021. /**
  108022. * Get a list of cameras by tags
  108023. * @param tagsQuery defines the tags query to use
  108024. * @param forEach defines a predicate used to filter results
  108025. * @returns an array of Camera
  108026. */
  108027. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  108028. /**
  108029. * Get a list of lights by tags
  108030. * @param tagsQuery defines the tags query to use
  108031. * @param forEach defines a predicate used to filter results
  108032. * @returns an array of Light
  108033. */
  108034. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  108035. /**
  108036. * Get a list of materials by tags
  108037. * @param tagsQuery defines the tags query to use
  108038. * @param forEach defines a predicate used to filter results
  108039. * @returns an array of Material
  108040. */
  108041. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  108042. /**
  108043. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  108044. * This allowed control for front to back rendering or reversly depending of the special needs.
  108045. *
  108046. * @param renderingGroupId The rendering group id corresponding to its index
  108047. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  108048. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  108049. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  108050. */
  108051. 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;
  108052. /**
  108053. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  108054. *
  108055. * @param renderingGroupId The rendering group id corresponding to its index
  108056. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108057. * @param depth Automatically clears depth between groups if true and autoClear is true.
  108058. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  108059. */
  108060. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  108061. /**
  108062. * Gets the current auto clear configuration for one rendering group of the rendering
  108063. * manager.
  108064. * @param index the rendering group index to get the information for
  108065. * @returns The auto clear setup for the requested rendering group
  108066. */
  108067. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  108068. private _blockMaterialDirtyMechanism;
  108069. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  108070. get blockMaterialDirtyMechanism(): boolean;
  108071. set blockMaterialDirtyMechanism(value: boolean);
  108072. /**
  108073. * Will flag all materials as dirty to trigger new shader compilation
  108074. * @param flag defines the flag used to specify which material part must be marked as dirty
  108075. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  108076. */
  108077. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  108078. /** @hidden */
  108079. _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;
  108080. /** @hidden */
  108081. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108082. /** @hidden */
  108083. _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;
  108084. /** @hidden */
  108085. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  108086. /** @hidden */
  108087. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108088. /** @hidden */
  108089. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108090. }
  108091. }
  108092. declare module BABYLON {
  108093. /**
  108094. * Set of assets to keep when moving a scene into an asset container.
  108095. */
  108096. export class KeepAssets extends AbstractScene {
  108097. }
  108098. /**
  108099. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  108100. */
  108101. export class InstantiatedEntries {
  108102. /**
  108103. * List of new root nodes (eg. nodes with no parent)
  108104. */
  108105. rootNodes: TransformNode[];
  108106. /**
  108107. * List of new skeletons
  108108. */
  108109. skeletons: Skeleton[];
  108110. /**
  108111. * List of new animation groups
  108112. */
  108113. animationGroups: AnimationGroup[];
  108114. }
  108115. /**
  108116. * Container with a set of assets that can be added or removed from a scene.
  108117. */
  108118. export class AssetContainer extends AbstractScene {
  108119. /**
  108120. * The scene the AssetContainer belongs to.
  108121. */
  108122. scene: Scene;
  108123. /**
  108124. * Instantiates an AssetContainer.
  108125. * @param scene The scene the AssetContainer belongs to.
  108126. */
  108127. constructor(scene: Scene);
  108128. /**
  108129. * Instantiate or clone all meshes and add the new ones to the scene.
  108130. * Skeletons and animation groups will all be cloned
  108131. * @param nameFunction defines an optional function used to get new names for clones
  108132. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  108133. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  108134. */
  108135. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  108136. /**
  108137. * Adds all the assets from the container to the scene.
  108138. */
  108139. addAllToScene(): void;
  108140. /**
  108141. * Removes all the assets in the container from the scene
  108142. */
  108143. removeAllFromScene(): void;
  108144. /**
  108145. * Disposes all the assets in the container
  108146. */
  108147. dispose(): void;
  108148. private _moveAssets;
  108149. /**
  108150. * Removes all the assets contained in the scene and adds them to the container.
  108151. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  108152. */
  108153. moveAllFromScene(keepAssets?: KeepAssets): void;
  108154. /**
  108155. * 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.
  108156. * @returns the root mesh
  108157. */
  108158. createRootMesh(): Mesh;
  108159. /**
  108160. * Merge animations from this asset container into a scene
  108161. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108162. * @param animatables set of animatables to retarget to a node from the scene
  108163. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  108164. */
  108165. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  108166. }
  108167. }
  108168. declare module BABYLON {
  108169. /**
  108170. * Defines how the parser contract is defined.
  108171. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  108172. */
  108173. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  108174. /**
  108175. * Defines how the individual parser contract is defined.
  108176. * These parser can parse an individual asset
  108177. */
  108178. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  108179. /**
  108180. * Base class of the scene acting as a container for the different elements composing a scene.
  108181. * This class is dynamically extended by the different components of the scene increasing
  108182. * flexibility and reducing coupling
  108183. */
  108184. export abstract class AbstractScene {
  108185. /**
  108186. * Stores the list of available parsers in the application.
  108187. */
  108188. private static _BabylonFileParsers;
  108189. /**
  108190. * Stores the list of available individual parsers in the application.
  108191. */
  108192. private static _IndividualBabylonFileParsers;
  108193. /**
  108194. * Adds a parser in the list of available ones
  108195. * @param name Defines the name of the parser
  108196. * @param parser Defines the parser to add
  108197. */
  108198. static AddParser(name: string, parser: BabylonFileParser): void;
  108199. /**
  108200. * Gets a general parser from the list of avaialble ones
  108201. * @param name Defines the name of the parser
  108202. * @returns the requested parser or null
  108203. */
  108204. static GetParser(name: string): Nullable<BabylonFileParser>;
  108205. /**
  108206. * Adds n individual parser in the list of available ones
  108207. * @param name Defines the name of the parser
  108208. * @param parser Defines the parser to add
  108209. */
  108210. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  108211. /**
  108212. * Gets an individual parser from the list of avaialble ones
  108213. * @param name Defines the name of the parser
  108214. * @returns the requested parser or null
  108215. */
  108216. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  108217. /**
  108218. * Parser json data and populate both a scene and its associated container object
  108219. * @param jsonData Defines the data to parse
  108220. * @param scene Defines the scene to parse the data for
  108221. * @param container Defines the container attached to the parsing sequence
  108222. * @param rootUrl Defines the root url of the data
  108223. */
  108224. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  108225. /**
  108226. * Gets the list of root nodes (ie. nodes with no parent)
  108227. */
  108228. rootNodes: Node[];
  108229. /** All of the cameras added to this scene
  108230. * @see http://doc.babylonjs.com/babylon101/cameras
  108231. */
  108232. cameras: Camera[];
  108233. /**
  108234. * All of the lights added to this scene
  108235. * @see http://doc.babylonjs.com/babylon101/lights
  108236. */
  108237. lights: Light[];
  108238. /**
  108239. * All of the (abstract) meshes added to this scene
  108240. */
  108241. meshes: AbstractMesh[];
  108242. /**
  108243. * The list of skeletons added to the scene
  108244. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108245. */
  108246. skeletons: Skeleton[];
  108247. /**
  108248. * All of the particle systems added to this scene
  108249. * @see http://doc.babylonjs.com/babylon101/particles
  108250. */
  108251. particleSystems: IParticleSystem[];
  108252. /**
  108253. * Gets a list of Animations associated with the scene
  108254. */
  108255. animations: Animation[];
  108256. /**
  108257. * All of the animation groups added to this scene
  108258. * @see http://doc.babylonjs.com/how_to/group
  108259. */
  108260. animationGroups: AnimationGroup[];
  108261. /**
  108262. * All of the multi-materials added to this scene
  108263. * @see http://doc.babylonjs.com/how_to/multi_materials
  108264. */
  108265. multiMaterials: MultiMaterial[];
  108266. /**
  108267. * All of the materials added to this scene
  108268. * In the context of a Scene, it is not supposed to be modified manually.
  108269. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  108270. * Note also that the order of the Material within the array is not significant and might change.
  108271. * @see http://doc.babylonjs.com/babylon101/materials
  108272. */
  108273. materials: Material[];
  108274. /**
  108275. * The list of morph target managers added to the scene
  108276. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  108277. */
  108278. morphTargetManagers: MorphTargetManager[];
  108279. /**
  108280. * The list of geometries used in the scene.
  108281. */
  108282. geometries: Geometry[];
  108283. /**
  108284. * All of the tranform nodes added to this scene
  108285. * In the context of a Scene, it is not supposed to be modified manually.
  108286. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  108287. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  108288. * @see http://doc.babylonjs.com/how_to/transformnode
  108289. */
  108290. transformNodes: TransformNode[];
  108291. /**
  108292. * ActionManagers available on the scene.
  108293. */
  108294. actionManagers: AbstractActionManager[];
  108295. /**
  108296. * Textures to keep.
  108297. */
  108298. textures: BaseTexture[];
  108299. /**
  108300. * Environment texture for the scene
  108301. */
  108302. environmentTexture: Nullable<BaseTexture>;
  108303. /**
  108304. * @returns all meshes, lights, cameras, transformNodes and bones
  108305. */
  108306. getNodes(): Array<Node>;
  108307. }
  108308. }
  108309. declare module BABYLON {
  108310. /**
  108311. * Interface used to define options for Sound class
  108312. */
  108313. export interface ISoundOptions {
  108314. /**
  108315. * Does the sound autoplay once loaded.
  108316. */
  108317. autoplay?: boolean;
  108318. /**
  108319. * Does the sound loop after it finishes playing once.
  108320. */
  108321. loop?: boolean;
  108322. /**
  108323. * Sound's volume
  108324. */
  108325. volume?: number;
  108326. /**
  108327. * Is it a spatial sound?
  108328. */
  108329. spatialSound?: boolean;
  108330. /**
  108331. * Maximum distance to hear that sound
  108332. */
  108333. maxDistance?: number;
  108334. /**
  108335. * Uses user defined attenuation function
  108336. */
  108337. useCustomAttenuation?: boolean;
  108338. /**
  108339. * Define the roll off factor of spatial sounds.
  108340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108341. */
  108342. rolloffFactor?: number;
  108343. /**
  108344. * Define the reference distance the sound should be heard perfectly.
  108345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108346. */
  108347. refDistance?: number;
  108348. /**
  108349. * Define the distance attenuation model the sound will follow.
  108350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108351. */
  108352. distanceModel?: string;
  108353. /**
  108354. * Defines the playback speed (1 by default)
  108355. */
  108356. playbackRate?: number;
  108357. /**
  108358. * Defines if the sound is from a streaming source
  108359. */
  108360. streaming?: boolean;
  108361. /**
  108362. * Defines an optional length (in seconds) inside the sound file
  108363. */
  108364. length?: number;
  108365. /**
  108366. * Defines an optional offset (in seconds) inside the sound file
  108367. */
  108368. offset?: number;
  108369. /**
  108370. * If true, URLs will not be required to state the audio file codec to use.
  108371. */
  108372. skipCodecCheck?: boolean;
  108373. }
  108374. /**
  108375. * Defines a sound that can be played in the application.
  108376. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  108377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108378. */
  108379. export class Sound {
  108380. /**
  108381. * The name of the sound in the scene.
  108382. */
  108383. name: string;
  108384. /**
  108385. * Does the sound autoplay once loaded.
  108386. */
  108387. autoplay: boolean;
  108388. /**
  108389. * Does the sound loop after it finishes playing once.
  108390. */
  108391. loop: boolean;
  108392. /**
  108393. * Does the sound use a custom attenuation curve to simulate the falloff
  108394. * happening when the source gets further away from the camera.
  108395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  108396. */
  108397. useCustomAttenuation: boolean;
  108398. /**
  108399. * The sound track id this sound belongs to.
  108400. */
  108401. soundTrackId: number;
  108402. /**
  108403. * Is this sound currently played.
  108404. */
  108405. isPlaying: boolean;
  108406. /**
  108407. * Is this sound currently paused.
  108408. */
  108409. isPaused: boolean;
  108410. /**
  108411. * Does this sound enables spatial sound.
  108412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108413. */
  108414. spatialSound: boolean;
  108415. /**
  108416. * Define the reference distance the sound should be heard perfectly.
  108417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108418. */
  108419. refDistance: number;
  108420. /**
  108421. * Define the roll off factor of spatial sounds.
  108422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108423. */
  108424. rolloffFactor: number;
  108425. /**
  108426. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  108427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108428. */
  108429. maxDistance: number;
  108430. /**
  108431. * Define the distance attenuation model the sound will follow.
  108432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108433. */
  108434. distanceModel: string;
  108435. /**
  108436. * @hidden
  108437. * Back Compat
  108438. **/
  108439. onended: () => any;
  108440. /**
  108441. * Observable event when the current playing sound finishes.
  108442. */
  108443. onEndedObservable: Observable<Sound>;
  108444. private _panningModel;
  108445. private _playbackRate;
  108446. private _streaming;
  108447. private _startTime;
  108448. private _startOffset;
  108449. private _position;
  108450. /** @hidden */
  108451. _positionInEmitterSpace: boolean;
  108452. private _localDirection;
  108453. private _volume;
  108454. private _isReadyToPlay;
  108455. private _isDirectional;
  108456. private _readyToPlayCallback;
  108457. private _audioBuffer;
  108458. private _soundSource;
  108459. private _streamingSource;
  108460. private _soundPanner;
  108461. private _soundGain;
  108462. private _inputAudioNode;
  108463. private _outputAudioNode;
  108464. private _coneInnerAngle;
  108465. private _coneOuterAngle;
  108466. private _coneOuterGain;
  108467. private _scene;
  108468. private _connectedTransformNode;
  108469. private _customAttenuationFunction;
  108470. private _registerFunc;
  108471. private _isOutputConnected;
  108472. private _htmlAudioElement;
  108473. private _urlType;
  108474. private _length?;
  108475. private _offset?;
  108476. /** @hidden */
  108477. static _SceneComponentInitialization: (scene: Scene) => void;
  108478. /**
  108479. * Create a sound and attach it to a scene
  108480. * @param name Name of your sound
  108481. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  108482. * @param scene defines the scene the sound belongs to
  108483. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  108484. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  108485. */
  108486. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  108487. /**
  108488. * Release the sound and its associated resources
  108489. */
  108490. dispose(): void;
  108491. /**
  108492. * Gets if the sounds is ready to be played or not.
  108493. * @returns true if ready, otherwise false
  108494. */
  108495. isReady(): boolean;
  108496. private _soundLoaded;
  108497. /**
  108498. * Sets the data of the sound from an audiobuffer
  108499. * @param audioBuffer The audioBuffer containing the data
  108500. */
  108501. setAudioBuffer(audioBuffer: AudioBuffer): void;
  108502. /**
  108503. * Updates the current sounds options such as maxdistance, loop...
  108504. * @param options A JSON object containing values named as the object properties
  108505. */
  108506. updateOptions(options: ISoundOptions): void;
  108507. private _createSpatialParameters;
  108508. private _updateSpatialParameters;
  108509. /**
  108510. * Switch the panning model to HRTF:
  108511. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108513. */
  108514. switchPanningModelToHRTF(): void;
  108515. /**
  108516. * Switch the panning model to Equal Power:
  108517. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108519. */
  108520. switchPanningModelToEqualPower(): void;
  108521. private _switchPanningModel;
  108522. /**
  108523. * Connect this sound to a sound track audio node like gain...
  108524. * @param soundTrackAudioNode the sound track audio node to connect to
  108525. */
  108526. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  108527. /**
  108528. * Transform this sound into a directional source
  108529. * @param coneInnerAngle Size of the inner cone in degree
  108530. * @param coneOuterAngle Size of the outer cone in degree
  108531. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  108532. */
  108533. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  108534. /**
  108535. * Gets or sets the inner angle for the directional cone.
  108536. */
  108537. get directionalConeInnerAngle(): number;
  108538. /**
  108539. * Gets or sets the inner angle for the directional cone.
  108540. */
  108541. set directionalConeInnerAngle(value: number);
  108542. /**
  108543. * Gets or sets the outer angle for the directional cone.
  108544. */
  108545. get directionalConeOuterAngle(): number;
  108546. /**
  108547. * Gets or sets the outer angle for the directional cone.
  108548. */
  108549. set directionalConeOuterAngle(value: number);
  108550. /**
  108551. * Sets the position of the emitter if spatial sound is enabled
  108552. * @param newPosition Defines the new posisiton
  108553. */
  108554. setPosition(newPosition: Vector3): void;
  108555. /**
  108556. * Sets the local direction of the emitter if spatial sound is enabled
  108557. * @param newLocalDirection Defines the new local direction
  108558. */
  108559. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  108560. private _updateDirection;
  108561. /** @hidden */
  108562. updateDistanceFromListener(): void;
  108563. /**
  108564. * Sets a new custom attenuation function for the sound.
  108565. * @param callback Defines the function used for the attenuation
  108566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  108567. */
  108568. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  108569. /**
  108570. * Play the sound
  108571. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  108572. * @param offset (optional) Start the sound at a specific time in seconds
  108573. * @param length (optional) Sound duration (in seconds)
  108574. */
  108575. play(time?: number, offset?: number, length?: number): void;
  108576. private _onended;
  108577. /**
  108578. * Stop the sound
  108579. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  108580. */
  108581. stop(time?: number): void;
  108582. /**
  108583. * Put the sound in pause
  108584. */
  108585. pause(): void;
  108586. /**
  108587. * Sets a dedicated volume for this sounds
  108588. * @param newVolume Define the new volume of the sound
  108589. * @param time Define time for gradual change to new volume
  108590. */
  108591. setVolume(newVolume: number, time?: number): void;
  108592. /**
  108593. * Set the sound play back rate
  108594. * @param newPlaybackRate Define the playback rate the sound should be played at
  108595. */
  108596. setPlaybackRate(newPlaybackRate: number): void;
  108597. /**
  108598. * Gets the volume of the sound.
  108599. * @returns the volume of the sound
  108600. */
  108601. getVolume(): number;
  108602. /**
  108603. * Attach the sound to a dedicated mesh
  108604. * @param transformNode The transform node to connect the sound with
  108605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  108606. */
  108607. attachToMesh(transformNode: TransformNode): void;
  108608. /**
  108609. * Detach the sound from the previously attached mesh
  108610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  108611. */
  108612. detachFromMesh(): void;
  108613. private _onRegisterAfterWorldMatrixUpdate;
  108614. /**
  108615. * Clone the current sound in the scene.
  108616. * @returns the new sound clone
  108617. */
  108618. clone(): Nullable<Sound>;
  108619. /**
  108620. * Gets the current underlying audio buffer containing the data
  108621. * @returns the audio buffer
  108622. */
  108623. getAudioBuffer(): Nullable<AudioBuffer>;
  108624. /**
  108625. * Serializes the Sound in a JSON representation
  108626. * @returns the JSON representation of the sound
  108627. */
  108628. serialize(): any;
  108629. /**
  108630. * Parse a JSON representation of a sound to innstantiate in a given scene
  108631. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  108632. * @param scene Define the scene the new parsed sound should be created in
  108633. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  108634. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  108635. * @returns the newly parsed sound
  108636. */
  108637. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  108638. }
  108639. }
  108640. declare module BABYLON {
  108641. /**
  108642. * This defines an action helpful to play a defined sound on a triggered action.
  108643. */
  108644. export class PlaySoundAction extends Action {
  108645. private _sound;
  108646. /**
  108647. * Instantiate the action
  108648. * @param triggerOptions defines the trigger options
  108649. * @param sound defines the sound to play
  108650. * @param condition defines the trigger related conditions
  108651. */
  108652. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  108653. /** @hidden */
  108654. _prepare(): void;
  108655. /**
  108656. * Execute the action and play the sound.
  108657. */
  108658. execute(): void;
  108659. /**
  108660. * Serializes the actions and its related information.
  108661. * @param parent defines the object to serialize in
  108662. * @returns the serialized object
  108663. */
  108664. serialize(parent: any): any;
  108665. }
  108666. /**
  108667. * This defines an action helpful to stop a defined sound on a triggered action.
  108668. */
  108669. export class StopSoundAction extends Action {
  108670. private _sound;
  108671. /**
  108672. * Instantiate the action
  108673. * @param triggerOptions defines the trigger options
  108674. * @param sound defines the sound to stop
  108675. * @param condition defines the trigger related conditions
  108676. */
  108677. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  108678. /** @hidden */
  108679. _prepare(): void;
  108680. /**
  108681. * Execute the action and stop the sound.
  108682. */
  108683. execute(): void;
  108684. /**
  108685. * Serializes the actions and its related information.
  108686. * @param parent defines the object to serialize in
  108687. * @returns the serialized object
  108688. */
  108689. serialize(parent: any): any;
  108690. }
  108691. }
  108692. declare module BABYLON {
  108693. /**
  108694. * This defines an action responsible to change the value of a property
  108695. * by interpolating between its current value and the newly set one once triggered.
  108696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108697. */
  108698. export class InterpolateValueAction extends Action {
  108699. /**
  108700. * Defines the path of the property where the value should be interpolated
  108701. */
  108702. propertyPath: string;
  108703. /**
  108704. * Defines the target value at the end of the interpolation.
  108705. */
  108706. value: any;
  108707. /**
  108708. * Defines the time it will take for the property to interpolate to the value.
  108709. */
  108710. duration: number;
  108711. /**
  108712. * Defines if the other scene animations should be stopped when the action has been triggered
  108713. */
  108714. stopOtherAnimations?: boolean;
  108715. /**
  108716. * Defines a callback raised once the interpolation animation has been done.
  108717. */
  108718. onInterpolationDone?: () => void;
  108719. /**
  108720. * Observable triggered once the interpolation animation has been done.
  108721. */
  108722. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  108723. private _target;
  108724. private _effectiveTarget;
  108725. private _property;
  108726. /**
  108727. * Instantiate the action
  108728. * @param triggerOptions defines the trigger options
  108729. * @param target defines the object containing the value to interpolate
  108730. * @param propertyPath defines the path to the property in the target object
  108731. * @param value defines the target value at the end of the interpolation
  108732. * @param duration deines the time it will take for the property to interpolate to the value.
  108733. * @param condition defines the trigger related conditions
  108734. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  108735. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  108736. */
  108737. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  108738. /** @hidden */
  108739. _prepare(): void;
  108740. /**
  108741. * Execute the action starts the value interpolation.
  108742. */
  108743. execute(): void;
  108744. /**
  108745. * Serializes the actions and its related information.
  108746. * @param parent defines the object to serialize in
  108747. * @returns the serialized object
  108748. */
  108749. serialize(parent: any): any;
  108750. }
  108751. }
  108752. declare module BABYLON {
  108753. /**
  108754. * Options allowed during the creation of a sound track.
  108755. */
  108756. export interface ISoundTrackOptions {
  108757. /**
  108758. * The volume the sound track should take during creation
  108759. */
  108760. volume?: number;
  108761. /**
  108762. * Define if the sound track is the main sound track of the scene
  108763. */
  108764. mainTrack?: boolean;
  108765. }
  108766. /**
  108767. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  108768. * It will be also used in a future release to apply effects on a specific track.
  108769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108770. */
  108771. export class SoundTrack {
  108772. /**
  108773. * The unique identifier of the sound track in the scene.
  108774. */
  108775. id: number;
  108776. /**
  108777. * The list of sounds included in the sound track.
  108778. */
  108779. soundCollection: Array<Sound>;
  108780. private _outputAudioNode;
  108781. private _scene;
  108782. private _connectedAnalyser;
  108783. private _options;
  108784. private _isInitialized;
  108785. /**
  108786. * Creates a new sound track.
  108787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108788. * @param scene Define the scene the sound track belongs to
  108789. * @param options
  108790. */
  108791. constructor(scene: Scene, options?: ISoundTrackOptions);
  108792. private _initializeSoundTrackAudioGraph;
  108793. /**
  108794. * Release the sound track and its associated resources
  108795. */
  108796. dispose(): void;
  108797. /**
  108798. * Adds a sound to this sound track
  108799. * @param sound define the cound to add
  108800. * @ignoreNaming
  108801. */
  108802. AddSound(sound: Sound): void;
  108803. /**
  108804. * Removes a sound to this sound track
  108805. * @param sound define the cound to remove
  108806. * @ignoreNaming
  108807. */
  108808. RemoveSound(sound: Sound): void;
  108809. /**
  108810. * Set a global volume for the full sound track.
  108811. * @param newVolume Define the new volume of the sound track
  108812. */
  108813. setVolume(newVolume: number): void;
  108814. /**
  108815. * Switch the panning model to HRTF:
  108816. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108818. */
  108819. switchPanningModelToHRTF(): void;
  108820. /**
  108821. * Switch the panning model to Equal Power:
  108822. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108824. */
  108825. switchPanningModelToEqualPower(): void;
  108826. /**
  108827. * Connect the sound track to an audio analyser allowing some amazing
  108828. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108830. * @param analyser The analyser to connect to the engine
  108831. */
  108832. connectToAnalyser(analyser: Analyser): void;
  108833. }
  108834. }
  108835. declare module BABYLON {
  108836. interface AbstractScene {
  108837. /**
  108838. * The list of sounds used in the scene.
  108839. */
  108840. sounds: Nullable<Array<Sound>>;
  108841. }
  108842. interface Scene {
  108843. /**
  108844. * @hidden
  108845. * Backing field
  108846. */
  108847. _mainSoundTrack: SoundTrack;
  108848. /**
  108849. * The main sound track played by the scene.
  108850. * It cotains your primary collection of sounds.
  108851. */
  108852. mainSoundTrack: SoundTrack;
  108853. /**
  108854. * The list of sound tracks added to the scene
  108855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108856. */
  108857. soundTracks: Nullable<Array<SoundTrack>>;
  108858. /**
  108859. * Gets a sound using a given name
  108860. * @param name defines the name to search for
  108861. * @return the found sound or null if not found at all.
  108862. */
  108863. getSoundByName(name: string): Nullable<Sound>;
  108864. /**
  108865. * Gets or sets if audio support is enabled
  108866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108867. */
  108868. audioEnabled: boolean;
  108869. /**
  108870. * Gets or sets if audio will be output to headphones
  108871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108872. */
  108873. headphone: boolean;
  108874. /**
  108875. * Gets or sets custom audio listener position provider
  108876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108877. */
  108878. audioListenerPositionProvider: Nullable<() => Vector3>;
  108879. /**
  108880. * Gets or sets a refresh rate when using 3D audio positioning
  108881. */
  108882. audioPositioningRefreshRate: number;
  108883. }
  108884. /**
  108885. * Defines the sound scene component responsible to manage any sounds
  108886. * in a given scene.
  108887. */
  108888. export class AudioSceneComponent implements ISceneSerializableComponent {
  108889. /**
  108890. * The component name helpfull to identify the component in the list of scene components.
  108891. */
  108892. readonly name: string;
  108893. /**
  108894. * The scene the component belongs to.
  108895. */
  108896. scene: Scene;
  108897. private _audioEnabled;
  108898. /**
  108899. * Gets whether audio is enabled or not.
  108900. * Please use related enable/disable method to switch state.
  108901. */
  108902. get audioEnabled(): boolean;
  108903. private _headphone;
  108904. /**
  108905. * Gets whether audio is outputing to headphone or not.
  108906. * Please use the according Switch methods to change output.
  108907. */
  108908. get headphone(): boolean;
  108909. /**
  108910. * Gets or sets a refresh rate when using 3D audio positioning
  108911. */
  108912. audioPositioningRefreshRate: number;
  108913. private _audioListenerPositionProvider;
  108914. /**
  108915. * Gets the current audio listener position provider
  108916. */
  108917. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108918. /**
  108919. * Sets a custom listener position for all sounds in the scene
  108920. * By default, this is the position of the first active camera
  108921. */
  108922. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108923. /**
  108924. * Creates a new instance of the component for the given scene
  108925. * @param scene Defines the scene to register the component in
  108926. */
  108927. constructor(scene: Scene);
  108928. /**
  108929. * Registers the component in a given scene
  108930. */
  108931. register(): void;
  108932. /**
  108933. * Rebuilds the elements related to this component in case of
  108934. * context lost for instance.
  108935. */
  108936. rebuild(): void;
  108937. /**
  108938. * Serializes the component data to the specified json object
  108939. * @param serializationObject The object to serialize to
  108940. */
  108941. serialize(serializationObject: any): void;
  108942. /**
  108943. * Adds all the elements from the container to the scene
  108944. * @param container the container holding the elements
  108945. */
  108946. addFromContainer(container: AbstractScene): void;
  108947. /**
  108948. * Removes all the elements in the container from the scene
  108949. * @param container contains the elements to remove
  108950. * @param dispose if the removed element should be disposed (default: false)
  108951. */
  108952. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108953. /**
  108954. * Disposes the component and the associated ressources.
  108955. */
  108956. dispose(): void;
  108957. /**
  108958. * Disables audio in the associated scene.
  108959. */
  108960. disableAudio(): void;
  108961. /**
  108962. * Enables audio in the associated scene.
  108963. */
  108964. enableAudio(): void;
  108965. /**
  108966. * Switch audio to headphone output.
  108967. */
  108968. switchAudioModeForHeadphones(): void;
  108969. /**
  108970. * Switch audio to normal speakers.
  108971. */
  108972. switchAudioModeForNormalSpeakers(): void;
  108973. private _cachedCameraDirection;
  108974. private _cachedCameraPosition;
  108975. private _lastCheck;
  108976. private _afterRender;
  108977. }
  108978. }
  108979. declare module BABYLON {
  108980. /**
  108981. * Wraps one or more Sound objects and selects one with random weight for playback.
  108982. */
  108983. export class WeightedSound {
  108984. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108985. loop: boolean;
  108986. private _coneInnerAngle;
  108987. private _coneOuterAngle;
  108988. private _volume;
  108989. /** A Sound is currently playing. */
  108990. isPlaying: boolean;
  108991. /** A Sound is currently paused. */
  108992. isPaused: boolean;
  108993. private _sounds;
  108994. private _weights;
  108995. private _currentIndex?;
  108996. /**
  108997. * Creates a new WeightedSound from the list of sounds given.
  108998. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  108999. * @param sounds Array of Sounds that will be selected from.
  109000. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  109001. */
  109002. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  109003. /**
  109004. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  109005. */
  109006. get directionalConeInnerAngle(): number;
  109007. /**
  109008. * The size of cone in degress for a directional sound in which there will be no attenuation.
  109009. */
  109010. set directionalConeInnerAngle(value: number);
  109011. /**
  109012. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  109013. * Listener angles between innerAngle and outerAngle will falloff linearly.
  109014. */
  109015. get directionalConeOuterAngle(): number;
  109016. /**
  109017. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  109018. * Listener angles between innerAngle and outerAngle will falloff linearly.
  109019. */
  109020. set directionalConeOuterAngle(value: number);
  109021. /**
  109022. * Playback volume.
  109023. */
  109024. get volume(): number;
  109025. /**
  109026. * Playback volume.
  109027. */
  109028. set volume(value: number);
  109029. private _onended;
  109030. /**
  109031. * Suspend playback
  109032. */
  109033. pause(): void;
  109034. /**
  109035. * Stop playback
  109036. */
  109037. stop(): void;
  109038. /**
  109039. * Start playback.
  109040. * @param startOffset Position the clip head at a specific time in seconds.
  109041. */
  109042. play(startOffset?: number): void;
  109043. }
  109044. }
  109045. declare module BABYLON {
  109046. /**
  109047. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  109048. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109049. */
  109050. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  109051. /**
  109052. * Gets the name of the behavior.
  109053. */
  109054. get name(): string;
  109055. /**
  109056. * The easing function used by animations
  109057. */
  109058. static EasingFunction: BackEase;
  109059. /**
  109060. * The easing mode used by animations
  109061. */
  109062. static EasingMode: number;
  109063. /**
  109064. * The duration of the animation, in milliseconds
  109065. */
  109066. transitionDuration: number;
  109067. /**
  109068. * Length of the distance animated by the transition when lower radius is reached
  109069. */
  109070. lowerRadiusTransitionRange: number;
  109071. /**
  109072. * Length of the distance animated by the transition when upper radius is reached
  109073. */
  109074. upperRadiusTransitionRange: number;
  109075. private _autoTransitionRange;
  109076. /**
  109077. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  109078. */
  109079. get autoTransitionRange(): boolean;
  109080. /**
  109081. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  109082. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  109083. */
  109084. set autoTransitionRange(value: boolean);
  109085. private _attachedCamera;
  109086. private _onAfterCheckInputsObserver;
  109087. private _onMeshTargetChangedObserver;
  109088. /**
  109089. * Initializes the behavior.
  109090. */
  109091. init(): void;
  109092. /**
  109093. * Attaches the behavior to its arc rotate camera.
  109094. * @param camera Defines the camera to attach the behavior to
  109095. */
  109096. attach(camera: ArcRotateCamera): void;
  109097. /**
  109098. * Detaches the behavior from its current arc rotate camera.
  109099. */
  109100. detach(): void;
  109101. private _radiusIsAnimating;
  109102. private _radiusBounceTransition;
  109103. private _animatables;
  109104. private _cachedWheelPrecision;
  109105. /**
  109106. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  109107. * @param radiusLimit The limit to check against.
  109108. * @return Bool to indicate if at limit.
  109109. */
  109110. private _isRadiusAtLimit;
  109111. /**
  109112. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  109113. * @param radiusDelta The delta by which to animate to. Can be negative.
  109114. */
  109115. private _applyBoundRadiusAnimation;
  109116. /**
  109117. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  109118. */
  109119. protected _clearAnimationLocks(): void;
  109120. /**
  109121. * Stops and removes all animations that have been applied to the camera
  109122. */
  109123. stopAllAnimations(): void;
  109124. }
  109125. }
  109126. declare module BABYLON {
  109127. /**
  109128. * 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.
  109129. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109130. */
  109131. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  109132. /**
  109133. * Gets the name of the behavior.
  109134. */
  109135. get name(): string;
  109136. private _mode;
  109137. private _radiusScale;
  109138. private _positionScale;
  109139. private _defaultElevation;
  109140. private _elevationReturnTime;
  109141. private _elevationReturnWaitTime;
  109142. private _zoomStopsAnimation;
  109143. private _framingTime;
  109144. /**
  109145. * The easing function used by animations
  109146. */
  109147. static EasingFunction: ExponentialEase;
  109148. /**
  109149. * The easing mode used by animations
  109150. */
  109151. static EasingMode: number;
  109152. /**
  109153. * Sets the current mode used by the behavior
  109154. */
  109155. set mode(mode: number);
  109156. /**
  109157. * Gets current mode used by the behavior.
  109158. */
  109159. get mode(): number;
  109160. /**
  109161. * Sets the scale applied to the radius (1 by default)
  109162. */
  109163. set radiusScale(radius: number);
  109164. /**
  109165. * Gets the scale applied to the radius
  109166. */
  109167. get radiusScale(): number;
  109168. /**
  109169. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  109170. */
  109171. set positionScale(scale: number);
  109172. /**
  109173. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  109174. */
  109175. get positionScale(): number;
  109176. /**
  109177. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  109178. * behaviour is triggered, in radians.
  109179. */
  109180. set defaultElevation(elevation: number);
  109181. /**
  109182. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  109183. * behaviour is triggered, in radians.
  109184. */
  109185. get defaultElevation(): number;
  109186. /**
  109187. * Sets the time (in milliseconds) taken to return to the default beta position.
  109188. * Negative value indicates camera should not return to default.
  109189. */
  109190. set elevationReturnTime(speed: number);
  109191. /**
  109192. * Gets the time (in milliseconds) taken to return to the default beta position.
  109193. * Negative value indicates camera should not return to default.
  109194. */
  109195. get elevationReturnTime(): number;
  109196. /**
  109197. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  109198. */
  109199. set elevationReturnWaitTime(time: number);
  109200. /**
  109201. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  109202. */
  109203. get elevationReturnWaitTime(): number;
  109204. /**
  109205. * Sets the flag that indicates if user zooming should stop animation.
  109206. */
  109207. set zoomStopsAnimation(flag: boolean);
  109208. /**
  109209. * Gets the flag that indicates if user zooming should stop animation.
  109210. */
  109211. get zoomStopsAnimation(): boolean;
  109212. /**
  109213. * Sets the transition time when framing the mesh, in milliseconds
  109214. */
  109215. set framingTime(time: number);
  109216. /**
  109217. * Gets the transition time when framing the mesh, in milliseconds
  109218. */
  109219. get framingTime(): number;
  109220. /**
  109221. * Define if the behavior should automatically change the configured
  109222. * camera limits and sensibilities.
  109223. */
  109224. autoCorrectCameraLimitsAndSensibility: boolean;
  109225. private _onPrePointerObservableObserver;
  109226. private _onAfterCheckInputsObserver;
  109227. private _onMeshTargetChangedObserver;
  109228. private _attachedCamera;
  109229. private _isPointerDown;
  109230. private _lastInteractionTime;
  109231. /**
  109232. * Initializes the behavior.
  109233. */
  109234. init(): void;
  109235. /**
  109236. * Attaches the behavior to its arc rotate camera.
  109237. * @param camera Defines the camera to attach the behavior to
  109238. */
  109239. attach(camera: ArcRotateCamera): void;
  109240. /**
  109241. * Detaches the behavior from its current arc rotate camera.
  109242. */
  109243. detach(): void;
  109244. private _animatables;
  109245. private _betaIsAnimating;
  109246. private _betaTransition;
  109247. private _radiusTransition;
  109248. private _vectorTransition;
  109249. /**
  109250. * Targets the given mesh and updates zoom level accordingly.
  109251. * @param mesh The mesh to target.
  109252. * @param radius Optional. If a cached radius position already exists, overrides default.
  109253. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  109254. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109255. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109256. */
  109257. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109258. /**
  109259. * Targets the given mesh with its children and updates zoom level accordingly.
  109260. * @param mesh The mesh to target.
  109261. * @param radius Optional. If a cached radius position already exists, overrides default.
  109262. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  109263. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109264. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109265. */
  109266. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109267. /**
  109268. * Targets the given meshes with their children and updates zoom level accordingly.
  109269. * @param meshes The mesh to target.
  109270. * @param radius Optional. If a cached radius position already exists, overrides default.
  109271. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  109272. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109273. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109274. */
  109275. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109276. /**
  109277. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  109278. * @param minimumWorld Determines the smaller position of the bounding box extend
  109279. * @param maximumWorld Determines the bigger position of the bounding box extend
  109280. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109281. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109282. */
  109283. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109284. /**
  109285. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  109286. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  109287. * frustum width.
  109288. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  109289. * to fully enclose the mesh in the viewing frustum.
  109290. */
  109291. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  109292. /**
  109293. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  109294. * is automatically returned to its default position (expected to be above ground plane).
  109295. */
  109296. private _maintainCameraAboveGround;
  109297. /**
  109298. * Returns the frustum slope based on the canvas ratio and camera FOV
  109299. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  109300. */
  109301. private _getFrustumSlope;
  109302. /**
  109303. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  109304. */
  109305. private _clearAnimationLocks;
  109306. /**
  109307. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109308. */
  109309. private _applyUserInteraction;
  109310. /**
  109311. * Stops and removes all animations that have been applied to the camera
  109312. */
  109313. stopAllAnimations(): void;
  109314. /**
  109315. * Gets a value indicating if the user is moving the camera
  109316. */
  109317. get isUserIsMoving(): boolean;
  109318. /**
  109319. * The camera can move all the way towards the mesh.
  109320. */
  109321. static IgnoreBoundsSizeMode: number;
  109322. /**
  109323. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  109324. */
  109325. static FitFrustumSidesMode: number;
  109326. }
  109327. }
  109328. declare module BABYLON {
  109329. /**
  109330. * Base class for Camera Pointer Inputs.
  109331. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  109332. * for example usage.
  109333. */
  109334. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  109335. /**
  109336. * Defines the camera the input is attached to.
  109337. */
  109338. abstract camera: Camera;
  109339. /**
  109340. * Whether keyboard modifier keys are pressed at time of last mouse event.
  109341. */
  109342. protected _altKey: boolean;
  109343. protected _ctrlKey: boolean;
  109344. protected _metaKey: boolean;
  109345. protected _shiftKey: boolean;
  109346. /**
  109347. * Which mouse buttons were pressed at time of last mouse event.
  109348. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  109349. */
  109350. protected _buttonsPressed: number;
  109351. /**
  109352. * Defines the buttons associated with the input to handle camera move.
  109353. */
  109354. buttons: number[];
  109355. /**
  109356. * Attach the input controls to a specific dom element to get the input from.
  109357. * @param element Defines the element the controls should be listened from
  109358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109359. */
  109360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109361. /**
  109362. * Detach the current controls from the specified dom element.
  109363. * @param element Defines the element to stop listening the inputs from
  109364. */
  109365. detachControl(element: Nullable<HTMLElement>): void;
  109366. /**
  109367. * Gets the class name of the current input.
  109368. * @returns the class name
  109369. */
  109370. getClassName(): string;
  109371. /**
  109372. * Get the friendly name associated with the input class.
  109373. * @returns the input friendly name
  109374. */
  109375. getSimpleName(): string;
  109376. /**
  109377. * Called on pointer POINTERDOUBLETAP event.
  109378. * Override this method to provide functionality on POINTERDOUBLETAP event.
  109379. */
  109380. protected onDoubleTap(type: string): void;
  109381. /**
  109382. * Called on pointer POINTERMOVE event if only a single touch is active.
  109383. * Override this method to provide functionality.
  109384. */
  109385. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  109386. /**
  109387. * Called on pointer POINTERMOVE event if multiple touches are active.
  109388. * Override this method to provide functionality.
  109389. */
  109390. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  109391. /**
  109392. * Called on JS contextmenu event.
  109393. * Override this method to provide functionality.
  109394. */
  109395. protected onContextMenu(evt: PointerEvent): void;
  109396. /**
  109397. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  109398. * press.
  109399. * Override this method to provide functionality.
  109400. */
  109401. protected onButtonDown(evt: PointerEvent): void;
  109402. /**
  109403. * Called each time a new POINTERUP event occurs. Ie, for each button
  109404. * release.
  109405. * Override this method to provide functionality.
  109406. */
  109407. protected onButtonUp(evt: PointerEvent): void;
  109408. /**
  109409. * Called when window becomes inactive.
  109410. * Override this method to provide functionality.
  109411. */
  109412. protected onLostFocus(): void;
  109413. private _pointerInput;
  109414. private _observer;
  109415. private _onLostFocus;
  109416. private pointA;
  109417. private pointB;
  109418. }
  109419. }
  109420. declare module BABYLON {
  109421. /**
  109422. * Manage the pointers inputs to control an arc rotate camera.
  109423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109424. */
  109425. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  109426. /**
  109427. * Defines the camera the input is attached to.
  109428. */
  109429. camera: ArcRotateCamera;
  109430. /**
  109431. * Gets the class name of the current input.
  109432. * @returns the class name
  109433. */
  109434. getClassName(): string;
  109435. /**
  109436. * Defines the buttons associated with the input to handle camera move.
  109437. */
  109438. buttons: number[];
  109439. /**
  109440. * Defines the pointer angular sensibility along the X axis or how fast is
  109441. * the camera rotating.
  109442. */
  109443. angularSensibilityX: number;
  109444. /**
  109445. * Defines the pointer angular sensibility along the Y axis or how fast is
  109446. * the camera rotating.
  109447. */
  109448. angularSensibilityY: number;
  109449. /**
  109450. * Defines the pointer pinch precision or how fast is the camera zooming.
  109451. */
  109452. pinchPrecision: number;
  109453. /**
  109454. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  109455. * from 0.
  109456. * It defines the percentage of current camera.radius to use as delta when
  109457. * pinch zoom is used.
  109458. */
  109459. pinchDeltaPercentage: number;
  109460. /**
  109461. * Defines the pointer panning sensibility or how fast is the camera moving.
  109462. */
  109463. panningSensibility: number;
  109464. /**
  109465. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  109466. */
  109467. multiTouchPanning: boolean;
  109468. /**
  109469. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  109470. * zoom (pinch) through multitouch.
  109471. */
  109472. multiTouchPanAndZoom: boolean;
  109473. /**
  109474. * Revers pinch action direction.
  109475. */
  109476. pinchInwards: boolean;
  109477. private _isPanClick;
  109478. private _twoFingerActivityCount;
  109479. private _isPinching;
  109480. /**
  109481. * Called on pointer POINTERMOVE event if only a single touch is active.
  109482. */
  109483. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  109484. /**
  109485. * Called on pointer POINTERDOUBLETAP event.
  109486. */
  109487. protected onDoubleTap(type: string): void;
  109488. /**
  109489. * Called on pointer POINTERMOVE event if multiple touches are active.
  109490. */
  109491. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  109492. /**
  109493. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  109494. * press.
  109495. */
  109496. protected onButtonDown(evt: PointerEvent): void;
  109497. /**
  109498. * Called each time a new POINTERUP event occurs. Ie, for each button
  109499. * release.
  109500. */
  109501. protected onButtonUp(evt: PointerEvent): void;
  109502. /**
  109503. * Called when window becomes inactive.
  109504. */
  109505. protected onLostFocus(): void;
  109506. }
  109507. }
  109508. declare module BABYLON {
  109509. /**
  109510. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  109511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109512. */
  109513. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  109514. /**
  109515. * Defines the camera the input is attached to.
  109516. */
  109517. camera: ArcRotateCamera;
  109518. /**
  109519. * Defines the list of key codes associated with the up action (increase alpha)
  109520. */
  109521. keysUp: number[];
  109522. /**
  109523. * Defines the list of key codes associated with the down action (decrease alpha)
  109524. */
  109525. keysDown: number[];
  109526. /**
  109527. * Defines the list of key codes associated with the left action (increase beta)
  109528. */
  109529. keysLeft: number[];
  109530. /**
  109531. * Defines the list of key codes associated with the right action (decrease beta)
  109532. */
  109533. keysRight: number[];
  109534. /**
  109535. * Defines the list of key codes associated with the reset action.
  109536. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  109537. */
  109538. keysReset: number[];
  109539. /**
  109540. * Defines the panning sensibility of the inputs.
  109541. * (How fast is the camera paning)
  109542. */
  109543. panningSensibility: number;
  109544. /**
  109545. * Defines the zooming sensibility of the inputs.
  109546. * (How fast is the camera zooming)
  109547. */
  109548. zoomingSensibility: number;
  109549. /**
  109550. * Defines wether maintaining the alt key down switch the movement mode from
  109551. * orientation to zoom.
  109552. */
  109553. useAltToZoom: boolean;
  109554. /**
  109555. * Rotation speed of the camera
  109556. */
  109557. angularSpeed: number;
  109558. private _keys;
  109559. private _ctrlPressed;
  109560. private _altPressed;
  109561. private _onCanvasBlurObserver;
  109562. private _onKeyboardObserver;
  109563. private _engine;
  109564. private _scene;
  109565. /**
  109566. * Attach the input controls to a specific dom element to get the input from.
  109567. * @param element Defines the element the controls should be listened from
  109568. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109569. */
  109570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109571. /**
  109572. * Detach the current controls from the specified dom element.
  109573. * @param element Defines the element to stop listening the inputs from
  109574. */
  109575. detachControl(element: Nullable<HTMLElement>): void;
  109576. /**
  109577. * Update the current camera state depending on the inputs that have been used this frame.
  109578. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109579. */
  109580. checkInputs(): void;
  109581. /**
  109582. * Gets the class name of the current intput.
  109583. * @returns the class name
  109584. */
  109585. getClassName(): string;
  109586. /**
  109587. * Get the friendly name associated with the input class.
  109588. * @returns the input friendly name
  109589. */
  109590. getSimpleName(): string;
  109591. }
  109592. }
  109593. declare module BABYLON {
  109594. /**
  109595. * Manage the mouse wheel inputs to control an arc rotate camera.
  109596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109597. */
  109598. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  109599. /**
  109600. * Defines the camera the input is attached to.
  109601. */
  109602. camera: ArcRotateCamera;
  109603. /**
  109604. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109605. */
  109606. wheelPrecision: number;
  109607. /**
  109608. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  109609. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  109610. */
  109611. wheelDeltaPercentage: number;
  109612. private _wheel;
  109613. private _observer;
  109614. private computeDeltaFromMouseWheelLegacyEvent;
  109615. /**
  109616. * Attach the input controls to a specific dom element to get the input from.
  109617. * @param element Defines the element the controls should be listened from
  109618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109619. */
  109620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109621. /**
  109622. * Detach the current controls from the specified dom element.
  109623. * @param element Defines the element to stop listening the inputs from
  109624. */
  109625. detachControl(element: Nullable<HTMLElement>): void;
  109626. /**
  109627. * Gets the class name of the current intput.
  109628. * @returns the class name
  109629. */
  109630. getClassName(): string;
  109631. /**
  109632. * Get the friendly name associated with the input class.
  109633. * @returns the input friendly name
  109634. */
  109635. getSimpleName(): string;
  109636. }
  109637. }
  109638. declare module BABYLON {
  109639. /**
  109640. * Default Inputs manager for the ArcRotateCamera.
  109641. * It groups all the default supported inputs for ease of use.
  109642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109643. */
  109644. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  109645. /**
  109646. * Instantiates a new ArcRotateCameraInputsManager.
  109647. * @param camera Defines the camera the inputs belong to
  109648. */
  109649. constructor(camera: ArcRotateCamera);
  109650. /**
  109651. * Add mouse wheel input support to the input manager.
  109652. * @returns the current input manager
  109653. */
  109654. addMouseWheel(): ArcRotateCameraInputsManager;
  109655. /**
  109656. * Add pointers input support to the input manager.
  109657. * @returns the current input manager
  109658. */
  109659. addPointers(): ArcRotateCameraInputsManager;
  109660. /**
  109661. * Add keyboard input support to the input manager.
  109662. * @returns the current input manager
  109663. */
  109664. addKeyboard(): ArcRotateCameraInputsManager;
  109665. }
  109666. }
  109667. declare module BABYLON {
  109668. /**
  109669. * This represents an orbital type of camera.
  109670. *
  109671. * 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.
  109672. * 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.
  109673. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  109674. */
  109675. export class ArcRotateCamera extends TargetCamera {
  109676. /**
  109677. * Defines the rotation angle of the camera along the longitudinal axis.
  109678. */
  109679. alpha: number;
  109680. /**
  109681. * Defines the rotation angle of the camera along the latitudinal axis.
  109682. */
  109683. beta: number;
  109684. /**
  109685. * Defines the radius of the camera from it s target point.
  109686. */
  109687. radius: number;
  109688. protected _target: Vector3;
  109689. protected _targetHost: Nullable<AbstractMesh>;
  109690. /**
  109691. * Defines the target point of the camera.
  109692. * The camera looks towards it form the radius distance.
  109693. */
  109694. get target(): Vector3;
  109695. set target(value: Vector3);
  109696. /**
  109697. * Define the current local position of the camera in the scene
  109698. */
  109699. get position(): Vector3;
  109700. set position(newPosition: Vector3);
  109701. protected _upVector: Vector3;
  109702. protected _upToYMatrix: Matrix;
  109703. protected _YToUpMatrix: Matrix;
  109704. /**
  109705. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  109706. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  109707. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  109708. */
  109709. set upVector(vec: Vector3);
  109710. get upVector(): Vector3;
  109711. /**
  109712. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  109713. */
  109714. setMatUp(): void;
  109715. /**
  109716. * Current inertia value on the longitudinal axis.
  109717. * The bigger this number the longer it will take for the camera to stop.
  109718. */
  109719. inertialAlphaOffset: number;
  109720. /**
  109721. * Current inertia value on the latitudinal axis.
  109722. * The bigger this number the longer it will take for the camera to stop.
  109723. */
  109724. inertialBetaOffset: number;
  109725. /**
  109726. * Current inertia value on the radius axis.
  109727. * The bigger this number the longer it will take for the camera to stop.
  109728. */
  109729. inertialRadiusOffset: number;
  109730. /**
  109731. * Minimum allowed angle on the longitudinal axis.
  109732. * This can help limiting how the Camera is able to move in the scene.
  109733. */
  109734. lowerAlphaLimit: Nullable<number>;
  109735. /**
  109736. * Maximum allowed angle on the longitudinal axis.
  109737. * This can help limiting how the Camera is able to move in the scene.
  109738. */
  109739. upperAlphaLimit: Nullable<number>;
  109740. /**
  109741. * Minimum allowed angle on the latitudinal axis.
  109742. * This can help limiting how the Camera is able to move in the scene.
  109743. */
  109744. lowerBetaLimit: number;
  109745. /**
  109746. * Maximum allowed angle on the latitudinal axis.
  109747. * This can help limiting how the Camera is able to move in the scene.
  109748. */
  109749. upperBetaLimit: number;
  109750. /**
  109751. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  109752. * This can help limiting how the Camera is able to move in the scene.
  109753. */
  109754. lowerRadiusLimit: Nullable<number>;
  109755. /**
  109756. * Maximum allowed distance of the camera to the target (The camera can not get further).
  109757. * This can help limiting how the Camera is able to move in the scene.
  109758. */
  109759. upperRadiusLimit: Nullable<number>;
  109760. /**
  109761. * Defines the current inertia value used during panning of the camera along the X axis.
  109762. */
  109763. inertialPanningX: number;
  109764. /**
  109765. * Defines the current inertia value used during panning of the camera along the Y axis.
  109766. */
  109767. inertialPanningY: number;
  109768. /**
  109769. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  109770. * Basically if your fingers moves away from more than this distance you will be considered
  109771. * in pinch mode.
  109772. */
  109773. pinchToPanMaxDistance: number;
  109774. /**
  109775. * Defines the maximum distance the camera can pan.
  109776. * This could help keeping the cammera always in your scene.
  109777. */
  109778. panningDistanceLimit: Nullable<number>;
  109779. /**
  109780. * Defines the target of the camera before paning.
  109781. */
  109782. panningOriginTarget: Vector3;
  109783. /**
  109784. * Defines the value of the inertia used during panning.
  109785. * 0 would mean stop inertia and one would mean no decelleration at all.
  109786. */
  109787. panningInertia: number;
  109788. /**
  109789. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  109790. */
  109791. get angularSensibilityX(): number;
  109792. set angularSensibilityX(value: number);
  109793. /**
  109794. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  109795. */
  109796. get angularSensibilityY(): number;
  109797. set angularSensibilityY(value: number);
  109798. /**
  109799. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  109800. */
  109801. get pinchPrecision(): number;
  109802. set pinchPrecision(value: number);
  109803. /**
  109804. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  109805. * It will be used instead of pinchDeltaPrecision if different from 0.
  109806. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109807. */
  109808. get pinchDeltaPercentage(): number;
  109809. set pinchDeltaPercentage(value: number);
  109810. /**
  109811. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  109812. */
  109813. get panningSensibility(): number;
  109814. set panningSensibility(value: number);
  109815. /**
  109816. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  109817. */
  109818. get keysUp(): number[];
  109819. set keysUp(value: number[]);
  109820. /**
  109821. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  109822. */
  109823. get keysDown(): number[];
  109824. set keysDown(value: number[]);
  109825. /**
  109826. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  109827. */
  109828. get keysLeft(): number[];
  109829. set keysLeft(value: number[]);
  109830. /**
  109831. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  109832. */
  109833. get keysRight(): number[];
  109834. set keysRight(value: number[]);
  109835. /**
  109836. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109837. */
  109838. get wheelPrecision(): number;
  109839. set wheelPrecision(value: number);
  109840. /**
  109841. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  109842. * It will be used instead of pinchDeltaPrecision if different from 0.
  109843. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109844. */
  109845. get wheelDeltaPercentage(): number;
  109846. set wheelDeltaPercentage(value: number);
  109847. /**
  109848. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  109849. */
  109850. zoomOnFactor: number;
  109851. /**
  109852. * Defines a screen offset for the camera position.
  109853. */
  109854. targetScreenOffset: Vector2;
  109855. /**
  109856. * Allows the camera to be completely reversed.
  109857. * If false the camera can not arrive upside down.
  109858. */
  109859. allowUpsideDown: boolean;
  109860. /**
  109861. * Define if double tap/click is used to restore the previously saved state of the camera.
  109862. */
  109863. useInputToRestoreState: boolean;
  109864. /** @hidden */
  109865. _viewMatrix: Matrix;
  109866. /** @hidden */
  109867. _useCtrlForPanning: boolean;
  109868. /** @hidden */
  109869. _panningMouseButton: number;
  109870. /**
  109871. * Defines the input associated to the camera.
  109872. */
  109873. inputs: ArcRotateCameraInputsManager;
  109874. /** @hidden */
  109875. _reset: () => void;
  109876. /**
  109877. * Defines the allowed panning axis.
  109878. */
  109879. panningAxis: Vector3;
  109880. protected _localDirection: Vector3;
  109881. protected _transformedDirection: Vector3;
  109882. private _bouncingBehavior;
  109883. /**
  109884. * Gets the bouncing behavior of the camera if it has been enabled.
  109885. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109886. */
  109887. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109888. /**
  109889. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109890. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109891. */
  109892. get useBouncingBehavior(): boolean;
  109893. set useBouncingBehavior(value: boolean);
  109894. private _framingBehavior;
  109895. /**
  109896. * Gets the framing behavior of the camera if it has been enabled.
  109897. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109898. */
  109899. get framingBehavior(): Nullable<FramingBehavior>;
  109900. /**
  109901. * Defines if the framing behavior of the camera is enabled on the camera.
  109902. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109903. */
  109904. get useFramingBehavior(): boolean;
  109905. set useFramingBehavior(value: boolean);
  109906. private _autoRotationBehavior;
  109907. /**
  109908. * Gets the auto rotation behavior of the camera if it has been enabled.
  109909. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109910. */
  109911. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109912. /**
  109913. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109914. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109915. */
  109916. get useAutoRotationBehavior(): boolean;
  109917. set useAutoRotationBehavior(value: boolean);
  109918. /**
  109919. * Observable triggered when the mesh target has been changed on the camera.
  109920. */
  109921. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109922. /**
  109923. * Event raised when the camera is colliding with a mesh.
  109924. */
  109925. onCollide: (collidedMesh: AbstractMesh) => void;
  109926. /**
  109927. * Defines whether the camera should check collision with the objects oh the scene.
  109928. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109929. */
  109930. checkCollisions: boolean;
  109931. /**
  109932. * Defines the collision radius of the camera.
  109933. * This simulates a sphere around the camera.
  109934. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109935. */
  109936. collisionRadius: Vector3;
  109937. protected _collider: Collider;
  109938. protected _previousPosition: Vector3;
  109939. protected _collisionVelocity: Vector3;
  109940. protected _newPosition: Vector3;
  109941. protected _previousAlpha: number;
  109942. protected _previousBeta: number;
  109943. protected _previousRadius: number;
  109944. protected _collisionTriggered: boolean;
  109945. protected _targetBoundingCenter: Nullable<Vector3>;
  109946. private _computationVector;
  109947. /**
  109948. * Instantiates a new ArcRotateCamera in a given scene
  109949. * @param name Defines the name of the camera
  109950. * @param alpha Defines the camera rotation along the logitudinal axis
  109951. * @param beta Defines the camera rotation along the latitudinal axis
  109952. * @param radius Defines the camera distance from its target
  109953. * @param target Defines the camera target
  109954. * @param scene Defines the scene the camera belongs to
  109955. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109956. */
  109957. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109958. /** @hidden */
  109959. _initCache(): void;
  109960. /** @hidden */
  109961. _updateCache(ignoreParentClass?: boolean): void;
  109962. protected _getTargetPosition(): Vector3;
  109963. private _storedAlpha;
  109964. private _storedBeta;
  109965. private _storedRadius;
  109966. private _storedTarget;
  109967. private _storedTargetScreenOffset;
  109968. /**
  109969. * Stores the current state of the camera (alpha, beta, radius and target)
  109970. * @returns the camera itself
  109971. */
  109972. storeState(): Camera;
  109973. /**
  109974. * @hidden
  109975. * Restored camera state. You must call storeState() first
  109976. */
  109977. _restoreStateValues(): boolean;
  109978. /** @hidden */
  109979. _isSynchronizedViewMatrix(): boolean;
  109980. /**
  109981. * Attached controls to the current camera.
  109982. * @param element Defines the element the controls should be listened from
  109983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109984. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109985. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109986. */
  109987. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  109988. /**
  109989. * Detach the current controls from the camera.
  109990. * The camera will stop reacting to inputs.
  109991. * @param element Defines the element to stop listening the inputs from
  109992. */
  109993. detachControl(element: HTMLElement): void;
  109994. /** @hidden */
  109995. _checkInputs(): void;
  109996. protected _checkLimits(): void;
  109997. /**
  109998. * Rebuilds angles (alpha, beta) and radius from the give position and target
  109999. */
  110000. rebuildAnglesAndRadius(): void;
  110001. /**
  110002. * Use a position to define the current camera related information like alpha, beta and radius
  110003. * @param position Defines the position to set the camera at
  110004. */
  110005. setPosition(position: Vector3): void;
  110006. /**
  110007. * Defines the target the camera should look at.
  110008. * This will automatically adapt alpha beta and radius to fit within the new target.
  110009. * @param target Defines the new target as a Vector or a mesh
  110010. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  110011. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  110012. */
  110013. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  110014. /** @hidden */
  110015. _getViewMatrix(): Matrix;
  110016. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  110017. /**
  110018. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  110019. * @param meshes Defines the mesh to zoom on
  110020. * @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)
  110021. */
  110022. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  110023. /**
  110024. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  110025. * The target will be changed but the radius
  110026. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  110027. * @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)
  110028. */
  110029. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  110030. min: Vector3;
  110031. max: Vector3;
  110032. distance: number;
  110033. }, doNotUpdateMaxZ?: boolean): void;
  110034. /**
  110035. * @override
  110036. * Override Camera.createRigCamera
  110037. */
  110038. createRigCamera(name: string, cameraIndex: number): Camera;
  110039. /**
  110040. * @hidden
  110041. * @override
  110042. * Override Camera._updateRigCameras
  110043. */
  110044. _updateRigCameras(): void;
  110045. /**
  110046. * Destroy the camera and release the current resources hold by it.
  110047. */
  110048. dispose(): void;
  110049. /**
  110050. * Gets the current object class name.
  110051. * @return the class name
  110052. */
  110053. getClassName(): string;
  110054. }
  110055. }
  110056. declare module BABYLON {
  110057. /**
  110058. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  110059. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  110060. */
  110061. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  110062. /**
  110063. * Gets the name of the behavior.
  110064. */
  110065. get name(): string;
  110066. private _zoomStopsAnimation;
  110067. private _idleRotationSpeed;
  110068. private _idleRotationWaitTime;
  110069. private _idleRotationSpinupTime;
  110070. /**
  110071. * Sets the flag that indicates if user zooming should stop animation.
  110072. */
  110073. set zoomStopsAnimation(flag: boolean);
  110074. /**
  110075. * Gets the flag that indicates if user zooming should stop animation.
  110076. */
  110077. get zoomStopsAnimation(): boolean;
  110078. /**
  110079. * Sets the default speed at which the camera rotates around the model.
  110080. */
  110081. set idleRotationSpeed(speed: number);
  110082. /**
  110083. * Gets the default speed at which the camera rotates around the model.
  110084. */
  110085. get idleRotationSpeed(): number;
  110086. /**
  110087. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  110088. */
  110089. set idleRotationWaitTime(time: number);
  110090. /**
  110091. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  110092. */
  110093. get idleRotationWaitTime(): number;
  110094. /**
  110095. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  110096. */
  110097. set idleRotationSpinupTime(time: number);
  110098. /**
  110099. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  110100. */
  110101. get idleRotationSpinupTime(): number;
  110102. /**
  110103. * Gets a value indicating if the camera is currently rotating because of this behavior
  110104. */
  110105. get rotationInProgress(): boolean;
  110106. private _onPrePointerObservableObserver;
  110107. private _onAfterCheckInputsObserver;
  110108. private _attachedCamera;
  110109. private _isPointerDown;
  110110. private _lastFrameTime;
  110111. private _lastInteractionTime;
  110112. private _cameraRotationSpeed;
  110113. /**
  110114. * Initializes the behavior.
  110115. */
  110116. init(): void;
  110117. /**
  110118. * Attaches the behavior to its arc rotate camera.
  110119. * @param camera Defines the camera to attach the behavior to
  110120. */
  110121. attach(camera: ArcRotateCamera): void;
  110122. /**
  110123. * Detaches the behavior from its current arc rotate camera.
  110124. */
  110125. detach(): void;
  110126. /**
  110127. * Returns true if user is scrolling.
  110128. * @return true if user is scrolling.
  110129. */
  110130. private _userIsZooming;
  110131. private _lastFrameRadius;
  110132. private _shouldAnimationStopForInteraction;
  110133. /**
  110134. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  110135. */
  110136. private _applyUserInteraction;
  110137. private _userIsMoving;
  110138. }
  110139. }
  110140. declare module BABYLON {
  110141. /**
  110142. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  110143. */
  110144. export class AttachToBoxBehavior implements Behavior<Mesh> {
  110145. private ui;
  110146. /**
  110147. * The name of the behavior
  110148. */
  110149. name: string;
  110150. /**
  110151. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  110152. */
  110153. distanceAwayFromFace: number;
  110154. /**
  110155. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  110156. */
  110157. distanceAwayFromBottomOfFace: number;
  110158. private _faceVectors;
  110159. private _target;
  110160. private _scene;
  110161. private _onRenderObserver;
  110162. private _tmpMatrix;
  110163. private _tmpVector;
  110164. /**
  110165. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  110166. * @param ui The transform node that should be attched to the mesh
  110167. */
  110168. constructor(ui: TransformNode);
  110169. /**
  110170. * Initializes the behavior
  110171. */
  110172. init(): void;
  110173. private _closestFace;
  110174. private _zeroVector;
  110175. private _lookAtTmpMatrix;
  110176. private _lookAtToRef;
  110177. /**
  110178. * Attaches the AttachToBoxBehavior to the passed in mesh
  110179. * @param target The mesh that the specified node will be attached to
  110180. */
  110181. attach(target: Mesh): void;
  110182. /**
  110183. * Detaches the behavior from the mesh
  110184. */
  110185. detach(): void;
  110186. }
  110187. }
  110188. declare module BABYLON {
  110189. /**
  110190. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  110191. */
  110192. export class FadeInOutBehavior implements Behavior<Mesh> {
  110193. /**
  110194. * Time in milliseconds to delay before fading in (Default: 0)
  110195. */
  110196. delay: number;
  110197. /**
  110198. * Time in milliseconds for the mesh to fade in (Default: 300)
  110199. */
  110200. fadeInTime: number;
  110201. private _millisecondsPerFrame;
  110202. private _hovered;
  110203. private _hoverValue;
  110204. private _ownerNode;
  110205. /**
  110206. * Instatiates the FadeInOutBehavior
  110207. */
  110208. constructor();
  110209. /**
  110210. * The name of the behavior
  110211. */
  110212. get name(): string;
  110213. /**
  110214. * Initializes the behavior
  110215. */
  110216. init(): void;
  110217. /**
  110218. * Attaches the fade behavior on the passed in mesh
  110219. * @param ownerNode The mesh that will be faded in/out once attached
  110220. */
  110221. attach(ownerNode: Mesh): void;
  110222. /**
  110223. * Detaches the behavior from the mesh
  110224. */
  110225. detach(): void;
  110226. /**
  110227. * Triggers the mesh to begin fading in or out
  110228. * @param value if the object should fade in or out (true to fade in)
  110229. */
  110230. fadeIn(value: boolean): void;
  110231. private _update;
  110232. private _setAllVisibility;
  110233. }
  110234. }
  110235. declare module BABYLON {
  110236. /**
  110237. * Class containing a set of static utilities functions for managing Pivots
  110238. * @hidden
  110239. */
  110240. export class PivotTools {
  110241. private static _PivotCached;
  110242. private static _OldPivotPoint;
  110243. private static _PivotTranslation;
  110244. private static _PivotTmpVector;
  110245. /** @hidden */
  110246. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  110247. /** @hidden */
  110248. static _RestorePivotPoint(mesh: AbstractMesh): void;
  110249. }
  110250. }
  110251. declare module BABYLON {
  110252. /**
  110253. * Class containing static functions to help procedurally build meshes
  110254. */
  110255. export class PlaneBuilder {
  110256. /**
  110257. * Creates a plane mesh
  110258. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110259. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110260. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110264. * @param name defines the name of the mesh
  110265. * @param options defines the options used to create the mesh
  110266. * @param scene defines the hosting scene
  110267. * @returns the plane mesh
  110268. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110269. */
  110270. static CreatePlane(name: string, options: {
  110271. size?: number;
  110272. width?: number;
  110273. height?: number;
  110274. sideOrientation?: number;
  110275. frontUVs?: Vector4;
  110276. backUVs?: Vector4;
  110277. updatable?: boolean;
  110278. sourcePlane?: Plane;
  110279. }, scene?: Nullable<Scene>): Mesh;
  110280. }
  110281. }
  110282. declare module BABYLON {
  110283. /**
  110284. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  110285. */
  110286. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  110287. private static _AnyMouseID;
  110288. /**
  110289. * Abstract mesh the behavior is set on
  110290. */
  110291. attachedNode: AbstractMesh;
  110292. private _dragPlane;
  110293. private _scene;
  110294. private _pointerObserver;
  110295. private _beforeRenderObserver;
  110296. private static _planeScene;
  110297. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  110298. /**
  110299. * 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)
  110300. */
  110301. maxDragAngle: number;
  110302. /**
  110303. * @hidden
  110304. */
  110305. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  110306. /**
  110307. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  110308. */
  110309. currentDraggingPointerID: number;
  110310. /**
  110311. * The last position where the pointer hit the drag plane in world space
  110312. */
  110313. lastDragPosition: Vector3;
  110314. /**
  110315. * If the behavior is currently in a dragging state
  110316. */
  110317. dragging: boolean;
  110318. /**
  110319. * 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)
  110320. */
  110321. dragDeltaRatio: number;
  110322. /**
  110323. * If the drag plane orientation should be updated during the dragging (Default: true)
  110324. */
  110325. updateDragPlane: boolean;
  110326. private _debugMode;
  110327. private _moving;
  110328. /**
  110329. * Fires each time the attached mesh is dragged with the pointer
  110330. * * delta between last drag position and current drag position in world space
  110331. * * dragDistance along the drag axis
  110332. * * dragPlaneNormal normal of the current drag plane used during the drag
  110333. * * dragPlanePoint in world space where the drag intersects the drag plane
  110334. */
  110335. onDragObservable: Observable<{
  110336. delta: Vector3;
  110337. dragPlanePoint: Vector3;
  110338. dragPlaneNormal: Vector3;
  110339. dragDistance: number;
  110340. pointerId: number;
  110341. }>;
  110342. /**
  110343. * Fires each time a drag begins (eg. mouse down on mesh)
  110344. */
  110345. onDragStartObservable: Observable<{
  110346. dragPlanePoint: Vector3;
  110347. pointerId: number;
  110348. }>;
  110349. /**
  110350. * Fires each time a drag ends (eg. mouse release after drag)
  110351. */
  110352. onDragEndObservable: Observable<{
  110353. dragPlanePoint: Vector3;
  110354. pointerId: number;
  110355. }>;
  110356. /**
  110357. * If the attached mesh should be moved when dragged
  110358. */
  110359. moveAttached: boolean;
  110360. /**
  110361. * If the drag behavior will react to drag events (Default: true)
  110362. */
  110363. enabled: boolean;
  110364. /**
  110365. * If pointer events should start and release the drag (Default: true)
  110366. */
  110367. startAndReleaseDragOnPointerEvents: boolean;
  110368. /**
  110369. * If camera controls should be detached during the drag
  110370. */
  110371. detachCameraControls: boolean;
  110372. /**
  110373. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  110374. */
  110375. useObjectOrientationForDragging: boolean;
  110376. private _options;
  110377. /**
  110378. * Gets the options used by the behavior
  110379. */
  110380. get options(): {
  110381. dragAxis?: Vector3;
  110382. dragPlaneNormal?: Vector3;
  110383. };
  110384. /**
  110385. * Sets the options used by the behavior
  110386. */
  110387. set options(options: {
  110388. dragAxis?: Vector3;
  110389. dragPlaneNormal?: Vector3;
  110390. });
  110391. /**
  110392. * Creates a pointer drag behavior that can be attached to a mesh
  110393. * @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)
  110394. */
  110395. constructor(options?: {
  110396. dragAxis?: Vector3;
  110397. dragPlaneNormal?: Vector3;
  110398. });
  110399. /**
  110400. * Predicate to determine if it is valid to move the object to a new position when it is moved
  110401. */
  110402. validateDrag: (targetPosition: Vector3) => boolean;
  110403. /**
  110404. * The name of the behavior
  110405. */
  110406. get name(): string;
  110407. /**
  110408. * Initializes the behavior
  110409. */
  110410. init(): void;
  110411. private _tmpVector;
  110412. private _alternatePickedPoint;
  110413. private _worldDragAxis;
  110414. private _targetPosition;
  110415. private _attachedElement;
  110416. /**
  110417. * Attaches the drag behavior the passed in mesh
  110418. * @param ownerNode The mesh that will be dragged around once attached
  110419. * @param predicate Predicate to use for pick filtering
  110420. */
  110421. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  110422. /**
  110423. * Force relase the drag action by code.
  110424. */
  110425. releaseDrag(): void;
  110426. private _startDragRay;
  110427. private _lastPointerRay;
  110428. /**
  110429. * Simulates the start of a pointer drag event on the behavior
  110430. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  110431. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  110432. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  110433. */
  110434. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  110435. private _startDrag;
  110436. private _dragDelta;
  110437. private _moveDrag;
  110438. private _pickWithRayOnDragPlane;
  110439. private _pointA;
  110440. private _pointB;
  110441. private _pointC;
  110442. private _lineA;
  110443. private _lineB;
  110444. private _localAxis;
  110445. private _lookAt;
  110446. private _updateDragPlanePosition;
  110447. /**
  110448. * Detaches the behavior from the mesh
  110449. */
  110450. detach(): void;
  110451. }
  110452. }
  110453. declare module BABYLON {
  110454. /**
  110455. * A behavior that when attached to a mesh will allow the mesh to be scaled
  110456. */
  110457. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  110458. private _dragBehaviorA;
  110459. private _dragBehaviorB;
  110460. private _startDistance;
  110461. private _initialScale;
  110462. private _targetScale;
  110463. private _ownerNode;
  110464. private _sceneRenderObserver;
  110465. /**
  110466. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  110467. */
  110468. constructor();
  110469. /**
  110470. * The name of the behavior
  110471. */
  110472. get name(): string;
  110473. /**
  110474. * Initializes the behavior
  110475. */
  110476. init(): void;
  110477. private _getCurrentDistance;
  110478. /**
  110479. * Attaches the scale behavior the passed in mesh
  110480. * @param ownerNode The mesh that will be scaled around once attached
  110481. */
  110482. attach(ownerNode: Mesh): void;
  110483. /**
  110484. * Detaches the behavior from the mesh
  110485. */
  110486. detach(): void;
  110487. }
  110488. }
  110489. declare module BABYLON {
  110490. /**
  110491. * 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
  110492. */
  110493. export class SixDofDragBehavior implements Behavior<Mesh> {
  110494. private static _virtualScene;
  110495. private _ownerNode;
  110496. private _sceneRenderObserver;
  110497. private _scene;
  110498. private _targetPosition;
  110499. private _virtualOriginMesh;
  110500. private _virtualDragMesh;
  110501. private _pointerObserver;
  110502. private _moving;
  110503. private _startingOrientation;
  110504. /**
  110505. * 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)
  110506. */
  110507. private zDragFactor;
  110508. /**
  110509. * If the object should rotate to face the drag origin
  110510. */
  110511. rotateDraggedObject: boolean;
  110512. /**
  110513. * If the behavior is currently in a dragging state
  110514. */
  110515. dragging: boolean;
  110516. /**
  110517. * 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)
  110518. */
  110519. dragDeltaRatio: number;
  110520. /**
  110521. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  110522. */
  110523. currentDraggingPointerID: number;
  110524. /**
  110525. * If camera controls should be detached during the drag
  110526. */
  110527. detachCameraControls: boolean;
  110528. /**
  110529. * Fires each time a drag starts
  110530. */
  110531. onDragStartObservable: Observable<{}>;
  110532. /**
  110533. * Fires each time a drag ends (eg. mouse release after drag)
  110534. */
  110535. onDragEndObservable: Observable<{}>;
  110536. /**
  110537. * 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
  110538. */
  110539. constructor();
  110540. /**
  110541. * The name of the behavior
  110542. */
  110543. get name(): string;
  110544. /**
  110545. * Initializes the behavior
  110546. */
  110547. init(): void;
  110548. /**
  110549. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  110550. */
  110551. private get _pointerCamera();
  110552. /**
  110553. * Attaches the scale behavior the passed in mesh
  110554. * @param ownerNode The mesh that will be scaled around once attached
  110555. */
  110556. attach(ownerNode: Mesh): void;
  110557. /**
  110558. * Detaches the behavior from the mesh
  110559. */
  110560. detach(): void;
  110561. }
  110562. }
  110563. declare module BABYLON {
  110564. /**
  110565. * Class used to apply inverse kinematics to bones
  110566. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  110567. */
  110568. export class BoneIKController {
  110569. private static _tmpVecs;
  110570. private static _tmpQuat;
  110571. private static _tmpMats;
  110572. /**
  110573. * Gets or sets the target mesh
  110574. */
  110575. targetMesh: AbstractMesh;
  110576. /** Gets or sets the mesh used as pole */
  110577. poleTargetMesh: AbstractMesh;
  110578. /**
  110579. * Gets or sets the bone used as pole
  110580. */
  110581. poleTargetBone: Nullable<Bone>;
  110582. /**
  110583. * Gets or sets the target position
  110584. */
  110585. targetPosition: Vector3;
  110586. /**
  110587. * Gets or sets the pole target position
  110588. */
  110589. poleTargetPosition: Vector3;
  110590. /**
  110591. * Gets or sets the pole target local offset
  110592. */
  110593. poleTargetLocalOffset: Vector3;
  110594. /**
  110595. * Gets or sets the pole angle
  110596. */
  110597. poleAngle: number;
  110598. /**
  110599. * Gets or sets the mesh associated with the controller
  110600. */
  110601. mesh: AbstractMesh;
  110602. /**
  110603. * 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)
  110604. */
  110605. slerpAmount: number;
  110606. private _bone1Quat;
  110607. private _bone1Mat;
  110608. private _bone2Ang;
  110609. private _bone1;
  110610. private _bone2;
  110611. private _bone1Length;
  110612. private _bone2Length;
  110613. private _maxAngle;
  110614. private _maxReach;
  110615. private _rightHandedSystem;
  110616. private _bendAxis;
  110617. private _slerping;
  110618. private _adjustRoll;
  110619. /**
  110620. * Gets or sets maximum allowed angle
  110621. */
  110622. get maxAngle(): number;
  110623. set maxAngle(value: number);
  110624. /**
  110625. * Creates a new BoneIKController
  110626. * @param mesh defines the mesh to control
  110627. * @param bone defines the bone to control
  110628. * @param options defines options to set up the controller
  110629. */
  110630. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  110631. targetMesh?: AbstractMesh;
  110632. poleTargetMesh?: AbstractMesh;
  110633. poleTargetBone?: Bone;
  110634. poleTargetLocalOffset?: Vector3;
  110635. poleAngle?: number;
  110636. bendAxis?: Vector3;
  110637. maxAngle?: number;
  110638. slerpAmount?: number;
  110639. });
  110640. private _setMaxAngle;
  110641. /**
  110642. * Force the controller to update the bones
  110643. */
  110644. update(): void;
  110645. }
  110646. }
  110647. declare module BABYLON {
  110648. /**
  110649. * Class used to make a bone look toward a point in space
  110650. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  110651. */
  110652. export class BoneLookController {
  110653. private static _tmpVecs;
  110654. private static _tmpQuat;
  110655. private static _tmpMats;
  110656. /**
  110657. * The target Vector3 that the bone will look at
  110658. */
  110659. target: Vector3;
  110660. /**
  110661. * The mesh that the bone is attached to
  110662. */
  110663. mesh: AbstractMesh;
  110664. /**
  110665. * The bone that will be looking to the target
  110666. */
  110667. bone: Bone;
  110668. /**
  110669. * The up axis of the coordinate system that is used when the bone is rotated
  110670. */
  110671. upAxis: Vector3;
  110672. /**
  110673. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  110674. */
  110675. upAxisSpace: Space;
  110676. /**
  110677. * Used to make an adjustment to the yaw of the bone
  110678. */
  110679. adjustYaw: number;
  110680. /**
  110681. * Used to make an adjustment to the pitch of the bone
  110682. */
  110683. adjustPitch: number;
  110684. /**
  110685. * Used to make an adjustment to the roll of the bone
  110686. */
  110687. adjustRoll: number;
  110688. /**
  110689. * 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)
  110690. */
  110691. slerpAmount: number;
  110692. private _minYaw;
  110693. private _maxYaw;
  110694. private _minPitch;
  110695. private _maxPitch;
  110696. private _minYawSin;
  110697. private _minYawCos;
  110698. private _maxYawSin;
  110699. private _maxYawCos;
  110700. private _midYawConstraint;
  110701. private _minPitchTan;
  110702. private _maxPitchTan;
  110703. private _boneQuat;
  110704. private _slerping;
  110705. private _transformYawPitch;
  110706. private _transformYawPitchInv;
  110707. private _firstFrameSkipped;
  110708. private _yawRange;
  110709. private _fowardAxis;
  110710. /**
  110711. * Gets or sets the minimum yaw angle that the bone can look to
  110712. */
  110713. get minYaw(): number;
  110714. set minYaw(value: number);
  110715. /**
  110716. * Gets or sets the maximum yaw angle that the bone can look to
  110717. */
  110718. get maxYaw(): number;
  110719. set maxYaw(value: number);
  110720. /**
  110721. * Gets or sets the minimum pitch angle that the bone can look to
  110722. */
  110723. get minPitch(): number;
  110724. set minPitch(value: number);
  110725. /**
  110726. * Gets or sets the maximum pitch angle that the bone can look to
  110727. */
  110728. get maxPitch(): number;
  110729. set maxPitch(value: number);
  110730. /**
  110731. * Create a BoneLookController
  110732. * @param mesh the mesh that the bone belongs to
  110733. * @param bone the bone that will be looking to the target
  110734. * @param target the target Vector3 to look at
  110735. * @param options optional settings:
  110736. * * maxYaw: the maximum angle the bone will yaw to
  110737. * * minYaw: the minimum angle the bone will yaw to
  110738. * * maxPitch: the maximum angle the bone will pitch to
  110739. * * minPitch: the minimum angle the bone will yaw to
  110740. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  110741. * * upAxis: the up axis of the coordinate system
  110742. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  110743. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  110744. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  110745. * * adjustYaw: used to make an adjustment to the yaw of the bone
  110746. * * adjustPitch: used to make an adjustment to the pitch of the bone
  110747. * * adjustRoll: used to make an adjustment to the roll of the bone
  110748. **/
  110749. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  110750. maxYaw?: number;
  110751. minYaw?: number;
  110752. maxPitch?: number;
  110753. minPitch?: number;
  110754. slerpAmount?: number;
  110755. upAxis?: Vector3;
  110756. upAxisSpace?: Space;
  110757. yawAxis?: Vector3;
  110758. pitchAxis?: Vector3;
  110759. adjustYaw?: number;
  110760. adjustPitch?: number;
  110761. adjustRoll?: number;
  110762. });
  110763. /**
  110764. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  110765. */
  110766. update(): void;
  110767. private _getAngleDiff;
  110768. private _getAngleBetween;
  110769. private _isAngleBetween;
  110770. }
  110771. }
  110772. declare module BABYLON {
  110773. /**
  110774. * Manage the gamepad inputs to control an arc rotate camera.
  110775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110776. */
  110777. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  110778. /**
  110779. * Defines the camera the input is attached to.
  110780. */
  110781. camera: ArcRotateCamera;
  110782. /**
  110783. * Defines the gamepad the input is gathering event from.
  110784. */
  110785. gamepad: Nullable<Gamepad>;
  110786. /**
  110787. * Defines the gamepad rotation sensiblity.
  110788. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110789. */
  110790. gamepadRotationSensibility: number;
  110791. /**
  110792. * Defines the gamepad move sensiblity.
  110793. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110794. */
  110795. gamepadMoveSensibility: number;
  110796. private _yAxisScale;
  110797. /**
  110798. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110799. */
  110800. get invertYAxis(): boolean;
  110801. set invertYAxis(value: boolean);
  110802. private _onGamepadConnectedObserver;
  110803. private _onGamepadDisconnectedObserver;
  110804. /**
  110805. * Attach the input controls to a specific dom element to get the input from.
  110806. * @param element Defines the element the controls should be listened from
  110807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110808. */
  110809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110810. /**
  110811. * Detach the current controls from the specified dom element.
  110812. * @param element Defines the element to stop listening the inputs from
  110813. */
  110814. detachControl(element: Nullable<HTMLElement>): void;
  110815. /**
  110816. * Update the current camera state depending on the inputs that have been used this frame.
  110817. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110818. */
  110819. checkInputs(): void;
  110820. /**
  110821. * Gets the class name of the current intput.
  110822. * @returns the class name
  110823. */
  110824. getClassName(): string;
  110825. /**
  110826. * Get the friendly name associated with the input class.
  110827. * @returns the input friendly name
  110828. */
  110829. getSimpleName(): string;
  110830. }
  110831. }
  110832. declare module BABYLON {
  110833. interface ArcRotateCameraInputsManager {
  110834. /**
  110835. * Add orientation input support to the input manager.
  110836. * @returns the current input manager
  110837. */
  110838. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  110839. }
  110840. /**
  110841. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  110842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110843. */
  110844. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  110845. /**
  110846. * Defines the camera the input is attached to.
  110847. */
  110848. camera: ArcRotateCamera;
  110849. /**
  110850. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  110851. */
  110852. alphaCorrection: number;
  110853. /**
  110854. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  110855. */
  110856. gammaCorrection: number;
  110857. private _alpha;
  110858. private _gamma;
  110859. private _dirty;
  110860. private _deviceOrientationHandler;
  110861. /**
  110862. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  110863. */
  110864. constructor();
  110865. /**
  110866. * Attach the input controls to a specific dom element to get the input from.
  110867. * @param element Defines the element the controls should be listened from
  110868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110869. */
  110870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110871. /** @hidden */
  110872. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  110873. /**
  110874. * Update the current camera state depending on the inputs that have been used this frame.
  110875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110876. */
  110877. checkInputs(): void;
  110878. /**
  110879. * Detach the current controls from the specified dom element.
  110880. * @param element Defines the element to stop listening the inputs from
  110881. */
  110882. detachControl(element: Nullable<HTMLElement>): void;
  110883. /**
  110884. * Gets the class name of the current intput.
  110885. * @returns the class name
  110886. */
  110887. getClassName(): string;
  110888. /**
  110889. * Get the friendly name associated with the input class.
  110890. * @returns the input friendly name
  110891. */
  110892. getSimpleName(): string;
  110893. }
  110894. }
  110895. declare module BABYLON {
  110896. /**
  110897. * Listen to mouse events to control the camera.
  110898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110899. */
  110900. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110901. /**
  110902. * Defines the camera the input is attached to.
  110903. */
  110904. camera: FlyCamera;
  110905. /**
  110906. * Defines if touch is enabled. (Default is true.)
  110907. */
  110908. touchEnabled: boolean;
  110909. /**
  110910. * Defines the buttons associated with the input to handle camera rotation.
  110911. */
  110912. buttons: number[];
  110913. /**
  110914. * Assign buttons for Yaw control.
  110915. */
  110916. buttonsYaw: number[];
  110917. /**
  110918. * Assign buttons for Pitch control.
  110919. */
  110920. buttonsPitch: number[];
  110921. /**
  110922. * Assign buttons for Roll control.
  110923. */
  110924. buttonsRoll: number[];
  110925. /**
  110926. * Detect if any button is being pressed while mouse is moved.
  110927. * -1 = Mouse locked.
  110928. * 0 = Left button.
  110929. * 1 = Middle Button.
  110930. * 2 = Right Button.
  110931. */
  110932. activeButton: number;
  110933. /**
  110934. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110935. * Higher values reduce its sensitivity.
  110936. */
  110937. angularSensibility: number;
  110938. private _mousemoveCallback;
  110939. private _observer;
  110940. private _rollObserver;
  110941. private previousPosition;
  110942. private noPreventDefault;
  110943. private element;
  110944. /**
  110945. * Listen to mouse events to control the camera.
  110946. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110948. */
  110949. constructor(touchEnabled?: boolean);
  110950. /**
  110951. * Attach the mouse control to the HTML DOM element.
  110952. * @param element Defines the element that listens to the input events.
  110953. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110954. */
  110955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110956. /**
  110957. * Detach the current controls from the specified dom element.
  110958. * @param element Defines the element to stop listening the inputs from
  110959. */
  110960. detachControl(element: Nullable<HTMLElement>): void;
  110961. /**
  110962. * Gets the class name of the current input.
  110963. * @returns the class name.
  110964. */
  110965. getClassName(): string;
  110966. /**
  110967. * Get the friendly name associated with the input class.
  110968. * @returns the input's friendly name.
  110969. */
  110970. getSimpleName(): string;
  110971. private _pointerInput;
  110972. private _onMouseMove;
  110973. /**
  110974. * Rotate camera by mouse offset.
  110975. */
  110976. private rotateCamera;
  110977. }
  110978. }
  110979. declare module BABYLON {
  110980. /**
  110981. * Default Inputs manager for the FlyCamera.
  110982. * It groups all the default supported inputs for ease of use.
  110983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110984. */
  110985. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110986. /**
  110987. * Instantiates a new FlyCameraInputsManager.
  110988. * @param camera Defines the camera the inputs belong to.
  110989. */
  110990. constructor(camera: FlyCamera);
  110991. /**
  110992. * Add keyboard input support to the input manager.
  110993. * @returns the new FlyCameraKeyboardMoveInput().
  110994. */
  110995. addKeyboard(): FlyCameraInputsManager;
  110996. /**
  110997. * Add mouse input support to the input manager.
  110998. * @param touchEnabled Enable touch screen support.
  110999. * @returns the new FlyCameraMouseInput().
  111000. */
  111001. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  111002. }
  111003. }
  111004. declare module BABYLON {
  111005. /**
  111006. * This is a flying camera, designed for 3D movement and rotation in all directions,
  111007. * such as in a 3D Space Shooter or a Flight Simulator.
  111008. */
  111009. export class FlyCamera extends TargetCamera {
  111010. /**
  111011. * Define the collision ellipsoid of the camera.
  111012. * This is helpful for simulating a camera body, like a player's body.
  111013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111014. */
  111015. ellipsoid: Vector3;
  111016. /**
  111017. * Define an offset for the position of the ellipsoid around the camera.
  111018. * This can be helpful if the camera is attached away from the player's body center,
  111019. * such as at its head.
  111020. */
  111021. ellipsoidOffset: Vector3;
  111022. /**
  111023. * Enable or disable collisions of the camera with the rest of the scene objects.
  111024. */
  111025. checkCollisions: boolean;
  111026. /**
  111027. * Enable or disable gravity on the camera.
  111028. */
  111029. applyGravity: boolean;
  111030. /**
  111031. * Define the current direction the camera is moving to.
  111032. */
  111033. cameraDirection: Vector3;
  111034. /**
  111035. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  111036. * This overrides and empties cameraRotation.
  111037. */
  111038. rotationQuaternion: Quaternion;
  111039. /**
  111040. * Track Roll to maintain the wanted Rolling when looking around.
  111041. */
  111042. _trackRoll: number;
  111043. /**
  111044. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  111045. */
  111046. rollCorrect: number;
  111047. /**
  111048. * Mimic a banked turn, Rolling the camera when Yawing.
  111049. * It's recommended to use rollCorrect = 10 for faster banking correction.
  111050. */
  111051. bankedTurn: boolean;
  111052. /**
  111053. * Limit in radians for how much Roll banking will add. (Default: 90°)
  111054. */
  111055. bankedTurnLimit: number;
  111056. /**
  111057. * Value of 0 disables the banked Roll.
  111058. * Value of 1 is equal to the Yaw angle in radians.
  111059. */
  111060. bankedTurnMultiplier: number;
  111061. /**
  111062. * The inputs manager loads all the input sources, such as keyboard and mouse.
  111063. */
  111064. inputs: FlyCameraInputsManager;
  111065. /**
  111066. * Gets the input sensibility for mouse input.
  111067. * Higher values reduce sensitivity.
  111068. */
  111069. get angularSensibility(): number;
  111070. /**
  111071. * Sets the input sensibility for a mouse input.
  111072. * Higher values reduce sensitivity.
  111073. */
  111074. set angularSensibility(value: number);
  111075. /**
  111076. * Get the keys for camera movement forward.
  111077. */
  111078. get keysForward(): number[];
  111079. /**
  111080. * Set the keys for camera movement forward.
  111081. */
  111082. set keysForward(value: number[]);
  111083. /**
  111084. * Get the keys for camera movement backward.
  111085. */
  111086. get keysBackward(): number[];
  111087. set keysBackward(value: number[]);
  111088. /**
  111089. * Get the keys for camera movement up.
  111090. */
  111091. get keysUp(): number[];
  111092. /**
  111093. * Set the keys for camera movement up.
  111094. */
  111095. set keysUp(value: number[]);
  111096. /**
  111097. * Get the keys for camera movement down.
  111098. */
  111099. get keysDown(): number[];
  111100. /**
  111101. * Set the keys for camera movement down.
  111102. */
  111103. set keysDown(value: number[]);
  111104. /**
  111105. * Get the keys for camera movement left.
  111106. */
  111107. get keysLeft(): number[];
  111108. /**
  111109. * Set the keys for camera movement left.
  111110. */
  111111. set keysLeft(value: number[]);
  111112. /**
  111113. * Set the keys for camera movement right.
  111114. */
  111115. get keysRight(): number[];
  111116. /**
  111117. * Set the keys for camera movement right.
  111118. */
  111119. set keysRight(value: number[]);
  111120. /**
  111121. * Event raised when the camera collides with a mesh in the scene.
  111122. */
  111123. onCollide: (collidedMesh: AbstractMesh) => void;
  111124. private _collider;
  111125. private _needMoveForGravity;
  111126. private _oldPosition;
  111127. private _diffPosition;
  111128. private _newPosition;
  111129. /** @hidden */
  111130. _localDirection: Vector3;
  111131. /** @hidden */
  111132. _transformedDirection: Vector3;
  111133. /**
  111134. * Instantiates a FlyCamera.
  111135. * This is a flying camera, designed for 3D movement and rotation in all directions,
  111136. * such as in a 3D Space Shooter or a Flight Simulator.
  111137. * @param name Define the name of the camera in the scene.
  111138. * @param position Define the starting position of the camera in the scene.
  111139. * @param scene Define the scene the camera belongs to.
  111140. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  111141. */
  111142. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111143. /**
  111144. * Attach a control to the HTML DOM element.
  111145. * @param element Defines the element that listens to the input events.
  111146. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  111147. */
  111148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111149. /**
  111150. * Detach a control from the HTML DOM element.
  111151. * The camera will stop reacting to that input.
  111152. * @param element Defines the element that listens to the input events.
  111153. */
  111154. detachControl(element: HTMLElement): void;
  111155. private _collisionMask;
  111156. /**
  111157. * Get the mask that the camera ignores in collision events.
  111158. */
  111159. get collisionMask(): number;
  111160. /**
  111161. * Set the mask that the camera ignores in collision events.
  111162. */
  111163. set collisionMask(mask: number);
  111164. /** @hidden */
  111165. _collideWithWorld(displacement: Vector3): void;
  111166. /** @hidden */
  111167. private _onCollisionPositionChange;
  111168. /** @hidden */
  111169. _checkInputs(): void;
  111170. /** @hidden */
  111171. _decideIfNeedsToMove(): boolean;
  111172. /** @hidden */
  111173. _updatePosition(): void;
  111174. /**
  111175. * Restore the Roll to its target value at the rate specified.
  111176. * @param rate - Higher means slower restoring.
  111177. * @hidden
  111178. */
  111179. restoreRoll(rate: number): void;
  111180. /**
  111181. * Destroy the camera and release the current resources held by it.
  111182. */
  111183. dispose(): void;
  111184. /**
  111185. * Get the current object class name.
  111186. * @returns the class name.
  111187. */
  111188. getClassName(): string;
  111189. }
  111190. }
  111191. declare module BABYLON {
  111192. /**
  111193. * Listen to keyboard events to control the camera.
  111194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111195. */
  111196. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  111197. /**
  111198. * Defines the camera the input is attached to.
  111199. */
  111200. camera: FlyCamera;
  111201. /**
  111202. * The list of keyboard keys used to control the forward move of the camera.
  111203. */
  111204. keysForward: number[];
  111205. /**
  111206. * The list of keyboard keys used to control the backward move of the camera.
  111207. */
  111208. keysBackward: number[];
  111209. /**
  111210. * The list of keyboard keys used to control the forward move of the camera.
  111211. */
  111212. keysUp: number[];
  111213. /**
  111214. * The list of keyboard keys used to control the backward move of the camera.
  111215. */
  111216. keysDown: number[];
  111217. /**
  111218. * The list of keyboard keys used to control the right strafe move of the camera.
  111219. */
  111220. keysRight: number[];
  111221. /**
  111222. * The list of keyboard keys used to control the left strafe move of the camera.
  111223. */
  111224. keysLeft: number[];
  111225. private _keys;
  111226. private _onCanvasBlurObserver;
  111227. private _onKeyboardObserver;
  111228. private _engine;
  111229. private _scene;
  111230. /**
  111231. * Attach the input controls to a specific dom element to get the input from.
  111232. * @param element Defines the element the controls should be listened from
  111233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111234. */
  111235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111236. /**
  111237. * Detach the current controls from the specified dom element.
  111238. * @param element Defines the element to stop listening the inputs from
  111239. */
  111240. detachControl(element: Nullable<HTMLElement>): void;
  111241. /**
  111242. * Gets the class name of the current intput.
  111243. * @returns the class name
  111244. */
  111245. getClassName(): string;
  111246. /** @hidden */
  111247. _onLostFocus(e: FocusEvent): void;
  111248. /**
  111249. * Get the friendly name associated with the input class.
  111250. * @returns the input friendly name
  111251. */
  111252. getSimpleName(): string;
  111253. /**
  111254. * Update the current camera state depending on the inputs that have been used this frame.
  111255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111256. */
  111257. checkInputs(): void;
  111258. }
  111259. }
  111260. declare module BABYLON {
  111261. /**
  111262. * Manage the mouse wheel inputs to control a follow camera.
  111263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111264. */
  111265. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  111266. /**
  111267. * Defines the camera the input is attached to.
  111268. */
  111269. camera: FollowCamera;
  111270. /**
  111271. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  111272. */
  111273. axisControlRadius: boolean;
  111274. /**
  111275. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  111276. */
  111277. axisControlHeight: boolean;
  111278. /**
  111279. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  111280. */
  111281. axisControlRotation: boolean;
  111282. /**
  111283. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  111284. * relation to mouseWheel events.
  111285. */
  111286. wheelPrecision: number;
  111287. /**
  111288. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111289. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111290. */
  111291. wheelDeltaPercentage: number;
  111292. private _wheel;
  111293. private _observer;
  111294. /**
  111295. * Attach the input controls to a specific dom element to get the input from.
  111296. * @param element Defines the element the controls should be listened from
  111297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111298. */
  111299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111300. /**
  111301. * Detach the current controls from the specified dom element.
  111302. * @param element Defines the element to stop listening the inputs from
  111303. */
  111304. detachControl(element: Nullable<HTMLElement>): void;
  111305. /**
  111306. * Gets the class name of the current intput.
  111307. * @returns the class name
  111308. */
  111309. getClassName(): string;
  111310. /**
  111311. * Get the friendly name associated with the input class.
  111312. * @returns the input friendly name
  111313. */
  111314. getSimpleName(): string;
  111315. }
  111316. }
  111317. declare module BABYLON {
  111318. /**
  111319. * Manage the pointers inputs to control an follow camera.
  111320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111321. */
  111322. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  111323. /**
  111324. * Defines the camera the input is attached to.
  111325. */
  111326. camera: FollowCamera;
  111327. /**
  111328. * Gets the class name of the current input.
  111329. * @returns the class name
  111330. */
  111331. getClassName(): string;
  111332. /**
  111333. * Defines the pointer angular sensibility along the X axis or how fast is
  111334. * the camera rotating.
  111335. * A negative number will reverse the axis direction.
  111336. */
  111337. angularSensibilityX: number;
  111338. /**
  111339. * Defines the pointer angular sensibility along the Y axis or how fast is
  111340. * the camera rotating.
  111341. * A negative number will reverse the axis direction.
  111342. */
  111343. angularSensibilityY: number;
  111344. /**
  111345. * Defines the pointer pinch precision or how fast is the camera zooming.
  111346. * A negative number will reverse the axis direction.
  111347. */
  111348. pinchPrecision: number;
  111349. /**
  111350. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111351. * from 0.
  111352. * It defines the percentage of current camera.radius to use as delta when
  111353. * pinch zoom is used.
  111354. */
  111355. pinchDeltaPercentage: number;
  111356. /**
  111357. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  111358. */
  111359. axisXControlRadius: boolean;
  111360. /**
  111361. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  111362. */
  111363. axisXControlHeight: boolean;
  111364. /**
  111365. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  111366. */
  111367. axisXControlRotation: boolean;
  111368. /**
  111369. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  111370. */
  111371. axisYControlRadius: boolean;
  111372. /**
  111373. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  111374. */
  111375. axisYControlHeight: boolean;
  111376. /**
  111377. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  111378. */
  111379. axisYControlRotation: boolean;
  111380. /**
  111381. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  111382. */
  111383. axisPinchControlRadius: boolean;
  111384. /**
  111385. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  111386. */
  111387. axisPinchControlHeight: boolean;
  111388. /**
  111389. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  111390. */
  111391. axisPinchControlRotation: boolean;
  111392. /**
  111393. * Log error messages if basic misconfiguration has occurred.
  111394. */
  111395. warningEnable: boolean;
  111396. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111397. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111398. private _warningCounter;
  111399. private _warning;
  111400. }
  111401. }
  111402. declare module BABYLON {
  111403. /**
  111404. * Default Inputs manager for the FollowCamera.
  111405. * It groups all the default supported inputs for ease of use.
  111406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111407. */
  111408. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  111409. /**
  111410. * Instantiates a new FollowCameraInputsManager.
  111411. * @param camera Defines the camera the inputs belong to
  111412. */
  111413. constructor(camera: FollowCamera);
  111414. /**
  111415. * Add keyboard input support to the input manager.
  111416. * @returns the current input manager
  111417. */
  111418. addKeyboard(): FollowCameraInputsManager;
  111419. /**
  111420. * Add mouse wheel input support to the input manager.
  111421. * @returns the current input manager
  111422. */
  111423. addMouseWheel(): FollowCameraInputsManager;
  111424. /**
  111425. * Add pointers input support to the input manager.
  111426. * @returns the current input manager
  111427. */
  111428. addPointers(): FollowCameraInputsManager;
  111429. /**
  111430. * Add orientation input support to the input manager.
  111431. * @returns the current input manager
  111432. */
  111433. addVRDeviceOrientation(): FollowCameraInputsManager;
  111434. }
  111435. }
  111436. declare module BABYLON {
  111437. /**
  111438. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  111439. * an arc rotate version arcFollowCamera are available.
  111440. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111441. */
  111442. export class FollowCamera extends TargetCamera {
  111443. /**
  111444. * Distance the follow camera should follow an object at
  111445. */
  111446. radius: number;
  111447. /**
  111448. * Minimum allowed distance of the camera to the axis of rotation
  111449. * (The camera can not get closer).
  111450. * This can help limiting how the Camera is able to move in the scene.
  111451. */
  111452. lowerRadiusLimit: Nullable<number>;
  111453. /**
  111454. * Maximum allowed distance of the camera to the axis of rotation
  111455. * (The camera can not get further).
  111456. * This can help limiting how the Camera is able to move in the scene.
  111457. */
  111458. upperRadiusLimit: Nullable<number>;
  111459. /**
  111460. * Define a rotation offset between the camera and the object it follows
  111461. */
  111462. rotationOffset: number;
  111463. /**
  111464. * Minimum allowed angle to camera position relative to target object.
  111465. * This can help limiting how the Camera is able to move in the scene.
  111466. */
  111467. lowerRotationOffsetLimit: Nullable<number>;
  111468. /**
  111469. * Maximum allowed angle to camera position relative to target object.
  111470. * This can help limiting how the Camera is able to move in the scene.
  111471. */
  111472. upperRotationOffsetLimit: Nullable<number>;
  111473. /**
  111474. * Define a height offset between the camera and the object it follows.
  111475. * It can help following an object from the top (like a car chaing a plane)
  111476. */
  111477. heightOffset: number;
  111478. /**
  111479. * Minimum allowed height of camera position relative to target object.
  111480. * This can help limiting how the Camera is able to move in the scene.
  111481. */
  111482. lowerHeightOffsetLimit: Nullable<number>;
  111483. /**
  111484. * Maximum allowed height of camera position relative to target object.
  111485. * This can help limiting how the Camera is able to move in the scene.
  111486. */
  111487. upperHeightOffsetLimit: Nullable<number>;
  111488. /**
  111489. * Define how fast the camera can accelerate to follow it s target.
  111490. */
  111491. cameraAcceleration: number;
  111492. /**
  111493. * Define the speed limit of the camera following an object.
  111494. */
  111495. maxCameraSpeed: number;
  111496. /**
  111497. * Define the target of the camera.
  111498. */
  111499. lockedTarget: Nullable<AbstractMesh>;
  111500. /**
  111501. * Defines the input associated with the camera.
  111502. */
  111503. inputs: FollowCameraInputsManager;
  111504. /**
  111505. * Instantiates the follow camera.
  111506. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111507. * @param name Define the name of the camera in the scene
  111508. * @param position Define the position of the camera
  111509. * @param scene Define the scene the camera belong to
  111510. * @param lockedTarget Define the target of the camera
  111511. */
  111512. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  111513. private _follow;
  111514. /**
  111515. * Attached controls to the current camera.
  111516. * @param element Defines the element the controls should be listened from
  111517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111518. */
  111519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111520. /**
  111521. * Detach the current controls from the camera.
  111522. * The camera will stop reacting to inputs.
  111523. * @param element Defines the element to stop listening the inputs from
  111524. */
  111525. detachControl(element: HTMLElement): void;
  111526. /** @hidden */
  111527. _checkInputs(): void;
  111528. private _checkLimits;
  111529. /**
  111530. * Gets the camera class name.
  111531. * @returns the class name
  111532. */
  111533. getClassName(): string;
  111534. }
  111535. /**
  111536. * Arc Rotate version of the follow camera.
  111537. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  111538. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111539. */
  111540. export class ArcFollowCamera extends TargetCamera {
  111541. /** The longitudinal angle of the camera */
  111542. alpha: number;
  111543. /** The latitudinal angle of the camera */
  111544. beta: number;
  111545. /** The radius of the camera from its target */
  111546. radius: number;
  111547. /** Define the camera target (the messh it should follow) */
  111548. target: Nullable<AbstractMesh>;
  111549. private _cartesianCoordinates;
  111550. /**
  111551. * Instantiates a new ArcFollowCamera
  111552. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111553. * @param name Define the name of the camera
  111554. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  111555. * @param beta Define the rotation angle of the camera around the elevation axis
  111556. * @param radius Define the radius of the camera from its target point
  111557. * @param target Define the target of the camera
  111558. * @param scene Define the scene the camera belongs to
  111559. */
  111560. constructor(name: string,
  111561. /** The longitudinal angle of the camera */
  111562. alpha: number,
  111563. /** The latitudinal angle of the camera */
  111564. beta: number,
  111565. /** The radius of the camera from its target */
  111566. radius: number,
  111567. /** Define the camera target (the messh it should follow) */
  111568. target: Nullable<AbstractMesh>, scene: Scene);
  111569. private _follow;
  111570. /** @hidden */
  111571. _checkInputs(): void;
  111572. /**
  111573. * Returns the class name of the object.
  111574. * It is mostly used internally for serialization purposes.
  111575. */
  111576. getClassName(): string;
  111577. }
  111578. }
  111579. declare module BABYLON {
  111580. /**
  111581. * Manage the keyboard inputs to control the movement of a follow camera.
  111582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111583. */
  111584. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  111585. /**
  111586. * Defines the camera the input is attached to.
  111587. */
  111588. camera: FollowCamera;
  111589. /**
  111590. * Defines the list of key codes associated with the up action (increase heightOffset)
  111591. */
  111592. keysHeightOffsetIncr: number[];
  111593. /**
  111594. * Defines the list of key codes associated with the down action (decrease heightOffset)
  111595. */
  111596. keysHeightOffsetDecr: number[];
  111597. /**
  111598. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  111599. */
  111600. keysHeightOffsetModifierAlt: boolean;
  111601. /**
  111602. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  111603. */
  111604. keysHeightOffsetModifierCtrl: boolean;
  111605. /**
  111606. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  111607. */
  111608. keysHeightOffsetModifierShift: boolean;
  111609. /**
  111610. * Defines the list of key codes associated with the left action (increase rotationOffset)
  111611. */
  111612. keysRotationOffsetIncr: number[];
  111613. /**
  111614. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  111615. */
  111616. keysRotationOffsetDecr: number[];
  111617. /**
  111618. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  111619. */
  111620. keysRotationOffsetModifierAlt: boolean;
  111621. /**
  111622. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  111623. */
  111624. keysRotationOffsetModifierCtrl: boolean;
  111625. /**
  111626. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  111627. */
  111628. keysRotationOffsetModifierShift: boolean;
  111629. /**
  111630. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  111631. */
  111632. keysRadiusIncr: number[];
  111633. /**
  111634. * Defines the list of key codes associated with the zoom-out action (increase radius)
  111635. */
  111636. keysRadiusDecr: number[];
  111637. /**
  111638. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  111639. */
  111640. keysRadiusModifierAlt: boolean;
  111641. /**
  111642. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  111643. */
  111644. keysRadiusModifierCtrl: boolean;
  111645. /**
  111646. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  111647. */
  111648. keysRadiusModifierShift: boolean;
  111649. /**
  111650. * Defines the rate of change of heightOffset.
  111651. */
  111652. heightSensibility: number;
  111653. /**
  111654. * Defines the rate of change of rotationOffset.
  111655. */
  111656. rotationSensibility: number;
  111657. /**
  111658. * Defines the rate of change of radius.
  111659. */
  111660. radiusSensibility: number;
  111661. private _keys;
  111662. private _ctrlPressed;
  111663. private _altPressed;
  111664. private _shiftPressed;
  111665. private _onCanvasBlurObserver;
  111666. private _onKeyboardObserver;
  111667. private _engine;
  111668. private _scene;
  111669. /**
  111670. * Attach the input controls to a specific dom element to get the input from.
  111671. * @param element Defines the element the controls should be listened from
  111672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111673. */
  111674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111675. /**
  111676. * Detach the current controls from the specified dom element.
  111677. * @param element Defines the element to stop listening the inputs from
  111678. */
  111679. detachControl(element: Nullable<HTMLElement>): void;
  111680. /**
  111681. * Update the current camera state depending on the inputs that have been used this frame.
  111682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111683. */
  111684. checkInputs(): void;
  111685. /**
  111686. * Gets the class name of the current input.
  111687. * @returns the class name
  111688. */
  111689. getClassName(): string;
  111690. /**
  111691. * Get the friendly name associated with the input class.
  111692. * @returns the input friendly name
  111693. */
  111694. getSimpleName(): string;
  111695. /**
  111696. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111697. * allow modification of the heightOffset value.
  111698. */
  111699. private _modifierHeightOffset;
  111700. /**
  111701. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111702. * allow modification of the rotationOffset value.
  111703. */
  111704. private _modifierRotationOffset;
  111705. /**
  111706. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111707. * allow modification of the radius value.
  111708. */
  111709. private _modifierRadius;
  111710. }
  111711. }
  111712. declare module BABYLON {
  111713. interface FreeCameraInputsManager {
  111714. /**
  111715. * @hidden
  111716. */
  111717. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  111718. /**
  111719. * Add orientation input support to the input manager.
  111720. * @returns the current input manager
  111721. */
  111722. addDeviceOrientation(): FreeCameraInputsManager;
  111723. }
  111724. /**
  111725. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  111726. * Screen rotation is taken into account.
  111727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111728. */
  111729. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  111730. private _camera;
  111731. private _screenOrientationAngle;
  111732. private _constantTranform;
  111733. private _screenQuaternion;
  111734. private _alpha;
  111735. private _beta;
  111736. private _gamma;
  111737. /**
  111738. * Can be used to detect if a device orientation sensor is available on a device
  111739. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  111740. * @returns a promise that will resolve on orientation change
  111741. */
  111742. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  111743. /**
  111744. * @hidden
  111745. */
  111746. _onDeviceOrientationChangedObservable: Observable<void>;
  111747. /**
  111748. * Instantiates a new input
  111749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111750. */
  111751. constructor();
  111752. /**
  111753. * Define the camera controlled by the input.
  111754. */
  111755. get camera(): FreeCamera;
  111756. set camera(camera: FreeCamera);
  111757. /**
  111758. * Attach the input controls to a specific dom element to get the input from.
  111759. * @param element Defines the element the controls should be listened from
  111760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111761. */
  111762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111763. private _orientationChanged;
  111764. private _deviceOrientation;
  111765. /**
  111766. * Detach the current controls from the specified dom element.
  111767. * @param element Defines the element to stop listening the inputs from
  111768. */
  111769. detachControl(element: Nullable<HTMLElement>): void;
  111770. /**
  111771. * Update the current camera state depending on the inputs that have been used this frame.
  111772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111773. */
  111774. checkInputs(): void;
  111775. /**
  111776. * Gets the class name of the current intput.
  111777. * @returns the class name
  111778. */
  111779. getClassName(): string;
  111780. /**
  111781. * Get the friendly name associated with the input class.
  111782. * @returns the input friendly name
  111783. */
  111784. getSimpleName(): string;
  111785. }
  111786. }
  111787. declare module BABYLON {
  111788. /**
  111789. * Manage the gamepad inputs to control a free camera.
  111790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111791. */
  111792. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  111793. /**
  111794. * Define the camera the input is attached to.
  111795. */
  111796. camera: FreeCamera;
  111797. /**
  111798. * Define the Gamepad controlling the input
  111799. */
  111800. gamepad: Nullable<Gamepad>;
  111801. /**
  111802. * Defines the gamepad rotation sensiblity.
  111803. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111804. */
  111805. gamepadAngularSensibility: number;
  111806. /**
  111807. * Defines the gamepad move sensiblity.
  111808. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111809. */
  111810. gamepadMoveSensibility: number;
  111811. private _yAxisScale;
  111812. /**
  111813. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  111814. */
  111815. get invertYAxis(): boolean;
  111816. set invertYAxis(value: boolean);
  111817. private _onGamepadConnectedObserver;
  111818. private _onGamepadDisconnectedObserver;
  111819. private _cameraTransform;
  111820. private _deltaTransform;
  111821. private _vector3;
  111822. private _vector2;
  111823. /**
  111824. * Attach the input controls to a specific dom element to get the input from.
  111825. * @param element Defines the element the controls should be listened from
  111826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111827. */
  111828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111829. /**
  111830. * Detach the current controls from the specified dom element.
  111831. * @param element Defines the element to stop listening the inputs from
  111832. */
  111833. detachControl(element: Nullable<HTMLElement>): void;
  111834. /**
  111835. * Update the current camera state depending on the inputs that have been used this frame.
  111836. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111837. */
  111838. checkInputs(): void;
  111839. /**
  111840. * Gets the class name of the current intput.
  111841. * @returns the class name
  111842. */
  111843. getClassName(): string;
  111844. /**
  111845. * Get the friendly name associated with the input class.
  111846. * @returns the input friendly name
  111847. */
  111848. getSimpleName(): string;
  111849. }
  111850. }
  111851. declare module BABYLON {
  111852. /**
  111853. * Defines the potential axis of a Joystick
  111854. */
  111855. export enum JoystickAxis {
  111856. /** X axis */
  111857. X = 0,
  111858. /** Y axis */
  111859. Y = 1,
  111860. /** Z axis */
  111861. Z = 2
  111862. }
  111863. /**
  111864. * Class used to define virtual joystick (used in touch mode)
  111865. */
  111866. export class VirtualJoystick {
  111867. /**
  111868. * Gets or sets a boolean indicating that left and right values must be inverted
  111869. */
  111870. reverseLeftRight: boolean;
  111871. /**
  111872. * Gets or sets a boolean indicating that up and down values must be inverted
  111873. */
  111874. reverseUpDown: boolean;
  111875. /**
  111876. * Gets the offset value for the position (ie. the change of the position value)
  111877. */
  111878. deltaPosition: Vector3;
  111879. /**
  111880. * Gets a boolean indicating if the virtual joystick was pressed
  111881. */
  111882. pressed: boolean;
  111883. /**
  111884. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111885. */
  111886. static Canvas: Nullable<HTMLCanvasElement>;
  111887. private static _globalJoystickIndex;
  111888. private static vjCanvasContext;
  111889. private static vjCanvasWidth;
  111890. private static vjCanvasHeight;
  111891. private static halfWidth;
  111892. private _action;
  111893. private _axisTargetedByLeftAndRight;
  111894. private _axisTargetedByUpAndDown;
  111895. private _joystickSensibility;
  111896. private _inversedSensibility;
  111897. private _joystickPointerID;
  111898. private _joystickColor;
  111899. private _joystickPointerPos;
  111900. private _joystickPreviousPointerPos;
  111901. private _joystickPointerStartPos;
  111902. private _deltaJoystickVector;
  111903. private _leftJoystick;
  111904. private _touches;
  111905. private _onPointerDownHandlerRef;
  111906. private _onPointerMoveHandlerRef;
  111907. private _onPointerUpHandlerRef;
  111908. private _onResize;
  111909. /**
  111910. * Creates a new virtual joystick
  111911. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111912. */
  111913. constructor(leftJoystick?: boolean);
  111914. /**
  111915. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111916. * @param newJoystickSensibility defines the new sensibility
  111917. */
  111918. setJoystickSensibility(newJoystickSensibility: number): void;
  111919. private _onPointerDown;
  111920. private _onPointerMove;
  111921. private _onPointerUp;
  111922. /**
  111923. * Change the color of the virtual joystick
  111924. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111925. */
  111926. setJoystickColor(newColor: string): void;
  111927. /**
  111928. * Defines a callback to call when the joystick is touched
  111929. * @param action defines the callback
  111930. */
  111931. setActionOnTouch(action: () => any): void;
  111932. /**
  111933. * Defines which axis you'd like to control for left & right
  111934. * @param axis defines the axis to use
  111935. */
  111936. setAxisForLeftRight(axis: JoystickAxis): void;
  111937. /**
  111938. * Defines which axis you'd like to control for up & down
  111939. * @param axis defines the axis to use
  111940. */
  111941. setAxisForUpDown(axis: JoystickAxis): void;
  111942. private _drawVirtualJoystick;
  111943. /**
  111944. * Release internal HTML canvas
  111945. */
  111946. releaseCanvas(): void;
  111947. }
  111948. }
  111949. declare module BABYLON {
  111950. interface FreeCameraInputsManager {
  111951. /**
  111952. * Add virtual joystick input support to the input manager.
  111953. * @returns the current input manager
  111954. */
  111955. addVirtualJoystick(): FreeCameraInputsManager;
  111956. }
  111957. /**
  111958. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111960. */
  111961. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111962. /**
  111963. * Defines the camera the input is attached to.
  111964. */
  111965. camera: FreeCamera;
  111966. private _leftjoystick;
  111967. private _rightjoystick;
  111968. /**
  111969. * Gets the left stick of the virtual joystick.
  111970. * @returns The virtual Joystick
  111971. */
  111972. getLeftJoystick(): VirtualJoystick;
  111973. /**
  111974. * Gets the right stick of the virtual joystick.
  111975. * @returns The virtual Joystick
  111976. */
  111977. getRightJoystick(): VirtualJoystick;
  111978. /**
  111979. * Update the current camera state depending on the inputs that have been used this frame.
  111980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111981. */
  111982. checkInputs(): void;
  111983. /**
  111984. * Attach the input controls to a specific dom element to get the input from.
  111985. * @param element Defines the element the controls should be listened from
  111986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111987. */
  111988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111989. /**
  111990. * Detach the current controls from the specified dom element.
  111991. * @param element Defines the element to stop listening the inputs from
  111992. */
  111993. detachControl(element: Nullable<HTMLElement>): void;
  111994. /**
  111995. * Gets the class name of the current intput.
  111996. * @returns the class name
  111997. */
  111998. getClassName(): string;
  111999. /**
  112000. * Get the friendly name associated with the input class.
  112001. * @returns the input friendly name
  112002. */
  112003. getSimpleName(): string;
  112004. }
  112005. }
  112006. declare module BABYLON {
  112007. /**
  112008. * This represents a FPS type of camera controlled by touch.
  112009. * This is like a universal camera minus the Gamepad controls.
  112010. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112011. */
  112012. export class TouchCamera extends FreeCamera {
  112013. /**
  112014. * Defines the touch sensibility for rotation.
  112015. * The higher the faster.
  112016. */
  112017. get touchAngularSensibility(): number;
  112018. set touchAngularSensibility(value: number);
  112019. /**
  112020. * Defines the touch sensibility for move.
  112021. * The higher the faster.
  112022. */
  112023. get touchMoveSensibility(): number;
  112024. set touchMoveSensibility(value: number);
  112025. /**
  112026. * Instantiates a new touch camera.
  112027. * This represents a FPS type of camera controlled by touch.
  112028. * This is like a universal camera minus the Gamepad controls.
  112029. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112030. * @param name Define the name of the camera in the scene
  112031. * @param position Define the start position of the camera in the scene
  112032. * @param scene Define the scene the camera belongs to
  112033. */
  112034. constructor(name: string, position: Vector3, scene: Scene);
  112035. /**
  112036. * Gets the current object class name.
  112037. * @return the class name
  112038. */
  112039. getClassName(): string;
  112040. /** @hidden */
  112041. _setupInputs(): void;
  112042. }
  112043. }
  112044. declare module BABYLON {
  112045. /**
  112046. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  112047. * being tilted forward or back and left or right.
  112048. */
  112049. export class DeviceOrientationCamera extends FreeCamera {
  112050. private _initialQuaternion;
  112051. private _quaternionCache;
  112052. private _tmpDragQuaternion;
  112053. private _disablePointerInputWhenUsingDeviceOrientation;
  112054. /**
  112055. * Creates a new device orientation camera
  112056. * @param name The name of the camera
  112057. * @param position The start position camera
  112058. * @param scene The scene the camera belongs to
  112059. */
  112060. constructor(name: string, position: Vector3, scene: Scene);
  112061. /**
  112062. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  112063. */
  112064. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  112065. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  112066. private _dragFactor;
  112067. /**
  112068. * Enabled turning on the y axis when the orientation sensor is active
  112069. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  112070. */
  112071. enableHorizontalDragging(dragFactor?: number): void;
  112072. /**
  112073. * Gets the current instance class name ("DeviceOrientationCamera").
  112074. * This helps avoiding instanceof at run time.
  112075. * @returns the class name
  112076. */
  112077. getClassName(): string;
  112078. /**
  112079. * @hidden
  112080. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  112081. */
  112082. _checkInputs(): void;
  112083. /**
  112084. * Reset the camera to its default orientation on the specified axis only.
  112085. * @param axis The axis to reset
  112086. */
  112087. resetToCurrentRotation(axis?: Axis): void;
  112088. }
  112089. }
  112090. declare module BABYLON {
  112091. /**
  112092. * Defines supported buttons for XBox360 compatible gamepads
  112093. */
  112094. export enum Xbox360Button {
  112095. /** A */
  112096. A = 0,
  112097. /** B */
  112098. B = 1,
  112099. /** X */
  112100. X = 2,
  112101. /** Y */
  112102. Y = 3,
  112103. /** Start */
  112104. Start = 4,
  112105. /** Back */
  112106. Back = 5,
  112107. /** Left button */
  112108. LB = 6,
  112109. /** Right button */
  112110. RB = 7,
  112111. /** Left stick */
  112112. LeftStick = 8,
  112113. /** Right stick */
  112114. RightStick = 9
  112115. }
  112116. /** Defines values for XBox360 DPad */
  112117. export enum Xbox360Dpad {
  112118. /** Up */
  112119. Up = 0,
  112120. /** Down */
  112121. Down = 1,
  112122. /** Left */
  112123. Left = 2,
  112124. /** Right */
  112125. Right = 3
  112126. }
  112127. /**
  112128. * Defines a XBox360 gamepad
  112129. */
  112130. export class Xbox360Pad extends Gamepad {
  112131. private _leftTrigger;
  112132. private _rightTrigger;
  112133. private _onlefttriggerchanged;
  112134. private _onrighttriggerchanged;
  112135. private _onbuttondown;
  112136. private _onbuttonup;
  112137. private _ondpaddown;
  112138. private _ondpadup;
  112139. /** Observable raised when a button is pressed */
  112140. onButtonDownObservable: Observable<Xbox360Button>;
  112141. /** Observable raised when a button is released */
  112142. onButtonUpObservable: Observable<Xbox360Button>;
  112143. /** Observable raised when a pad is pressed */
  112144. onPadDownObservable: Observable<Xbox360Dpad>;
  112145. /** Observable raised when a pad is released */
  112146. onPadUpObservable: Observable<Xbox360Dpad>;
  112147. private _buttonA;
  112148. private _buttonB;
  112149. private _buttonX;
  112150. private _buttonY;
  112151. private _buttonBack;
  112152. private _buttonStart;
  112153. private _buttonLB;
  112154. private _buttonRB;
  112155. private _buttonLeftStick;
  112156. private _buttonRightStick;
  112157. private _dPadUp;
  112158. private _dPadDown;
  112159. private _dPadLeft;
  112160. private _dPadRight;
  112161. private _isXboxOnePad;
  112162. /**
  112163. * Creates a new XBox360 gamepad object
  112164. * @param id defines the id of this gamepad
  112165. * @param index defines its index
  112166. * @param gamepad defines the internal HTML gamepad object
  112167. * @param xboxOne defines if it is a XBox One gamepad
  112168. */
  112169. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  112170. /**
  112171. * Defines the callback to call when left trigger is pressed
  112172. * @param callback defines the callback to use
  112173. */
  112174. onlefttriggerchanged(callback: (value: number) => void): void;
  112175. /**
  112176. * Defines the callback to call when right trigger is pressed
  112177. * @param callback defines the callback to use
  112178. */
  112179. onrighttriggerchanged(callback: (value: number) => void): void;
  112180. /**
  112181. * Gets the left trigger value
  112182. */
  112183. get leftTrigger(): number;
  112184. /**
  112185. * Sets the left trigger value
  112186. */
  112187. set leftTrigger(newValue: number);
  112188. /**
  112189. * Gets the right trigger value
  112190. */
  112191. get rightTrigger(): number;
  112192. /**
  112193. * Sets the right trigger value
  112194. */
  112195. set rightTrigger(newValue: number);
  112196. /**
  112197. * Defines the callback to call when a button is pressed
  112198. * @param callback defines the callback to use
  112199. */
  112200. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  112201. /**
  112202. * Defines the callback to call when a button is released
  112203. * @param callback defines the callback to use
  112204. */
  112205. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  112206. /**
  112207. * Defines the callback to call when a pad is pressed
  112208. * @param callback defines the callback to use
  112209. */
  112210. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  112211. /**
  112212. * Defines the callback to call when a pad is released
  112213. * @param callback defines the callback to use
  112214. */
  112215. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  112216. private _setButtonValue;
  112217. private _setDPadValue;
  112218. /**
  112219. * Gets the value of the `A` button
  112220. */
  112221. get buttonA(): number;
  112222. /**
  112223. * Sets the value of the `A` button
  112224. */
  112225. set buttonA(value: number);
  112226. /**
  112227. * Gets the value of the `B` button
  112228. */
  112229. get buttonB(): number;
  112230. /**
  112231. * Sets the value of the `B` button
  112232. */
  112233. set buttonB(value: number);
  112234. /**
  112235. * Gets the value of the `X` button
  112236. */
  112237. get buttonX(): number;
  112238. /**
  112239. * Sets the value of the `X` button
  112240. */
  112241. set buttonX(value: number);
  112242. /**
  112243. * Gets the value of the `Y` button
  112244. */
  112245. get buttonY(): number;
  112246. /**
  112247. * Sets the value of the `Y` button
  112248. */
  112249. set buttonY(value: number);
  112250. /**
  112251. * Gets the value of the `Start` button
  112252. */
  112253. get buttonStart(): number;
  112254. /**
  112255. * Sets the value of the `Start` button
  112256. */
  112257. set buttonStart(value: number);
  112258. /**
  112259. * Gets the value of the `Back` button
  112260. */
  112261. get buttonBack(): number;
  112262. /**
  112263. * Sets the value of the `Back` button
  112264. */
  112265. set buttonBack(value: number);
  112266. /**
  112267. * Gets the value of the `Left` button
  112268. */
  112269. get buttonLB(): number;
  112270. /**
  112271. * Sets the value of the `Left` button
  112272. */
  112273. set buttonLB(value: number);
  112274. /**
  112275. * Gets the value of the `Right` button
  112276. */
  112277. get buttonRB(): number;
  112278. /**
  112279. * Sets the value of the `Right` button
  112280. */
  112281. set buttonRB(value: number);
  112282. /**
  112283. * Gets the value of the Left joystick
  112284. */
  112285. get buttonLeftStick(): number;
  112286. /**
  112287. * Sets the value of the Left joystick
  112288. */
  112289. set buttonLeftStick(value: number);
  112290. /**
  112291. * Gets the value of the Right joystick
  112292. */
  112293. get buttonRightStick(): number;
  112294. /**
  112295. * Sets the value of the Right joystick
  112296. */
  112297. set buttonRightStick(value: number);
  112298. /**
  112299. * Gets the value of D-pad up
  112300. */
  112301. get dPadUp(): number;
  112302. /**
  112303. * Sets the value of D-pad up
  112304. */
  112305. set dPadUp(value: number);
  112306. /**
  112307. * Gets the value of D-pad down
  112308. */
  112309. get dPadDown(): number;
  112310. /**
  112311. * Sets the value of D-pad down
  112312. */
  112313. set dPadDown(value: number);
  112314. /**
  112315. * Gets the value of D-pad left
  112316. */
  112317. get dPadLeft(): number;
  112318. /**
  112319. * Sets the value of D-pad left
  112320. */
  112321. set dPadLeft(value: number);
  112322. /**
  112323. * Gets the value of D-pad right
  112324. */
  112325. get dPadRight(): number;
  112326. /**
  112327. * Sets the value of D-pad right
  112328. */
  112329. set dPadRight(value: number);
  112330. /**
  112331. * Force the gamepad to synchronize with device values
  112332. */
  112333. update(): void;
  112334. /**
  112335. * Disposes the gamepad
  112336. */
  112337. dispose(): void;
  112338. }
  112339. }
  112340. declare module BABYLON {
  112341. /**
  112342. * Defines supported buttons for DualShock compatible gamepads
  112343. */
  112344. export enum DualShockButton {
  112345. /** Cross */
  112346. Cross = 0,
  112347. /** Circle */
  112348. Circle = 1,
  112349. /** Square */
  112350. Square = 2,
  112351. /** Triangle */
  112352. Triangle = 3,
  112353. /** Options */
  112354. Options = 4,
  112355. /** Share */
  112356. Share = 5,
  112357. /** L1 */
  112358. L1 = 6,
  112359. /** R1 */
  112360. R1 = 7,
  112361. /** Left stick */
  112362. LeftStick = 8,
  112363. /** Right stick */
  112364. RightStick = 9
  112365. }
  112366. /** Defines values for DualShock DPad */
  112367. export enum DualShockDpad {
  112368. /** Up */
  112369. Up = 0,
  112370. /** Down */
  112371. Down = 1,
  112372. /** Left */
  112373. Left = 2,
  112374. /** Right */
  112375. Right = 3
  112376. }
  112377. /**
  112378. * Defines a DualShock gamepad
  112379. */
  112380. export class DualShockPad extends Gamepad {
  112381. private _leftTrigger;
  112382. private _rightTrigger;
  112383. private _onlefttriggerchanged;
  112384. private _onrighttriggerchanged;
  112385. private _onbuttondown;
  112386. private _onbuttonup;
  112387. private _ondpaddown;
  112388. private _ondpadup;
  112389. /** Observable raised when a button is pressed */
  112390. onButtonDownObservable: Observable<DualShockButton>;
  112391. /** Observable raised when a button is released */
  112392. onButtonUpObservable: Observable<DualShockButton>;
  112393. /** Observable raised when a pad is pressed */
  112394. onPadDownObservable: Observable<DualShockDpad>;
  112395. /** Observable raised when a pad is released */
  112396. onPadUpObservable: Observable<DualShockDpad>;
  112397. private _buttonCross;
  112398. private _buttonCircle;
  112399. private _buttonSquare;
  112400. private _buttonTriangle;
  112401. private _buttonShare;
  112402. private _buttonOptions;
  112403. private _buttonL1;
  112404. private _buttonR1;
  112405. private _buttonLeftStick;
  112406. private _buttonRightStick;
  112407. private _dPadUp;
  112408. private _dPadDown;
  112409. private _dPadLeft;
  112410. private _dPadRight;
  112411. /**
  112412. * Creates a new DualShock gamepad object
  112413. * @param id defines the id of this gamepad
  112414. * @param index defines its index
  112415. * @param gamepad defines the internal HTML gamepad object
  112416. */
  112417. constructor(id: string, index: number, gamepad: any);
  112418. /**
  112419. * Defines the callback to call when left trigger is pressed
  112420. * @param callback defines the callback to use
  112421. */
  112422. onlefttriggerchanged(callback: (value: number) => void): void;
  112423. /**
  112424. * Defines the callback to call when right trigger is pressed
  112425. * @param callback defines the callback to use
  112426. */
  112427. onrighttriggerchanged(callback: (value: number) => void): void;
  112428. /**
  112429. * Gets the left trigger value
  112430. */
  112431. get leftTrigger(): number;
  112432. /**
  112433. * Sets the left trigger value
  112434. */
  112435. set leftTrigger(newValue: number);
  112436. /**
  112437. * Gets the right trigger value
  112438. */
  112439. get rightTrigger(): number;
  112440. /**
  112441. * Sets the right trigger value
  112442. */
  112443. set rightTrigger(newValue: number);
  112444. /**
  112445. * Defines the callback to call when a button is pressed
  112446. * @param callback defines the callback to use
  112447. */
  112448. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  112449. /**
  112450. * Defines the callback to call when a button is released
  112451. * @param callback defines the callback to use
  112452. */
  112453. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  112454. /**
  112455. * Defines the callback to call when a pad is pressed
  112456. * @param callback defines the callback to use
  112457. */
  112458. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  112459. /**
  112460. * Defines the callback to call when a pad is released
  112461. * @param callback defines the callback to use
  112462. */
  112463. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  112464. private _setButtonValue;
  112465. private _setDPadValue;
  112466. /**
  112467. * Gets the value of the `Cross` button
  112468. */
  112469. get buttonCross(): number;
  112470. /**
  112471. * Sets the value of the `Cross` button
  112472. */
  112473. set buttonCross(value: number);
  112474. /**
  112475. * Gets the value of the `Circle` button
  112476. */
  112477. get buttonCircle(): number;
  112478. /**
  112479. * Sets the value of the `Circle` button
  112480. */
  112481. set buttonCircle(value: number);
  112482. /**
  112483. * Gets the value of the `Square` button
  112484. */
  112485. get buttonSquare(): number;
  112486. /**
  112487. * Sets the value of the `Square` button
  112488. */
  112489. set buttonSquare(value: number);
  112490. /**
  112491. * Gets the value of the `Triangle` button
  112492. */
  112493. get buttonTriangle(): number;
  112494. /**
  112495. * Sets the value of the `Triangle` button
  112496. */
  112497. set buttonTriangle(value: number);
  112498. /**
  112499. * Gets the value of the `Options` button
  112500. */
  112501. get buttonOptions(): number;
  112502. /**
  112503. * Sets the value of the `Options` button
  112504. */
  112505. set buttonOptions(value: number);
  112506. /**
  112507. * Gets the value of the `Share` button
  112508. */
  112509. get buttonShare(): number;
  112510. /**
  112511. * Sets the value of the `Share` button
  112512. */
  112513. set buttonShare(value: number);
  112514. /**
  112515. * Gets the value of the `L1` button
  112516. */
  112517. get buttonL1(): number;
  112518. /**
  112519. * Sets the value of the `L1` button
  112520. */
  112521. set buttonL1(value: number);
  112522. /**
  112523. * Gets the value of the `R1` button
  112524. */
  112525. get buttonR1(): number;
  112526. /**
  112527. * Sets the value of the `R1` button
  112528. */
  112529. set buttonR1(value: number);
  112530. /**
  112531. * Gets the value of the Left joystick
  112532. */
  112533. get buttonLeftStick(): number;
  112534. /**
  112535. * Sets the value of the Left joystick
  112536. */
  112537. set buttonLeftStick(value: number);
  112538. /**
  112539. * Gets the value of the Right joystick
  112540. */
  112541. get buttonRightStick(): number;
  112542. /**
  112543. * Sets the value of the Right joystick
  112544. */
  112545. set buttonRightStick(value: number);
  112546. /**
  112547. * Gets the value of D-pad up
  112548. */
  112549. get dPadUp(): number;
  112550. /**
  112551. * Sets the value of D-pad up
  112552. */
  112553. set dPadUp(value: number);
  112554. /**
  112555. * Gets the value of D-pad down
  112556. */
  112557. get dPadDown(): number;
  112558. /**
  112559. * Sets the value of D-pad down
  112560. */
  112561. set dPadDown(value: number);
  112562. /**
  112563. * Gets the value of D-pad left
  112564. */
  112565. get dPadLeft(): number;
  112566. /**
  112567. * Sets the value of D-pad left
  112568. */
  112569. set dPadLeft(value: number);
  112570. /**
  112571. * Gets the value of D-pad right
  112572. */
  112573. get dPadRight(): number;
  112574. /**
  112575. * Sets the value of D-pad right
  112576. */
  112577. set dPadRight(value: number);
  112578. /**
  112579. * Force the gamepad to synchronize with device values
  112580. */
  112581. update(): void;
  112582. /**
  112583. * Disposes the gamepad
  112584. */
  112585. dispose(): void;
  112586. }
  112587. }
  112588. declare module BABYLON {
  112589. /**
  112590. * Manager for handling gamepads
  112591. */
  112592. export class GamepadManager {
  112593. private _scene?;
  112594. private _babylonGamepads;
  112595. private _oneGamepadConnected;
  112596. /** @hidden */
  112597. _isMonitoring: boolean;
  112598. private _gamepadEventSupported;
  112599. private _gamepadSupport?;
  112600. /**
  112601. * observable to be triggered when the gamepad controller has been connected
  112602. */
  112603. onGamepadConnectedObservable: Observable<Gamepad>;
  112604. /**
  112605. * observable to be triggered when the gamepad controller has been disconnected
  112606. */
  112607. onGamepadDisconnectedObservable: Observable<Gamepad>;
  112608. private _onGamepadConnectedEvent;
  112609. private _onGamepadDisconnectedEvent;
  112610. /**
  112611. * Initializes the gamepad manager
  112612. * @param _scene BabylonJS scene
  112613. */
  112614. constructor(_scene?: Scene | undefined);
  112615. /**
  112616. * The gamepads in the game pad manager
  112617. */
  112618. get gamepads(): Gamepad[];
  112619. /**
  112620. * Get the gamepad controllers based on type
  112621. * @param type The type of gamepad controller
  112622. * @returns Nullable gamepad
  112623. */
  112624. getGamepadByType(type?: number): Nullable<Gamepad>;
  112625. /**
  112626. * Disposes the gamepad manager
  112627. */
  112628. dispose(): void;
  112629. private _addNewGamepad;
  112630. private _startMonitoringGamepads;
  112631. private _stopMonitoringGamepads;
  112632. /** @hidden */
  112633. _checkGamepadsStatus(): void;
  112634. private _updateGamepadObjects;
  112635. }
  112636. }
  112637. declare module BABYLON {
  112638. interface Scene {
  112639. /** @hidden */
  112640. _gamepadManager: Nullable<GamepadManager>;
  112641. /**
  112642. * Gets the gamepad manager associated with the scene
  112643. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  112644. */
  112645. gamepadManager: GamepadManager;
  112646. }
  112647. /**
  112648. * Interface representing a free camera inputs manager
  112649. */
  112650. interface FreeCameraInputsManager {
  112651. /**
  112652. * Adds gamepad input support to the FreeCameraInputsManager.
  112653. * @returns the FreeCameraInputsManager
  112654. */
  112655. addGamepad(): FreeCameraInputsManager;
  112656. }
  112657. /**
  112658. * Interface representing an arc rotate camera inputs manager
  112659. */
  112660. interface ArcRotateCameraInputsManager {
  112661. /**
  112662. * Adds gamepad input support to the ArcRotateCamera InputManager.
  112663. * @returns the camera inputs manager
  112664. */
  112665. addGamepad(): ArcRotateCameraInputsManager;
  112666. }
  112667. /**
  112668. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  112669. */
  112670. export class GamepadSystemSceneComponent implements ISceneComponent {
  112671. /**
  112672. * The component name helpfull to identify the component in the list of scene components.
  112673. */
  112674. readonly name: string;
  112675. /**
  112676. * The scene the component belongs to.
  112677. */
  112678. scene: Scene;
  112679. /**
  112680. * Creates a new instance of the component for the given scene
  112681. * @param scene Defines the scene to register the component in
  112682. */
  112683. constructor(scene: Scene);
  112684. /**
  112685. * Registers the component in a given scene
  112686. */
  112687. register(): void;
  112688. /**
  112689. * Rebuilds the elements related to this component in case of
  112690. * context lost for instance.
  112691. */
  112692. rebuild(): void;
  112693. /**
  112694. * Disposes the component and the associated ressources
  112695. */
  112696. dispose(): void;
  112697. private _beforeCameraUpdate;
  112698. }
  112699. }
  112700. declare module BABYLON {
  112701. /**
  112702. * 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,
  112703. * which still works and will still be found in many Playgrounds.
  112704. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112705. */
  112706. export class UniversalCamera extends TouchCamera {
  112707. /**
  112708. * Defines the gamepad rotation sensiblity.
  112709. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112710. */
  112711. get gamepadAngularSensibility(): number;
  112712. set gamepadAngularSensibility(value: number);
  112713. /**
  112714. * Defines the gamepad move sensiblity.
  112715. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112716. */
  112717. get gamepadMoveSensibility(): number;
  112718. set gamepadMoveSensibility(value: number);
  112719. /**
  112720. * 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,
  112721. * which still works and will still be found in many Playgrounds.
  112722. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112723. * @param name Define the name of the camera in the scene
  112724. * @param position Define the start position of the camera in the scene
  112725. * @param scene Define the scene the camera belongs to
  112726. */
  112727. constructor(name: string, position: Vector3, scene: Scene);
  112728. /**
  112729. * Gets the current object class name.
  112730. * @return the class name
  112731. */
  112732. getClassName(): string;
  112733. }
  112734. }
  112735. declare module BABYLON {
  112736. /**
  112737. * This represents a FPS type of camera. This is only here for back compat purpose.
  112738. * Please use the UniversalCamera instead as both are identical.
  112739. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112740. */
  112741. export class GamepadCamera extends UniversalCamera {
  112742. /**
  112743. * Instantiates a new Gamepad Camera
  112744. * This represents a FPS type of camera. This is only here for back compat purpose.
  112745. * Please use the UniversalCamera instead as both are identical.
  112746. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112747. * @param name Define the name of the camera in the scene
  112748. * @param position Define the start position of the camera in the scene
  112749. * @param scene Define the scene the camera belongs to
  112750. */
  112751. constructor(name: string, position: Vector3, scene: Scene);
  112752. /**
  112753. * Gets the current object class name.
  112754. * @return the class name
  112755. */
  112756. getClassName(): string;
  112757. }
  112758. }
  112759. declare module BABYLON {
  112760. /** @hidden */
  112761. export var passPixelShader: {
  112762. name: string;
  112763. shader: string;
  112764. };
  112765. }
  112766. declare module BABYLON {
  112767. /** @hidden */
  112768. export var passCubePixelShader: {
  112769. name: string;
  112770. shader: string;
  112771. };
  112772. }
  112773. declare module BABYLON {
  112774. /**
  112775. * PassPostProcess which produces an output the same as it's input
  112776. */
  112777. export class PassPostProcess extends PostProcess {
  112778. /**
  112779. * Creates the PassPostProcess
  112780. * @param name The name of the effect.
  112781. * @param options The required width/height ratio to downsize to before computing the render pass.
  112782. * @param camera The camera to apply the render pass to.
  112783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112784. * @param engine The engine which the post process will be applied. (default: current engine)
  112785. * @param reusable If the post process can be reused on the same frame. (default: false)
  112786. * @param textureType The type of texture to be used when performing the post processing.
  112787. * @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)
  112788. */
  112789. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112790. }
  112791. /**
  112792. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  112793. */
  112794. export class PassCubePostProcess extends PostProcess {
  112795. private _face;
  112796. /**
  112797. * Gets or sets the cube face to display.
  112798. * * 0 is +X
  112799. * * 1 is -X
  112800. * * 2 is +Y
  112801. * * 3 is -Y
  112802. * * 4 is +Z
  112803. * * 5 is -Z
  112804. */
  112805. get face(): number;
  112806. set face(value: number);
  112807. /**
  112808. * Creates the PassCubePostProcess
  112809. * @param name The name of the effect.
  112810. * @param options The required width/height ratio to downsize to before computing the render pass.
  112811. * @param camera The camera to apply the render pass to.
  112812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112813. * @param engine The engine which the post process will be applied. (default: current engine)
  112814. * @param reusable If the post process can be reused on the same frame. (default: false)
  112815. * @param textureType The type of texture to be used when performing the post processing.
  112816. * @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)
  112817. */
  112818. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112819. }
  112820. }
  112821. declare module BABYLON {
  112822. /** @hidden */
  112823. export var anaglyphPixelShader: {
  112824. name: string;
  112825. shader: string;
  112826. };
  112827. }
  112828. declare module BABYLON {
  112829. /**
  112830. * Postprocess used to generate anaglyphic rendering
  112831. */
  112832. export class AnaglyphPostProcess extends PostProcess {
  112833. private _passedProcess;
  112834. /**
  112835. * Creates a new AnaglyphPostProcess
  112836. * @param name defines postprocess name
  112837. * @param options defines creation options or target ratio scale
  112838. * @param rigCameras defines cameras using this postprocess
  112839. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  112840. * @param engine defines hosting engine
  112841. * @param reusable defines if the postprocess will be reused multiple times per frame
  112842. */
  112843. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  112844. }
  112845. }
  112846. declare module BABYLON {
  112847. /**
  112848. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  112849. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112850. */
  112851. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  112852. /**
  112853. * Creates a new AnaglyphArcRotateCamera
  112854. * @param name defines camera name
  112855. * @param alpha defines alpha angle (in radians)
  112856. * @param beta defines beta angle (in radians)
  112857. * @param radius defines radius
  112858. * @param target defines camera target
  112859. * @param interaxialDistance defines distance between each color axis
  112860. * @param scene defines the hosting scene
  112861. */
  112862. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  112863. /**
  112864. * Gets camera class name
  112865. * @returns AnaglyphArcRotateCamera
  112866. */
  112867. getClassName(): string;
  112868. }
  112869. }
  112870. declare module BABYLON {
  112871. /**
  112872. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  112873. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112874. */
  112875. export class AnaglyphFreeCamera extends FreeCamera {
  112876. /**
  112877. * Creates a new AnaglyphFreeCamera
  112878. * @param name defines camera name
  112879. * @param position defines initial position
  112880. * @param interaxialDistance defines distance between each color axis
  112881. * @param scene defines the hosting scene
  112882. */
  112883. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112884. /**
  112885. * Gets camera class name
  112886. * @returns AnaglyphFreeCamera
  112887. */
  112888. getClassName(): string;
  112889. }
  112890. }
  112891. declare module BABYLON {
  112892. /**
  112893. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112894. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112895. */
  112896. export class AnaglyphGamepadCamera extends GamepadCamera {
  112897. /**
  112898. * Creates a new AnaglyphGamepadCamera
  112899. * @param name defines camera name
  112900. * @param position defines initial position
  112901. * @param interaxialDistance defines distance between each color axis
  112902. * @param scene defines the hosting scene
  112903. */
  112904. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112905. /**
  112906. * Gets camera class name
  112907. * @returns AnaglyphGamepadCamera
  112908. */
  112909. getClassName(): string;
  112910. }
  112911. }
  112912. declare module BABYLON {
  112913. /**
  112914. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112915. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112916. */
  112917. export class AnaglyphUniversalCamera extends UniversalCamera {
  112918. /**
  112919. * Creates a new AnaglyphUniversalCamera
  112920. * @param name defines camera name
  112921. * @param position defines initial position
  112922. * @param interaxialDistance defines distance between each color axis
  112923. * @param scene defines the hosting scene
  112924. */
  112925. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112926. /**
  112927. * Gets camera class name
  112928. * @returns AnaglyphUniversalCamera
  112929. */
  112930. getClassName(): string;
  112931. }
  112932. }
  112933. declare module BABYLON {
  112934. /** @hidden */
  112935. export var stereoscopicInterlacePixelShader: {
  112936. name: string;
  112937. shader: string;
  112938. };
  112939. }
  112940. declare module BABYLON {
  112941. /**
  112942. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112943. */
  112944. export class StereoscopicInterlacePostProcess extends PostProcess {
  112945. private _stepSize;
  112946. private _passedProcess;
  112947. /**
  112948. * Initializes a StereoscopicInterlacePostProcess
  112949. * @param name The name of the effect.
  112950. * @param rigCameras The rig cameras to be appled to the post process
  112951. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112953. * @param engine The engine which the post process will be applied. (default: current engine)
  112954. * @param reusable If the post process can be reused on the same frame. (default: false)
  112955. */
  112956. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112957. }
  112958. }
  112959. declare module BABYLON {
  112960. /**
  112961. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112962. * @see http://doc.babylonjs.com/features/cameras
  112963. */
  112964. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112965. /**
  112966. * Creates a new StereoscopicArcRotateCamera
  112967. * @param name defines camera name
  112968. * @param alpha defines alpha angle (in radians)
  112969. * @param beta defines beta angle (in radians)
  112970. * @param radius defines radius
  112971. * @param target defines camera target
  112972. * @param interaxialDistance defines distance between each color axis
  112973. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112974. * @param scene defines the hosting scene
  112975. */
  112976. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112977. /**
  112978. * Gets camera class name
  112979. * @returns StereoscopicArcRotateCamera
  112980. */
  112981. getClassName(): string;
  112982. }
  112983. }
  112984. declare module BABYLON {
  112985. /**
  112986. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112987. * @see http://doc.babylonjs.com/features/cameras
  112988. */
  112989. export class StereoscopicFreeCamera extends FreeCamera {
  112990. /**
  112991. * Creates a new StereoscopicFreeCamera
  112992. * @param name defines camera name
  112993. * @param position defines initial position
  112994. * @param interaxialDistance defines distance between each color axis
  112995. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112996. * @param scene defines the hosting scene
  112997. */
  112998. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112999. /**
  113000. * Gets camera class name
  113001. * @returns StereoscopicFreeCamera
  113002. */
  113003. getClassName(): string;
  113004. }
  113005. }
  113006. declare module BABYLON {
  113007. /**
  113008. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  113009. * @see http://doc.babylonjs.com/features/cameras
  113010. */
  113011. export class StereoscopicGamepadCamera extends GamepadCamera {
  113012. /**
  113013. * Creates a new StereoscopicGamepadCamera
  113014. * @param name defines camera name
  113015. * @param position defines initial position
  113016. * @param interaxialDistance defines distance between each color axis
  113017. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  113018. * @param scene defines the hosting scene
  113019. */
  113020. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  113021. /**
  113022. * Gets camera class name
  113023. * @returns StereoscopicGamepadCamera
  113024. */
  113025. getClassName(): string;
  113026. }
  113027. }
  113028. declare module BABYLON {
  113029. /**
  113030. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  113031. * @see http://doc.babylonjs.com/features/cameras
  113032. */
  113033. export class StereoscopicUniversalCamera extends UniversalCamera {
  113034. /**
  113035. * Creates a new StereoscopicUniversalCamera
  113036. * @param name defines camera name
  113037. * @param position defines initial position
  113038. * @param interaxialDistance defines distance between each color axis
  113039. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  113040. * @param scene defines the hosting scene
  113041. */
  113042. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  113043. /**
  113044. * Gets camera class name
  113045. * @returns StereoscopicUniversalCamera
  113046. */
  113047. getClassName(): string;
  113048. }
  113049. }
  113050. declare module BABYLON {
  113051. /**
  113052. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  113053. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  113054. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  113055. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  113056. */
  113057. export class VirtualJoysticksCamera extends FreeCamera {
  113058. /**
  113059. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  113060. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  113061. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  113062. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  113063. * @param name Define the name of the camera in the scene
  113064. * @param position Define the start position of the camera in the scene
  113065. * @param scene Define the scene the camera belongs to
  113066. */
  113067. constructor(name: string, position: Vector3, scene: Scene);
  113068. /**
  113069. * Gets the current object class name.
  113070. * @return the class name
  113071. */
  113072. getClassName(): string;
  113073. }
  113074. }
  113075. declare module BABYLON {
  113076. /**
  113077. * This represents all the required metrics to create a VR camera.
  113078. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  113079. */
  113080. export class VRCameraMetrics {
  113081. /**
  113082. * Define the horizontal resolution off the screen.
  113083. */
  113084. hResolution: number;
  113085. /**
  113086. * Define the vertical resolution off the screen.
  113087. */
  113088. vResolution: number;
  113089. /**
  113090. * Define the horizontal screen size.
  113091. */
  113092. hScreenSize: number;
  113093. /**
  113094. * Define the vertical screen size.
  113095. */
  113096. vScreenSize: number;
  113097. /**
  113098. * Define the vertical screen center position.
  113099. */
  113100. vScreenCenter: number;
  113101. /**
  113102. * Define the distance of the eyes to the screen.
  113103. */
  113104. eyeToScreenDistance: number;
  113105. /**
  113106. * Define the distance between both lenses
  113107. */
  113108. lensSeparationDistance: number;
  113109. /**
  113110. * Define the distance between both viewer's eyes.
  113111. */
  113112. interpupillaryDistance: number;
  113113. /**
  113114. * Define the distortion factor of the VR postprocess.
  113115. * Please, touch with care.
  113116. */
  113117. distortionK: number[];
  113118. /**
  113119. * Define the chromatic aberration correction factors for the VR post process.
  113120. */
  113121. chromaAbCorrection: number[];
  113122. /**
  113123. * Define the scale factor of the post process.
  113124. * The smaller the better but the slower.
  113125. */
  113126. postProcessScaleFactor: number;
  113127. /**
  113128. * Define an offset for the lens center.
  113129. */
  113130. lensCenterOffset: number;
  113131. /**
  113132. * Define if the current vr camera should compensate the distortion of the lense or not.
  113133. */
  113134. compensateDistortion: boolean;
  113135. /**
  113136. * Defines if multiview should be enabled when rendering (Default: false)
  113137. */
  113138. multiviewEnabled: boolean;
  113139. /**
  113140. * Gets the rendering aspect ratio based on the provided resolutions.
  113141. */
  113142. get aspectRatio(): number;
  113143. /**
  113144. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  113145. */
  113146. get aspectRatioFov(): number;
  113147. /**
  113148. * @hidden
  113149. */
  113150. get leftHMatrix(): Matrix;
  113151. /**
  113152. * @hidden
  113153. */
  113154. get rightHMatrix(): Matrix;
  113155. /**
  113156. * @hidden
  113157. */
  113158. get leftPreViewMatrix(): Matrix;
  113159. /**
  113160. * @hidden
  113161. */
  113162. get rightPreViewMatrix(): Matrix;
  113163. /**
  113164. * Get the default VRMetrics based on the most generic setup.
  113165. * @returns the default vr metrics
  113166. */
  113167. static GetDefault(): VRCameraMetrics;
  113168. }
  113169. }
  113170. declare module BABYLON {
  113171. /** @hidden */
  113172. export var vrDistortionCorrectionPixelShader: {
  113173. name: string;
  113174. shader: string;
  113175. };
  113176. }
  113177. declare module BABYLON {
  113178. /**
  113179. * VRDistortionCorrectionPostProcess used for mobile VR
  113180. */
  113181. export class VRDistortionCorrectionPostProcess extends PostProcess {
  113182. private _isRightEye;
  113183. private _distortionFactors;
  113184. private _postProcessScaleFactor;
  113185. private _lensCenterOffset;
  113186. private _scaleIn;
  113187. private _scaleFactor;
  113188. private _lensCenter;
  113189. /**
  113190. * Initializes the VRDistortionCorrectionPostProcess
  113191. * @param name The name of the effect.
  113192. * @param camera The camera to apply the render pass to.
  113193. * @param isRightEye If this is for the right eye distortion
  113194. * @param vrMetrics All the required metrics for the VR camera
  113195. */
  113196. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  113197. }
  113198. }
  113199. declare module BABYLON {
  113200. /**
  113201. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  113202. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  113203. */
  113204. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  113205. /**
  113206. * Creates a new VRDeviceOrientationArcRotateCamera
  113207. * @param name defines camera name
  113208. * @param alpha defines the camera rotation along the logitudinal axis
  113209. * @param beta defines the camera rotation along the latitudinal axis
  113210. * @param radius defines the camera distance from its target
  113211. * @param target defines the camera target
  113212. * @param scene defines the scene the camera belongs to
  113213. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  113214. * @param vrCameraMetrics defines the vr metrics associated to the camera
  113215. */
  113216. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  113217. /**
  113218. * Gets camera class name
  113219. * @returns VRDeviceOrientationArcRotateCamera
  113220. */
  113221. getClassName(): string;
  113222. }
  113223. }
  113224. declare module BABYLON {
  113225. /**
  113226. * Camera used to simulate VR rendering (based on FreeCamera)
  113227. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  113228. */
  113229. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  113230. /**
  113231. * Creates a new VRDeviceOrientationFreeCamera
  113232. * @param name defines camera name
  113233. * @param position defines the start position of the camera
  113234. * @param scene defines the scene the camera belongs to
  113235. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  113236. * @param vrCameraMetrics defines the vr metrics associated to the camera
  113237. */
  113238. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  113239. /**
  113240. * Gets camera class name
  113241. * @returns VRDeviceOrientationFreeCamera
  113242. */
  113243. getClassName(): string;
  113244. }
  113245. }
  113246. declare module BABYLON {
  113247. /**
  113248. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  113249. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  113250. */
  113251. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  113252. /**
  113253. * Creates a new VRDeviceOrientationGamepadCamera
  113254. * @param name defines camera name
  113255. * @param position defines the start position of the camera
  113256. * @param scene defines the scene the camera belongs to
  113257. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  113258. * @param vrCameraMetrics defines the vr metrics associated to the camera
  113259. */
  113260. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  113261. /**
  113262. * Gets camera class name
  113263. * @returns VRDeviceOrientationGamepadCamera
  113264. */
  113265. getClassName(): string;
  113266. }
  113267. }
  113268. declare module BABYLON {
  113269. /** @hidden */
  113270. export var imageProcessingPixelShader: {
  113271. name: string;
  113272. shader: string;
  113273. };
  113274. }
  113275. declare module BABYLON {
  113276. /**
  113277. * ImageProcessingPostProcess
  113278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  113279. */
  113280. export class ImageProcessingPostProcess extends PostProcess {
  113281. /**
  113282. * Default configuration related to image processing available in the PBR Material.
  113283. */
  113284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113285. /**
  113286. * Gets the image processing configuration used either in this material.
  113287. */
  113288. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  113289. /**
  113290. * Sets the Default image processing configuration used either in the this material.
  113291. *
  113292. * If sets to null, the scene one is in use.
  113293. */
  113294. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  113295. /**
  113296. * Keep track of the image processing observer to allow dispose and replace.
  113297. */
  113298. private _imageProcessingObserver;
  113299. /**
  113300. * Attaches a new image processing configuration to the PBR Material.
  113301. * @param configuration
  113302. */
  113303. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  113304. /**
  113305. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  113306. */
  113307. get colorCurves(): Nullable<ColorCurves>;
  113308. /**
  113309. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  113310. */
  113311. set colorCurves(value: Nullable<ColorCurves>);
  113312. /**
  113313. * Gets wether the color curves effect is enabled.
  113314. */
  113315. get colorCurvesEnabled(): boolean;
  113316. /**
  113317. * Sets wether the color curves effect is enabled.
  113318. */
  113319. set colorCurvesEnabled(value: boolean);
  113320. /**
  113321. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  113322. */
  113323. get colorGradingTexture(): Nullable<BaseTexture>;
  113324. /**
  113325. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  113326. */
  113327. set colorGradingTexture(value: Nullable<BaseTexture>);
  113328. /**
  113329. * Gets wether the color grading effect is enabled.
  113330. */
  113331. get colorGradingEnabled(): boolean;
  113332. /**
  113333. * Gets wether the color grading effect is enabled.
  113334. */
  113335. set colorGradingEnabled(value: boolean);
  113336. /**
  113337. * Gets exposure used in the effect.
  113338. */
  113339. get exposure(): number;
  113340. /**
  113341. * Sets exposure used in the effect.
  113342. */
  113343. set exposure(value: number);
  113344. /**
  113345. * Gets wether tonemapping is enabled or not.
  113346. */
  113347. get toneMappingEnabled(): boolean;
  113348. /**
  113349. * Sets wether tonemapping is enabled or not
  113350. */
  113351. set toneMappingEnabled(value: boolean);
  113352. /**
  113353. * Gets the type of tone mapping effect.
  113354. */
  113355. get toneMappingType(): number;
  113356. /**
  113357. * Sets the type of tone mapping effect.
  113358. */
  113359. set toneMappingType(value: number);
  113360. /**
  113361. * Gets contrast used in the effect.
  113362. */
  113363. get contrast(): number;
  113364. /**
  113365. * Sets contrast used in the effect.
  113366. */
  113367. set contrast(value: number);
  113368. /**
  113369. * Gets Vignette stretch size.
  113370. */
  113371. get vignetteStretch(): number;
  113372. /**
  113373. * Sets Vignette stretch size.
  113374. */
  113375. set vignetteStretch(value: number);
  113376. /**
  113377. * Gets Vignette centre X Offset.
  113378. */
  113379. get vignetteCentreX(): number;
  113380. /**
  113381. * Sets Vignette centre X Offset.
  113382. */
  113383. set vignetteCentreX(value: number);
  113384. /**
  113385. * Gets Vignette centre Y Offset.
  113386. */
  113387. get vignetteCentreY(): number;
  113388. /**
  113389. * Sets Vignette centre Y Offset.
  113390. */
  113391. set vignetteCentreY(value: number);
  113392. /**
  113393. * Gets Vignette weight or intensity of the vignette effect.
  113394. */
  113395. get vignetteWeight(): number;
  113396. /**
  113397. * Sets Vignette weight or intensity of the vignette effect.
  113398. */
  113399. set vignetteWeight(value: number);
  113400. /**
  113401. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  113402. * if vignetteEnabled is set to true.
  113403. */
  113404. get vignetteColor(): Color4;
  113405. /**
  113406. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  113407. * if vignetteEnabled is set to true.
  113408. */
  113409. set vignetteColor(value: Color4);
  113410. /**
  113411. * Gets Camera field of view used by the Vignette effect.
  113412. */
  113413. get vignetteCameraFov(): number;
  113414. /**
  113415. * Sets Camera field of view used by the Vignette effect.
  113416. */
  113417. set vignetteCameraFov(value: number);
  113418. /**
  113419. * Gets the vignette blend mode allowing different kind of effect.
  113420. */
  113421. get vignetteBlendMode(): number;
  113422. /**
  113423. * Sets the vignette blend mode allowing different kind of effect.
  113424. */
  113425. set vignetteBlendMode(value: number);
  113426. /**
  113427. * Gets wether the vignette effect is enabled.
  113428. */
  113429. get vignetteEnabled(): boolean;
  113430. /**
  113431. * Sets wether the vignette effect is enabled.
  113432. */
  113433. set vignetteEnabled(value: boolean);
  113434. private _fromLinearSpace;
  113435. /**
  113436. * Gets wether the input of the processing is in Gamma or Linear Space.
  113437. */
  113438. get fromLinearSpace(): boolean;
  113439. /**
  113440. * Sets wether the input of the processing is in Gamma or Linear Space.
  113441. */
  113442. set fromLinearSpace(value: boolean);
  113443. /**
  113444. * Defines cache preventing GC.
  113445. */
  113446. private _defines;
  113447. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  113448. /**
  113449. * "ImageProcessingPostProcess"
  113450. * @returns "ImageProcessingPostProcess"
  113451. */
  113452. getClassName(): string;
  113453. protected _updateParameters(): void;
  113454. dispose(camera?: Camera): void;
  113455. }
  113456. }
  113457. declare module BABYLON {
  113458. /**
  113459. * Class containing static functions to help procedurally build meshes
  113460. */
  113461. export class GroundBuilder {
  113462. /**
  113463. * Creates a ground mesh
  113464. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  113465. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  113466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113467. * @param name defines the name of the mesh
  113468. * @param options defines the options used to create the mesh
  113469. * @param scene defines the hosting scene
  113470. * @returns the ground mesh
  113471. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  113472. */
  113473. static CreateGround(name: string, options: {
  113474. width?: number;
  113475. height?: number;
  113476. subdivisions?: number;
  113477. subdivisionsX?: number;
  113478. subdivisionsY?: number;
  113479. updatable?: boolean;
  113480. }, scene: any): Mesh;
  113481. /**
  113482. * Creates a tiled ground mesh
  113483. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  113484. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  113485. * * 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
  113486. * * 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
  113487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113488. * @param name defines the name of the mesh
  113489. * @param options defines the options used to create the mesh
  113490. * @param scene defines the hosting scene
  113491. * @returns the tiled ground mesh
  113492. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  113493. */
  113494. static CreateTiledGround(name: string, options: {
  113495. xmin: number;
  113496. zmin: number;
  113497. xmax: number;
  113498. zmax: number;
  113499. subdivisions?: {
  113500. w: number;
  113501. h: number;
  113502. };
  113503. precision?: {
  113504. w: number;
  113505. h: number;
  113506. };
  113507. updatable?: boolean;
  113508. }, scene?: Nullable<Scene>): Mesh;
  113509. /**
  113510. * Creates a ground mesh from a height map
  113511. * * The parameter `url` sets the URL of the height map image resource.
  113512. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  113513. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  113514. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  113515. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  113516. * * 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.
  113517. * * 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).
  113518. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  113519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113520. * @param name defines the name of the mesh
  113521. * @param url defines the url to the height map
  113522. * @param options defines the options used to create the mesh
  113523. * @param scene defines the hosting scene
  113524. * @returns the ground mesh
  113525. * @see https://doc.babylonjs.com/babylon101/height_map
  113526. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  113527. */
  113528. static CreateGroundFromHeightMap(name: string, url: string, options: {
  113529. width?: number;
  113530. height?: number;
  113531. subdivisions?: number;
  113532. minHeight?: number;
  113533. maxHeight?: number;
  113534. colorFilter?: Color3;
  113535. alphaFilter?: number;
  113536. updatable?: boolean;
  113537. onReady?: (mesh: GroundMesh) => void;
  113538. }, scene?: Nullable<Scene>): GroundMesh;
  113539. }
  113540. }
  113541. declare module BABYLON {
  113542. /**
  113543. * Class containing static functions to help procedurally build meshes
  113544. */
  113545. export class TorusBuilder {
  113546. /**
  113547. * Creates a torus mesh
  113548. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  113549. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  113550. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  113551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113554. * @param name defines the name of the mesh
  113555. * @param options defines the options used to create the mesh
  113556. * @param scene defines the hosting scene
  113557. * @returns the torus mesh
  113558. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  113559. */
  113560. static CreateTorus(name: string, options: {
  113561. diameter?: number;
  113562. thickness?: number;
  113563. tessellation?: number;
  113564. updatable?: boolean;
  113565. sideOrientation?: number;
  113566. frontUVs?: Vector4;
  113567. backUVs?: Vector4;
  113568. }, scene: any): Mesh;
  113569. }
  113570. }
  113571. declare module BABYLON {
  113572. /**
  113573. * Class containing static functions to help procedurally build meshes
  113574. */
  113575. export class CylinderBuilder {
  113576. /**
  113577. * Creates a cylinder or a cone mesh
  113578. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  113579. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  113580. * * 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.
  113581. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  113582. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  113583. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  113584. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  113585. * * 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).
  113586. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  113587. * * 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).
  113588. * * 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
  113589. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  113590. * * 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
  113591. * * 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.
  113592. * * If `enclose` is false, a ring surface is one element.
  113593. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  113594. * * 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
  113595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113598. * @param name defines the name of the mesh
  113599. * @param options defines the options used to create the mesh
  113600. * @param scene defines the hosting scene
  113601. * @returns the cylinder mesh
  113602. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  113603. */
  113604. static CreateCylinder(name: string, options: {
  113605. height?: number;
  113606. diameterTop?: number;
  113607. diameterBottom?: number;
  113608. diameter?: number;
  113609. tessellation?: number;
  113610. subdivisions?: number;
  113611. arc?: number;
  113612. faceColors?: Color4[];
  113613. faceUV?: Vector4[];
  113614. updatable?: boolean;
  113615. hasRings?: boolean;
  113616. enclose?: boolean;
  113617. cap?: number;
  113618. sideOrientation?: number;
  113619. frontUVs?: Vector4;
  113620. backUVs?: Vector4;
  113621. }, scene: any): Mesh;
  113622. }
  113623. }
  113624. declare module BABYLON {
  113625. /**
  113626. * States of the webXR experience
  113627. */
  113628. export enum WebXRState {
  113629. /**
  113630. * Transitioning to being in XR mode
  113631. */
  113632. ENTERING_XR = 0,
  113633. /**
  113634. * Transitioning to non XR mode
  113635. */
  113636. EXITING_XR = 1,
  113637. /**
  113638. * In XR mode and presenting
  113639. */
  113640. IN_XR = 2,
  113641. /**
  113642. * Not entered XR mode
  113643. */
  113644. NOT_IN_XR = 3
  113645. }
  113646. /**
  113647. * Abstraction of the XR render target
  113648. */
  113649. export interface WebXRRenderTarget extends IDisposable {
  113650. /**
  113651. * xrpresent context of the canvas which can be used to display/mirror xr content
  113652. */
  113653. canvasContext: WebGLRenderingContext;
  113654. /**
  113655. * xr layer for the canvas
  113656. */
  113657. xrLayer: Nullable<XRWebGLLayer>;
  113658. /**
  113659. * Initializes the xr layer for the session
  113660. * @param xrSession xr session
  113661. * @returns a promise that will resolve once the XR Layer has been created
  113662. */
  113663. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  113664. }
  113665. }
  113666. declare module BABYLON {
  113667. /**
  113668. * COnfiguration object for WebXR output canvas
  113669. */
  113670. export class WebXRManagedOutputCanvasOptions {
  113671. /**
  113672. * Options for this XR Layer output
  113673. */
  113674. canvasOptions: XRWebGLLayerOptions;
  113675. /**
  113676. * CSS styling for a newly created canvas (if not provided)
  113677. */
  113678. newCanvasCssStyle?: string;
  113679. /**
  113680. * Get the default values of the configuration object
  113681. * @returns default values of this configuration object
  113682. */
  113683. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  113684. }
  113685. /**
  113686. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  113687. */
  113688. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  113689. private configuration;
  113690. private _engine;
  113691. private _canvas;
  113692. /**
  113693. * xrpresent context of the canvas which can be used to display/mirror xr content
  113694. */
  113695. canvasContext: WebGLRenderingContext;
  113696. /**
  113697. * xr layer for the canvas
  113698. */
  113699. xrLayer: Nullable<XRWebGLLayer>;
  113700. /**
  113701. * Initializes the xr layer for the session
  113702. * @param xrSession xr session
  113703. * @returns a promise that will resolve once the XR Layer has been created
  113704. */
  113705. initializeXRLayerAsync(xrSession: any): any;
  113706. /**
  113707. * Initializes the canvas to be added/removed upon entering/exiting xr
  113708. * @param engine the Babylon engine
  113709. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  113710. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  113711. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  113712. */
  113713. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  113714. /**
  113715. * Disposes of the object
  113716. */
  113717. dispose(): void;
  113718. private _setManagedOutputCanvas;
  113719. private _addCanvas;
  113720. private _removeCanvas;
  113721. }
  113722. }
  113723. declare module BABYLON {
  113724. /**
  113725. * Manages an XRSession to work with Babylon's engine
  113726. * @see https://doc.babylonjs.com/how_to/webxr
  113727. */
  113728. export class WebXRSessionManager implements IDisposable {
  113729. /** The scene which the session should be created for */
  113730. scene: Scene;
  113731. /**
  113732. * Fires every time a new xrFrame arrives which can be used to update the camera
  113733. */
  113734. onXRFrameObservable: Observable<XRFrame>;
  113735. /**
  113736. * Fires when the xr session is ended either by the device or manually done
  113737. */
  113738. onXRSessionEnded: Observable<any>;
  113739. /**
  113740. * Fires when the xr session is ended either by the device or manually done
  113741. */
  113742. onXRSessionInit: Observable<XRSession>;
  113743. /**
  113744. * Underlying xr session
  113745. */
  113746. session: XRSession;
  113747. /**
  113748. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  113749. * or get the offset the player is currently at.
  113750. */
  113751. viewerReferenceSpace: XRReferenceSpace;
  113752. /**
  113753. * The current reference space used in this session. This reference space can constantly change!
  113754. * It is mainly used to offset the camera's position.
  113755. */
  113756. referenceSpace: XRReferenceSpace;
  113757. /**
  113758. * The base reference space from which the session started. good if you want to reset your
  113759. * reference space
  113760. */
  113761. baseReferenceSpace: XRReferenceSpace;
  113762. /**
  113763. * Used just in case of a failure to initialize an immersive session.
  113764. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  113765. */
  113766. defaultHeightCompensation: number;
  113767. /**
  113768. * Current XR frame
  113769. */
  113770. currentFrame: Nullable<XRFrame>;
  113771. /** WebXR timestamp updated every frame */
  113772. currentTimestamp: number;
  113773. private _xrNavigator;
  113774. private baseLayer;
  113775. private _rttProvider;
  113776. private _sessionEnded;
  113777. /**
  113778. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  113779. * @param scene The scene which the session should be created for
  113780. */
  113781. constructor(
  113782. /** The scene which the session should be created for */
  113783. scene: Scene);
  113784. /**
  113785. * Initializes the manager
  113786. * After initialization enterXR can be called to start an XR session
  113787. * @returns Promise which resolves after it is initialized
  113788. */
  113789. initializeAsync(): Promise<void>;
  113790. /**
  113791. * Initializes an xr session
  113792. * @param xrSessionMode mode to initialize
  113793. * @param optionalFeatures defines optional values to pass to the session builder
  113794. * @returns a promise which will resolve once the session has been initialized
  113795. */
  113796. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  113797. /**
  113798. * Sets the reference space on the xr session
  113799. * @param referenceSpace space to set
  113800. * @returns a promise that will resolve once the reference space has been set
  113801. */
  113802. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  113803. /**
  113804. * Updates the render state of the session
  113805. * @param state state to set
  113806. * @returns a promise that resolves once the render state has been updated
  113807. */
  113808. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  113809. /**
  113810. * Starts rendering to the xr layer
  113811. * @returns a promise that will resolve once rendering has started
  113812. */
  113813. startRenderingToXRAsync(): Promise<void>;
  113814. /**
  113815. * Gets the correct render target texture to be rendered this frame for this eye
  113816. * @param eye the eye for which to get the render target
  113817. * @returns the render target for the specified eye
  113818. */
  113819. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  113820. /**
  113821. * Stops the xrSession and restores the renderloop
  113822. * @returns Promise which resolves after it exits XR
  113823. */
  113824. exitXRAsync(): Promise<void>;
  113825. /**
  113826. * Checks if a session would be supported for the creation options specified
  113827. * @param sessionMode session mode to check if supported eg. immersive-vr
  113828. * @returns true if supported
  113829. */
  113830. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113831. /**
  113832. * Creates a WebXRRenderTarget object for the XR session
  113833. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  113834. * @param options optional options to provide when creating a new render target
  113835. * @returns a WebXR render target to which the session can render
  113836. */
  113837. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  113838. /**
  113839. * @hidden
  113840. * Converts the render layer of xrSession to a render target
  113841. * @param session session to create render target for
  113842. * @param scene scene the new render target should be created for
  113843. * @param baseLayer the webgl layer to create the render target for
  113844. */
  113845. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  113846. /**
  113847. * Disposes of the session manager
  113848. */
  113849. dispose(): void;
  113850. /**
  113851. * Gets a promise returning true when fullfiled if the given session mode is supported
  113852. * @param sessionMode defines the session to test
  113853. * @returns a promise
  113854. */
  113855. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113856. }
  113857. }
  113858. declare module BABYLON {
  113859. /**
  113860. * WebXR Camera which holds the views for the xrSession
  113861. * @see https://doc.babylonjs.com/how_to/webxr
  113862. */
  113863. export class WebXRCamera extends FreeCamera {
  113864. private _xrSessionManager;
  113865. /**
  113866. * Is the camera in debug mode. Used when using an emulator
  113867. */
  113868. debugMode: boolean;
  113869. private _firstFrame;
  113870. private _referencedPosition;
  113871. private _referenceQuaternion;
  113872. private _xrInvPositionCache;
  113873. private _xrInvQuaternionCache;
  113874. /**
  113875. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  113876. * @param name the name of the camera
  113877. * @param scene the scene to add the camera to
  113878. */
  113879. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  113880. private _updateNumberOfRigCameras;
  113881. /** @hidden */
  113882. _updateForDualEyeDebugging(): void;
  113883. private _updateReferenceSpace;
  113884. private _updateReferenceSpaceOffset;
  113885. private _updateFromXRSession;
  113886. }
  113887. }
  113888. declare module BABYLON {
  113889. /**
  113890. * Defining the interface required for a (webxr) feature
  113891. */
  113892. export interface IWebXRFeature extends IDisposable {
  113893. /**
  113894. * Attach the feature to the session
  113895. * Will usually be called by the features manager
  113896. *
  113897. * @returns true if successful.
  113898. */
  113899. attach(): boolean;
  113900. /**
  113901. * Detach the feature from the session
  113902. * Will usually be called by the features manager
  113903. *
  113904. * @returns true if successful.
  113905. */
  113906. detach(): boolean;
  113907. }
  113908. /**
  113909. * Defining the constructor of a feature. Used to register the modules.
  113910. */
  113911. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113912. /**
  113913. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113914. * It is mainly used in AR sessions.
  113915. *
  113916. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113917. */
  113918. export class WebXRFeaturesManager implements IDisposable {
  113919. private _xrSessionManager;
  113920. private static readonly _AvailableFeatures;
  113921. /**
  113922. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113923. * Mainly used internally.
  113924. *
  113925. * @param featureName the name of the feature to register
  113926. * @param constructorFunction the function used to construct the module
  113927. * @param version the (babylon) version of the module
  113928. * @param stable is that a stable version of this module
  113929. */
  113930. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113931. /**
  113932. * Returns a constructor of a specific feature.
  113933. *
  113934. * @param featureName the name of the feature to construct
  113935. * @param version the version of the feature to load
  113936. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113937. * @param options optional options provided to the module.
  113938. * @returns a function that, when called, will return a new instance of this feature
  113939. */
  113940. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113941. /**
  113942. * Return the latest unstable version of this feature
  113943. * @param featureName the name of the feature to search
  113944. * @returns the version number. if not found will return -1
  113945. */
  113946. static GetLatestVersionOfFeature(featureName: string): number;
  113947. /**
  113948. * Return the latest stable version of this feature
  113949. * @param featureName the name of the feature to search
  113950. * @returns the version number. if not found will return -1
  113951. */
  113952. static GetStableVersionOfFeature(featureName: string): number;
  113953. /**
  113954. * Can be used to return the list of features currently registered
  113955. *
  113956. * @returns an Array of available features
  113957. */
  113958. static GetAvailableFeatures(): string[];
  113959. /**
  113960. * Gets the versions available for a specific feature
  113961. * @param featureName the name of the feature
  113962. * @returns an array with the available versions
  113963. */
  113964. static GetAvailableVersions(featureName: string): string[];
  113965. private _features;
  113966. /**
  113967. * constructs a new features manages.
  113968. *
  113969. * @param _xrSessionManager an instance of WebXRSessionManager
  113970. */
  113971. constructor(_xrSessionManager: WebXRSessionManager);
  113972. /**
  113973. * 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.
  113974. *
  113975. * @param featureName the name of the feature to load or the class of the feature
  113976. * @param version optional version to load. if not provided the latest version will be enabled
  113977. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113978. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113979. * @returns a new constructed feature or throws an error if feature not found.
  113980. */
  113981. enableFeature(featureName: string | {
  113982. Name: string;
  113983. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113984. /**
  113985. * Used to disable an already-enabled feature
  113986. * @param featureName the feature to disable
  113987. * @returns true if disable was successful
  113988. */
  113989. disableFeature(featureName: string | {
  113990. Name: string;
  113991. }): boolean;
  113992. /**
  113993. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  113994. * Can be used during a session to start a feature
  113995. * @param featureName the name of feature to attach
  113996. */
  113997. attachFeature(featureName: string): void;
  113998. /**
  113999. * Can be used inside a session or when the session ends to detach a specific feature
  114000. * @param featureName the name of the feature to detach
  114001. */
  114002. detachFeature(featureName: string): void;
  114003. /**
  114004. * Get the list of enabled features
  114005. * @returns an array of enabled features
  114006. */
  114007. getEnabledFeatures(): string[];
  114008. /**
  114009. * get the implementation of an enabled feature.
  114010. * @param featureName the name of the feature to load
  114011. * @returns the feature class, if found
  114012. */
  114013. getEnabledFeature(featureName: string): IWebXRFeature;
  114014. /**
  114015. * dispose this features manager
  114016. */
  114017. dispose(): void;
  114018. }
  114019. }
  114020. declare module BABYLON {
  114021. /**
  114022. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  114023. * @see https://doc.babylonjs.com/how_to/webxr
  114024. */
  114025. export class WebXRExperienceHelper implements IDisposable {
  114026. private scene;
  114027. /**
  114028. * Camera used to render xr content
  114029. */
  114030. camera: WebXRCamera;
  114031. /**
  114032. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  114033. */
  114034. state: WebXRState;
  114035. private _setState;
  114036. /**
  114037. * Fires when the state of the experience helper has changed
  114038. */
  114039. onStateChangedObservable: Observable<WebXRState>;
  114040. /**
  114041. * Observers registered here will be triggered after the camera's initial transformation is set
  114042. * This can be used to set a different ground level or an extra rotation.
  114043. *
  114044. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  114045. * to the position set after this observable is done executing.
  114046. */
  114047. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  114048. /** Session manager used to keep track of xr session */
  114049. sessionManager: WebXRSessionManager;
  114050. /** A features manager for this xr session */
  114051. featuresManager: WebXRFeaturesManager;
  114052. private _nonVRCamera;
  114053. private _originalSceneAutoClear;
  114054. private _supported;
  114055. /**
  114056. * Creates the experience helper
  114057. * @param scene the scene to attach the experience helper to
  114058. * @returns a promise for the experience helper
  114059. */
  114060. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  114061. /**
  114062. * Creates a WebXRExperienceHelper
  114063. * @param scene The scene the helper should be created in
  114064. */
  114065. private constructor();
  114066. /**
  114067. * Exits XR mode and returns the scene to its original state
  114068. * @returns promise that resolves after xr mode has exited
  114069. */
  114070. exitXRAsync(): Promise<void>;
  114071. /**
  114072. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  114073. * @param sessionMode options for the XR session
  114074. * @param referenceSpaceType frame of reference of the XR session
  114075. * @param renderTarget the output canvas that will be used to enter XR mode
  114076. * @returns promise that resolves after xr mode has entered
  114077. */
  114078. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  114079. /**
  114080. * Disposes of the experience helper
  114081. */
  114082. dispose(): void;
  114083. private _nonXRToXRCamera;
  114084. }
  114085. }
  114086. declare module BABYLON {
  114087. /**
  114088. * X-Y values for axes in WebXR
  114089. */
  114090. export interface IWebXRMotionControllerAxesValue {
  114091. /**
  114092. * The value of the x axis
  114093. */
  114094. x: number;
  114095. /**
  114096. * The value of the y-axis
  114097. */
  114098. y: number;
  114099. }
  114100. /**
  114101. * changed / previous values for the values of this component
  114102. */
  114103. export interface IWebXRMotionControllerComponentChangesValues<T> {
  114104. /**
  114105. * current (this frame) value
  114106. */
  114107. current: T;
  114108. /**
  114109. * previous (last change) value
  114110. */
  114111. previous: T;
  114112. }
  114113. /**
  114114. * Represents changes in the component between current frame and last values recorded
  114115. */
  114116. export interface IWebXRMotionControllerComponentChanges {
  114117. /**
  114118. * will be populated with previous and current values if touched changed
  114119. */
  114120. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  114121. /**
  114122. * will be populated with previous and current values if pressed changed
  114123. */
  114124. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  114125. /**
  114126. * will be populated with previous and current values if value changed
  114127. */
  114128. value?: IWebXRMotionControllerComponentChangesValues<number>;
  114129. /**
  114130. * will be populated with previous and current values if axes changed
  114131. */
  114132. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  114133. }
  114134. /**
  114135. * This class represents a single component (for example button or thumbstick) of a motion controller
  114136. */
  114137. export class WebXRControllerComponent implements IDisposable {
  114138. /**
  114139. * the id of this component
  114140. */
  114141. id: string;
  114142. /**
  114143. * the type of the component
  114144. */
  114145. type: MotionControllerComponentType;
  114146. private _buttonIndex;
  114147. private _axesIndices;
  114148. /**
  114149. * Observers registered here will be triggered when the state of a button changes
  114150. * State change is either pressed / touched / value
  114151. */
  114152. onButtonStateChanged: Observable<WebXRControllerComponent>;
  114153. /**
  114154. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  114155. * the axes data changes
  114156. */
  114157. onAxisValueChanged: Observable<{
  114158. x: number;
  114159. y: number;
  114160. }>;
  114161. private _currentValue;
  114162. private _touched;
  114163. private _pressed;
  114164. private _axes;
  114165. private _changes;
  114166. /**
  114167. * Creates a new component for a motion controller.
  114168. * It is created by the motion controller itself
  114169. *
  114170. * @param id the id of this component
  114171. * @param type the type of the component
  114172. * @param _buttonIndex index in the buttons array of the gamepad
  114173. * @param _axesIndices indices of the values in the axes array of the gamepad
  114174. */
  114175. constructor(
  114176. /**
  114177. * the id of this component
  114178. */
  114179. id: string,
  114180. /**
  114181. * the type of the component
  114182. */
  114183. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  114184. /**
  114185. * Get the current value of this component
  114186. */
  114187. get value(): number;
  114188. /**
  114189. * is the button currently pressed
  114190. */
  114191. get pressed(): boolean;
  114192. /**
  114193. * is the button currently touched
  114194. */
  114195. get touched(): boolean;
  114196. /**
  114197. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  114198. */
  114199. get axes(): IWebXRMotionControllerAxesValue;
  114200. /**
  114201. * Get the changes. Elements will be populated only if they changed with their previous and current value
  114202. */
  114203. get changes(): IWebXRMotionControllerComponentChanges;
  114204. /**
  114205. * Is this component a button (hence - pressable)
  114206. * @returns true if can be pressed
  114207. */
  114208. isButton(): boolean;
  114209. /**
  114210. * Are there axes correlating to this component
  114211. * @return true is axes data is available
  114212. */
  114213. isAxes(): boolean;
  114214. /**
  114215. * update this component using the gamepad object it is in. Called on every frame
  114216. * @param nativeController the native gamepad controller object
  114217. */
  114218. update(nativeController: IMinimalMotionControllerObject): void;
  114219. /**
  114220. * Dispose this component
  114221. */
  114222. dispose(): void;
  114223. }
  114224. }
  114225. declare module BABYLON {
  114226. /**
  114227. * Class used to represent data loading progression
  114228. */
  114229. export class SceneLoaderProgressEvent {
  114230. /** defines if data length to load can be evaluated */
  114231. readonly lengthComputable: boolean;
  114232. /** defines the loaded data length */
  114233. readonly loaded: number;
  114234. /** defines the data length to load */
  114235. readonly total: number;
  114236. /**
  114237. * Create a new progress event
  114238. * @param lengthComputable defines if data length to load can be evaluated
  114239. * @param loaded defines the loaded data length
  114240. * @param total defines the data length to load
  114241. */
  114242. constructor(
  114243. /** defines if data length to load can be evaluated */
  114244. lengthComputable: boolean,
  114245. /** defines the loaded data length */
  114246. loaded: number,
  114247. /** defines the data length to load */
  114248. total: number);
  114249. /**
  114250. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  114251. * @param event defines the source event
  114252. * @returns a new SceneLoaderProgressEvent
  114253. */
  114254. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  114255. }
  114256. /**
  114257. * Interface used by SceneLoader plugins to define supported file extensions
  114258. */
  114259. export interface ISceneLoaderPluginExtensions {
  114260. /**
  114261. * Defines the list of supported extensions
  114262. */
  114263. [extension: string]: {
  114264. isBinary: boolean;
  114265. };
  114266. }
  114267. /**
  114268. * Interface used by SceneLoader plugin factory
  114269. */
  114270. export interface ISceneLoaderPluginFactory {
  114271. /**
  114272. * Defines the name of the factory
  114273. */
  114274. name: string;
  114275. /**
  114276. * Function called to create a new plugin
  114277. * @return the new plugin
  114278. */
  114279. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  114280. /**
  114281. * The callback that returns true if the data can be directly loaded.
  114282. * @param data string containing the file data
  114283. * @returns if the data can be loaded directly
  114284. */
  114285. canDirectLoad?(data: string): boolean;
  114286. }
  114287. /**
  114288. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  114289. */
  114290. export interface ISceneLoaderPluginBase {
  114291. /**
  114292. * The friendly name of this plugin.
  114293. */
  114294. name: string;
  114295. /**
  114296. * The file extensions supported by this plugin.
  114297. */
  114298. extensions: string | ISceneLoaderPluginExtensions;
  114299. /**
  114300. * The callback called when loading from a url.
  114301. * @param scene scene loading this url
  114302. * @param url url to load
  114303. * @param onSuccess callback called when the file successfully loads
  114304. * @param onProgress callback called while file is loading (if the server supports this mode)
  114305. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114306. * @param onError callback called when the file fails to load
  114307. * @returns a file request object
  114308. */
  114309. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  114310. /**
  114311. * The callback called when loading from a file object.
  114312. * @param scene scene loading this file
  114313. * @param file defines the file to load
  114314. * @param onSuccess defines the callback to call when data is loaded
  114315. * @param onProgress defines the callback to call during loading process
  114316. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114317. * @param onError defines the callback to call when an error occurs
  114318. * @returns a file request object
  114319. */
  114320. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  114321. /**
  114322. * The callback that returns true if the data can be directly loaded.
  114323. * @param data string containing the file data
  114324. * @returns if the data can be loaded directly
  114325. */
  114326. canDirectLoad?(data: string): boolean;
  114327. /**
  114328. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  114329. * @param scene scene loading this data
  114330. * @param data string containing the data
  114331. * @returns data to pass to the plugin
  114332. */
  114333. directLoad?(scene: Scene, data: string): any;
  114334. /**
  114335. * The callback that allows custom handling of the root url based on the response url.
  114336. * @param rootUrl the original root url
  114337. * @param responseURL the response url if available
  114338. * @returns the new root url
  114339. */
  114340. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  114341. }
  114342. /**
  114343. * Interface used to define a SceneLoader plugin
  114344. */
  114345. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  114346. /**
  114347. * Import meshes into a scene.
  114348. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114349. * @param scene The scene to import into
  114350. * @param data The data to import
  114351. * @param rootUrl The root url for scene and resources
  114352. * @param meshes The meshes array to import into
  114353. * @param particleSystems The particle systems array to import into
  114354. * @param skeletons The skeletons array to import into
  114355. * @param onError The callback when import fails
  114356. * @returns True if successful or false otherwise
  114357. */
  114358. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  114359. /**
  114360. * Load into a scene.
  114361. * @param scene The scene to load into
  114362. * @param data The data to import
  114363. * @param rootUrl The root url for scene and resources
  114364. * @param onError The callback when import fails
  114365. * @returns True if successful or false otherwise
  114366. */
  114367. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  114368. /**
  114369. * Load into an asset container.
  114370. * @param scene The scene to load into
  114371. * @param data The data to import
  114372. * @param rootUrl The root url for scene and resources
  114373. * @param onError The callback when import fails
  114374. * @returns The loaded asset container
  114375. */
  114376. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  114377. }
  114378. /**
  114379. * Interface used to define an async SceneLoader plugin
  114380. */
  114381. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  114382. /**
  114383. * Import meshes into a scene.
  114384. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114385. * @param scene The scene to import into
  114386. * @param data The data to import
  114387. * @param rootUrl The root url for scene and resources
  114388. * @param onProgress The callback when the load progresses
  114389. * @param fileName Defines the name of the file to load
  114390. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  114391. */
  114392. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  114393. meshes: AbstractMesh[];
  114394. particleSystems: IParticleSystem[];
  114395. skeletons: Skeleton[];
  114396. animationGroups: AnimationGroup[];
  114397. }>;
  114398. /**
  114399. * Load into a scene.
  114400. * @param scene The scene to load into
  114401. * @param data The data to import
  114402. * @param rootUrl The root url for scene and resources
  114403. * @param onProgress The callback when the load progresses
  114404. * @param fileName Defines the name of the file to load
  114405. * @returns Nothing
  114406. */
  114407. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  114408. /**
  114409. * Load into an asset container.
  114410. * @param scene The scene to load into
  114411. * @param data The data to import
  114412. * @param rootUrl The root url for scene and resources
  114413. * @param onProgress The callback when the load progresses
  114414. * @param fileName Defines the name of the file to load
  114415. * @returns The loaded asset container
  114416. */
  114417. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  114418. }
  114419. /**
  114420. * Mode that determines how to handle old animation groups before loading new ones.
  114421. */
  114422. export enum SceneLoaderAnimationGroupLoadingMode {
  114423. /**
  114424. * Reset all old animations to initial state then dispose them.
  114425. */
  114426. Clean = 0,
  114427. /**
  114428. * Stop all old animations.
  114429. */
  114430. Stop = 1,
  114431. /**
  114432. * Restart old animations from first frame.
  114433. */
  114434. Sync = 2,
  114435. /**
  114436. * Old animations remains untouched.
  114437. */
  114438. NoSync = 3
  114439. }
  114440. /**
  114441. * Class used to load scene from various file formats using registered plugins
  114442. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  114443. */
  114444. export class SceneLoader {
  114445. /**
  114446. * No logging while loading
  114447. */
  114448. static readonly NO_LOGGING: number;
  114449. /**
  114450. * Minimal logging while loading
  114451. */
  114452. static readonly MINIMAL_LOGGING: number;
  114453. /**
  114454. * Summary logging while loading
  114455. */
  114456. static readonly SUMMARY_LOGGING: number;
  114457. /**
  114458. * Detailled logging while loading
  114459. */
  114460. static readonly DETAILED_LOGGING: number;
  114461. /**
  114462. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  114463. */
  114464. static get ForceFullSceneLoadingForIncremental(): boolean;
  114465. static set ForceFullSceneLoadingForIncremental(value: boolean);
  114466. /**
  114467. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  114468. */
  114469. static get ShowLoadingScreen(): boolean;
  114470. static set ShowLoadingScreen(value: boolean);
  114471. /**
  114472. * Defines the current logging level (while loading the scene)
  114473. * @ignorenaming
  114474. */
  114475. static get loggingLevel(): number;
  114476. static set loggingLevel(value: number);
  114477. /**
  114478. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  114479. */
  114480. static get CleanBoneMatrixWeights(): boolean;
  114481. static set CleanBoneMatrixWeights(value: boolean);
  114482. /**
  114483. * Event raised when a plugin is used to load a scene
  114484. */
  114485. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  114486. private static _registeredPlugins;
  114487. private static _getDefaultPlugin;
  114488. private static _getPluginForExtension;
  114489. private static _getPluginForDirectLoad;
  114490. private static _getPluginForFilename;
  114491. private static _getDirectLoad;
  114492. private static _loadData;
  114493. private static _getFileInfo;
  114494. /**
  114495. * Gets a plugin that can load the given extension
  114496. * @param extension defines the extension to load
  114497. * @returns a plugin or null if none works
  114498. */
  114499. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  114500. /**
  114501. * Gets a boolean indicating that the given extension can be loaded
  114502. * @param extension defines the extension to load
  114503. * @returns true if the extension is supported
  114504. */
  114505. static IsPluginForExtensionAvailable(extension: string): boolean;
  114506. /**
  114507. * Adds a new plugin to the list of registered plugins
  114508. * @param plugin defines the plugin to add
  114509. */
  114510. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  114511. /**
  114512. * Import meshes into a scene
  114513. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114514. * @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)
  114515. * @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)
  114516. * @param scene the instance of BABYLON.Scene to append to
  114517. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  114518. * @param onProgress a callback with a progress event for each file being loaded
  114519. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114520. * @param pluginExtension the extension used to determine the plugin
  114521. * @returns The loaded plugin
  114522. */
  114523. 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>;
  114524. /**
  114525. * Import meshes into a scene
  114526. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114527. * @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)
  114528. * @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)
  114529. * @param scene the instance of BABYLON.Scene to append to
  114530. * @param onProgress a callback with a progress event for each file being loaded
  114531. * @param pluginExtension the extension used to determine the plugin
  114532. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  114533. */
  114534. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  114535. meshes: AbstractMesh[];
  114536. particleSystems: IParticleSystem[];
  114537. skeletons: Skeleton[];
  114538. animationGroups: AnimationGroup[];
  114539. }>;
  114540. /**
  114541. * Load a scene
  114542. * @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)
  114543. * @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)
  114544. * @param engine is the instance of BABYLON.Engine to use to create the scene
  114545. * @param onSuccess a callback with the scene when import succeeds
  114546. * @param onProgress a callback with a progress event for each file being loaded
  114547. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114548. * @param pluginExtension the extension used to determine the plugin
  114549. * @returns The loaded plugin
  114550. */
  114551. 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>;
  114552. /**
  114553. * Load a scene
  114554. * @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)
  114555. * @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)
  114556. * @param engine is the instance of BABYLON.Engine to use to create the scene
  114557. * @param onProgress a callback with a progress event for each file being loaded
  114558. * @param pluginExtension the extension used to determine the plugin
  114559. * @returns The loaded scene
  114560. */
  114561. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  114562. /**
  114563. * Append a scene
  114564. * @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)
  114565. * @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)
  114566. * @param scene is the instance of BABYLON.Scene to append to
  114567. * @param onSuccess a callback with the scene when import succeeds
  114568. * @param onProgress a callback with a progress event for each file being loaded
  114569. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114570. * @param pluginExtension the extension used to determine the plugin
  114571. * @returns The loaded plugin
  114572. */
  114573. 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>;
  114574. /**
  114575. * Append a scene
  114576. * @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)
  114577. * @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)
  114578. * @param scene is the instance of BABYLON.Scene to append to
  114579. * @param onProgress a callback with a progress event for each file being loaded
  114580. * @param pluginExtension the extension used to determine the plugin
  114581. * @returns The given scene
  114582. */
  114583. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  114584. /**
  114585. * Load a scene into an asset container
  114586. * @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)
  114587. * @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)
  114588. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  114589. * @param onSuccess a callback with the scene when import succeeds
  114590. * @param onProgress a callback with a progress event for each file being loaded
  114591. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114592. * @param pluginExtension the extension used to determine the plugin
  114593. * @returns The loaded plugin
  114594. */
  114595. 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>;
  114596. /**
  114597. * Load a scene into an asset container
  114598. * @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)
  114599. * @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)
  114600. * @param scene is the instance of Scene to append to
  114601. * @param onProgress a callback with a progress event for each file being loaded
  114602. * @param pluginExtension the extension used to determine the plugin
  114603. * @returns The loaded asset container
  114604. */
  114605. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  114606. /**
  114607. * Import animations from a file into a scene
  114608. * @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)
  114609. * @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)
  114610. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  114611. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  114612. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  114613. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  114614. * @param onSuccess a callback with the scene when import succeeds
  114615. * @param onProgress a callback with a progress event for each file being loaded
  114616. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114617. */
  114618. 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;
  114619. /**
  114620. * Import animations from a file into a scene
  114621. * @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)
  114622. * @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)
  114623. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  114624. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  114625. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  114626. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  114627. * @param onSuccess a callback with the scene when import succeeds
  114628. * @param onProgress a callback with a progress event for each file being loaded
  114629. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114630. * @returns the updated scene with imported animations
  114631. */
  114632. 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>;
  114633. }
  114634. }
  114635. declare module BABYLON {
  114636. /**
  114637. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  114638. */
  114639. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  114640. /**
  114641. * The type of components available in motion controllers.
  114642. * This is not the name of the component.
  114643. */
  114644. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  114645. /**
  114646. * The schema of motion controller layout.
  114647. * No object will be initialized using this interface
  114648. * This is used just to define the profile.
  114649. */
  114650. export interface IMotionControllerLayout {
  114651. /**
  114652. * Defines the main button component id
  114653. */
  114654. selectComponentId: string;
  114655. /**
  114656. * Available components (unsorted)
  114657. */
  114658. components: {
  114659. /**
  114660. * A map of component Ids
  114661. */
  114662. [componentId: string]: {
  114663. /**
  114664. * The type of input the component outputs
  114665. */
  114666. type: MotionControllerComponentType;
  114667. };
  114668. };
  114669. /**
  114670. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  114671. */
  114672. gamepad?: {
  114673. /**
  114674. * Is the mapping based on the xr-standard defined here:
  114675. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  114676. */
  114677. mapping: "" | "xr-standard";
  114678. /**
  114679. * The buttons available in this input in the right order
  114680. * index of this button will be the index in the gamepadObject.buttons array
  114681. * correlates to the componentId in components
  114682. */
  114683. buttons: Array<string | null>;
  114684. /**
  114685. * Definition of the axes of the gamepad input, sorted
  114686. * Correlates to componentIds in the components map
  114687. */
  114688. axes: Array<{
  114689. /**
  114690. * The component id that the axis correlates to
  114691. */
  114692. componentId: string;
  114693. /**
  114694. * X or Y Axis
  114695. */
  114696. axis: "x-axis" | "y-axis";
  114697. } | null>;
  114698. };
  114699. }
  114700. /**
  114701. * A definition for the layout map in the input profile
  114702. */
  114703. export interface IMotionControllerLayoutMap {
  114704. /**
  114705. * Layouts with handness type as a key
  114706. */
  114707. [handness: string]: IMotionControllerLayout;
  114708. }
  114709. /**
  114710. * The XR Input profile schema
  114711. * Profiles can be found here:
  114712. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  114713. */
  114714. export interface IMotionControllerProfile {
  114715. /**
  114716. * The id of this profile
  114717. * correlates to the profile(s) in the xrInput.profiles array
  114718. */
  114719. profileId: string;
  114720. /**
  114721. * fallback profiles for this profileId
  114722. */
  114723. fallbackProfileIds: string[];
  114724. /**
  114725. * The layout map, with handness as key
  114726. */
  114727. layouts: IMotionControllerLayoutMap;
  114728. }
  114729. /**
  114730. * A helper-interface for the 3 meshes needed for controller button animation
  114731. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  114732. */
  114733. export interface IMotionControllerButtonMeshMap {
  114734. /**
  114735. * The mesh that will be changed when value changes
  114736. */
  114737. valueMesh: AbstractMesh;
  114738. /**
  114739. * the mesh that defines the pressed value mesh position.
  114740. * This is used to find the max-position of this button
  114741. */
  114742. pressedMesh: AbstractMesh;
  114743. /**
  114744. * the mesh that defines the unpressed value mesh position.
  114745. * This is used to find the min (or initial) position of this button
  114746. */
  114747. unpressedMesh: AbstractMesh;
  114748. }
  114749. /**
  114750. * A helper-interface for the 3 meshes needed for controller axis animation.
  114751. * This will be expanded when touchpad animations are fully supported
  114752. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  114753. */
  114754. export interface IMotionControllerAxisMeshMap {
  114755. /**
  114756. * The mesh that will be changed when axis value changes
  114757. */
  114758. valueMesh: AbstractMesh;
  114759. /**
  114760. * the mesh that defines the minimum value mesh position.
  114761. */
  114762. minMesh: AbstractMesh;
  114763. /**
  114764. * the mesh that defines the maximum value mesh position.
  114765. */
  114766. maxMesh: AbstractMesh;
  114767. }
  114768. /**
  114769. * The elements needed for change-detection of the gamepad objects in motion controllers
  114770. */
  114771. export interface IMinimalMotionControllerObject {
  114772. /**
  114773. * An array of available buttons
  114774. */
  114775. buttons: Array<{
  114776. /**
  114777. * Value of the button/trigger
  114778. */
  114779. value: number;
  114780. /**
  114781. * If the button/trigger is currently touched
  114782. */
  114783. touched: boolean;
  114784. /**
  114785. * If the button/trigger is currently pressed
  114786. */
  114787. pressed: boolean;
  114788. }>;
  114789. /**
  114790. * Available axes of this controller
  114791. */
  114792. axes: number[];
  114793. }
  114794. /**
  114795. * An Abstract Motion controller
  114796. * This class receives an xrInput and a profile layout and uses those to initialize the components
  114797. * Each component has an observable to check for changes in value and state
  114798. */
  114799. export abstract class WebXRAbstractMotionController implements IDisposable {
  114800. protected scene: Scene;
  114801. protected layout: IMotionControllerLayout;
  114802. /**
  114803. * The gamepad object correlating to this controller
  114804. */
  114805. gamepadObject: IMinimalMotionControllerObject;
  114806. /**
  114807. * handness (left/right/none) of this controller
  114808. */
  114809. handness: MotionControllerHandness;
  114810. /**
  114811. * Component type map
  114812. */
  114813. static ComponentType: {
  114814. TRIGGER: string;
  114815. SQUEEZE: string;
  114816. TOUCHPAD: string;
  114817. THUMBSTICK: string;
  114818. BUTTON: string;
  114819. };
  114820. /**
  114821. * The profile id of this motion controller
  114822. */
  114823. abstract profileId: string;
  114824. /**
  114825. * A map of components (WebXRControllerComponent) in this motion controller
  114826. * Components have a ComponentType and can also have both button and axis definitions
  114827. */
  114828. readonly components: {
  114829. [id: string]: WebXRControllerComponent;
  114830. };
  114831. /**
  114832. * Observers registered here will be triggered when the model of this controller is done loading
  114833. */
  114834. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  114835. /**
  114836. * The root mesh of the model. It is null if the model was not yet initialized
  114837. */
  114838. rootMesh: Nullable<AbstractMesh>;
  114839. private _modelReady;
  114840. /**
  114841. * constructs a new abstract motion controller
  114842. * @param scene the scene to which the model of the controller will be added
  114843. * @param layout The profile layout to load
  114844. * @param gamepadObject The gamepad object correlating to this controller
  114845. * @param handness handness (left/right/none) of this controller
  114846. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  114847. */
  114848. constructor(scene: Scene, layout: IMotionControllerLayout,
  114849. /**
  114850. * The gamepad object correlating to this controller
  114851. */
  114852. gamepadObject: IMinimalMotionControllerObject,
  114853. /**
  114854. * handness (left/right/none) of this controller
  114855. */
  114856. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  114857. private _initComponent;
  114858. /**
  114859. * Update this model using the current XRFrame
  114860. * @param xrFrame the current xr frame to use and update the model
  114861. */
  114862. updateFromXRFrame(xrFrame: XRFrame): void;
  114863. /**
  114864. * Get the list of components available in this motion controller
  114865. * @returns an array of strings correlating to available components
  114866. */
  114867. getComponentTypes(): string[];
  114868. /**
  114869. * Get the main (Select) component of this controller as defined in the layout
  114870. * @returns the main component of this controller
  114871. */
  114872. getMainComponent(): WebXRControllerComponent;
  114873. /**
  114874. * get a component based an its component id as defined in layout.components
  114875. * @param id the id of the component
  114876. * @returns the component correlates to the id or undefined if not found
  114877. */
  114878. getComponent(id: string): WebXRControllerComponent;
  114879. /**
  114880. * Loads the model correlating to this controller
  114881. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  114882. * @returns A promise fulfilled with the result of the model loading
  114883. */
  114884. loadModel(): Promise<boolean>;
  114885. /**
  114886. * Update the model itself with the current frame data
  114887. * @param xrFrame the frame to use for updating the model mesh
  114888. */
  114889. protected updateModel(xrFrame: XRFrame): void;
  114890. /**
  114891. * Moves the axis on the controller mesh based on its current state
  114892. * @param axis the index of the axis
  114893. * @param axisValue the value of the axis which determines the meshes new position
  114894. * @hidden
  114895. */
  114896. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  114897. /**
  114898. * Moves the buttons on the controller mesh based on their current state
  114899. * @param buttonName the name of the button to move
  114900. * @param buttonValue the value of the button which determines the buttons new position
  114901. */
  114902. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  114903. private _getGenericFilenameAndPath;
  114904. private _getGenericParentMesh;
  114905. /**
  114906. * Get the filename and path for this controller's model
  114907. * @returns a map of filename and path
  114908. */
  114909. protected abstract _getFilenameAndPath(): {
  114910. filename: string;
  114911. path: string;
  114912. };
  114913. /**
  114914. * This function will be called after the model was successfully loaded and can be used
  114915. * for mesh transformations before it is available for the user
  114916. * @param meshes the loaded meshes
  114917. */
  114918. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  114919. /**
  114920. * Set the root mesh for this controller. Important for the WebXR controller class
  114921. * @param meshes the loaded meshes
  114922. */
  114923. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  114924. /**
  114925. * A function executed each frame that updates the mesh (if needed)
  114926. * @param xrFrame the current xrFrame
  114927. */
  114928. protected abstract _updateModel(xrFrame: XRFrame): void;
  114929. /**
  114930. * This function is called before the mesh is loaded. It checks for loading constraints.
  114931. * For example, this function can check if the GLB loader is available
  114932. * If this function returns false, the generic controller will be loaded instead
  114933. * @returns Is the client ready to load the mesh
  114934. */
  114935. protected abstract _getModelLoadingConstraints(): boolean;
  114936. /**
  114937. * Dispose this controller, the model mesh and all its components
  114938. */
  114939. dispose(): void;
  114940. }
  114941. }
  114942. declare module BABYLON {
  114943. /**
  114944. * A generic trigger-only motion controller for WebXR
  114945. */
  114946. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  114947. /**
  114948. * Static version of the profile id of this controller
  114949. */
  114950. static ProfileId: string;
  114951. profileId: string;
  114952. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  114953. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  114954. protected _updateModel(): void;
  114955. protected _getFilenameAndPath(): {
  114956. filename: string;
  114957. path: string;
  114958. };
  114959. protected _setRootMesh(meshes: AbstractMesh[]): void;
  114960. protected _getModelLoadingConstraints(): boolean;
  114961. }
  114962. }
  114963. declare module BABYLON {
  114964. /**
  114965. * A construction function type to create a new controller based on an xrInput object
  114966. */
  114967. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  114968. /**
  114969. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  114970. *
  114971. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  114972. * it should be replaced with auto-loaded controllers.
  114973. *
  114974. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  114975. */
  114976. export class WebXRMotionControllerManager {
  114977. private static _AvailableControllers;
  114978. private static _Fallbacks;
  114979. /**
  114980. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  114981. *
  114982. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  114983. *
  114984. * @param type the profile type to register
  114985. * @param constructFunction the function to be called when loading this profile
  114986. */
  114987. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  114988. /**
  114989. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  114990. * The order of search:
  114991. *
  114992. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  114993. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  114994. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  114995. * 4) return the generic trigger controller if none were found
  114996. *
  114997. * @param xrInput the xrInput to which a new controller is initialized
  114998. * @param scene the scene to which the model will be added
  114999. * @return the motion controller class for this profile id or the generic standard class if none was found
  115000. */
  115001. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene): WebXRAbstractMotionController;
  115002. /**
  115003. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  115004. * @param profileId the profile to which a fallback needs to be found
  115005. * @return an array with corresponding fallback profiles
  115006. */
  115007. static FindFallbackWithProfileId(profileId: string): string[];
  115008. /**
  115009. * Register a fallback to a specific profile.
  115010. * @param profileId the profileId that will receive the fallbacks
  115011. * @param fallbacks A list of fallback profiles
  115012. */
  115013. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  115014. /**
  115015. * Register the default fallbacks.
  115016. * This function is called automatically when this file is imported.
  115017. */
  115018. static DefaultFallbacks(): void;
  115019. }
  115020. }
  115021. declare module BABYLON {
  115022. /**
  115023. * Represents an XR input
  115024. */
  115025. export class WebXRController {
  115026. private scene;
  115027. /** The underlying input source for the controller */
  115028. inputSource: XRInputSource;
  115029. /**
  115030. * 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
  115031. */
  115032. grip?: AbstractMesh;
  115033. /**
  115034. * Pointer which can be used to select objects or attach a visible laser to
  115035. */
  115036. pointer: AbstractMesh;
  115037. private _gamepadMode;
  115038. /**
  115039. * If available, this is the gamepad object related to this controller.
  115040. * Using this object it is possible to get click events and trackpad changes of the
  115041. * webxr controller that is currently being used.
  115042. */
  115043. gamepadController?: WebXRAbstractMotionController;
  115044. /**
  115045. * Event that fires when the controller is removed/disposed
  115046. */
  115047. onDisposeObservable: Observable<{}>;
  115048. private _tmpQuaternion;
  115049. private _tmpVector;
  115050. /**
  115051. * Creates the controller
  115052. * @see https://doc.babylonjs.com/how_to/webxr
  115053. * @param scene the scene which the controller should be associated to
  115054. * @param inputSource the underlying input source for the controller
  115055. * @param parentContainer parent that the controller meshes should be children of
  115056. */
  115057. constructor(scene: Scene,
  115058. /** The underlying input source for the controller */
  115059. inputSource: XRInputSource);
  115060. /**
  115061. * Updates the controller pose based on the given XRFrame
  115062. * @param xrFrame xr frame to update the pose with
  115063. * @param referenceSpace reference space to use
  115064. */
  115065. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  115066. /**
  115067. * Gets a world space ray coming from the controller
  115068. * @param result the resulting ray
  115069. */
  115070. getWorldPointerRayToRef(result: Ray): void;
  115071. /**
  115072. * Get the scene associated with this controller
  115073. * @returns the scene object
  115074. */
  115075. getScene(): Scene;
  115076. /**
  115077. * Disposes of the object
  115078. */
  115079. dispose(): void;
  115080. }
  115081. }
  115082. declare module BABYLON {
  115083. /**
  115084. * The schema for initialization options of the XR Input class
  115085. */
  115086. export interface IWebXRInputOptions {
  115087. /**
  115088. * If set to true no model will be automatically loaded
  115089. */
  115090. doNotLoadControllerMeshes?: boolean;
  115091. }
  115092. /**
  115093. * XR input used to track XR inputs such as controllers/rays
  115094. */
  115095. export class WebXRInput implements IDisposable {
  115096. /**
  115097. * the xr session manager for this session
  115098. */
  115099. xrSessionManager: WebXRSessionManager;
  115100. /**
  115101. * the WebXR camera for this session. Mainly used for teleportation
  115102. */
  115103. xrCamera: WebXRCamera;
  115104. private readonly options;
  115105. /**
  115106. * XR controllers being tracked
  115107. */
  115108. controllers: Array<WebXRController>;
  115109. private _frameObserver;
  115110. private _sessionEndedObserver;
  115111. private _sessionInitObserver;
  115112. /**
  115113. * Event when a controller has been connected/added
  115114. */
  115115. onControllerAddedObservable: Observable<WebXRController>;
  115116. /**
  115117. * Event when a controller has been removed/disconnected
  115118. */
  115119. onControllerRemovedObservable: Observable<WebXRController>;
  115120. /**
  115121. * Initializes the WebXRInput
  115122. * @param xrSessionManager the xr session manager for this session
  115123. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  115124. * @param options = initialization options for this xr input
  115125. */
  115126. constructor(
  115127. /**
  115128. * the xr session manager for this session
  115129. */
  115130. xrSessionManager: WebXRSessionManager,
  115131. /**
  115132. * the WebXR camera for this session. Mainly used for teleportation
  115133. */
  115134. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  115135. private _onInputSourcesChange;
  115136. private _addAndRemoveControllers;
  115137. /**
  115138. * Disposes of the object
  115139. */
  115140. dispose(): void;
  115141. }
  115142. }
  115143. declare module BABYLON {
  115144. /**
  115145. * Handles pointer input automatically for the pointer of XR controllers
  115146. */
  115147. export class WebXRControllerPointerSelection {
  115148. private static _idCounter;
  115149. private _tmpRay;
  115150. /**
  115151. * Creates a WebXRControllerPointerSelection
  115152. * @param input input manager to setup pointer selection
  115153. */
  115154. constructor(input: WebXRInput);
  115155. private _convertNormalToDirectionOfRay;
  115156. private _updatePointerDistance;
  115157. }
  115158. }
  115159. declare module BABYLON {
  115160. /**
  115161. * Enables teleportation
  115162. */
  115163. export class WebXRControllerTeleportation {
  115164. private _teleportationFillColor;
  115165. private _teleportationBorderColor;
  115166. private _tmpRay;
  115167. private _tmpVector;
  115168. /**
  115169. * when set to true (default) teleportation will wait for thumbstick changes.
  115170. * When set to false teleportation will be disabled.
  115171. *
  115172. * If set to false while teleporting results can be unexpected.
  115173. */
  115174. enabled: boolean;
  115175. /**
  115176. * Creates a WebXRControllerTeleportation
  115177. * @param input input manager to add teleportation to
  115178. * @param floorMeshes floormeshes which can be teleported to
  115179. */
  115180. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  115181. }
  115182. }
  115183. declare module BABYLON {
  115184. /**
  115185. * Button which can be used to enter a different mode of XR
  115186. */
  115187. export class WebXREnterExitUIButton {
  115188. /** button element */
  115189. element: HTMLElement;
  115190. /** XR initialization options for the button */
  115191. sessionMode: XRSessionMode;
  115192. /** Reference space type */
  115193. referenceSpaceType: XRReferenceSpaceType;
  115194. /**
  115195. * Creates a WebXREnterExitUIButton
  115196. * @param element button element
  115197. * @param sessionMode XR initialization session mode
  115198. * @param referenceSpaceType the type of reference space to be used
  115199. */
  115200. constructor(
  115201. /** button element */
  115202. element: HTMLElement,
  115203. /** XR initialization options for the button */
  115204. sessionMode: XRSessionMode,
  115205. /** Reference space type */
  115206. referenceSpaceType: XRReferenceSpaceType);
  115207. /**
  115208. * Overwritable function which can be used to update the button's visuals when the state changes
  115209. * @param activeButton the current active button in the UI
  115210. */
  115211. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  115212. }
  115213. /**
  115214. * Options to create the webXR UI
  115215. */
  115216. export class WebXREnterExitUIOptions {
  115217. /**
  115218. * Context to enter xr with
  115219. */
  115220. renderTarget?: Nullable<WebXRRenderTarget>;
  115221. /**
  115222. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  115223. */
  115224. customButtons?: Array<WebXREnterExitUIButton>;
  115225. /**
  115226. * A session mode to use when creating the default button.
  115227. * Default is immersive-vr
  115228. */
  115229. sessionMode?: XRSessionMode;
  115230. /**
  115231. * A reference space type to use when creating the default button.
  115232. * Default is local-floor
  115233. */
  115234. referenceSpaceType?: XRReferenceSpaceType;
  115235. }
  115236. /**
  115237. * UI to allow the user to enter/exit XR mode
  115238. */
  115239. export class WebXREnterExitUI implements IDisposable {
  115240. private scene;
  115241. /** version of the options passed to this UI */
  115242. options: WebXREnterExitUIOptions;
  115243. private _overlay;
  115244. private _buttons;
  115245. private _activeButton;
  115246. /**
  115247. * Fired every time the active button is changed.
  115248. *
  115249. * When xr is entered via a button that launches xr that button will be the callback parameter
  115250. *
  115251. * When exiting xr the callback parameter will be null)
  115252. */
  115253. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  115254. /**
  115255. * Creates UI to allow the user to enter/exit XR mode
  115256. * @param scene the scene to add the ui to
  115257. * @param helper the xr experience helper to enter/exit xr with
  115258. * @param options options to configure the UI
  115259. * @returns the created ui
  115260. */
  115261. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  115262. /**
  115263. *
  115264. * @param scene babylon scene object to use
  115265. * @param options (read-only) version of the options passed to this UI
  115266. */
  115267. private constructor();
  115268. private _updateButtons;
  115269. /**
  115270. * Disposes of the object
  115271. */
  115272. dispose(): void;
  115273. }
  115274. }
  115275. declare module BABYLON {
  115276. /**
  115277. * Options for the default xr helper
  115278. */
  115279. export class WebXRDefaultExperienceOptions {
  115280. /**
  115281. * Floor meshes that should be used for teleporting
  115282. */
  115283. floorMeshes?: Array<AbstractMesh>;
  115284. /**
  115285. * Enable or disable default UI to enter XR
  115286. */
  115287. disableDefaultUI?: boolean;
  115288. /**
  115289. * optional configuration for the output canvas
  115290. */
  115291. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  115292. /**
  115293. * optional UI options. This can be used among other to change session mode and reference space type
  115294. */
  115295. uiOptions?: WebXREnterExitUIOptions;
  115296. /**
  115297. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  115298. */
  115299. inputOptions?: IWebXRInputOptions;
  115300. }
  115301. /**
  115302. * Default experience which provides a similar setup to the previous webVRExperience
  115303. */
  115304. export class WebXRDefaultExperience {
  115305. /**
  115306. * Base experience
  115307. */
  115308. baseExperience: WebXRExperienceHelper;
  115309. /**
  115310. * Input experience extension
  115311. */
  115312. input: WebXRInput;
  115313. /**
  115314. * Enables laser pointer and selection
  115315. */
  115316. pointerSelection: WebXRControllerPointerSelection;
  115317. /**
  115318. * Enables teleportation
  115319. */
  115320. teleportation: WebXRControllerTeleportation;
  115321. /**
  115322. * Enables ui for entering/exiting xr
  115323. */
  115324. enterExitUI: WebXREnterExitUI;
  115325. /**
  115326. * Default target xr should render to
  115327. */
  115328. renderTarget: WebXRRenderTarget;
  115329. /**
  115330. * Creates the default xr experience
  115331. * @param scene scene
  115332. * @param options options for basic configuration
  115333. * @returns resulting WebXRDefaultExperience
  115334. */
  115335. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115336. private constructor();
  115337. /**
  115338. * DIsposes of the experience helper
  115339. */
  115340. dispose(): void;
  115341. }
  115342. }
  115343. declare module BABYLON {
  115344. /**
  115345. * Options to modify the vr teleportation behavior.
  115346. */
  115347. export interface VRTeleportationOptions {
  115348. /**
  115349. * The name of the mesh which should be used as the teleportation floor. (default: null)
  115350. */
  115351. floorMeshName?: string;
  115352. /**
  115353. * A list of meshes to be used as the teleportation floor. (default: empty)
  115354. */
  115355. floorMeshes?: Mesh[];
  115356. /**
  115357. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  115358. */
  115359. teleportationMode?: number;
  115360. /**
  115361. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  115362. */
  115363. teleportationTime?: number;
  115364. /**
  115365. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  115366. */
  115367. teleportationSpeed?: number;
  115368. /**
  115369. * The easing function used in the animation or null for Linear. (default CircleEase)
  115370. */
  115371. easingFunction?: EasingFunction;
  115372. }
  115373. /**
  115374. * Options to modify the vr experience helper's behavior.
  115375. */
  115376. export interface VRExperienceHelperOptions extends WebVROptions {
  115377. /**
  115378. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  115379. */
  115380. createDeviceOrientationCamera?: boolean;
  115381. /**
  115382. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  115383. */
  115384. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  115385. /**
  115386. * Uses the main button on the controller to toggle the laser casted. (default: true)
  115387. */
  115388. laserToggle?: boolean;
  115389. /**
  115390. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  115391. */
  115392. floorMeshes?: Mesh[];
  115393. /**
  115394. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  115395. */
  115396. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  115397. /**
  115398. * Defines if WebXR should be used instead of WebVR (if available)
  115399. */
  115400. useXR?: boolean;
  115401. }
  115402. /**
  115403. * Event containing information after VR has been entered
  115404. */
  115405. export class OnAfterEnteringVRObservableEvent {
  115406. /**
  115407. * If entering vr was successful
  115408. */
  115409. success: boolean;
  115410. }
  115411. /**
  115412. * Helps to quickly add VR support to an existing scene.
  115413. * See http://doc.babylonjs.com/how_to/webvr_helper
  115414. */
  115415. export class VRExperienceHelper {
  115416. /** Options to modify the vr experience helper's behavior. */
  115417. webVROptions: VRExperienceHelperOptions;
  115418. private _scene;
  115419. private _position;
  115420. private _btnVR;
  115421. private _btnVRDisplayed;
  115422. private _webVRsupported;
  115423. private _webVRready;
  115424. private _webVRrequesting;
  115425. private _webVRpresenting;
  115426. private _hasEnteredVR;
  115427. private _fullscreenVRpresenting;
  115428. private _inputElement;
  115429. private _webVRCamera;
  115430. private _vrDeviceOrientationCamera;
  115431. private _deviceOrientationCamera;
  115432. private _existingCamera;
  115433. private _onKeyDown;
  115434. private _onVrDisplayPresentChange;
  115435. private _onVRDisplayChanged;
  115436. private _onVRRequestPresentStart;
  115437. private _onVRRequestPresentComplete;
  115438. /**
  115439. * 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)
  115440. */
  115441. enableGazeEvenWhenNoPointerLock: boolean;
  115442. /**
  115443. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  115444. */
  115445. exitVROnDoubleTap: boolean;
  115446. /**
  115447. * Observable raised right before entering VR.
  115448. */
  115449. onEnteringVRObservable: Observable<VRExperienceHelper>;
  115450. /**
  115451. * Observable raised when entering VR has completed.
  115452. */
  115453. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  115454. /**
  115455. * Observable raised when exiting VR.
  115456. */
  115457. onExitingVRObservable: Observable<VRExperienceHelper>;
  115458. /**
  115459. * Observable raised when controller mesh is loaded.
  115460. */
  115461. onControllerMeshLoadedObservable: Observable<WebVRController>;
  115462. /** Return this.onEnteringVRObservable
  115463. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  115464. */
  115465. get onEnteringVR(): Observable<VRExperienceHelper>;
  115466. /** Return this.onExitingVRObservable
  115467. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  115468. */
  115469. get onExitingVR(): Observable<VRExperienceHelper>;
  115470. /** Return this.onControllerMeshLoadedObservable
  115471. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  115472. */
  115473. get onControllerMeshLoaded(): Observable<WebVRController>;
  115474. private _rayLength;
  115475. private _useCustomVRButton;
  115476. private _teleportationRequested;
  115477. private _teleportActive;
  115478. private _floorMeshName;
  115479. private _floorMeshesCollection;
  115480. private _teleportationMode;
  115481. private _teleportationTime;
  115482. private _teleportationSpeed;
  115483. private _teleportationEasing;
  115484. private _rotationAllowed;
  115485. private _teleportBackwardsVector;
  115486. private _teleportationTarget;
  115487. private _isDefaultTeleportationTarget;
  115488. private _postProcessMove;
  115489. private _teleportationFillColor;
  115490. private _teleportationBorderColor;
  115491. private _rotationAngle;
  115492. private _haloCenter;
  115493. private _cameraGazer;
  115494. private _padSensibilityUp;
  115495. private _padSensibilityDown;
  115496. private _leftController;
  115497. private _rightController;
  115498. private _gazeColor;
  115499. private _laserColor;
  115500. private _pickedLaserColor;
  115501. private _pickedGazeColor;
  115502. /**
  115503. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  115504. */
  115505. onNewMeshSelected: Observable<AbstractMesh>;
  115506. /**
  115507. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  115508. * This observable will provide the mesh and the controller used to select the mesh
  115509. */
  115510. onMeshSelectedWithController: Observable<{
  115511. mesh: AbstractMesh;
  115512. controller: WebVRController;
  115513. }>;
  115514. /**
  115515. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  115516. */
  115517. onNewMeshPicked: Observable<PickingInfo>;
  115518. private _circleEase;
  115519. /**
  115520. * Observable raised before camera teleportation
  115521. */
  115522. onBeforeCameraTeleport: Observable<Vector3>;
  115523. /**
  115524. * Observable raised after camera teleportation
  115525. */
  115526. onAfterCameraTeleport: Observable<Vector3>;
  115527. /**
  115528. * Observable raised when current selected mesh gets unselected
  115529. */
  115530. onSelectedMeshUnselected: Observable<AbstractMesh>;
  115531. private _raySelectionPredicate;
  115532. /**
  115533. * To be optionaly changed by user to define custom ray selection
  115534. */
  115535. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  115536. /**
  115537. * To be optionaly changed by user to define custom selection logic (after ray selection)
  115538. */
  115539. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115540. /**
  115541. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  115542. */
  115543. teleportationEnabled: boolean;
  115544. private _defaultHeight;
  115545. private _teleportationInitialized;
  115546. private _interactionsEnabled;
  115547. private _interactionsRequested;
  115548. private _displayGaze;
  115549. private _displayLaserPointer;
  115550. /**
  115551. * The mesh used to display where the user is going to teleport.
  115552. */
  115553. get teleportationTarget(): Mesh;
  115554. /**
  115555. * Sets the mesh to be used to display where the user is going to teleport.
  115556. */
  115557. set teleportationTarget(value: Mesh);
  115558. /**
  115559. * 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
  115560. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  115561. * See http://doc.babylonjs.com/resources/baking_transformations
  115562. */
  115563. get gazeTrackerMesh(): Mesh;
  115564. set gazeTrackerMesh(value: Mesh);
  115565. /**
  115566. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  115567. */
  115568. updateGazeTrackerScale: boolean;
  115569. /**
  115570. * If the gaze trackers color should be updated when selecting meshes
  115571. */
  115572. updateGazeTrackerColor: boolean;
  115573. /**
  115574. * If the controller laser color should be updated when selecting meshes
  115575. */
  115576. updateControllerLaserColor: boolean;
  115577. /**
  115578. * The gaze tracking mesh corresponding to the left controller
  115579. */
  115580. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  115581. /**
  115582. * The gaze tracking mesh corresponding to the right controller
  115583. */
  115584. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  115585. /**
  115586. * If the ray of the gaze should be displayed.
  115587. */
  115588. get displayGaze(): boolean;
  115589. /**
  115590. * Sets if the ray of the gaze should be displayed.
  115591. */
  115592. set displayGaze(value: boolean);
  115593. /**
  115594. * If the ray of the LaserPointer should be displayed.
  115595. */
  115596. get displayLaserPointer(): boolean;
  115597. /**
  115598. * Sets if the ray of the LaserPointer should be displayed.
  115599. */
  115600. set displayLaserPointer(value: boolean);
  115601. /**
  115602. * The deviceOrientationCamera used as the camera when not in VR.
  115603. */
  115604. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  115605. /**
  115606. * Based on the current WebVR support, returns the current VR camera used.
  115607. */
  115608. get currentVRCamera(): Nullable<Camera>;
  115609. /**
  115610. * The webVRCamera which is used when in VR.
  115611. */
  115612. get webVRCamera(): WebVRFreeCamera;
  115613. /**
  115614. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  115615. */
  115616. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  115617. /**
  115618. * The html button that is used to trigger entering into VR.
  115619. */
  115620. get vrButton(): Nullable<HTMLButtonElement>;
  115621. private get _teleportationRequestInitiated();
  115622. /**
  115623. * Defines wether or not Pointer lock should be requested when switching to
  115624. * full screen.
  115625. */
  115626. requestPointerLockOnFullScreen: boolean;
  115627. /**
  115628. * If asking to force XR, this will be populated with the default xr experience
  115629. */
  115630. xr: WebXRDefaultExperience;
  115631. /**
  115632. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  115633. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  115634. */
  115635. xrTestDone: boolean;
  115636. /**
  115637. * Instantiates a VRExperienceHelper.
  115638. * Helps to quickly add VR support to an existing scene.
  115639. * @param scene The scene the VRExperienceHelper belongs to.
  115640. * @param webVROptions Options to modify the vr experience helper's behavior.
  115641. */
  115642. constructor(scene: Scene,
  115643. /** Options to modify the vr experience helper's behavior. */
  115644. webVROptions?: VRExperienceHelperOptions);
  115645. private completeVRInit;
  115646. private _onDefaultMeshLoaded;
  115647. private _onResize;
  115648. private _onFullscreenChange;
  115649. /**
  115650. * Gets a value indicating if we are currently in VR mode.
  115651. */
  115652. get isInVRMode(): boolean;
  115653. private onVrDisplayPresentChange;
  115654. private onVRDisplayChanged;
  115655. private moveButtonToBottomRight;
  115656. private displayVRButton;
  115657. private updateButtonVisibility;
  115658. private _cachedAngularSensibility;
  115659. /**
  115660. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  115661. * Otherwise, will use the fullscreen API.
  115662. */
  115663. enterVR(): void;
  115664. /**
  115665. * Attempt to exit VR, or fullscreen.
  115666. */
  115667. exitVR(): void;
  115668. /**
  115669. * The position of the vr experience helper.
  115670. */
  115671. get position(): Vector3;
  115672. /**
  115673. * Sets the position of the vr experience helper.
  115674. */
  115675. set position(value: Vector3);
  115676. /**
  115677. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  115678. */
  115679. enableInteractions(): void;
  115680. private get _noControllerIsActive();
  115681. private beforeRender;
  115682. private _isTeleportationFloor;
  115683. /**
  115684. * Adds a floor mesh to be used for teleportation.
  115685. * @param floorMesh the mesh to be used for teleportation.
  115686. */
  115687. addFloorMesh(floorMesh: Mesh): void;
  115688. /**
  115689. * Removes a floor mesh from being used for teleportation.
  115690. * @param floorMesh the mesh to be removed.
  115691. */
  115692. removeFloorMesh(floorMesh: Mesh): void;
  115693. /**
  115694. * Enables interactions and teleportation using the VR controllers and gaze.
  115695. * @param vrTeleportationOptions options to modify teleportation behavior.
  115696. */
  115697. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  115698. private _onNewGamepadConnected;
  115699. private _tryEnableInteractionOnController;
  115700. private _onNewGamepadDisconnected;
  115701. private _enableInteractionOnController;
  115702. private _checkTeleportWithRay;
  115703. private _checkRotate;
  115704. private _checkTeleportBackwards;
  115705. private _enableTeleportationOnController;
  115706. private _createTeleportationCircles;
  115707. private _displayTeleportationTarget;
  115708. private _hideTeleportationTarget;
  115709. private _rotateCamera;
  115710. private _moveTeleportationSelectorTo;
  115711. private _workingVector;
  115712. private _workingQuaternion;
  115713. private _workingMatrix;
  115714. /**
  115715. * Time Constant Teleportation Mode
  115716. */
  115717. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  115718. /**
  115719. * Speed Constant Teleportation Mode
  115720. */
  115721. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  115722. /**
  115723. * Teleports the users feet to the desired location
  115724. * @param location The location where the user's feet should be placed
  115725. */
  115726. teleportCamera(location: Vector3): void;
  115727. private _convertNormalToDirectionOfRay;
  115728. private _castRayAndSelectObject;
  115729. private _notifySelectedMeshUnselected;
  115730. /**
  115731. * Permanently set new colors for the laser pointer
  115732. * @param color the new laser color
  115733. * @param pickedColor the new laser color when picked mesh detected
  115734. */
  115735. setLaserColor(color: Color3, pickedColor?: Color3): void;
  115736. /**
  115737. * Permanently set new colors for the gaze pointer
  115738. * @param color the new gaze color
  115739. * @param pickedColor the new gaze color when picked mesh detected
  115740. */
  115741. setGazeColor(color: Color3, pickedColor?: Color3): void;
  115742. /**
  115743. * Sets the color of the laser ray from the vr controllers.
  115744. * @param color new color for the ray.
  115745. */
  115746. changeLaserColor(color: Color3): void;
  115747. /**
  115748. * Sets the color of the ray from the vr headsets gaze.
  115749. * @param color new color for the ray.
  115750. */
  115751. changeGazeColor(color: Color3): void;
  115752. /**
  115753. * Exits VR and disposes of the vr experience helper
  115754. */
  115755. dispose(): void;
  115756. /**
  115757. * Gets the name of the VRExperienceHelper class
  115758. * @returns "VRExperienceHelper"
  115759. */
  115760. getClassName(): string;
  115761. }
  115762. }
  115763. declare module BABYLON {
  115764. /**
  115765. * Options used for hit testing
  115766. */
  115767. export interface IWebXRHitTestOptions {
  115768. /**
  115769. * Only test when user interacted with the scene. Default - hit test every frame
  115770. */
  115771. testOnPointerDownOnly?: boolean;
  115772. /**
  115773. * The node to use to transform the local results to world coordinates
  115774. */
  115775. worldParentNode?: TransformNode;
  115776. }
  115777. /**
  115778. * Interface defining the babylon result of raycasting/hit-test
  115779. */
  115780. export interface IWebXRHitResult {
  115781. /**
  115782. * The native hit test result
  115783. */
  115784. xrHitResult: XRHitResult;
  115785. /**
  115786. * Transformation matrix that can be applied to a node that will put it in the hit point location
  115787. */
  115788. transformationMatrix: Matrix;
  115789. }
  115790. /**
  115791. * The currently-working hit-test module.
  115792. * Hit test (or raycasting) is used to interact with the real world.
  115793. * For further information read here - https://github.com/immersive-web/hit-test
  115794. */
  115795. export class WebXRHitTestLegacy implements IWebXRFeature {
  115796. private _xrSessionManager;
  115797. /**
  115798. * options to use when constructing this feature
  115799. */
  115800. readonly options: IWebXRHitTestOptions;
  115801. /**
  115802. * The module's name
  115803. */
  115804. static readonly Name: string;
  115805. /**
  115806. * The (Babylon) version of this module.
  115807. * This is an integer representing the implementation version.
  115808. * This number does not correspond to the webxr specs version
  115809. */
  115810. static readonly Version: number;
  115811. /**
  115812. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  115813. * @param event the (select) event to use to select with
  115814. * @param referenceSpace the reference space to use for this hit test
  115815. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  115816. */
  115817. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  115818. /**
  115819. * execute a hit test with an XR Ray
  115820. *
  115821. * @param xrSession a native xrSession that will execute this hit test
  115822. * @param xrRay the ray (position and direction) to use for raycasting
  115823. * @param referenceSpace native XR reference space to use for the hit-test
  115824. * @param filter filter function that will filter the results
  115825. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  115826. */
  115827. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  115828. /**
  115829. * Triggered when new babylon (transformed) hit test results are available
  115830. */
  115831. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  115832. /**
  115833. * Creates a new instance of the (legacy version) hit test feature
  115834. * @param _xrSessionManager an instance of WebXRSessionManager
  115835. * @param options options to use when constructing this feature
  115836. */
  115837. constructor(_xrSessionManager: WebXRSessionManager,
  115838. /**
  115839. * options to use when constructing this feature
  115840. */
  115841. options?: IWebXRHitTestOptions);
  115842. private _onSelectEnabled;
  115843. private _xrFrameObserver;
  115844. private _attached;
  115845. /**
  115846. * Populated with the last native XR Hit Results
  115847. */
  115848. lastNativeXRHitResults: XRHitResult[];
  115849. /**
  115850. * attach this feature
  115851. * Will usually be called by the features manager
  115852. *
  115853. * @returns true if successful.
  115854. */
  115855. attach(): boolean;
  115856. /**
  115857. * detach this feature.
  115858. * Will usually be called by the features manager
  115859. *
  115860. * @returns true if successful.
  115861. */
  115862. detach(): boolean;
  115863. private _onHitTestResults;
  115864. private _onSelect;
  115865. /**
  115866. * Dispose this feature and all of the resources attached
  115867. */
  115868. dispose(): void;
  115869. }
  115870. }
  115871. declare module BABYLON {
  115872. /**
  115873. * Options used in the plane detector module
  115874. */
  115875. export interface IWebXRPlaneDetectorOptions {
  115876. /**
  115877. * The node to use to transform the local results to world coordinates
  115878. */
  115879. worldParentNode?: TransformNode;
  115880. }
  115881. /**
  115882. * A babylon interface for a webxr plane.
  115883. * A Plane is actually a polygon, built from N points in space
  115884. */
  115885. export interface IWebXRPlane {
  115886. /**
  115887. * a babylon-assigned ID for this polygon
  115888. */
  115889. id: number;
  115890. /**
  115891. * the native xr-plane object
  115892. */
  115893. xrPlane: XRPlane;
  115894. /**
  115895. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  115896. */
  115897. polygonDefinition: Array<Vector3>;
  115898. /**
  115899. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  115900. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  115901. */
  115902. transformationMatrix: Matrix;
  115903. }
  115904. /**
  115905. * The plane detector is used to detect planes in the real world when in AR
  115906. * For more information see https://github.com/immersive-web/real-world-geometry/
  115907. */
  115908. export class WebXRPlaneDetector implements IWebXRFeature {
  115909. private _xrSessionManager;
  115910. private _options;
  115911. /**
  115912. * The module's name
  115913. */
  115914. static readonly Name: string;
  115915. /**
  115916. * The (Babylon) version of this module.
  115917. * This is an integer representing the implementation version.
  115918. * This number does not correspond to the webxr specs version
  115919. */
  115920. static readonly Version: number;
  115921. /**
  115922. * Observers registered here will be executed when a new plane was added to the session
  115923. */
  115924. onPlaneAddedObservable: Observable<IWebXRPlane>;
  115925. /**
  115926. * Observers registered here will be executed when a plane is no longer detected in the session
  115927. */
  115928. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  115929. /**
  115930. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  115931. * This can execute N times every frame
  115932. */
  115933. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  115934. private _enabled;
  115935. private _attached;
  115936. private _detectedPlanes;
  115937. private _lastFrameDetected;
  115938. private _observerTracked;
  115939. /**
  115940. * construct a new Plane Detector
  115941. * @param _xrSessionManager an instance of xr Session manager
  115942. * @param _options configuration to use when constructing this feature
  115943. */
  115944. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  115945. /**
  115946. * attach this feature
  115947. * Will usually be called by the features manager
  115948. *
  115949. * @returns true if successful.
  115950. */
  115951. attach(): boolean;
  115952. /**
  115953. * detach this feature.
  115954. * Will usually be called by the features manager
  115955. *
  115956. * @returns true if successful.
  115957. */
  115958. detach(): boolean;
  115959. /**
  115960. * Dispose this feature and all of the resources attached
  115961. */
  115962. dispose(): void;
  115963. private _updatePlaneWithXRPlane;
  115964. /**
  115965. * avoiding using Array.find for global support.
  115966. * @param xrPlane the plane to find in the array
  115967. */
  115968. private findIndexInPlaneArray;
  115969. }
  115970. }
  115971. declare module BABYLON {
  115972. /**
  115973. * Configuration options of the anchor system
  115974. */
  115975. export interface IWebXRAnchorSystemOptions {
  115976. /**
  115977. * a node that will be used to convert local to world coordinates
  115978. */
  115979. worldParentNode?: TransformNode;
  115980. /**
  115981. * should the anchor system use plane detection.
  115982. * If set to true, the plane-detection feature should be set using setPlaneDetector
  115983. */
  115984. usePlaneDetection?: boolean;
  115985. /**
  115986. * Should a new anchor be added every time a select event is triggered
  115987. */
  115988. addAnchorOnSelect?: boolean;
  115989. }
  115990. /**
  115991. * A babylon container for an XR Anchor
  115992. */
  115993. export interface IWebXRAnchor {
  115994. /**
  115995. * A babylon-assigned ID for this anchor
  115996. */
  115997. id: number;
  115998. /**
  115999. * The native anchor object
  116000. */
  116001. xrAnchor: XRAnchor;
  116002. /**
  116003. * Transformation matrix to apply to an object attached to this anchor
  116004. */
  116005. transformationMatrix: Matrix;
  116006. }
  116007. /**
  116008. * An implementation of the anchor system of WebXR.
  116009. * Note that the current documented implementation is not available in any browser. Future implementations
  116010. * will use the frame to create an anchor and not the session or a detected plane
  116011. * For further information see https://github.com/immersive-web/anchors/
  116012. */
  116013. export class WebXRAnchorSystem implements IWebXRFeature {
  116014. private _xrSessionManager;
  116015. private _options;
  116016. /**
  116017. * The module's name
  116018. */
  116019. static readonly Name: string;
  116020. /**
  116021. * The (Babylon) version of this module.
  116022. * This is an integer representing the implementation version.
  116023. * This number does not correspond to the webxr specs version
  116024. */
  116025. static readonly Version: number;
  116026. /**
  116027. * Observers registered here will be executed when a new anchor was added to the session
  116028. */
  116029. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  116030. /**
  116031. * Observers registered here will be executed when an existing anchor updates
  116032. * This can execute N times every frame
  116033. */
  116034. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  116035. /**
  116036. * Observers registered here will be executed when an anchor was removed from the session
  116037. */
  116038. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  116039. private _planeDetector;
  116040. private _hitTestModule;
  116041. private _enabled;
  116042. private _attached;
  116043. private _trackedAnchors;
  116044. private _lastFrameDetected;
  116045. private _observerTracked;
  116046. /**
  116047. * constructs a new anchor system
  116048. * @param _xrSessionManager an instance of WebXRSessionManager
  116049. * @param _options configuration object for this feature
  116050. */
  116051. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  116052. /**
  116053. * set the plane detector to use in order to create anchors from frames
  116054. * @param planeDetector the plane-detector module to use
  116055. * @param enable enable plane-anchors. default is true
  116056. */
  116057. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  116058. /**
  116059. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  116060. * @param hitTestModule the hit-test module to use.
  116061. */
  116062. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  116063. /**
  116064. * attach this feature
  116065. * Will usually be called by the features manager
  116066. *
  116067. * @returns true if successful.
  116068. */
  116069. attach(): boolean;
  116070. /**
  116071. * detach this feature.
  116072. * Will usually be called by the features manager
  116073. *
  116074. * @returns true if successful.
  116075. */
  116076. detach(): boolean;
  116077. /**
  116078. * Dispose this feature and all of the resources attached
  116079. */
  116080. dispose(): void;
  116081. private _onSelect;
  116082. /**
  116083. * Add anchor at a specific XR point.
  116084. *
  116085. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  116086. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  116087. * @returns a promise the fulfills when the anchor was created
  116088. */
  116089. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  116090. private _updateAnchorWithXRFrame;
  116091. /**
  116092. * avoiding using Array.find for global support.
  116093. * @param xrAnchor the plane to find in the array
  116094. */
  116095. private _findIndexInAnchorArray;
  116096. }
  116097. }
  116098. declare module BABYLON {
  116099. /**
  116100. * Options interface for the background remover plugin
  116101. */
  116102. export interface IWebXRBackgroundRemoverOptions {
  116103. /**
  116104. * don't disable the environment helper
  116105. */
  116106. ignoreEnvironmentHelper?: boolean;
  116107. /**
  116108. * flags to configure the removal of the environment helper.
  116109. * If not set, the entire background will be removed. If set, flags should be set as well.
  116110. */
  116111. environmentHelperRemovalFlags?: {
  116112. /**
  116113. * Should the skybox be removed (default false)
  116114. */
  116115. skyBox?: boolean;
  116116. /**
  116117. * Should the ground be removed (default false)
  116118. */
  116119. ground?: boolean;
  116120. };
  116121. /**
  116122. * Further background meshes to disable when entering AR
  116123. */
  116124. backgroundMeshes?: AbstractMesh[];
  116125. }
  116126. /**
  116127. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  116128. */
  116129. export class WebXRBackgroundRemover implements IWebXRFeature {
  116130. private _xrSessionManager;
  116131. /**
  116132. * read-only options to be used in this module
  116133. */
  116134. readonly options: IWebXRBackgroundRemoverOptions;
  116135. /**
  116136. * The module's name
  116137. */
  116138. static readonly Name: string;
  116139. /**
  116140. * The (Babylon) version of this module.
  116141. * This is an integer representing the implementation version.
  116142. * This number does not correspond to the webxr specs version
  116143. */
  116144. static readonly Version: number;
  116145. /**
  116146. * registered observers will be triggered when the background state changes
  116147. */
  116148. onBackgroundStateChangedObservable: Observable<boolean>;
  116149. /**
  116150. * constructs a new background remover module
  116151. * @param _xrSessionManager the session manager for this module
  116152. * @param options read-only options to be used in this module
  116153. */
  116154. constructor(_xrSessionManager: WebXRSessionManager,
  116155. /**
  116156. * read-only options to be used in this module
  116157. */
  116158. options?: IWebXRBackgroundRemoverOptions);
  116159. /**
  116160. * attach this feature
  116161. * Will usually be called by the features manager
  116162. *
  116163. * @returns true if successful.
  116164. */
  116165. attach(): boolean;
  116166. /**
  116167. * detach this feature.
  116168. * Will usually be called by the features manager
  116169. *
  116170. * @returns true if successful.
  116171. */
  116172. detach(): boolean;
  116173. private _setBackgroundState;
  116174. /**
  116175. * Dispose this feature and all of the resources attached
  116176. */
  116177. dispose(): void;
  116178. }
  116179. }
  116180. declare module BABYLON {
  116181. /**
  116182. * The motion controller class for all microsoft mixed reality controllers
  116183. */
  116184. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  116185. /**
  116186. * The base url used to load the left and right controller models
  116187. */
  116188. static MODEL_BASE_URL: string;
  116189. /**
  116190. * The name of the left controller model file
  116191. */
  116192. static MODEL_LEFT_FILENAME: string;
  116193. /**
  116194. * The name of the right controller model file
  116195. */
  116196. static MODEL_RIGHT_FILENAME: string;
  116197. profileId: string;
  116198. protected readonly _mapping: {
  116199. defaultButton: {
  116200. "valueNodeName": string;
  116201. "unpressedNodeName": string;
  116202. "pressedNodeName": string;
  116203. };
  116204. defaultAxis: {
  116205. "valueNodeName": string;
  116206. "minNodeName": string;
  116207. "maxNodeName": string;
  116208. };
  116209. buttons: {
  116210. "xr-standard-trigger": {
  116211. "rootNodeName": string;
  116212. "componentProperty": string;
  116213. "states": string[];
  116214. };
  116215. "xr-standard-squeeze": {
  116216. "rootNodeName": string;
  116217. "componentProperty": string;
  116218. "states": string[];
  116219. };
  116220. "xr-standard-touchpad": {
  116221. "rootNodeName": string;
  116222. "labelAnchorNodeName": string;
  116223. "touchPointNodeName": string;
  116224. };
  116225. "xr-standard-thumbstick": {
  116226. "rootNodeName": string;
  116227. "componentProperty": string;
  116228. "states": string[];
  116229. };
  116230. "menu": {
  116231. "rootNodeName": string;
  116232. "componentProperty": string;
  116233. "states": string[];
  116234. };
  116235. };
  116236. axes: {
  116237. "xr-standard-touchpad": {
  116238. "x-axis": {
  116239. "rootNodeName": string;
  116240. };
  116241. "y-axis": {
  116242. "rootNodeName": string;
  116243. };
  116244. };
  116245. "xr-standard-thumbstick": {
  116246. "x-axis": {
  116247. "rootNodeName": string;
  116248. };
  116249. "y-axis": {
  116250. "rootNodeName": string;
  116251. };
  116252. };
  116253. };
  116254. };
  116255. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  116256. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116257. private _getChildByName;
  116258. private _getImmediateChildByName;
  116259. protected _getFilenameAndPath(): {
  116260. filename: string;
  116261. path: string;
  116262. };
  116263. protected _updateModel(): void;
  116264. protected _getModelLoadingConstraints(): boolean;
  116265. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116266. }
  116267. }
  116268. declare module BABYLON {
  116269. /**
  116270. * The motion controller class for oculus touch (quest, rift).
  116271. * This class supports legacy mapping as well the standard xr mapping
  116272. */
  116273. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  116274. private _forceLegacyControllers;
  116275. /**
  116276. * The base url used to load the left and right controller models
  116277. */
  116278. static MODEL_BASE_URL: string;
  116279. /**
  116280. * The name of the left controller model file
  116281. */
  116282. static MODEL_LEFT_FILENAME: string;
  116283. /**
  116284. * The name of the right controller model file
  116285. */
  116286. static MODEL_RIGHT_FILENAME: string;
  116287. /**
  116288. * Base Url for the Quest controller model.
  116289. */
  116290. static QUEST_MODEL_BASE_URL: string;
  116291. profileId: string;
  116292. private _modelRootNode;
  116293. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  116294. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116295. protected _getFilenameAndPath(): {
  116296. filename: string;
  116297. path: string;
  116298. };
  116299. /**
  116300. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  116301. * between the touch and touch 2.
  116302. */
  116303. private _isQuest;
  116304. protected _updateModel(): void;
  116305. protected _getModelLoadingConstraints(): boolean;
  116306. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116307. }
  116308. }
  116309. declare module BABYLON {
  116310. /**
  116311. * The motion controller class for the standard HTC-Vive controllers
  116312. */
  116313. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  116314. /**
  116315. * The base url used to load the left and right controller models
  116316. */
  116317. static MODEL_BASE_URL: string;
  116318. /**
  116319. * File name for the controller model.
  116320. */
  116321. static MODEL_FILENAME: string;
  116322. profileId: string;
  116323. private _modelRootNode;
  116324. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  116325. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116326. protected _getFilenameAndPath(): {
  116327. filename: string;
  116328. path: string;
  116329. };
  116330. protected _updateModel(): void;
  116331. protected _getModelLoadingConstraints(): boolean;
  116332. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116333. }
  116334. }
  116335. declare module BABYLON {
  116336. /**
  116337. * Contains an array of blocks representing the octree
  116338. */
  116339. export interface IOctreeContainer<T> {
  116340. /**
  116341. * Blocks within the octree
  116342. */
  116343. blocks: Array<OctreeBlock<T>>;
  116344. }
  116345. /**
  116346. * Class used to store a cell in an octree
  116347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116348. */
  116349. export class OctreeBlock<T> {
  116350. /**
  116351. * Gets the content of the current block
  116352. */
  116353. entries: T[];
  116354. /**
  116355. * Gets the list of block children
  116356. */
  116357. blocks: Array<OctreeBlock<T>>;
  116358. private _depth;
  116359. private _maxDepth;
  116360. private _capacity;
  116361. private _minPoint;
  116362. private _maxPoint;
  116363. private _boundingVectors;
  116364. private _creationFunc;
  116365. /**
  116366. * Creates a new block
  116367. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  116368. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  116369. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  116370. * @param depth defines the current depth of this block in the octree
  116371. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  116372. * @param creationFunc defines a callback to call when an element is added to the block
  116373. */
  116374. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  116375. /**
  116376. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  116377. */
  116378. get capacity(): number;
  116379. /**
  116380. * Gets the minimum vector (in world space) of the block's bounding box
  116381. */
  116382. get minPoint(): Vector3;
  116383. /**
  116384. * Gets the maximum vector (in world space) of the block's bounding box
  116385. */
  116386. get maxPoint(): Vector3;
  116387. /**
  116388. * Add a new element to this block
  116389. * @param entry defines the element to add
  116390. */
  116391. addEntry(entry: T): void;
  116392. /**
  116393. * Remove an element from this block
  116394. * @param entry defines the element to remove
  116395. */
  116396. removeEntry(entry: T): void;
  116397. /**
  116398. * Add an array of elements to this block
  116399. * @param entries defines the array of elements to add
  116400. */
  116401. addEntries(entries: T[]): void;
  116402. /**
  116403. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  116404. * @param frustumPlanes defines the frustum planes to test
  116405. * @param selection defines the array to store current content if selection is positive
  116406. * @param allowDuplicate defines if the selection array can contains duplicated entries
  116407. */
  116408. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  116409. /**
  116410. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  116411. * @param sphereCenter defines the bounding sphere center
  116412. * @param sphereRadius defines the bounding sphere radius
  116413. * @param selection defines the array to store current content if selection is positive
  116414. * @param allowDuplicate defines if the selection array can contains duplicated entries
  116415. */
  116416. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  116417. /**
  116418. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  116419. * @param ray defines the ray to test with
  116420. * @param selection defines the array to store current content if selection is positive
  116421. */
  116422. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  116423. /**
  116424. * Subdivide the content into child blocks (this block will then be empty)
  116425. */
  116426. createInnerBlocks(): void;
  116427. /**
  116428. * @hidden
  116429. */
  116430. 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;
  116431. }
  116432. }
  116433. declare module BABYLON {
  116434. /**
  116435. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  116436. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116437. */
  116438. export class Octree<T> {
  116439. /** 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.) */
  116440. maxDepth: number;
  116441. /**
  116442. * Blocks within the octree containing objects
  116443. */
  116444. blocks: Array<OctreeBlock<T>>;
  116445. /**
  116446. * Content stored in the octree
  116447. */
  116448. dynamicContent: T[];
  116449. private _maxBlockCapacity;
  116450. private _selectionContent;
  116451. private _creationFunc;
  116452. /**
  116453. * Creates a octree
  116454. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116455. * @param creationFunc function to be used to instatiate the octree
  116456. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  116457. * @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.)
  116458. */
  116459. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  116460. /** 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.) */
  116461. maxDepth?: number);
  116462. /**
  116463. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  116464. * @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);
  116465. * @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);
  116466. * @param entries meshes to be added to the octree blocks
  116467. */
  116468. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  116469. /**
  116470. * Adds a mesh to the octree
  116471. * @param entry Mesh to add to the octree
  116472. */
  116473. addMesh(entry: T): void;
  116474. /**
  116475. * Remove an element from the octree
  116476. * @param entry defines the element to remove
  116477. */
  116478. removeMesh(entry: T): void;
  116479. /**
  116480. * Selects an array of meshes within the frustum
  116481. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  116482. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  116483. * @returns array of meshes within the frustum
  116484. */
  116485. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  116486. /**
  116487. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  116488. * @param sphereCenter defines the bounding sphere center
  116489. * @param sphereRadius defines the bounding sphere radius
  116490. * @param allowDuplicate defines if the selection array can contains duplicated entries
  116491. * @returns an array of objects that intersect the sphere
  116492. */
  116493. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  116494. /**
  116495. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  116496. * @param ray defines the ray to test with
  116497. * @returns array of intersected objects
  116498. */
  116499. intersectsRay(ray: Ray): SmartArray<T>;
  116500. /**
  116501. * Adds a mesh into the octree block if it intersects the block
  116502. */
  116503. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  116504. /**
  116505. * Adds a submesh into the octree block if it intersects the block
  116506. */
  116507. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  116508. }
  116509. }
  116510. declare module BABYLON {
  116511. interface Scene {
  116512. /**
  116513. * @hidden
  116514. * Backing Filed
  116515. */
  116516. _selectionOctree: Octree<AbstractMesh>;
  116517. /**
  116518. * Gets the octree used to boost mesh selection (picking)
  116519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116520. */
  116521. selectionOctree: Octree<AbstractMesh>;
  116522. /**
  116523. * Creates or updates the octree used to boost selection (picking)
  116524. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116525. * @param maxCapacity defines the maximum capacity per leaf
  116526. * @param maxDepth defines the maximum depth of the octree
  116527. * @returns an octree of AbstractMesh
  116528. */
  116529. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  116530. }
  116531. interface AbstractMesh {
  116532. /**
  116533. * @hidden
  116534. * Backing Field
  116535. */
  116536. _submeshesOctree: Octree<SubMesh>;
  116537. /**
  116538. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  116539. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  116540. * @param maxCapacity defines the maximum size of each block (64 by default)
  116541. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  116542. * @returns the new octree
  116543. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  116544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116545. */
  116546. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  116547. }
  116548. /**
  116549. * Defines the octree scene component responsible to manage any octrees
  116550. * in a given scene.
  116551. */
  116552. export class OctreeSceneComponent {
  116553. /**
  116554. * The component name help to identify the component in the list of scene components.
  116555. */
  116556. readonly name: string;
  116557. /**
  116558. * The scene the component belongs to.
  116559. */
  116560. scene: Scene;
  116561. /**
  116562. * Indicates if the meshes have been checked to make sure they are isEnabled()
  116563. */
  116564. readonly checksIsEnabled: boolean;
  116565. /**
  116566. * Creates a new instance of the component for the given scene
  116567. * @param scene Defines the scene to register the component in
  116568. */
  116569. constructor(scene: Scene);
  116570. /**
  116571. * Registers the component in a given scene
  116572. */
  116573. register(): void;
  116574. /**
  116575. * Return the list of active meshes
  116576. * @returns the list of active meshes
  116577. */
  116578. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116579. /**
  116580. * Return the list of active sub meshes
  116581. * @param mesh The mesh to get the candidates sub meshes from
  116582. * @returns the list of active sub meshes
  116583. */
  116584. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116585. private _tempRay;
  116586. /**
  116587. * Return the list of sub meshes intersecting with a given local ray
  116588. * @param mesh defines the mesh to find the submesh for
  116589. * @param localRay defines the ray in local space
  116590. * @returns the list of intersecting sub meshes
  116591. */
  116592. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  116593. /**
  116594. * Return the list of sub meshes colliding with a collider
  116595. * @param mesh defines the mesh to find the submesh for
  116596. * @param collider defines the collider to evaluate the collision against
  116597. * @returns the list of colliding sub meshes
  116598. */
  116599. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  116600. /**
  116601. * Rebuilds the elements related to this component in case of
  116602. * context lost for instance.
  116603. */
  116604. rebuild(): void;
  116605. /**
  116606. * Disposes the component and the associated ressources.
  116607. */
  116608. dispose(): void;
  116609. }
  116610. }
  116611. declare module BABYLON {
  116612. /**
  116613. * Renders a layer on top of an existing scene
  116614. */
  116615. export class UtilityLayerRenderer implements IDisposable {
  116616. /** the original scene that will be rendered on top of */
  116617. originalScene: Scene;
  116618. private _pointerCaptures;
  116619. private _lastPointerEvents;
  116620. private static _DefaultUtilityLayer;
  116621. private static _DefaultKeepDepthUtilityLayer;
  116622. private _sharedGizmoLight;
  116623. private _renderCamera;
  116624. /**
  116625. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  116626. * @returns the camera that is used when rendering the utility layer
  116627. */
  116628. getRenderCamera(): Nullable<Camera>;
  116629. /**
  116630. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  116631. * @param cam the camera that should be used when rendering the utility layer
  116632. */
  116633. setRenderCamera(cam: Nullable<Camera>): void;
  116634. /**
  116635. * @hidden
  116636. * Light which used by gizmos to get light shading
  116637. */
  116638. _getSharedGizmoLight(): HemisphericLight;
  116639. /**
  116640. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  116641. */
  116642. pickUtilitySceneFirst: boolean;
  116643. /**
  116644. * 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)
  116645. */
  116646. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  116647. /**
  116648. * 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)
  116649. */
  116650. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  116651. /**
  116652. * The scene that is rendered on top of the original scene
  116653. */
  116654. utilityLayerScene: Scene;
  116655. /**
  116656. * If the utility layer should automatically be rendered on top of existing scene
  116657. */
  116658. shouldRender: boolean;
  116659. /**
  116660. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  116661. */
  116662. onlyCheckPointerDownEvents: boolean;
  116663. /**
  116664. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  116665. */
  116666. processAllEvents: boolean;
  116667. /**
  116668. * Observable raised when the pointer move from the utility layer scene to the main scene
  116669. */
  116670. onPointerOutObservable: Observable<number>;
  116671. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  116672. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  116673. private _afterRenderObserver;
  116674. private _sceneDisposeObserver;
  116675. private _originalPointerObserver;
  116676. /**
  116677. * Instantiates a UtilityLayerRenderer
  116678. * @param originalScene the original scene that will be rendered on top of
  116679. * @param handleEvents boolean indicating if the utility layer should handle events
  116680. */
  116681. constructor(
  116682. /** the original scene that will be rendered on top of */
  116683. originalScene: Scene, handleEvents?: boolean);
  116684. private _notifyObservers;
  116685. /**
  116686. * Renders the utility layers scene on top of the original scene
  116687. */
  116688. render(): void;
  116689. /**
  116690. * Disposes of the renderer
  116691. */
  116692. dispose(): void;
  116693. private _updateCamera;
  116694. }
  116695. }
  116696. declare module BABYLON {
  116697. /**
  116698. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  116699. */
  116700. export class Gizmo implements IDisposable {
  116701. /** The utility layer the gizmo will be added to */
  116702. gizmoLayer: UtilityLayerRenderer;
  116703. /**
  116704. * The root mesh of the gizmo
  116705. */
  116706. _rootMesh: Mesh;
  116707. private _attachedMesh;
  116708. /**
  116709. * Ratio for the scale of the gizmo (Default: 1)
  116710. */
  116711. scaleRatio: number;
  116712. /**
  116713. * If a custom mesh has been set (Default: false)
  116714. */
  116715. protected _customMeshSet: boolean;
  116716. /**
  116717. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  116718. * * When set, interactions will be enabled
  116719. */
  116720. get attachedMesh(): Nullable<AbstractMesh>;
  116721. set attachedMesh(value: Nullable<AbstractMesh>);
  116722. /**
  116723. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  116724. * @param mesh The mesh to replace the default mesh of the gizmo
  116725. */
  116726. setCustomMesh(mesh: Mesh): void;
  116727. /**
  116728. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  116729. */
  116730. updateGizmoRotationToMatchAttachedMesh: boolean;
  116731. /**
  116732. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  116733. */
  116734. updateGizmoPositionToMatchAttachedMesh: boolean;
  116735. /**
  116736. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  116737. */
  116738. updateScale: boolean;
  116739. protected _interactionsEnabled: boolean;
  116740. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116741. private _beforeRenderObserver;
  116742. private _tempVector;
  116743. /**
  116744. * Creates a gizmo
  116745. * @param gizmoLayer The utility layer the gizmo will be added to
  116746. */
  116747. constructor(
  116748. /** The utility layer the gizmo will be added to */
  116749. gizmoLayer?: UtilityLayerRenderer);
  116750. /**
  116751. * Updates the gizmo to match the attached mesh's position/rotation
  116752. */
  116753. protected _update(): void;
  116754. /**
  116755. * Disposes of the gizmo
  116756. */
  116757. dispose(): void;
  116758. }
  116759. }
  116760. declare module BABYLON {
  116761. /**
  116762. * Single plane drag gizmo
  116763. */
  116764. export class PlaneDragGizmo extends Gizmo {
  116765. /**
  116766. * Drag behavior responsible for the gizmos dragging interactions
  116767. */
  116768. dragBehavior: PointerDragBehavior;
  116769. private _pointerObserver;
  116770. /**
  116771. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116772. */
  116773. snapDistance: number;
  116774. /**
  116775. * Event that fires each time the gizmo snaps to a new location.
  116776. * * snapDistance is the the change in distance
  116777. */
  116778. onSnapObservable: Observable<{
  116779. snapDistance: number;
  116780. }>;
  116781. private _plane;
  116782. private _coloredMaterial;
  116783. private _hoverMaterial;
  116784. private _isEnabled;
  116785. private _parent;
  116786. /** @hidden */
  116787. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  116788. /** @hidden */
  116789. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  116790. /**
  116791. * Creates a PlaneDragGizmo
  116792. * @param gizmoLayer The utility layer the gizmo will be added to
  116793. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  116794. * @param color The color of the gizmo
  116795. */
  116796. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  116797. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116798. /**
  116799. * If the gizmo is enabled
  116800. */
  116801. set isEnabled(value: boolean);
  116802. get isEnabled(): boolean;
  116803. /**
  116804. * Disposes of the gizmo
  116805. */
  116806. dispose(): void;
  116807. }
  116808. }
  116809. declare module BABYLON {
  116810. /**
  116811. * Gizmo that enables dragging a mesh along 3 axis
  116812. */
  116813. export class PositionGizmo extends Gizmo {
  116814. /**
  116815. * Internal gizmo used for interactions on the x axis
  116816. */
  116817. xGizmo: AxisDragGizmo;
  116818. /**
  116819. * Internal gizmo used for interactions on the y axis
  116820. */
  116821. yGizmo: AxisDragGizmo;
  116822. /**
  116823. * Internal gizmo used for interactions on the z axis
  116824. */
  116825. zGizmo: AxisDragGizmo;
  116826. /**
  116827. * Internal gizmo used for interactions on the yz plane
  116828. */
  116829. xPlaneGizmo: PlaneDragGizmo;
  116830. /**
  116831. * Internal gizmo used for interactions on the xz plane
  116832. */
  116833. yPlaneGizmo: PlaneDragGizmo;
  116834. /**
  116835. * Internal gizmo used for interactions on the xy plane
  116836. */
  116837. zPlaneGizmo: PlaneDragGizmo;
  116838. /**
  116839. * private variables
  116840. */
  116841. private _meshAttached;
  116842. private _updateGizmoRotationToMatchAttachedMesh;
  116843. private _snapDistance;
  116844. private _scaleRatio;
  116845. /** Fires an event when any of it's sub gizmos are dragged */
  116846. onDragStartObservable: Observable<unknown>;
  116847. /** Fires an event when any of it's sub gizmos are released from dragging */
  116848. onDragEndObservable: Observable<unknown>;
  116849. /**
  116850. * If set to true, planar drag is enabled
  116851. */
  116852. private _planarGizmoEnabled;
  116853. get attachedMesh(): Nullable<AbstractMesh>;
  116854. set attachedMesh(mesh: Nullable<AbstractMesh>);
  116855. /**
  116856. * Creates a PositionGizmo
  116857. * @param gizmoLayer The utility layer the gizmo will be added to
  116858. */
  116859. constructor(gizmoLayer?: UtilityLayerRenderer);
  116860. /**
  116861. * If the planar drag gizmo is enabled
  116862. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  116863. */
  116864. set planarGizmoEnabled(value: boolean);
  116865. get planarGizmoEnabled(): boolean;
  116866. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  116867. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  116868. /**
  116869. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116870. */
  116871. set snapDistance(value: number);
  116872. get snapDistance(): number;
  116873. /**
  116874. * Ratio for the scale of the gizmo (Default: 1)
  116875. */
  116876. set scaleRatio(value: number);
  116877. get scaleRatio(): number;
  116878. /**
  116879. * Disposes of the gizmo
  116880. */
  116881. dispose(): void;
  116882. /**
  116883. * CustomMeshes are not supported by this gizmo
  116884. * @param mesh The mesh to replace the default mesh of the gizmo
  116885. */
  116886. setCustomMesh(mesh: Mesh): void;
  116887. }
  116888. }
  116889. declare module BABYLON {
  116890. /**
  116891. * Single axis drag gizmo
  116892. */
  116893. export class AxisDragGizmo extends Gizmo {
  116894. /**
  116895. * Drag behavior responsible for the gizmos dragging interactions
  116896. */
  116897. dragBehavior: PointerDragBehavior;
  116898. private _pointerObserver;
  116899. /**
  116900. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116901. */
  116902. snapDistance: number;
  116903. /**
  116904. * Event that fires each time the gizmo snaps to a new location.
  116905. * * snapDistance is the the change in distance
  116906. */
  116907. onSnapObservable: Observable<{
  116908. snapDistance: number;
  116909. }>;
  116910. private _isEnabled;
  116911. private _parent;
  116912. private _arrow;
  116913. private _coloredMaterial;
  116914. private _hoverMaterial;
  116915. /** @hidden */
  116916. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  116917. /** @hidden */
  116918. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  116919. /**
  116920. * Creates an AxisDragGizmo
  116921. * @param gizmoLayer The utility layer the gizmo will be added to
  116922. * @param dragAxis The axis which the gizmo will be able to drag on
  116923. * @param color The color of the gizmo
  116924. */
  116925. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  116926. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116927. /**
  116928. * If the gizmo is enabled
  116929. */
  116930. set isEnabled(value: boolean);
  116931. get isEnabled(): boolean;
  116932. /**
  116933. * Disposes of the gizmo
  116934. */
  116935. dispose(): void;
  116936. }
  116937. }
  116938. declare module BABYLON.Debug {
  116939. /**
  116940. * The Axes viewer will show 3 axes in a specific point in space
  116941. */
  116942. export class AxesViewer {
  116943. private _xAxis;
  116944. private _yAxis;
  116945. private _zAxis;
  116946. private _scaleLinesFactor;
  116947. private _instanced;
  116948. /**
  116949. * Gets the hosting scene
  116950. */
  116951. scene: Scene;
  116952. /**
  116953. * Gets or sets a number used to scale line length
  116954. */
  116955. scaleLines: number;
  116956. /** Gets the node hierarchy used to render x-axis */
  116957. get xAxis(): TransformNode;
  116958. /** Gets the node hierarchy used to render y-axis */
  116959. get yAxis(): TransformNode;
  116960. /** Gets the node hierarchy used to render z-axis */
  116961. get zAxis(): TransformNode;
  116962. /**
  116963. * Creates a new AxesViewer
  116964. * @param scene defines the hosting scene
  116965. * @param scaleLines defines a number used to scale line length (1 by default)
  116966. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  116967. * @param xAxis defines the node hierarchy used to render the x-axis
  116968. * @param yAxis defines the node hierarchy used to render the y-axis
  116969. * @param zAxis defines the node hierarchy used to render the z-axis
  116970. */
  116971. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  116972. /**
  116973. * Force the viewer to update
  116974. * @param position defines the position of the viewer
  116975. * @param xaxis defines the x axis of the viewer
  116976. * @param yaxis defines the y axis of the viewer
  116977. * @param zaxis defines the z axis of the viewer
  116978. */
  116979. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  116980. /**
  116981. * Creates an instance of this axes viewer.
  116982. * @returns a new axes viewer with instanced meshes
  116983. */
  116984. createInstance(): AxesViewer;
  116985. /** Releases resources */
  116986. dispose(): void;
  116987. private static _SetRenderingGroupId;
  116988. }
  116989. }
  116990. declare module BABYLON.Debug {
  116991. /**
  116992. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  116993. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  116994. */
  116995. export class BoneAxesViewer extends AxesViewer {
  116996. /**
  116997. * Gets or sets the target mesh where to display the axes viewer
  116998. */
  116999. mesh: Nullable<Mesh>;
  117000. /**
  117001. * Gets or sets the target bone where to display the axes viewer
  117002. */
  117003. bone: Nullable<Bone>;
  117004. /** Gets current position */
  117005. pos: Vector3;
  117006. /** Gets direction of X axis */
  117007. xaxis: Vector3;
  117008. /** Gets direction of Y axis */
  117009. yaxis: Vector3;
  117010. /** Gets direction of Z axis */
  117011. zaxis: Vector3;
  117012. /**
  117013. * Creates a new BoneAxesViewer
  117014. * @param scene defines the hosting scene
  117015. * @param bone defines the target bone
  117016. * @param mesh defines the target mesh
  117017. * @param scaleLines defines a scaling factor for line length (1 by default)
  117018. */
  117019. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  117020. /**
  117021. * Force the viewer to update
  117022. */
  117023. update(): void;
  117024. /** Releases resources */
  117025. dispose(): void;
  117026. }
  117027. }
  117028. declare module BABYLON {
  117029. /**
  117030. * Interface used to define scene explorer extensibility option
  117031. */
  117032. export interface IExplorerExtensibilityOption {
  117033. /**
  117034. * Define the option label
  117035. */
  117036. label: string;
  117037. /**
  117038. * Defines the action to execute on click
  117039. */
  117040. action: (entity: any) => void;
  117041. }
  117042. /**
  117043. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  117044. */
  117045. export interface IExplorerExtensibilityGroup {
  117046. /**
  117047. * Defines a predicate to test if a given type mut be extended
  117048. */
  117049. predicate: (entity: any) => boolean;
  117050. /**
  117051. * Gets the list of options added to a type
  117052. */
  117053. entries: IExplorerExtensibilityOption[];
  117054. }
  117055. /**
  117056. * Interface used to define the options to use to create the Inspector
  117057. */
  117058. export interface IInspectorOptions {
  117059. /**
  117060. * Display in overlay mode (default: false)
  117061. */
  117062. overlay?: boolean;
  117063. /**
  117064. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  117065. */
  117066. globalRoot?: HTMLElement;
  117067. /**
  117068. * Display the Scene explorer
  117069. */
  117070. showExplorer?: boolean;
  117071. /**
  117072. * Display the property inspector
  117073. */
  117074. showInspector?: boolean;
  117075. /**
  117076. * Display in embed mode (both panes on the right)
  117077. */
  117078. embedMode?: boolean;
  117079. /**
  117080. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  117081. */
  117082. handleResize?: boolean;
  117083. /**
  117084. * Allow the panes to popup (default: true)
  117085. */
  117086. enablePopup?: boolean;
  117087. /**
  117088. * Allow the panes to be closed by users (default: true)
  117089. */
  117090. enableClose?: boolean;
  117091. /**
  117092. * Optional list of extensibility entries
  117093. */
  117094. explorerExtensibility?: IExplorerExtensibilityGroup[];
  117095. /**
  117096. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  117097. */
  117098. inspectorURL?: string;
  117099. /**
  117100. * Optional initial tab (default to DebugLayerTab.Properties)
  117101. */
  117102. initialTab?: DebugLayerTab;
  117103. }
  117104. interface Scene {
  117105. /**
  117106. * @hidden
  117107. * Backing field
  117108. */
  117109. _debugLayer: DebugLayer;
  117110. /**
  117111. * Gets the debug layer (aka Inspector) associated with the scene
  117112. * @see http://doc.babylonjs.com/features/playground_debuglayer
  117113. */
  117114. debugLayer: DebugLayer;
  117115. }
  117116. /**
  117117. * Enum of inspector action tab
  117118. */
  117119. export enum DebugLayerTab {
  117120. /**
  117121. * Properties tag (default)
  117122. */
  117123. Properties = 0,
  117124. /**
  117125. * Debug tab
  117126. */
  117127. Debug = 1,
  117128. /**
  117129. * Statistics tab
  117130. */
  117131. Statistics = 2,
  117132. /**
  117133. * Tools tab
  117134. */
  117135. Tools = 3,
  117136. /**
  117137. * Settings tab
  117138. */
  117139. Settings = 4
  117140. }
  117141. /**
  117142. * The debug layer (aka Inspector) is the go to tool in order to better understand
  117143. * what is happening in your scene
  117144. * @see http://doc.babylonjs.com/features/playground_debuglayer
  117145. */
  117146. export class DebugLayer {
  117147. /**
  117148. * Define the url to get the inspector script from.
  117149. * By default it uses the babylonjs CDN.
  117150. * @ignoreNaming
  117151. */
  117152. static InspectorURL: string;
  117153. private _scene;
  117154. private BJSINSPECTOR;
  117155. private _onPropertyChangedObservable?;
  117156. /**
  117157. * Observable triggered when a property is changed through the inspector.
  117158. */
  117159. get onPropertyChangedObservable(): any;
  117160. /**
  117161. * Instantiates a new debug layer.
  117162. * The debug layer (aka Inspector) is the go to tool in order to better understand
  117163. * what is happening in your scene
  117164. * @see http://doc.babylonjs.com/features/playground_debuglayer
  117165. * @param scene Defines the scene to inspect
  117166. */
  117167. constructor(scene: Scene);
  117168. /** Creates the inspector window. */
  117169. private _createInspector;
  117170. /**
  117171. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  117172. * @param entity defines the entity to select
  117173. * @param lineContainerTitle defines the specific block to highlight
  117174. */
  117175. select(entity: any, lineContainerTitle?: string): void;
  117176. /** Get the inspector from bundle or global */
  117177. private _getGlobalInspector;
  117178. /**
  117179. * Get if the inspector is visible or not.
  117180. * @returns true if visible otherwise, false
  117181. */
  117182. isVisible(): boolean;
  117183. /**
  117184. * Hide the inspector and close its window.
  117185. */
  117186. hide(): void;
  117187. /**
  117188. * Launch the debugLayer.
  117189. * @param config Define the configuration of the inspector
  117190. * @return a promise fulfilled when the debug layer is visible
  117191. */
  117192. show(config?: IInspectorOptions): Promise<DebugLayer>;
  117193. }
  117194. }
  117195. declare module BABYLON {
  117196. /**
  117197. * Class containing static functions to help procedurally build meshes
  117198. */
  117199. export class BoxBuilder {
  117200. /**
  117201. * Creates a box mesh
  117202. * * The parameter `size` sets the size (float) of each box side (default 1)
  117203. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  117204. * * 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)
  117205. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117209. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117210. * @param name defines the name of the mesh
  117211. * @param options defines the options used to create the mesh
  117212. * @param scene defines the hosting scene
  117213. * @returns the box mesh
  117214. */
  117215. static CreateBox(name: string, options: {
  117216. size?: number;
  117217. width?: number;
  117218. height?: number;
  117219. depth?: number;
  117220. faceUV?: Vector4[];
  117221. faceColors?: Color4[];
  117222. sideOrientation?: number;
  117223. frontUVs?: Vector4;
  117224. backUVs?: Vector4;
  117225. wrap?: boolean;
  117226. topBaseAt?: number;
  117227. bottomBaseAt?: number;
  117228. updatable?: boolean;
  117229. }, scene?: Nullable<Scene>): Mesh;
  117230. }
  117231. }
  117232. declare module BABYLON {
  117233. /**
  117234. * Class containing static functions to help procedurally build meshes
  117235. */
  117236. export class SphereBuilder {
  117237. /**
  117238. * Creates a sphere mesh
  117239. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117240. * * 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`)
  117241. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117242. * * 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
  117243. * * 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)
  117244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117247. * @param name defines the name of the mesh
  117248. * @param options defines the options used to create the mesh
  117249. * @param scene defines the hosting scene
  117250. * @returns the sphere mesh
  117251. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117252. */
  117253. static CreateSphere(name: string, options: {
  117254. segments?: number;
  117255. diameter?: number;
  117256. diameterX?: number;
  117257. diameterY?: number;
  117258. diameterZ?: number;
  117259. arc?: number;
  117260. slice?: number;
  117261. sideOrientation?: number;
  117262. frontUVs?: Vector4;
  117263. backUVs?: Vector4;
  117264. updatable?: boolean;
  117265. }, scene?: Nullable<Scene>): Mesh;
  117266. }
  117267. }
  117268. declare module BABYLON.Debug {
  117269. /**
  117270. * Used to show the physics impostor around the specific mesh
  117271. */
  117272. export class PhysicsViewer {
  117273. /** @hidden */
  117274. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  117275. /** @hidden */
  117276. protected _meshes: Array<Nullable<AbstractMesh>>;
  117277. /** @hidden */
  117278. protected _scene: Nullable<Scene>;
  117279. /** @hidden */
  117280. protected _numMeshes: number;
  117281. /** @hidden */
  117282. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  117283. private _renderFunction;
  117284. private _utilityLayer;
  117285. private _debugBoxMesh;
  117286. private _debugSphereMesh;
  117287. private _debugCylinderMesh;
  117288. private _debugMaterial;
  117289. private _debugMeshMeshes;
  117290. /**
  117291. * Creates a new PhysicsViewer
  117292. * @param scene defines the hosting scene
  117293. */
  117294. constructor(scene: Scene);
  117295. /** @hidden */
  117296. protected _updateDebugMeshes(): void;
  117297. /**
  117298. * Renders a specified physic impostor
  117299. * @param impostor defines the impostor to render
  117300. * @param targetMesh defines the mesh represented by the impostor
  117301. * @returns the new debug mesh used to render the impostor
  117302. */
  117303. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  117304. /**
  117305. * Hides a specified physic impostor
  117306. * @param impostor defines the impostor to hide
  117307. */
  117308. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  117309. private _getDebugMaterial;
  117310. private _getDebugBoxMesh;
  117311. private _getDebugSphereMesh;
  117312. private _getDebugCylinderMesh;
  117313. private _getDebugMeshMesh;
  117314. private _getDebugMesh;
  117315. /** Releases all resources */
  117316. dispose(): void;
  117317. }
  117318. }
  117319. declare module BABYLON {
  117320. /**
  117321. * Class containing static functions to help procedurally build meshes
  117322. */
  117323. export class LinesBuilder {
  117324. /**
  117325. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117326. * * 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
  117327. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117328. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117329. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117330. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117331. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117332. * * 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
  117333. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117336. * @param name defines the name of the new line system
  117337. * @param options defines the options used to create the line system
  117338. * @param scene defines the hosting scene
  117339. * @returns a new line system mesh
  117340. */
  117341. static CreateLineSystem(name: string, options: {
  117342. lines: Vector3[][];
  117343. updatable?: boolean;
  117344. instance?: Nullable<LinesMesh>;
  117345. colors?: Nullable<Color4[][]>;
  117346. useVertexAlpha?: boolean;
  117347. }, scene: Nullable<Scene>): LinesMesh;
  117348. /**
  117349. * Creates a line mesh
  117350. * 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
  117351. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117352. * * The parameter `points` is an array successive Vector3
  117353. * * 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
  117354. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117355. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117356. * * When updating an instance, remember that only point positions can change, not the number of points
  117357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117359. * @param name defines the name of the new line system
  117360. * @param options defines the options used to create the line system
  117361. * @param scene defines the hosting scene
  117362. * @returns a new line mesh
  117363. */
  117364. static CreateLines(name: string, options: {
  117365. points: Vector3[];
  117366. updatable?: boolean;
  117367. instance?: Nullable<LinesMesh>;
  117368. colors?: Color4[];
  117369. useVertexAlpha?: boolean;
  117370. }, scene?: Nullable<Scene>): LinesMesh;
  117371. /**
  117372. * Creates a dashed line mesh
  117373. * * 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
  117374. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117375. * * The parameter `points` is an array successive Vector3
  117376. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117377. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117378. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117379. * * 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
  117380. * * When updating an instance, remember that only point positions can change, not the number of points
  117381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117382. * @param name defines the name of the mesh
  117383. * @param options defines the options used to create the mesh
  117384. * @param scene defines the hosting scene
  117385. * @returns the dashed line mesh
  117386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117387. */
  117388. static CreateDashedLines(name: string, options: {
  117389. points: Vector3[];
  117390. dashSize?: number;
  117391. gapSize?: number;
  117392. dashNb?: number;
  117393. updatable?: boolean;
  117394. instance?: LinesMesh;
  117395. }, scene?: Nullable<Scene>): LinesMesh;
  117396. }
  117397. }
  117398. declare module BABYLON {
  117399. /**
  117400. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  117401. * in order to better appreciate the issue one might have.
  117402. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  117403. */
  117404. export class RayHelper {
  117405. /**
  117406. * Defines the ray we are currently tryin to visualize.
  117407. */
  117408. ray: Nullable<Ray>;
  117409. private _renderPoints;
  117410. private _renderLine;
  117411. private _renderFunction;
  117412. private _scene;
  117413. private _updateToMeshFunction;
  117414. private _attachedToMesh;
  117415. private _meshSpaceDirection;
  117416. private _meshSpaceOrigin;
  117417. /**
  117418. * Helper function to create a colored helper in a scene in one line.
  117419. * @param ray Defines the ray we are currently tryin to visualize
  117420. * @param scene Defines the scene the ray is used in
  117421. * @param color Defines the color we want to see the ray in
  117422. * @returns The newly created ray helper.
  117423. */
  117424. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  117425. /**
  117426. * Instantiate a new ray helper.
  117427. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  117428. * in order to better appreciate the issue one might have.
  117429. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  117430. * @param ray Defines the ray we are currently tryin to visualize
  117431. */
  117432. constructor(ray: Ray);
  117433. /**
  117434. * Shows the ray we are willing to debug.
  117435. * @param scene Defines the scene the ray needs to be rendered in
  117436. * @param color Defines the color the ray needs to be rendered in
  117437. */
  117438. show(scene: Scene, color?: Color3): void;
  117439. /**
  117440. * Hides the ray we are debugging.
  117441. */
  117442. hide(): void;
  117443. private _render;
  117444. /**
  117445. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  117446. * @param mesh Defines the mesh we want the helper attached to
  117447. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  117448. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  117449. * @param length Defines the length of the ray
  117450. */
  117451. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  117452. /**
  117453. * Detach the ray helper from the mesh it has previously been attached to.
  117454. */
  117455. detachFromMesh(): void;
  117456. private _updateToMesh;
  117457. /**
  117458. * Dispose the helper and release its associated resources.
  117459. */
  117460. dispose(): void;
  117461. }
  117462. }
  117463. declare module BABYLON.Debug {
  117464. /**
  117465. * Class used to render a debug view of a given skeleton
  117466. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  117467. */
  117468. export class SkeletonViewer {
  117469. /** defines the skeleton to render */
  117470. skeleton: Skeleton;
  117471. /** defines the mesh attached to the skeleton */
  117472. mesh: AbstractMesh;
  117473. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  117474. autoUpdateBonesMatrices: boolean;
  117475. /** defines the rendering group id to use with the viewer */
  117476. renderingGroupId: number;
  117477. /** Gets or sets the color used to render the skeleton */
  117478. color: Color3;
  117479. private _scene;
  117480. private _debugLines;
  117481. private _debugMesh;
  117482. private _isEnabled;
  117483. private _renderFunction;
  117484. private _utilityLayer;
  117485. /**
  117486. * Returns the mesh used to render the bones
  117487. */
  117488. get debugMesh(): Nullable<LinesMesh>;
  117489. /**
  117490. * Creates a new SkeletonViewer
  117491. * @param skeleton defines the skeleton to render
  117492. * @param mesh defines the mesh attached to the skeleton
  117493. * @param scene defines the hosting scene
  117494. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  117495. * @param renderingGroupId defines the rendering group id to use with the viewer
  117496. */
  117497. constructor(
  117498. /** defines the skeleton to render */
  117499. skeleton: Skeleton,
  117500. /** defines the mesh attached to the skeleton */
  117501. mesh: AbstractMesh, scene: Scene,
  117502. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  117503. autoUpdateBonesMatrices?: boolean,
  117504. /** defines the rendering group id to use with the viewer */
  117505. renderingGroupId?: number);
  117506. /** Gets or sets a boolean indicating if the viewer is enabled */
  117507. set isEnabled(value: boolean);
  117508. get isEnabled(): boolean;
  117509. private _getBonePosition;
  117510. private _getLinesForBonesWithLength;
  117511. private _getLinesForBonesNoLength;
  117512. /** Update the viewer to sync with current skeleton state */
  117513. update(): void;
  117514. /** Release associated resources */
  117515. dispose(): void;
  117516. }
  117517. }
  117518. declare module BABYLON {
  117519. /**
  117520. * Options to create the null engine
  117521. */
  117522. export class NullEngineOptions {
  117523. /**
  117524. * Render width (Default: 512)
  117525. */
  117526. renderWidth: number;
  117527. /**
  117528. * Render height (Default: 256)
  117529. */
  117530. renderHeight: number;
  117531. /**
  117532. * Texture size (Default: 512)
  117533. */
  117534. textureSize: number;
  117535. /**
  117536. * If delta time between frames should be constant
  117537. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117538. */
  117539. deterministicLockstep: boolean;
  117540. /**
  117541. * Maximum about of steps between frames (Default: 4)
  117542. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117543. */
  117544. lockstepMaxSteps: number;
  117545. }
  117546. /**
  117547. * The null engine class provides support for headless version of babylon.js.
  117548. * This can be used in server side scenario or for testing purposes
  117549. */
  117550. export class NullEngine extends Engine {
  117551. private _options;
  117552. /**
  117553. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117554. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117555. * @returns true if engine is in deterministic lock step mode
  117556. */
  117557. isDeterministicLockStep(): boolean;
  117558. /**
  117559. * Gets the max steps when engine is running in deterministic lock step
  117560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117561. * @returns the max steps
  117562. */
  117563. getLockstepMaxSteps(): number;
  117564. /**
  117565. * Gets the current hardware scaling level.
  117566. * By default the hardware scaling level is computed from the window device ratio.
  117567. * 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.
  117568. * @returns a number indicating the current hardware scaling level
  117569. */
  117570. getHardwareScalingLevel(): number;
  117571. constructor(options?: NullEngineOptions);
  117572. /**
  117573. * Creates a vertex buffer
  117574. * @param vertices the data for the vertex buffer
  117575. * @returns the new WebGL static buffer
  117576. */
  117577. createVertexBuffer(vertices: FloatArray): DataBuffer;
  117578. /**
  117579. * Creates a new index buffer
  117580. * @param indices defines the content of the index buffer
  117581. * @param updatable defines if the index buffer must be updatable
  117582. * @returns a new webGL buffer
  117583. */
  117584. createIndexBuffer(indices: IndicesArray): DataBuffer;
  117585. /**
  117586. * Clear the current render buffer or the current render target (if any is set up)
  117587. * @param color defines the color to use
  117588. * @param backBuffer defines if the back buffer must be cleared
  117589. * @param depth defines if the depth buffer must be cleared
  117590. * @param stencil defines if the stencil buffer must be cleared
  117591. */
  117592. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117593. /**
  117594. * Gets the current render width
  117595. * @param useScreen defines if screen size must be used (or the current render target if any)
  117596. * @returns a number defining the current render width
  117597. */
  117598. getRenderWidth(useScreen?: boolean): number;
  117599. /**
  117600. * Gets the current render height
  117601. * @param useScreen defines if screen size must be used (or the current render target if any)
  117602. * @returns a number defining the current render height
  117603. */
  117604. getRenderHeight(useScreen?: boolean): number;
  117605. /**
  117606. * Set the WebGL's viewport
  117607. * @param viewport defines the viewport element to be used
  117608. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  117609. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  117610. */
  117611. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  117612. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  117613. /**
  117614. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  117615. * @param pipelineContext defines the pipeline context to use
  117616. * @param uniformsNames defines the list of uniform names
  117617. * @returns an array of webGL uniform locations
  117618. */
  117619. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  117620. /**
  117621. * Gets the lsit of active attributes for a given webGL program
  117622. * @param pipelineContext defines the pipeline context to use
  117623. * @param attributesNames defines the list of attribute names to get
  117624. * @returns an array of indices indicating the offset of each attribute
  117625. */
  117626. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117627. /**
  117628. * Binds an effect to the webGL context
  117629. * @param effect defines the effect to bind
  117630. */
  117631. bindSamplers(effect: Effect): void;
  117632. /**
  117633. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  117634. * @param effect defines the effect to activate
  117635. */
  117636. enableEffect(effect: Effect): void;
  117637. /**
  117638. * Set various states to the webGL context
  117639. * @param culling defines backface culling state
  117640. * @param zOffset defines the value to apply to zOffset (0 by default)
  117641. * @param force defines if states must be applied even if cache is up to date
  117642. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117643. */
  117644. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117645. /**
  117646. * Set the value of an uniform to an array of int32
  117647. * @param uniform defines the webGL uniform location where to store the value
  117648. * @param array defines the array of int32 to store
  117649. */
  117650. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117651. /**
  117652. * Set the value of an uniform to an array of int32 (stored as vec2)
  117653. * @param uniform defines the webGL uniform location where to store the value
  117654. * @param array defines the array of int32 to store
  117655. */
  117656. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117657. /**
  117658. * Set the value of an uniform to an array of int32 (stored as vec3)
  117659. * @param uniform defines the webGL uniform location where to store the value
  117660. * @param array defines the array of int32 to store
  117661. */
  117662. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117663. /**
  117664. * Set the value of an uniform to an array of int32 (stored as vec4)
  117665. * @param uniform defines the webGL uniform location where to store the value
  117666. * @param array defines the array of int32 to store
  117667. */
  117668. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117669. /**
  117670. * Set the value of an uniform to an array of float32
  117671. * @param uniform defines the webGL uniform location where to store the value
  117672. * @param array defines the array of float32 to store
  117673. */
  117674. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117675. /**
  117676. * Set the value of an uniform to an array of float32 (stored as vec2)
  117677. * @param uniform defines the webGL uniform location where to store the value
  117678. * @param array defines the array of float32 to store
  117679. */
  117680. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117681. /**
  117682. * Set the value of an uniform to an array of float32 (stored as vec3)
  117683. * @param uniform defines the webGL uniform location where to store the value
  117684. * @param array defines the array of float32 to store
  117685. */
  117686. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117687. /**
  117688. * Set the value of an uniform to an array of float32 (stored as vec4)
  117689. * @param uniform defines the webGL uniform location where to store the value
  117690. * @param array defines the array of float32 to store
  117691. */
  117692. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117693. /**
  117694. * Set the value of an uniform to an array of number
  117695. * @param uniform defines the webGL uniform location where to store the value
  117696. * @param array defines the array of number to store
  117697. */
  117698. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117699. /**
  117700. * Set the value of an uniform to an array of number (stored as vec2)
  117701. * @param uniform defines the webGL uniform location where to store the value
  117702. * @param array defines the array of number to store
  117703. */
  117704. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117705. /**
  117706. * Set the value of an uniform to an array of number (stored as vec3)
  117707. * @param uniform defines the webGL uniform location where to store the value
  117708. * @param array defines the array of number to store
  117709. */
  117710. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117711. /**
  117712. * Set the value of an uniform to an array of number (stored as vec4)
  117713. * @param uniform defines the webGL uniform location where to store the value
  117714. * @param array defines the array of number to store
  117715. */
  117716. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117717. /**
  117718. * Set the value of an uniform to an array of float32 (stored as matrices)
  117719. * @param uniform defines the webGL uniform location where to store the value
  117720. * @param matrices defines the array of float32 to store
  117721. */
  117722. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117723. /**
  117724. * Set the value of an uniform to a matrix (3x3)
  117725. * @param uniform defines the webGL uniform location where to store the value
  117726. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  117727. */
  117728. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117729. /**
  117730. * Set the value of an uniform to a matrix (2x2)
  117731. * @param uniform defines the webGL uniform location where to store the value
  117732. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  117733. */
  117734. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117735. /**
  117736. * Set the value of an uniform to a number (float)
  117737. * @param uniform defines the webGL uniform location where to store the value
  117738. * @param value defines the float number to store
  117739. */
  117740. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117741. /**
  117742. * Set the value of an uniform to a vec2
  117743. * @param uniform defines the webGL uniform location where to store the value
  117744. * @param x defines the 1st component of the value
  117745. * @param y defines the 2nd component of the value
  117746. */
  117747. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117748. /**
  117749. * Set the value of an uniform to a vec3
  117750. * @param uniform defines the webGL uniform location where to store the value
  117751. * @param x defines the 1st component of the value
  117752. * @param y defines the 2nd component of the value
  117753. * @param z defines the 3rd component of the value
  117754. */
  117755. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117756. /**
  117757. * Set the value of an uniform to a boolean
  117758. * @param uniform defines the webGL uniform location where to store the value
  117759. * @param bool defines the boolean to store
  117760. */
  117761. setBool(uniform: WebGLUniformLocation, bool: number): void;
  117762. /**
  117763. * Set the value of an uniform to a vec4
  117764. * @param uniform defines the webGL uniform location where to store the value
  117765. * @param x defines the 1st component of the value
  117766. * @param y defines the 2nd component of the value
  117767. * @param z defines the 3rd component of the value
  117768. * @param w defines the 4th component of the value
  117769. */
  117770. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117771. /**
  117772. * Sets the current alpha mode
  117773. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  117774. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117775. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117776. */
  117777. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117778. /**
  117779. * Bind webGl buffers directly to the webGL context
  117780. * @param vertexBuffers defines the vertex buffer to bind
  117781. * @param indexBuffer defines the index buffer to bind
  117782. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  117783. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  117784. * @param effect defines the effect associated with the vertex buffer
  117785. */
  117786. bindBuffers(vertexBuffers: {
  117787. [key: string]: VertexBuffer;
  117788. }, indexBuffer: DataBuffer, effect: Effect): void;
  117789. /**
  117790. * Force the entire cache to be cleared
  117791. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  117792. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  117793. */
  117794. wipeCaches(bruteForce?: boolean): void;
  117795. /**
  117796. * Send a draw order
  117797. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  117798. * @param indexStart defines the starting index
  117799. * @param indexCount defines the number of index to draw
  117800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117801. */
  117802. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  117803. /**
  117804. * Draw a list of indexed primitives
  117805. * @param fillMode defines the primitive to use
  117806. * @param indexStart defines the starting index
  117807. * @param indexCount defines the number of index to draw
  117808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117809. */
  117810. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117811. /**
  117812. * Draw a list of unindexed primitives
  117813. * @param fillMode defines the primitive to use
  117814. * @param verticesStart defines the index of first vertex to draw
  117815. * @param verticesCount defines the count of vertices to draw
  117816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117817. */
  117818. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117819. /** @hidden */
  117820. _createTexture(): WebGLTexture;
  117821. /** @hidden */
  117822. _releaseTexture(texture: InternalTexture): void;
  117823. /**
  117824. * Usually called from Texture.ts.
  117825. * Passed information to create a WebGLTexture
  117826. * @param urlArg defines a value which contains one of the following:
  117827. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117828. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117829. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117830. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117831. * @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)
  117832. * @param scene needed for loading to the correct scene
  117833. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  117834. * @param onLoad optional callback to be called upon successful completion
  117835. * @param onError optional callback to be called upon failure
  117836. * @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
  117837. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117838. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117839. * @param forcedExtension defines the extension to use to pick the right loader
  117840. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  117841. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117842. */
  117843. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  117844. /**
  117845. * Creates a new render target texture
  117846. * @param size defines the size of the texture
  117847. * @param options defines the options used to create the texture
  117848. * @returns a new render target texture stored in an InternalTexture
  117849. */
  117850. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  117851. /**
  117852. * Update the sampling mode of a given texture
  117853. * @param samplingMode defines the required sampling mode
  117854. * @param texture defines the texture to update
  117855. */
  117856. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117857. /**
  117858. * Binds the frame buffer to the specified texture.
  117859. * @param texture The texture to render to or null for the default canvas
  117860. * @param faceIndex The face of the texture to render to in case of cube texture
  117861. * @param requiredWidth The width of the target to render to
  117862. * @param requiredHeight The height of the target to render to
  117863. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  117864. * @param depthStencilTexture The depth stencil texture to use to render
  117865. * @param lodLevel defines le lod level to bind to the frame buffer
  117866. */
  117867. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117868. /**
  117869. * Unbind the current render target texture from the webGL context
  117870. * @param texture defines the render target texture to unbind
  117871. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117872. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117873. */
  117874. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117875. /**
  117876. * Creates a dynamic vertex buffer
  117877. * @param vertices the data for the dynamic vertex buffer
  117878. * @returns the new WebGL dynamic buffer
  117879. */
  117880. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  117881. /**
  117882. * Update the content of a dynamic texture
  117883. * @param texture defines the texture to update
  117884. * @param canvas defines the canvas containing the source
  117885. * @param invertY defines if data must be stored with Y axis inverted
  117886. * @param premulAlpha defines if alpha is stored as premultiplied
  117887. * @param format defines the format of the data
  117888. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  117889. */
  117890. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  117891. /**
  117892. * Gets a boolean indicating if all created effects are ready
  117893. * @returns true if all effects are ready
  117894. */
  117895. areAllEffectsReady(): boolean;
  117896. /**
  117897. * @hidden
  117898. * Get the current error code of the webGL context
  117899. * @returns the error code
  117900. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  117901. */
  117902. getError(): number;
  117903. /** @hidden */
  117904. _getUnpackAlignement(): number;
  117905. /** @hidden */
  117906. _unpackFlipY(value: boolean): void;
  117907. /**
  117908. * Update a dynamic index buffer
  117909. * @param indexBuffer defines the target index buffer
  117910. * @param indices defines the data to update
  117911. * @param offset defines the offset in the target index buffer where update should start
  117912. */
  117913. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  117914. /**
  117915. * Updates a dynamic vertex buffer.
  117916. * @param vertexBuffer the vertex buffer to update
  117917. * @param vertices the data used to update the vertex buffer
  117918. * @param byteOffset the byte offset of the data (optional)
  117919. * @param byteLength the byte length of the data (optional)
  117920. */
  117921. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  117922. /** @hidden */
  117923. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  117924. /** @hidden */
  117925. _bindTexture(channel: number, texture: InternalTexture): void;
  117926. protected _deleteBuffer(buffer: WebGLBuffer): void;
  117927. /**
  117928. * 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
  117929. */
  117930. releaseEffects(): void;
  117931. displayLoadingUI(): void;
  117932. hideLoadingUI(): void;
  117933. /** @hidden */
  117934. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117935. /** @hidden */
  117936. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117937. /** @hidden */
  117938. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117939. /** @hidden */
  117940. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117941. }
  117942. }
  117943. declare module BABYLON {
  117944. /** @hidden */
  117945. export class _OcclusionDataStorage {
  117946. /** @hidden */
  117947. occlusionInternalRetryCounter: number;
  117948. /** @hidden */
  117949. isOcclusionQueryInProgress: boolean;
  117950. /** @hidden */
  117951. isOccluded: boolean;
  117952. /** @hidden */
  117953. occlusionRetryCount: number;
  117954. /** @hidden */
  117955. occlusionType: number;
  117956. /** @hidden */
  117957. occlusionQueryAlgorithmType: number;
  117958. }
  117959. interface Engine {
  117960. /**
  117961. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  117962. * @return the new query
  117963. */
  117964. createQuery(): WebGLQuery;
  117965. /**
  117966. * Delete and release a webGL query
  117967. * @param query defines the query to delete
  117968. * @return the current engine
  117969. */
  117970. deleteQuery(query: WebGLQuery): Engine;
  117971. /**
  117972. * Check if a given query has resolved and got its value
  117973. * @param query defines the query to check
  117974. * @returns true if the query got its value
  117975. */
  117976. isQueryResultAvailable(query: WebGLQuery): boolean;
  117977. /**
  117978. * Gets the value of a given query
  117979. * @param query defines the query to check
  117980. * @returns the value of the query
  117981. */
  117982. getQueryResult(query: WebGLQuery): number;
  117983. /**
  117984. * Initiates an occlusion query
  117985. * @param algorithmType defines the algorithm to use
  117986. * @param query defines the query to use
  117987. * @returns the current engine
  117988. * @see http://doc.babylonjs.com/features/occlusionquery
  117989. */
  117990. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  117991. /**
  117992. * Ends an occlusion query
  117993. * @see http://doc.babylonjs.com/features/occlusionquery
  117994. * @param algorithmType defines the algorithm to use
  117995. * @returns the current engine
  117996. */
  117997. endOcclusionQuery(algorithmType: number): Engine;
  117998. /**
  117999. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  118000. * Please note that only one query can be issued at a time
  118001. * @returns a time token used to track the time span
  118002. */
  118003. startTimeQuery(): Nullable<_TimeToken>;
  118004. /**
  118005. * Ends a time query
  118006. * @param token defines the token used to measure the time span
  118007. * @returns the time spent (in ns)
  118008. */
  118009. endTimeQuery(token: _TimeToken): int;
  118010. /** @hidden */
  118011. _currentNonTimestampToken: Nullable<_TimeToken>;
  118012. /** @hidden */
  118013. _createTimeQuery(): WebGLQuery;
  118014. /** @hidden */
  118015. _deleteTimeQuery(query: WebGLQuery): void;
  118016. /** @hidden */
  118017. _getGlAlgorithmType(algorithmType: number): number;
  118018. /** @hidden */
  118019. _getTimeQueryResult(query: WebGLQuery): any;
  118020. /** @hidden */
  118021. _getTimeQueryAvailability(query: WebGLQuery): any;
  118022. }
  118023. interface AbstractMesh {
  118024. /**
  118025. * Backing filed
  118026. * @hidden
  118027. */
  118028. __occlusionDataStorage: _OcclusionDataStorage;
  118029. /**
  118030. * Access property
  118031. * @hidden
  118032. */
  118033. _occlusionDataStorage: _OcclusionDataStorage;
  118034. /**
  118035. * 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.
  118036. * The default value is -1 which means don't break the query and wait till the result
  118037. * @see http://doc.babylonjs.com/features/occlusionquery
  118038. */
  118039. occlusionRetryCount: number;
  118040. /**
  118041. * 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:
  118042. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  118043. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  118044. * * 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.
  118045. * @see http://doc.babylonjs.com/features/occlusionquery
  118046. */
  118047. occlusionType: number;
  118048. /**
  118049. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  118050. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  118051. * * 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.
  118052. * @see http://doc.babylonjs.com/features/occlusionquery
  118053. */
  118054. occlusionQueryAlgorithmType: number;
  118055. /**
  118056. * 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
  118057. * @see http://doc.babylonjs.com/features/occlusionquery
  118058. */
  118059. isOccluded: boolean;
  118060. /**
  118061. * Flag to check the progress status of the query
  118062. * @see http://doc.babylonjs.com/features/occlusionquery
  118063. */
  118064. isOcclusionQueryInProgress: boolean;
  118065. }
  118066. }
  118067. declare module BABYLON {
  118068. /** @hidden */
  118069. export var _forceTransformFeedbackToBundle: boolean;
  118070. interface Engine {
  118071. /**
  118072. * Creates a webGL transform feedback object
  118073. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  118074. * @returns the webGL transform feedback object
  118075. */
  118076. createTransformFeedback(): WebGLTransformFeedback;
  118077. /**
  118078. * Delete a webGL transform feedback object
  118079. * @param value defines the webGL transform feedback object to delete
  118080. */
  118081. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  118082. /**
  118083. * Bind a webGL transform feedback object to the webgl context
  118084. * @param value defines the webGL transform feedback object to bind
  118085. */
  118086. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  118087. /**
  118088. * Begins a transform feedback operation
  118089. * @param usePoints defines if points or triangles must be used
  118090. */
  118091. beginTransformFeedback(usePoints: boolean): void;
  118092. /**
  118093. * Ends a transform feedback operation
  118094. */
  118095. endTransformFeedback(): void;
  118096. /**
  118097. * Specify the varyings to use with transform feedback
  118098. * @param program defines the associated webGL program
  118099. * @param value defines the list of strings representing the varying names
  118100. */
  118101. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  118102. /**
  118103. * Bind a webGL buffer for a transform feedback operation
  118104. * @param value defines the webGL buffer to bind
  118105. */
  118106. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  118107. }
  118108. }
  118109. declare module BABYLON {
  118110. /**
  118111. * Creation options of the multi render target texture.
  118112. */
  118113. export interface IMultiRenderTargetOptions {
  118114. /**
  118115. * Define if the texture needs to create mip maps after render.
  118116. */
  118117. generateMipMaps?: boolean;
  118118. /**
  118119. * Define the types of all the draw buffers we want to create
  118120. */
  118121. types?: number[];
  118122. /**
  118123. * Define the sampling modes of all the draw buffers we want to create
  118124. */
  118125. samplingModes?: number[];
  118126. /**
  118127. * Define if a depth buffer is required
  118128. */
  118129. generateDepthBuffer?: boolean;
  118130. /**
  118131. * Define if a stencil buffer is required
  118132. */
  118133. generateStencilBuffer?: boolean;
  118134. /**
  118135. * Define if a depth texture is required instead of a depth buffer
  118136. */
  118137. generateDepthTexture?: boolean;
  118138. /**
  118139. * Define the number of desired draw buffers
  118140. */
  118141. textureCount?: number;
  118142. /**
  118143. * Define if aspect ratio should be adapted to the texture or stay the scene one
  118144. */
  118145. doNotChangeAspectRatio?: boolean;
  118146. /**
  118147. * Define the default type of the buffers we are creating
  118148. */
  118149. defaultType?: number;
  118150. }
  118151. /**
  118152. * A multi render target, like a render target provides the ability to render to a texture.
  118153. * Unlike the render target, it can render to several draw buffers in one draw.
  118154. * This is specially interesting in deferred rendering or for any effects requiring more than
  118155. * just one color from a single pass.
  118156. */
  118157. export class MultiRenderTarget extends RenderTargetTexture {
  118158. private _internalTextures;
  118159. private _textures;
  118160. private _multiRenderTargetOptions;
  118161. /**
  118162. * Get if draw buffers are currently supported by the used hardware and browser.
  118163. */
  118164. get isSupported(): boolean;
  118165. /**
  118166. * Get the list of textures generated by the multi render target.
  118167. */
  118168. get textures(): Texture[];
  118169. /**
  118170. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  118171. */
  118172. get depthTexture(): Texture;
  118173. /**
  118174. * Set the wrapping mode on U of all the textures we are rendering to.
  118175. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  118176. */
  118177. set wrapU(wrap: number);
  118178. /**
  118179. * Set the wrapping mode on V of all the textures we are rendering to.
  118180. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  118181. */
  118182. set wrapV(wrap: number);
  118183. /**
  118184. * Instantiate a new multi render target texture.
  118185. * A multi render target, like a render target provides the ability to render to a texture.
  118186. * Unlike the render target, it can render to several draw buffers in one draw.
  118187. * This is specially interesting in deferred rendering or for any effects requiring more than
  118188. * just one color from a single pass.
  118189. * @param name Define the name of the texture
  118190. * @param size Define the size of the buffers to render to
  118191. * @param count Define the number of target we are rendering into
  118192. * @param scene Define the scene the texture belongs to
  118193. * @param options Define the options used to create the multi render target
  118194. */
  118195. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  118196. /** @hidden */
  118197. _rebuild(): void;
  118198. private _createInternalTextures;
  118199. private _createTextures;
  118200. /**
  118201. * Define the number of samples used if MSAA is enabled.
  118202. */
  118203. get samples(): number;
  118204. set samples(value: number);
  118205. /**
  118206. * Resize all the textures in the multi render target.
  118207. * Be carrefull as it will recreate all the data in the new texture.
  118208. * @param size Define the new size
  118209. */
  118210. resize(size: any): void;
  118211. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  118212. /**
  118213. * Dispose the render targets and their associated resources
  118214. */
  118215. dispose(): void;
  118216. /**
  118217. * Release all the underlying texture used as draw buffers.
  118218. */
  118219. releaseInternalTextures(): void;
  118220. }
  118221. }
  118222. declare module BABYLON {
  118223. interface ThinEngine {
  118224. /**
  118225. * Unbind a list of render target textures from the webGL context
  118226. * This is used only when drawBuffer extension or webGL2 are active
  118227. * @param textures defines the render target textures to unbind
  118228. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  118229. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  118230. */
  118231. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  118232. /**
  118233. * Create a multi render target texture
  118234. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  118235. * @param size defines the size of the texture
  118236. * @param options defines the creation options
  118237. * @returns the cube texture as an InternalTexture
  118238. */
  118239. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  118240. /**
  118241. * Update the sample count for a given multiple render target texture
  118242. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118243. * @param textures defines the textures to update
  118244. * @param samples defines the sample count to set
  118245. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118246. */
  118247. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  118248. }
  118249. }
  118250. declare module BABYLON {
  118251. /**
  118252. * Class used to define an additional view for the engine
  118253. * @see https://doc.babylonjs.com/how_to/multi_canvases
  118254. */
  118255. export class EngineView {
  118256. /** Defines the canvas where to render the view */
  118257. target: HTMLCanvasElement;
  118258. /** Defines an optional camera used to render the view (will use active camera else) */
  118259. camera?: Camera;
  118260. }
  118261. interface Engine {
  118262. /**
  118263. * Gets or sets the HTML element to use for attaching events
  118264. */
  118265. inputElement: Nullable<HTMLElement>;
  118266. /**
  118267. * Gets the current engine view
  118268. * @see https://doc.babylonjs.com/how_to/multi_canvases
  118269. */
  118270. activeView: Nullable<EngineView>;
  118271. /** Gets or sets the list of views */
  118272. views: EngineView[];
  118273. /**
  118274. * Register a new child canvas
  118275. * @param canvas defines the canvas to register
  118276. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  118277. * @returns the associated view
  118278. */
  118279. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  118280. /**
  118281. * Remove a registered child canvas
  118282. * @param canvas defines the canvas to remove
  118283. * @returns the current engine
  118284. */
  118285. unRegisterView(canvas: HTMLCanvasElement): Engine;
  118286. }
  118287. }
  118288. declare module BABYLON {
  118289. /**
  118290. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  118291. */
  118292. export interface CubeMapInfo {
  118293. /**
  118294. * The pixel array for the front face.
  118295. * This is stored in format, left to right, up to down format.
  118296. */
  118297. front: Nullable<ArrayBufferView>;
  118298. /**
  118299. * The pixel array for the back face.
  118300. * This is stored in format, left to right, up to down format.
  118301. */
  118302. back: Nullable<ArrayBufferView>;
  118303. /**
  118304. * The pixel array for the left face.
  118305. * This is stored in format, left to right, up to down format.
  118306. */
  118307. left: Nullable<ArrayBufferView>;
  118308. /**
  118309. * The pixel array for the right face.
  118310. * This is stored in format, left to right, up to down format.
  118311. */
  118312. right: Nullable<ArrayBufferView>;
  118313. /**
  118314. * The pixel array for the up face.
  118315. * This is stored in format, left to right, up to down format.
  118316. */
  118317. up: Nullable<ArrayBufferView>;
  118318. /**
  118319. * The pixel array for the down face.
  118320. * This is stored in format, left to right, up to down format.
  118321. */
  118322. down: Nullable<ArrayBufferView>;
  118323. /**
  118324. * The size of the cubemap stored.
  118325. *
  118326. * Each faces will be size * size pixels.
  118327. */
  118328. size: number;
  118329. /**
  118330. * The format of the texture.
  118331. *
  118332. * RGBA, RGB.
  118333. */
  118334. format: number;
  118335. /**
  118336. * The type of the texture data.
  118337. *
  118338. * UNSIGNED_INT, FLOAT.
  118339. */
  118340. type: number;
  118341. /**
  118342. * Specifies whether the texture is in gamma space.
  118343. */
  118344. gammaSpace: boolean;
  118345. }
  118346. /**
  118347. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  118348. */
  118349. export class PanoramaToCubeMapTools {
  118350. private static FACE_FRONT;
  118351. private static FACE_BACK;
  118352. private static FACE_RIGHT;
  118353. private static FACE_LEFT;
  118354. private static FACE_DOWN;
  118355. private static FACE_UP;
  118356. /**
  118357. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  118358. *
  118359. * @param float32Array The source data.
  118360. * @param inputWidth The width of the input panorama.
  118361. * @param inputHeight The height of the input panorama.
  118362. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  118363. * @return The cubemap data
  118364. */
  118365. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  118366. private static CreateCubemapTexture;
  118367. private static CalcProjectionSpherical;
  118368. }
  118369. }
  118370. declare module BABYLON {
  118371. /**
  118372. * Helper class dealing with the extraction of spherical polynomial dataArray
  118373. * from a cube map.
  118374. */
  118375. export class CubeMapToSphericalPolynomialTools {
  118376. private static FileFaces;
  118377. /**
  118378. * Converts a texture to the according Spherical Polynomial data.
  118379. * This extracts the first 3 orders only as they are the only one used in the lighting.
  118380. *
  118381. * @param texture The texture to extract the information from.
  118382. * @return The Spherical Polynomial data.
  118383. */
  118384. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  118385. /**
  118386. * Converts a cubemap to the according Spherical Polynomial data.
  118387. * This extracts the first 3 orders only as they are the only one used in the lighting.
  118388. *
  118389. * @param cubeInfo The Cube map to extract the information from.
  118390. * @return The Spherical Polynomial data.
  118391. */
  118392. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  118393. }
  118394. }
  118395. declare module BABYLON {
  118396. interface BaseTexture {
  118397. /**
  118398. * Get the polynomial representation of the texture data.
  118399. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  118400. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  118401. */
  118402. sphericalPolynomial: Nullable<SphericalPolynomial>;
  118403. }
  118404. }
  118405. declare module BABYLON {
  118406. /** @hidden */
  118407. export var rgbdEncodePixelShader: {
  118408. name: string;
  118409. shader: string;
  118410. };
  118411. }
  118412. declare module BABYLON {
  118413. /** @hidden */
  118414. export var rgbdDecodePixelShader: {
  118415. name: string;
  118416. shader: string;
  118417. };
  118418. }
  118419. declare module BABYLON {
  118420. /**
  118421. * Raw texture data and descriptor sufficient for WebGL texture upload
  118422. */
  118423. export interface EnvironmentTextureInfo {
  118424. /**
  118425. * Version of the environment map
  118426. */
  118427. version: number;
  118428. /**
  118429. * Width of image
  118430. */
  118431. width: number;
  118432. /**
  118433. * Irradiance information stored in the file.
  118434. */
  118435. irradiance: any;
  118436. /**
  118437. * Specular information stored in the file.
  118438. */
  118439. specular: any;
  118440. }
  118441. /**
  118442. * Defines One Image in the file. It requires only the position in the file
  118443. * as well as the length.
  118444. */
  118445. interface BufferImageData {
  118446. /**
  118447. * Length of the image data.
  118448. */
  118449. length: number;
  118450. /**
  118451. * Position of the data from the null terminator delimiting the end of the JSON.
  118452. */
  118453. position: number;
  118454. }
  118455. /**
  118456. * Defines the specular data enclosed in the file.
  118457. * This corresponds to the version 1 of the data.
  118458. */
  118459. export interface EnvironmentTextureSpecularInfoV1 {
  118460. /**
  118461. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  118462. */
  118463. specularDataPosition?: number;
  118464. /**
  118465. * This contains all the images data needed to reconstruct the cubemap.
  118466. */
  118467. mipmaps: Array<BufferImageData>;
  118468. /**
  118469. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  118470. */
  118471. lodGenerationScale: number;
  118472. }
  118473. /**
  118474. * Sets of helpers addressing the serialization and deserialization of environment texture
  118475. * stored in a BabylonJS env file.
  118476. * Those files are usually stored as .env files.
  118477. */
  118478. export class EnvironmentTextureTools {
  118479. /**
  118480. * Magic number identifying the env file.
  118481. */
  118482. private static _MagicBytes;
  118483. /**
  118484. * Gets the environment info from an env file.
  118485. * @param data The array buffer containing the .env bytes.
  118486. * @returns the environment file info (the json header) if successfully parsed.
  118487. */
  118488. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  118489. /**
  118490. * Creates an environment texture from a loaded cube texture.
  118491. * @param texture defines the cube texture to convert in env file
  118492. * @return a promise containing the environment data if succesfull.
  118493. */
  118494. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  118495. /**
  118496. * Creates a JSON representation of the spherical data.
  118497. * @param texture defines the texture containing the polynomials
  118498. * @return the JSON representation of the spherical info
  118499. */
  118500. private static _CreateEnvTextureIrradiance;
  118501. /**
  118502. * Creates the ArrayBufferViews used for initializing environment texture image data.
  118503. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  118504. * @param info parameters that determine what views will be created for accessing the underlying buffer
  118505. * @return the views described by info providing access to the underlying buffer
  118506. */
  118507. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  118508. /**
  118509. * Uploads the texture info contained in the env file to the GPU.
  118510. * @param texture defines the internal texture to upload to
  118511. * @param arrayBuffer defines the buffer cotaining the data to load
  118512. * @param info defines the texture info retrieved through the GetEnvInfo method
  118513. * @returns a promise
  118514. */
  118515. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  118516. private static _OnImageReadyAsync;
  118517. /**
  118518. * Uploads the levels of image data to the GPU.
  118519. * @param texture defines the internal texture to upload to
  118520. * @param imageData defines the array buffer views of image data [mipmap][face]
  118521. * @returns a promise
  118522. */
  118523. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  118524. /**
  118525. * Uploads spherical polynomials information to the texture.
  118526. * @param texture defines the texture we are trying to upload the information to
  118527. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  118528. */
  118529. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  118530. /** @hidden */
  118531. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  118532. }
  118533. }
  118534. declare module BABYLON {
  118535. /**
  118536. * Contains position and normal vectors for a vertex
  118537. */
  118538. export class PositionNormalVertex {
  118539. /** the position of the vertex (defaut: 0,0,0) */
  118540. position: Vector3;
  118541. /** the normal of the vertex (defaut: 0,1,0) */
  118542. normal: Vector3;
  118543. /**
  118544. * Creates a PositionNormalVertex
  118545. * @param position the position of the vertex (defaut: 0,0,0)
  118546. * @param normal the normal of the vertex (defaut: 0,1,0)
  118547. */
  118548. constructor(
  118549. /** the position of the vertex (defaut: 0,0,0) */
  118550. position?: Vector3,
  118551. /** the normal of the vertex (defaut: 0,1,0) */
  118552. normal?: Vector3);
  118553. /**
  118554. * Clones the PositionNormalVertex
  118555. * @returns the cloned PositionNormalVertex
  118556. */
  118557. clone(): PositionNormalVertex;
  118558. }
  118559. /**
  118560. * Contains position, normal and uv vectors for a vertex
  118561. */
  118562. export class PositionNormalTextureVertex {
  118563. /** the position of the vertex (defaut: 0,0,0) */
  118564. position: Vector3;
  118565. /** the normal of the vertex (defaut: 0,1,0) */
  118566. normal: Vector3;
  118567. /** the uv of the vertex (default: 0,0) */
  118568. uv: Vector2;
  118569. /**
  118570. * Creates a PositionNormalTextureVertex
  118571. * @param position the position of the vertex (defaut: 0,0,0)
  118572. * @param normal the normal of the vertex (defaut: 0,1,0)
  118573. * @param uv the uv of the vertex (default: 0,0)
  118574. */
  118575. constructor(
  118576. /** the position of the vertex (defaut: 0,0,0) */
  118577. position?: Vector3,
  118578. /** the normal of the vertex (defaut: 0,1,0) */
  118579. normal?: Vector3,
  118580. /** the uv of the vertex (default: 0,0) */
  118581. uv?: Vector2);
  118582. /**
  118583. * Clones the PositionNormalTextureVertex
  118584. * @returns the cloned PositionNormalTextureVertex
  118585. */
  118586. clone(): PositionNormalTextureVertex;
  118587. }
  118588. }
  118589. declare module BABYLON {
  118590. /** @hidden */
  118591. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  118592. private _genericAttributeLocation;
  118593. private _varyingLocationCount;
  118594. private _varyingLocationMap;
  118595. private _replacements;
  118596. private _textureCount;
  118597. private _uniforms;
  118598. lineProcessor(line: string): string;
  118599. attributeProcessor(attribute: string): string;
  118600. varyingProcessor(varying: string, isFragment: boolean): string;
  118601. uniformProcessor(uniform: string): string;
  118602. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  118603. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118604. }
  118605. }
  118606. declare module BABYLON {
  118607. /**
  118608. * Container for accessors for natively-stored mesh data buffers.
  118609. */
  118610. class NativeDataBuffer extends DataBuffer {
  118611. /**
  118612. * Accessor value used to identify/retrieve a natively-stored index buffer.
  118613. */
  118614. nativeIndexBuffer?: any;
  118615. /**
  118616. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  118617. */
  118618. nativeVertexBuffer?: any;
  118619. }
  118620. /** @hidden */
  118621. class NativeTexture extends InternalTexture {
  118622. getInternalTexture(): InternalTexture;
  118623. getViewCount(): number;
  118624. }
  118625. /** @hidden */
  118626. export class NativeEngine extends Engine {
  118627. private readonly _native;
  118628. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  118629. private readonly INVALID_HANDLE;
  118630. getHardwareScalingLevel(): number;
  118631. constructor();
  118632. /**
  118633. * Can be used to override the current requestAnimationFrame requester.
  118634. * @hidden
  118635. */
  118636. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  118637. /**
  118638. * Override default engine behavior.
  118639. * @param color
  118640. * @param backBuffer
  118641. * @param depth
  118642. * @param stencil
  118643. */
  118644. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  118645. /**
  118646. * Gets host document
  118647. * @returns the host document object
  118648. */
  118649. getHostDocument(): Nullable<Document>;
  118650. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  118651. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  118652. createVertexBuffer(data: DataArray): NativeDataBuffer;
  118653. recordVertexArrayObject(vertexBuffers: {
  118654. [key: string]: VertexBuffer;
  118655. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  118656. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  118657. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  118658. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  118659. /**
  118660. * Draw a list of indexed primitives
  118661. * @param fillMode defines the primitive to use
  118662. * @param indexStart defines the starting index
  118663. * @param indexCount defines the number of index to draw
  118664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  118665. */
  118666. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  118667. /**
  118668. * Draw a list of unindexed primitives
  118669. * @param fillMode defines the primitive to use
  118670. * @param verticesStart defines the index of first vertex to draw
  118671. * @param verticesCount defines the count of vertices to draw
  118672. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  118673. */
  118674. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  118675. createPipelineContext(): IPipelineContext;
  118676. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  118677. /** @hidden */
  118678. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  118679. /** @hidden */
  118680. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  118681. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  118682. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  118683. protected _setProgram(program: WebGLProgram): void;
  118684. _releaseEffect(effect: Effect): void;
  118685. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118686. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  118687. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  118688. bindSamplers(effect: Effect): void;
  118689. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  118690. getRenderWidth(useScreen?: boolean): number;
  118691. getRenderHeight(useScreen?: boolean): number;
  118692. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  118693. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118694. /**
  118695. * Set the z offset to apply to current rendering
  118696. * @param value defines the offset to apply
  118697. */
  118698. setZOffset(value: number): void;
  118699. /**
  118700. * Gets the current value of the zOffset
  118701. * @returns the current zOffset state
  118702. */
  118703. getZOffset(): number;
  118704. /**
  118705. * Enable or disable depth buffering
  118706. * @param enable defines the state to set
  118707. */
  118708. setDepthBuffer(enable: boolean): void;
  118709. /**
  118710. * Gets a boolean indicating if depth writing is enabled
  118711. * @returns the current depth writing state
  118712. */
  118713. getDepthWrite(): boolean;
  118714. /**
  118715. * Enable or disable depth writing
  118716. * @param enable defines the state to set
  118717. */
  118718. setDepthWrite(enable: boolean): void;
  118719. /**
  118720. * Enable or disable color writing
  118721. * @param enable defines the state to set
  118722. */
  118723. setColorWrite(enable: boolean): void;
  118724. /**
  118725. * Gets a boolean indicating if color writing is enabled
  118726. * @returns the current color writing state
  118727. */
  118728. getColorWrite(): boolean;
  118729. /**
  118730. * Sets alpha constants used by some alpha blending modes
  118731. * @param r defines the red component
  118732. * @param g defines the green component
  118733. * @param b defines the blue component
  118734. * @param a defines the alpha component
  118735. */
  118736. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  118737. /**
  118738. * Sets the current alpha mode
  118739. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  118740. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  118741. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  118742. */
  118743. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  118744. /**
  118745. * Gets the current alpha mode
  118746. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  118747. * @returns the current alpha mode
  118748. */
  118749. getAlphaMode(): number;
  118750. setInt(uniform: WebGLUniformLocation, int: number): void;
  118751. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  118752. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  118753. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  118754. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  118755. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  118756. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  118757. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  118758. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  118759. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  118760. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  118761. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  118762. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  118763. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  118764. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  118765. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  118766. setFloat(uniform: WebGLUniformLocation, value: number): void;
  118767. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  118768. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  118769. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  118770. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  118771. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  118772. wipeCaches(bruteForce?: boolean): void;
  118773. _createTexture(): WebGLTexture;
  118774. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  118775. /**
  118776. * Usually called from BABYLON.Texture.ts.
  118777. * Passed information to create a WebGLTexture
  118778. * @param urlArg defines a value which contains one of the following:
  118779. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  118780. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  118781. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  118782. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  118783. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  118784. * @param scene needed for loading to the correct scene
  118785. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  118786. * @param onLoad optional callback to be called upon successful completion
  118787. * @param onError optional callback to be called upon failure
  118788. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  118789. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  118790. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  118791. * @param forcedExtension defines the extension to use to pick the right loader
  118792. * @returns a InternalTexture for assignment back into BABYLON.Texture
  118793. */
  118794. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  118795. /**
  118796. * Creates a cube texture
  118797. * @param rootUrl defines the url where the files to load is located
  118798. * @param scene defines the current scene
  118799. * @param files defines the list of files to load (1 per face)
  118800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  118801. * @param onLoad defines an optional callback raised when the texture is loaded
  118802. * @param onError defines an optional callback raised if there is an issue to load the texture
  118803. * @param format defines the format of the data
  118804. * @param forcedExtension defines the extension to use to pick the right loader
  118805. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  118806. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  118807. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  118808. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  118809. * @returns the cube texture as an InternalTexture
  118810. */
  118811. 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;
  118812. private _getSamplingFilter;
  118813. private static _GetNativeTextureFormat;
  118814. createRenderTargetTexture(size: number | {
  118815. width: number;
  118816. height: number;
  118817. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  118818. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  118819. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  118820. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  118821. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  118822. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  118823. /**
  118824. * Updates a dynamic vertex buffer.
  118825. * @param vertexBuffer the vertex buffer to update
  118826. * @param data the data used to update the vertex buffer
  118827. * @param byteOffset the byte offset of the data (optional)
  118828. * @param byteLength the byte length of the data (optional)
  118829. */
  118830. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  118831. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  118832. private _updateAnisotropicLevel;
  118833. private _getAddressMode;
  118834. /** @hidden */
  118835. _bindTexture(channel: number, texture: InternalTexture): void;
  118836. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  118837. releaseEffects(): void;
  118838. /** @hidden */
  118839. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  118840. /** @hidden */
  118841. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  118842. /** @hidden */
  118843. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  118844. /** @hidden */
  118845. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  118846. }
  118847. }
  118848. declare module BABYLON {
  118849. /**
  118850. * Gather the list of clipboard event types as constants.
  118851. */
  118852. export class ClipboardEventTypes {
  118853. /**
  118854. * The clipboard event is fired when a copy command is active (pressed).
  118855. */
  118856. static readonly COPY: number;
  118857. /**
  118858. * The clipboard event is fired when a cut command is active (pressed).
  118859. */
  118860. static readonly CUT: number;
  118861. /**
  118862. * The clipboard event is fired when a paste command is active (pressed).
  118863. */
  118864. static readonly PASTE: number;
  118865. }
  118866. /**
  118867. * This class is used to store clipboard related info for the onClipboardObservable event.
  118868. */
  118869. export class ClipboardInfo {
  118870. /**
  118871. * Defines the type of event (BABYLON.ClipboardEventTypes)
  118872. */
  118873. type: number;
  118874. /**
  118875. * Defines the related dom event
  118876. */
  118877. event: ClipboardEvent;
  118878. /**
  118879. *Creates an instance of ClipboardInfo.
  118880. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  118881. * @param event Defines the related dom event
  118882. */
  118883. constructor(
  118884. /**
  118885. * Defines the type of event (BABYLON.ClipboardEventTypes)
  118886. */
  118887. type: number,
  118888. /**
  118889. * Defines the related dom event
  118890. */
  118891. event: ClipboardEvent);
  118892. /**
  118893. * Get the clipboard event's type from the keycode.
  118894. * @param keyCode Defines the keyCode for the current keyboard event.
  118895. * @return {number}
  118896. */
  118897. static GetTypeFromCharacter(keyCode: number): number;
  118898. }
  118899. }
  118900. declare module BABYLON {
  118901. /**
  118902. * Google Daydream controller
  118903. */
  118904. export class DaydreamController extends WebVRController {
  118905. /**
  118906. * Base Url for the controller model.
  118907. */
  118908. static MODEL_BASE_URL: string;
  118909. /**
  118910. * File name for the controller model.
  118911. */
  118912. static MODEL_FILENAME: string;
  118913. /**
  118914. * Gamepad Id prefix used to identify Daydream Controller.
  118915. */
  118916. static readonly GAMEPAD_ID_PREFIX: string;
  118917. /**
  118918. * Creates a new DaydreamController from a gamepad
  118919. * @param vrGamepad the gamepad that the controller should be created from
  118920. */
  118921. constructor(vrGamepad: any);
  118922. /**
  118923. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  118924. * @param scene scene in which to add meshes
  118925. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  118926. */
  118927. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  118928. /**
  118929. * Called once for each button that changed state since the last frame
  118930. * @param buttonIdx Which button index changed
  118931. * @param state New state of the button
  118932. * @param changes Which properties on the state changed since last frame
  118933. */
  118934. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  118935. }
  118936. }
  118937. declare module BABYLON {
  118938. /**
  118939. * Gear VR Controller
  118940. */
  118941. export class GearVRController extends WebVRController {
  118942. /**
  118943. * Base Url for the controller model.
  118944. */
  118945. static MODEL_BASE_URL: string;
  118946. /**
  118947. * File name for the controller model.
  118948. */
  118949. static MODEL_FILENAME: string;
  118950. /**
  118951. * Gamepad Id prefix used to identify this controller.
  118952. */
  118953. static readonly GAMEPAD_ID_PREFIX: string;
  118954. private readonly _buttonIndexToObservableNameMap;
  118955. /**
  118956. * Creates a new GearVRController from a gamepad
  118957. * @param vrGamepad the gamepad that the controller should be created from
  118958. */
  118959. constructor(vrGamepad: any);
  118960. /**
  118961. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  118962. * @param scene scene in which to add meshes
  118963. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  118964. */
  118965. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  118966. /**
  118967. * Called once for each button that changed state since the last frame
  118968. * @param buttonIdx Which button index changed
  118969. * @param state New state of the button
  118970. * @param changes Which properties on the state changed since last frame
  118971. */
  118972. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  118973. }
  118974. }
  118975. declare module BABYLON {
  118976. /**
  118977. * Generic Controller
  118978. */
  118979. export class GenericController extends WebVRController {
  118980. /**
  118981. * Base Url for the controller model.
  118982. */
  118983. static readonly MODEL_BASE_URL: string;
  118984. /**
  118985. * File name for the controller model.
  118986. */
  118987. static readonly MODEL_FILENAME: string;
  118988. /**
  118989. * Creates a new GenericController from a gamepad
  118990. * @param vrGamepad the gamepad that the controller should be created from
  118991. */
  118992. constructor(vrGamepad: any);
  118993. /**
  118994. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  118995. * @param scene scene in which to add meshes
  118996. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  118997. */
  118998. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  118999. /**
  119000. * Called once for each button that changed state since the last frame
  119001. * @param buttonIdx Which button index changed
  119002. * @param state New state of the button
  119003. * @param changes Which properties on the state changed since last frame
  119004. */
  119005. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119006. }
  119007. }
  119008. declare module BABYLON {
  119009. /**
  119010. * Oculus Touch Controller
  119011. */
  119012. export class OculusTouchController extends WebVRController {
  119013. /**
  119014. * Base Url for the controller model.
  119015. */
  119016. static MODEL_BASE_URL: string;
  119017. /**
  119018. * File name for the left controller model.
  119019. */
  119020. static MODEL_LEFT_FILENAME: string;
  119021. /**
  119022. * File name for the right controller model.
  119023. */
  119024. static MODEL_RIGHT_FILENAME: string;
  119025. /**
  119026. * Base Url for the Quest controller model.
  119027. */
  119028. static QUEST_MODEL_BASE_URL: string;
  119029. /**
  119030. * @hidden
  119031. * If the controllers are running on a device that needs the updated Quest controller models
  119032. */
  119033. static _IsQuest: boolean;
  119034. /**
  119035. * Fired when the secondary trigger on this controller is modified
  119036. */
  119037. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  119038. /**
  119039. * Fired when the thumb rest on this controller is modified
  119040. */
  119041. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  119042. /**
  119043. * Creates a new OculusTouchController from a gamepad
  119044. * @param vrGamepad the gamepad that the controller should be created from
  119045. */
  119046. constructor(vrGamepad: any);
  119047. /**
  119048. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119049. * @param scene scene in which to add meshes
  119050. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119051. */
  119052. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  119053. /**
  119054. * Fired when the A button on this controller is modified
  119055. */
  119056. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119057. /**
  119058. * Fired when the B button on this controller is modified
  119059. */
  119060. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119061. /**
  119062. * Fired when the X button on this controller is modified
  119063. */
  119064. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119065. /**
  119066. * Fired when the Y button on this controller is modified
  119067. */
  119068. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119069. /**
  119070. * Called once for each button that changed state since the last frame
  119071. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  119072. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  119073. * 2) secondary trigger (same)
  119074. * 3) A (right) X (left), touch, pressed = value
  119075. * 4) B / Y
  119076. * 5) thumb rest
  119077. * @param buttonIdx Which button index changed
  119078. * @param state New state of the button
  119079. * @param changes Which properties on the state changed since last frame
  119080. */
  119081. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119082. }
  119083. }
  119084. declare module BABYLON {
  119085. /**
  119086. * Vive Controller
  119087. */
  119088. export class ViveController extends WebVRController {
  119089. /**
  119090. * Base Url for the controller model.
  119091. */
  119092. static MODEL_BASE_URL: string;
  119093. /**
  119094. * File name for the controller model.
  119095. */
  119096. static MODEL_FILENAME: string;
  119097. /**
  119098. * Creates a new ViveController from a gamepad
  119099. * @param vrGamepad the gamepad that the controller should be created from
  119100. */
  119101. constructor(vrGamepad: any);
  119102. /**
  119103. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119104. * @param scene scene in which to add meshes
  119105. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119106. */
  119107. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  119108. /**
  119109. * Fired when the left button on this controller is modified
  119110. */
  119111. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119112. /**
  119113. * Fired when the right button on this controller is modified
  119114. */
  119115. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119116. /**
  119117. * Fired when the menu button on this controller is modified
  119118. */
  119119. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119120. /**
  119121. * Called once for each button that changed state since the last frame
  119122. * Vive mapping:
  119123. * 0: touchpad
  119124. * 1: trigger
  119125. * 2: left AND right buttons
  119126. * 3: menu button
  119127. * @param buttonIdx Which button index changed
  119128. * @param state New state of the button
  119129. * @param changes Which properties on the state changed since last frame
  119130. */
  119131. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119132. }
  119133. }
  119134. declare module BABYLON {
  119135. /**
  119136. * Defines the WindowsMotionController object that the state of the windows motion controller
  119137. */
  119138. export class WindowsMotionController extends WebVRController {
  119139. /**
  119140. * The base url used to load the left and right controller models
  119141. */
  119142. static MODEL_BASE_URL: string;
  119143. /**
  119144. * The name of the left controller model file
  119145. */
  119146. static MODEL_LEFT_FILENAME: string;
  119147. /**
  119148. * The name of the right controller model file
  119149. */
  119150. static MODEL_RIGHT_FILENAME: string;
  119151. /**
  119152. * The controller name prefix for this controller type
  119153. */
  119154. static readonly GAMEPAD_ID_PREFIX: string;
  119155. /**
  119156. * The controller id pattern for this controller type
  119157. */
  119158. private static readonly GAMEPAD_ID_PATTERN;
  119159. private _loadedMeshInfo;
  119160. protected readonly _mapping: {
  119161. buttons: string[];
  119162. buttonMeshNames: {
  119163. 'trigger': string;
  119164. 'menu': string;
  119165. 'grip': string;
  119166. 'thumbstick': string;
  119167. 'trackpad': string;
  119168. };
  119169. buttonObservableNames: {
  119170. 'trigger': string;
  119171. 'menu': string;
  119172. 'grip': string;
  119173. 'thumbstick': string;
  119174. 'trackpad': string;
  119175. };
  119176. axisMeshNames: string[];
  119177. pointingPoseMeshName: string;
  119178. };
  119179. /**
  119180. * Fired when the trackpad on this controller is clicked
  119181. */
  119182. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  119183. /**
  119184. * Fired when the trackpad on this controller is modified
  119185. */
  119186. onTrackpadValuesChangedObservable: Observable<StickValues>;
  119187. /**
  119188. * The current x and y values of this controller's trackpad
  119189. */
  119190. trackpad: StickValues;
  119191. /**
  119192. * Creates a new WindowsMotionController from a gamepad
  119193. * @param vrGamepad the gamepad that the controller should be created from
  119194. */
  119195. constructor(vrGamepad: any);
  119196. /**
  119197. * Fired when the trigger on this controller is modified
  119198. */
  119199. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119200. /**
  119201. * Fired when the menu button on this controller is modified
  119202. */
  119203. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119204. /**
  119205. * Fired when the grip button on this controller is modified
  119206. */
  119207. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119208. /**
  119209. * Fired when the thumbstick button on this controller is modified
  119210. */
  119211. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119212. /**
  119213. * Fired when the touchpad button on this controller is modified
  119214. */
  119215. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119216. /**
  119217. * Fired when the touchpad values on this controller are modified
  119218. */
  119219. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  119220. protected _updateTrackpad(): void;
  119221. /**
  119222. * Called once per frame by the engine.
  119223. */
  119224. update(): void;
  119225. /**
  119226. * Called once for each button that changed state since the last frame
  119227. * @param buttonIdx Which button index changed
  119228. * @param state New state of the button
  119229. * @param changes Which properties on the state changed since last frame
  119230. */
  119231. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119232. /**
  119233. * Moves the buttons on the controller mesh based on their current state
  119234. * @param buttonName the name of the button to move
  119235. * @param buttonValue the value of the button which determines the buttons new position
  119236. */
  119237. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  119238. /**
  119239. * Moves the axis on the controller mesh based on its current state
  119240. * @param axis the index of the axis
  119241. * @param axisValue the value of the axis which determines the meshes new position
  119242. * @hidden
  119243. */
  119244. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  119245. /**
  119246. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119247. * @param scene scene in which to add meshes
  119248. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119249. */
  119250. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  119251. /**
  119252. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  119253. * can be transformed by button presses and axes values, based on this._mapping.
  119254. *
  119255. * @param scene scene in which the meshes exist
  119256. * @param meshes list of meshes that make up the controller model to process
  119257. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  119258. */
  119259. private processModel;
  119260. private createMeshInfo;
  119261. /**
  119262. * Gets the ray of the controller in the direction the controller is pointing
  119263. * @param length the length the resulting ray should be
  119264. * @returns a ray in the direction the controller is pointing
  119265. */
  119266. getForwardRay(length?: number): Ray;
  119267. /**
  119268. * Disposes of the controller
  119269. */
  119270. dispose(): void;
  119271. }
  119272. /**
  119273. * This class represents a new windows motion controller in XR.
  119274. */
  119275. export class XRWindowsMotionController extends WindowsMotionController {
  119276. /**
  119277. * Changing the original WIndowsMotionController mapping to fir the new mapping
  119278. */
  119279. protected readonly _mapping: {
  119280. buttons: string[];
  119281. buttonMeshNames: {
  119282. 'trigger': string;
  119283. 'menu': string;
  119284. 'grip': string;
  119285. 'thumbstick': string;
  119286. 'trackpad': string;
  119287. };
  119288. buttonObservableNames: {
  119289. 'trigger': string;
  119290. 'menu': string;
  119291. 'grip': string;
  119292. 'thumbstick': string;
  119293. 'trackpad': string;
  119294. };
  119295. axisMeshNames: string[];
  119296. pointingPoseMeshName: string;
  119297. };
  119298. /**
  119299. * Construct a new XR-Based windows motion controller
  119300. *
  119301. * @param gamepadInfo the gamepad object from the browser
  119302. */
  119303. constructor(gamepadInfo: any);
  119304. /**
  119305. * holds the thumbstick values (X,Y)
  119306. */
  119307. thumbstickValues: StickValues;
  119308. /**
  119309. * Fired when the thumbstick on this controller is clicked
  119310. */
  119311. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  119312. /**
  119313. * Fired when the thumbstick on this controller is modified
  119314. */
  119315. onThumbstickValuesChangedObservable: Observable<StickValues>;
  119316. /**
  119317. * Fired when the touchpad button on this controller is modified
  119318. */
  119319. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  119320. /**
  119321. * Fired when the touchpad values on this controller are modified
  119322. */
  119323. onTrackpadValuesChangedObservable: Observable<StickValues>;
  119324. /**
  119325. * Fired when the thumbstick button on this controller is modified
  119326. * here to prevent breaking changes
  119327. */
  119328. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119329. /**
  119330. * updating the thumbstick(!) and not the trackpad.
  119331. * This is named this way due to the difference between WebVR and XR and to avoid
  119332. * changing the parent class.
  119333. */
  119334. protected _updateTrackpad(): void;
  119335. /**
  119336. * Disposes the class with joy
  119337. */
  119338. dispose(): void;
  119339. }
  119340. }
  119341. declare module BABYLON {
  119342. /**
  119343. * Class containing static functions to help procedurally build meshes
  119344. */
  119345. export class PolyhedronBuilder {
  119346. /**
  119347. * Creates a polyhedron mesh
  119348. * * 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
  119349. * * The parameter `size` (positive float, default 1) sets the polygon size
  119350. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  119351. * * 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`
  119352. * * 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
  119353. * * 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)`)
  119354. * * 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
  119355. * * 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
  119356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119359. * @param name defines the name of the mesh
  119360. * @param options defines the options used to create the mesh
  119361. * @param scene defines the hosting scene
  119362. * @returns the polyhedron mesh
  119363. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  119364. */
  119365. static CreatePolyhedron(name: string, options: {
  119366. type?: number;
  119367. size?: number;
  119368. sizeX?: number;
  119369. sizeY?: number;
  119370. sizeZ?: number;
  119371. custom?: any;
  119372. faceUV?: Vector4[];
  119373. faceColors?: Color4[];
  119374. flat?: boolean;
  119375. updatable?: boolean;
  119376. sideOrientation?: number;
  119377. frontUVs?: Vector4;
  119378. backUVs?: Vector4;
  119379. }, scene?: Nullable<Scene>): Mesh;
  119380. }
  119381. }
  119382. declare module BABYLON {
  119383. /**
  119384. * Gizmo that enables scaling a mesh along 3 axis
  119385. */
  119386. export class ScaleGizmo extends Gizmo {
  119387. /**
  119388. * Internal gizmo used for interactions on the x axis
  119389. */
  119390. xGizmo: AxisScaleGizmo;
  119391. /**
  119392. * Internal gizmo used for interactions on the y axis
  119393. */
  119394. yGizmo: AxisScaleGizmo;
  119395. /**
  119396. * Internal gizmo used for interactions on the z axis
  119397. */
  119398. zGizmo: AxisScaleGizmo;
  119399. /**
  119400. * Internal gizmo used to scale all axis equally
  119401. */
  119402. uniformScaleGizmo: AxisScaleGizmo;
  119403. private _meshAttached;
  119404. private _updateGizmoRotationToMatchAttachedMesh;
  119405. private _snapDistance;
  119406. private _scaleRatio;
  119407. private _uniformScalingMesh;
  119408. private _octahedron;
  119409. private _sensitivity;
  119410. /** Fires an event when any of it's sub gizmos are dragged */
  119411. onDragStartObservable: Observable<unknown>;
  119412. /** Fires an event when any of it's sub gizmos are released from dragging */
  119413. onDragEndObservable: Observable<unknown>;
  119414. get attachedMesh(): Nullable<AbstractMesh>;
  119415. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119416. /**
  119417. * Creates a ScaleGizmo
  119418. * @param gizmoLayer The utility layer the gizmo will be added to
  119419. */
  119420. constructor(gizmoLayer?: UtilityLayerRenderer);
  119421. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119422. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119423. /**
  119424. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119425. */
  119426. set snapDistance(value: number);
  119427. get snapDistance(): number;
  119428. /**
  119429. * Ratio for the scale of the gizmo (Default: 1)
  119430. */
  119431. set scaleRatio(value: number);
  119432. get scaleRatio(): number;
  119433. /**
  119434. * Sensitivity factor for dragging (Default: 1)
  119435. */
  119436. set sensitivity(value: number);
  119437. get sensitivity(): number;
  119438. /**
  119439. * Disposes of the gizmo
  119440. */
  119441. dispose(): void;
  119442. }
  119443. }
  119444. declare module BABYLON {
  119445. /**
  119446. * Single axis scale gizmo
  119447. */
  119448. export class AxisScaleGizmo extends Gizmo {
  119449. /**
  119450. * Drag behavior responsible for the gizmos dragging interactions
  119451. */
  119452. dragBehavior: PointerDragBehavior;
  119453. private _pointerObserver;
  119454. /**
  119455. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119456. */
  119457. snapDistance: number;
  119458. /**
  119459. * Event that fires each time the gizmo snaps to a new location.
  119460. * * snapDistance is the the change in distance
  119461. */
  119462. onSnapObservable: Observable<{
  119463. snapDistance: number;
  119464. }>;
  119465. /**
  119466. * If the scaling operation should be done on all axis (default: false)
  119467. */
  119468. uniformScaling: boolean;
  119469. /**
  119470. * Custom sensitivity value for the drag strength
  119471. */
  119472. sensitivity: number;
  119473. private _isEnabled;
  119474. private _parent;
  119475. private _arrow;
  119476. private _coloredMaterial;
  119477. private _hoverMaterial;
  119478. /**
  119479. * Creates an AxisScaleGizmo
  119480. * @param gizmoLayer The utility layer the gizmo will be added to
  119481. * @param dragAxis The axis which the gizmo will be able to scale on
  119482. * @param color The color of the gizmo
  119483. */
  119484. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  119485. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119486. /**
  119487. * If the gizmo is enabled
  119488. */
  119489. set isEnabled(value: boolean);
  119490. get isEnabled(): boolean;
  119491. /**
  119492. * Disposes of the gizmo
  119493. */
  119494. dispose(): void;
  119495. /**
  119496. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119497. * @param mesh The mesh to replace the default mesh of the gizmo
  119498. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  119499. */
  119500. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  119501. }
  119502. }
  119503. declare module BABYLON {
  119504. /**
  119505. * Bounding box gizmo
  119506. */
  119507. export class BoundingBoxGizmo extends Gizmo {
  119508. private _lineBoundingBox;
  119509. private _rotateSpheresParent;
  119510. private _scaleBoxesParent;
  119511. private _boundingDimensions;
  119512. private _renderObserver;
  119513. private _pointerObserver;
  119514. private _scaleDragSpeed;
  119515. private _tmpQuaternion;
  119516. private _tmpVector;
  119517. private _tmpRotationMatrix;
  119518. /**
  119519. * 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)
  119520. */
  119521. ignoreChildren: boolean;
  119522. /**
  119523. * 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)
  119524. */
  119525. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  119526. /**
  119527. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  119528. */
  119529. rotationSphereSize: number;
  119530. /**
  119531. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  119532. */
  119533. scaleBoxSize: number;
  119534. /**
  119535. * 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)
  119536. */
  119537. fixedDragMeshScreenSize: boolean;
  119538. /**
  119539. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  119540. */
  119541. fixedDragMeshScreenSizeDistanceFactor: number;
  119542. /**
  119543. * Fired when a rotation sphere or scale box is dragged
  119544. */
  119545. onDragStartObservable: Observable<{}>;
  119546. /**
  119547. * Fired when a scale box is dragged
  119548. */
  119549. onScaleBoxDragObservable: Observable<{}>;
  119550. /**
  119551. * Fired when a scale box drag is ended
  119552. */
  119553. onScaleBoxDragEndObservable: Observable<{}>;
  119554. /**
  119555. * Fired when a rotation sphere is dragged
  119556. */
  119557. onRotationSphereDragObservable: Observable<{}>;
  119558. /**
  119559. * Fired when a rotation sphere drag is ended
  119560. */
  119561. onRotationSphereDragEndObservable: Observable<{}>;
  119562. /**
  119563. * 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)
  119564. */
  119565. scalePivot: Nullable<Vector3>;
  119566. /**
  119567. * Mesh used as a pivot to rotate the attached mesh
  119568. */
  119569. private _anchorMesh;
  119570. private _existingMeshScale;
  119571. private _dragMesh;
  119572. private pointerDragBehavior;
  119573. private coloredMaterial;
  119574. private hoverColoredMaterial;
  119575. /**
  119576. * Sets the color of the bounding box gizmo
  119577. * @param color the color to set
  119578. */
  119579. setColor(color: Color3): void;
  119580. /**
  119581. * Creates an BoundingBoxGizmo
  119582. * @param gizmoLayer The utility layer the gizmo will be added to
  119583. * @param color The color of the gizmo
  119584. */
  119585. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  119586. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119587. private _selectNode;
  119588. /**
  119589. * Updates the bounding box information for the Gizmo
  119590. */
  119591. updateBoundingBox(): void;
  119592. private _updateRotationSpheres;
  119593. private _updateScaleBoxes;
  119594. /**
  119595. * Enables rotation on the specified axis and disables rotation on the others
  119596. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  119597. */
  119598. setEnabledRotationAxis(axis: string): void;
  119599. /**
  119600. * Enables/disables scaling
  119601. * @param enable if scaling should be enabled
  119602. */
  119603. setEnabledScaling(enable: boolean): void;
  119604. private _updateDummy;
  119605. /**
  119606. * Enables a pointer drag behavior on the bounding box of the gizmo
  119607. */
  119608. enableDragBehavior(): void;
  119609. /**
  119610. * Disposes of the gizmo
  119611. */
  119612. dispose(): void;
  119613. /**
  119614. * 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)
  119615. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  119616. * @returns the bounding box mesh with the passed in mesh as a child
  119617. */
  119618. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  119619. /**
  119620. * CustomMeshes are not supported by this gizmo
  119621. * @param mesh The mesh to replace the default mesh of the gizmo
  119622. */
  119623. setCustomMesh(mesh: Mesh): void;
  119624. }
  119625. }
  119626. declare module BABYLON {
  119627. /**
  119628. * Single plane rotation gizmo
  119629. */
  119630. export class PlaneRotationGizmo extends Gizmo {
  119631. /**
  119632. * Drag behavior responsible for the gizmos dragging interactions
  119633. */
  119634. dragBehavior: PointerDragBehavior;
  119635. private _pointerObserver;
  119636. /**
  119637. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  119638. */
  119639. snapDistance: number;
  119640. /**
  119641. * Event that fires each time the gizmo snaps to a new location.
  119642. * * snapDistance is the the change in distance
  119643. */
  119644. onSnapObservable: Observable<{
  119645. snapDistance: number;
  119646. }>;
  119647. private _isEnabled;
  119648. private _parent;
  119649. /**
  119650. * Creates a PlaneRotationGizmo
  119651. * @param gizmoLayer The utility layer the gizmo will be added to
  119652. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  119653. * @param color The color of the gizmo
  119654. * @param tessellation Amount of tessellation to be used when creating rotation circles
  119655. * @param useEulerRotation Use and update Euler angle instead of quaternion
  119656. */
  119657. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  119658. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119659. /**
  119660. * If the gizmo is enabled
  119661. */
  119662. set isEnabled(value: boolean);
  119663. get isEnabled(): boolean;
  119664. /**
  119665. * Disposes of the gizmo
  119666. */
  119667. dispose(): void;
  119668. }
  119669. }
  119670. declare module BABYLON {
  119671. /**
  119672. * Gizmo that enables rotating a mesh along 3 axis
  119673. */
  119674. export class RotationGizmo extends Gizmo {
  119675. /**
  119676. * Internal gizmo used for interactions on the x axis
  119677. */
  119678. xGizmo: PlaneRotationGizmo;
  119679. /**
  119680. * Internal gizmo used for interactions on the y axis
  119681. */
  119682. yGizmo: PlaneRotationGizmo;
  119683. /**
  119684. * Internal gizmo used for interactions on the z axis
  119685. */
  119686. zGizmo: PlaneRotationGizmo;
  119687. /** Fires an event when any of it's sub gizmos are dragged */
  119688. onDragStartObservable: Observable<unknown>;
  119689. /** Fires an event when any of it's sub gizmos are released from dragging */
  119690. onDragEndObservable: Observable<unknown>;
  119691. private _meshAttached;
  119692. get attachedMesh(): Nullable<AbstractMesh>;
  119693. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119694. /**
  119695. * Creates a RotationGizmo
  119696. * @param gizmoLayer The utility layer the gizmo will be added to
  119697. * @param tessellation Amount of tessellation to be used when creating rotation circles
  119698. * @param useEulerRotation Use and update Euler angle instead of quaternion
  119699. */
  119700. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  119701. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119702. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119703. /**
  119704. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119705. */
  119706. set snapDistance(value: number);
  119707. get snapDistance(): number;
  119708. /**
  119709. * Ratio for the scale of the gizmo (Default: 1)
  119710. */
  119711. set scaleRatio(value: number);
  119712. get scaleRatio(): number;
  119713. /**
  119714. * Disposes of the gizmo
  119715. */
  119716. dispose(): void;
  119717. /**
  119718. * CustomMeshes are not supported by this gizmo
  119719. * @param mesh The mesh to replace the default mesh of the gizmo
  119720. */
  119721. setCustomMesh(mesh: Mesh): void;
  119722. }
  119723. }
  119724. declare module BABYLON {
  119725. /**
  119726. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  119727. */
  119728. export class GizmoManager implements IDisposable {
  119729. private scene;
  119730. /**
  119731. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  119732. */
  119733. gizmos: {
  119734. positionGizmo: Nullable<PositionGizmo>;
  119735. rotationGizmo: Nullable<RotationGizmo>;
  119736. scaleGizmo: Nullable<ScaleGizmo>;
  119737. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  119738. };
  119739. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  119740. clearGizmoOnEmptyPointerEvent: boolean;
  119741. /** Fires an event when the manager is attached to a mesh */
  119742. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  119743. private _gizmosEnabled;
  119744. private _pointerObserver;
  119745. private _attachedMesh;
  119746. private _boundingBoxColor;
  119747. private _defaultUtilityLayer;
  119748. private _defaultKeepDepthUtilityLayer;
  119749. /**
  119750. * When bounding box gizmo is enabled, this can be used to track drag/end events
  119751. */
  119752. boundingBoxDragBehavior: SixDofDragBehavior;
  119753. /**
  119754. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  119755. */
  119756. attachableMeshes: Nullable<Array<AbstractMesh>>;
  119757. /**
  119758. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  119759. */
  119760. usePointerToAttachGizmos: boolean;
  119761. /**
  119762. * Utility layer that the bounding box gizmo belongs to
  119763. */
  119764. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  119765. /**
  119766. * Utility layer that all gizmos besides bounding box belong to
  119767. */
  119768. get utilityLayer(): UtilityLayerRenderer;
  119769. /**
  119770. * Instatiates a gizmo manager
  119771. * @param scene the scene to overlay the gizmos on top of
  119772. */
  119773. constructor(scene: Scene);
  119774. /**
  119775. * Attaches a set of gizmos to the specified mesh
  119776. * @param mesh The mesh the gizmo's should be attached to
  119777. */
  119778. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119779. /**
  119780. * If the position gizmo is enabled
  119781. */
  119782. set positionGizmoEnabled(value: boolean);
  119783. get positionGizmoEnabled(): boolean;
  119784. /**
  119785. * If the rotation gizmo is enabled
  119786. */
  119787. set rotationGizmoEnabled(value: boolean);
  119788. get rotationGizmoEnabled(): boolean;
  119789. /**
  119790. * If the scale gizmo is enabled
  119791. */
  119792. set scaleGizmoEnabled(value: boolean);
  119793. get scaleGizmoEnabled(): boolean;
  119794. /**
  119795. * If the boundingBox gizmo is enabled
  119796. */
  119797. set boundingBoxGizmoEnabled(value: boolean);
  119798. get boundingBoxGizmoEnabled(): boolean;
  119799. /**
  119800. * Disposes of the gizmo manager
  119801. */
  119802. dispose(): void;
  119803. }
  119804. }
  119805. declare module BABYLON {
  119806. /**
  119807. * A directional light is defined by a direction (what a surprise!).
  119808. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  119809. * 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.
  119810. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119811. */
  119812. export class DirectionalLight extends ShadowLight {
  119813. private _shadowFrustumSize;
  119814. /**
  119815. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  119816. */
  119817. get shadowFrustumSize(): number;
  119818. /**
  119819. * Specifies a fix frustum size for the shadow generation.
  119820. */
  119821. set shadowFrustumSize(value: number);
  119822. private _shadowOrthoScale;
  119823. /**
  119824. * Gets the shadow projection scale against the optimal computed one.
  119825. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  119826. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  119827. */
  119828. get shadowOrthoScale(): number;
  119829. /**
  119830. * Sets the shadow projection scale against the optimal computed one.
  119831. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  119832. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  119833. */
  119834. set shadowOrthoScale(value: number);
  119835. /**
  119836. * Automatically compute the projection matrix to best fit (including all the casters)
  119837. * on each frame.
  119838. */
  119839. autoUpdateExtends: boolean;
  119840. /**
  119841. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  119842. * on each frame. autoUpdateExtends must be set to true for this to work
  119843. */
  119844. autoCalcShadowZBounds: boolean;
  119845. private _orthoLeft;
  119846. private _orthoRight;
  119847. private _orthoTop;
  119848. private _orthoBottom;
  119849. /**
  119850. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  119851. * The directional light is emitted from everywhere in the given direction.
  119852. * It can cast shadows.
  119853. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119854. * @param name The friendly name of the light
  119855. * @param direction The direction of the light
  119856. * @param scene The scene the light belongs to
  119857. */
  119858. constructor(name: string, direction: Vector3, scene: Scene);
  119859. /**
  119860. * Returns the string "DirectionalLight".
  119861. * @return The class name
  119862. */
  119863. getClassName(): string;
  119864. /**
  119865. * Returns the integer 1.
  119866. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119867. */
  119868. getTypeID(): number;
  119869. /**
  119870. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  119871. * Returns the DirectionalLight Shadow projection matrix.
  119872. */
  119873. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119874. /**
  119875. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  119876. * Returns the DirectionalLight Shadow projection matrix.
  119877. */
  119878. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  119879. /**
  119880. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  119881. * Returns the DirectionalLight Shadow projection matrix.
  119882. */
  119883. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119884. protected _buildUniformLayout(): void;
  119885. /**
  119886. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  119887. * @param effect The effect to update
  119888. * @param lightIndex The index of the light in the effect to update
  119889. * @returns The directional light
  119890. */
  119891. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  119892. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  119893. /**
  119894. * Gets the minZ used for shadow according to both the scene and the light.
  119895. *
  119896. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  119897. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  119898. * @param activeCamera The camera we are returning the min for
  119899. * @returns the depth min z
  119900. */
  119901. getDepthMinZ(activeCamera: Camera): number;
  119902. /**
  119903. * Gets the maxZ used for shadow according to both the scene and the light.
  119904. *
  119905. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  119906. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  119907. * @param activeCamera The camera we are returning the max for
  119908. * @returns the depth max z
  119909. */
  119910. getDepthMaxZ(activeCamera: Camera): number;
  119911. /**
  119912. * Prepares the list of defines specific to the light type.
  119913. * @param defines the list of defines
  119914. * @param lightIndex defines the index of the light for the effect
  119915. */
  119916. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119917. }
  119918. }
  119919. declare module BABYLON {
  119920. /**
  119921. * Class containing static functions to help procedurally build meshes
  119922. */
  119923. export class HemisphereBuilder {
  119924. /**
  119925. * Creates a hemisphere mesh
  119926. * @param name defines the name of the mesh
  119927. * @param options defines the options used to create the mesh
  119928. * @param scene defines the hosting scene
  119929. * @returns the hemisphere mesh
  119930. */
  119931. static CreateHemisphere(name: string, options: {
  119932. segments?: number;
  119933. diameter?: number;
  119934. sideOrientation?: number;
  119935. }, scene: any): Mesh;
  119936. }
  119937. }
  119938. declare module BABYLON {
  119939. /**
  119940. * A spot light is defined by a position, a direction, an angle, and an exponent.
  119941. * These values define a cone of light starting from the position, emitting toward the direction.
  119942. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  119943. * and the exponent defines the speed of the decay of the light with distance (reach).
  119944. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119945. */
  119946. export class SpotLight extends ShadowLight {
  119947. private _angle;
  119948. private _innerAngle;
  119949. private _cosHalfAngle;
  119950. private _lightAngleScale;
  119951. private _lightAngleOffset;
  119952. /**
  119953. * Gets the cone angle of the spot light in Radians.
  119954. */
  119955. get angle(): number;
  119956. /**
  119957. * Sets the cone angle of the spot light in Radians.
  119958. */
  119959. set angle(value: number);
  119960. /**
  119961. * Only used in gltf falloff mode, this defines the angle where
  119962. * the directional falloff will start before cutting at angle which could be seen
  119963. * as outer angle.
  119964. */
  119965. get innerAngle(): number;
  119966. /**
  119967. * Only used in gltf falloff mode, this defines the angle where
  119968. * the directional falloff will start before cutting at angle which could be seen
  119969. * as outer angle.
  119970. */
  119971. set innerAngle(value: number);
  119972. private _shadowAngleScale;
  119973. /**
  119974. * Allows scaling the angle of the light for shadow generation only.
  119975. */
  119976. get shadowAngleScale(): number;
  119977. /**
  119978. * Allows scaling the angle of the light for shadow generation only.
  119979. */
  119980. set shadowAngleScale(value: number);
  119981. /**
  119982. * The light decay speed with the distance from the emission spot.
  119983. */
  119984. exponent: number;
  119985. private _projectionTextureMatrix;
  119986. /**
  119987. * Allows reading the projecton texture
  119988. */
  119989. get projectionTextureMatrix(): Matrix;
  119990. protected _projectionTextureLightNear: number;
  119991. /**
  119992. * Gets the near clip of the Spotlight for texture projection.
  119993. */
  119994. get projectionTextureLightNear(): number;
  119995. /**
  119996. * Sets the near clip of the Spotlight for texture projection.
  119997. */
  119998. set projectionTextureLightNear(value: number);
  119999. protected _projectionTextureLightFar: number;
  120000. /**
  120001. * Gets the far clip of the Spotlight for texture projection.
  120002. */
  120003. get projectionTextureLightFar(): number;
  120004. /**
  120005. * Sets the far clip of the Spotlight for texture projection.
  120006. */
  120007. set projectionTextureLightFar(value: number);
  120008. protected _projectionTextureUpDirection: Vector3;
  120009. /**
  120010. * Gets the Up vector of the Spotlight for texture projection.
  120011. */
  120012. get projectionTextureUpDirection(): Vector3;
  120013. /**
  120014. * Sets the Up vector of the Spotlight for texture projection.
  120015. */
  120016. set projectionTextureUpDirection(value: Vector3);
  120017. private _projectionTexture;
  120018. /**
  120019. * Gets the projection texture of the light.
  120020. */
  120021. get projectionTexture(): Nullable<BaseTexture>;
  120022. /**
  120023. * Sets the projection texture of the light.
  120024. */
  120025. set projectionTexture(value: Nullable<BaseTexture>);
  120026. private _projectionTextureViewLightDirty;
  120027. private _projectionTextureProjectionLightDirty;
  120028. private _projectionTextureDirty;
  120029. private _projectionTextureViewTargetVector;
  120030. private _projectionTextureViewLightMatrix;
  120031. private _projectionTextureProjectionLightMatrix;
  120032. private _projectionTextureScalingMatrix;
  120033. /**
  120034. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  120035. * It can cast shadows.
  120036. * Documentation : https://doc.babylonjs.com/babylon101/lights
  120037. * @param name The light friendly name
  120038. * @param position The position of the spot light in the scene
  120039. * @param direction The direction of the light in the scene
  120040. * @param angle The cone angle of the light in Radians
  120041. * @param exponent The light decay speed with the distance from the emission spot
  120042. * @param scene The scene the lights belongs to
  120043. */
  120044. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  120045. /**
  120046. * Returns the string "SpotLight".
  120047. * @returns the class name
  120048. */
  120049. getClassName(): string;
  120050. /**
  120051. * Returns the integer 2.
  120052. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120053. */
  120054. getTypeID(): number;
  120055. /**
  120056. * Overrides the direction setter to recompute the projection texture view light Matrix.
  120057. */
  120058. protected _setDirection(value: Vector3): void;
  120059. /**
  120060. * Overrides the position setter to recompute the projection texture view light Matrix.
  120061. */
  120062. protected _setPosition(value: Vector3): void;
  120063. /**
  120064. * 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.
  120065. * Returns the SpotLight.
  120066. */
  120067. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120068. protected _computeProjectionTextureViewLightMatrix(): void;
  120069. protected _computeProjectionTextureProjectionLightMatrix(): void;
  120070. /**
  120071. * Main function for light texture projection matrix computing.
  120072. */
  120073. protected _computeProjectionTextureMatrix(): void;
  120074. protected _buildUniformLayout(): void;
  120075. private _computeAngleValues;
  120076. /**
  120077. * Sets the passed Effect "effect" with the Light textures.
  120078. * @param effect The effect to update
  120079. * @param lightIndex The index of the light in the effect to update
  120080. * @returns The light
  120081. */
  120082. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  120083. /**
  120084. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  120085. * @param effect The effect to update
  120086. * @param lightIndex The index of the light in the effect to update
  120087. * @returns The spot light
  120088. */
  120089. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  120090. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120091. /**
  120092. * Disposes the light and the associated resources.
  120093. */
  120094. dispose(): void;
  120095. /**
  120096. * Prepares the list of defines specific to the light type.
  120097. * @param defines the list of defines
  120098. * @param lightIndex defines the index of the light for the effect
  120099. */
  120100. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120101. }
  120102. }
  120103. declare module BABYLON {
  120104. /**
  120105. * Gizmo that enables viewing a light
  120106. */
  120107. export class LightGizmo extends Gizmo {
  120108. private _lightMesh;
  120109. private _material;
  120110. private _cachedPosition;
  120111. private _cachedForward;
  120112. private _attachedMeshParent;
  120113. /**
  120114. * Creates a LightGizmo
  120115. * @param gizmoLayer The utility layer the gizmo will be added to
  120116. */
  120117. constructor(gizmoLayer?: UtilityLayerRenderer);
  120118. private _light;
  120119. /**
  120120. * The light that the gizmo is attached to
  120121. */
  120122. set light(light: Nullable<Light>);
  120123. get light(): Nullable<Light>;
  120124. /**
  120125. * Gets the material used to render the light gizmo
  120126. */
  120127. get material(): StandardMaterial;
  120128. /**
  120129. * @hidden
  120130. * Updates the gizmo to match the attached mesh's position/rotation
  120131. */
  120132. protected _update(): void;
  120133. private static _Scale;
  120134. /**
  120135. * Creates the lines for a light mesh
  120136. */
  120137. private static _CreateLightLines;
  120138. /**
  120139. * Disposes of the light gizmo
  120140. */
  120141. dispose(): void;
  120142. private static _CreateHemisphericLightMesh;
  120143. private static _CreatePointLightMesh;
  120144. private static _CreateSpotLightMesh;
  120145. private static _CreateDirectionalLightMesh;
  120146. }
  120147. }
  120148. declare module BABYLON {
  120149. /** @hidden */
  120150. export var backgroundFragmentDeclaration: {
  120151. name: string;
  120152. shader: string;
  120153. };
  120154. }
  120155. declare module BABYLON {
  120156. /** @hidden */
  120157. export var backgroundUboDeclaration: {
  120158. name: string;
  120159. shader: string;
  120160. };
  120161. }
  120162. declare module BABYLON {
  120163. /** @hidden */
  120164. export var backgroundPixelShader: {
  120165. name: string;
  120166. shader: string;
  120167. };
  120168. }
  120169. declare module BABYLON {
  120170. /** @hidden */
  120171. export var backgroundVertexDeclaration: {
  120172. name: string;
  120173. shader: string;
  120174. };
  120175. }
  120176. declare module BABYLON {
  120177. /** @hidden */
  120178. export var backgroundVertexShader: {
  120179. name: string;
  120180. shader: string;
  120181. };
  120182. }
  120183. declare module BABYLON {
  120184. /**
  120185. * Background material used to create an efficient environement around your scene.
  120186. */
  120187. export class BackgroundMaterial extends PushMaterial {
  120188. /**
  120189. * Standard reflectance value at parallel view angle.
  120190. */
  120191. static StandardReflectance0: number;
  120192. /**
  120193. * Standard reflectance value at grazing angle.
  120194. */
  120195. static StandardReflectance90: number;
  120196. protected _primaryColor: Color3;
  120197. /**
  120198. * Key light Color (multiply against the environement texture)
  120199. */
  120200. primaryColor: Color3;
  120201. protected __perceptualColor: Nullable<Color3>;
  120202. /**
  120203. * Experimental Internal Use Only.
  120204. *
  120205. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  120206. * This acts as a helper to set the primary color to a more "human friendly" value.
  120207. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  120208. * output color as close as possible from the chosen value.
  120209. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  120210. * part of lighting setup.)
  120211. */
  120212. get _perceptualColor(): Nullable<Color3>;
  120213. set _perceptualColor(value: Nullable<Color3>);
  120214. protected _primaryColorShadowLevel: float;
  120215. /**
  120216. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  120217. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  120218. */
  120219. get primaryColorShadowLevel(): float;
  120220. set primaryColorShadowLevel(value: float);
  120221. protected _primaryColorHighlightLevel: float;
  120222. /**
  120223. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  120224. * The primary color is used at the level chosen to define what the white area would look.
  120225. */
  120226. get primaryColorHighlightLevel(): float;
  120227. set primaryColorHighlightLevel(value: float);
  120228. protected _reflectionTexture: Nullable<BaseTexture>;
  120229. /**
  120230. * Reflection Texture used in the material.
  120231. * Should be author in a specific way for the best result (refer to the documentation).
  120232. */
  120233. reflectionTexture: Nullable<BaseTexture>;
  120234. protected _reflectionBlur: float;
  120235. /**
  120236. * Reflection Texture level of blur.
  120237. *
  120238. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  120239. * texture twice.
  120240. */
  120241. reflectionBlur: float;
  120242. protected _diffuseTexture: Nullable<BaseTexture>;
  120243. /**
  120244. * Diffuse Texture used in the material.
  120245. * Should be author in a specific way for the best result (refer to the documentation).
  120246. */
  120247. diffuseTexture: Nullable<BaseTexture>;
  120248. protected _shadowLights: Nullable<IShadowLight[]>;
  120249. /**
  120250. * Specify the list of lights casting shadow on the material.
  120251. * All scene shadow lights will be included if null.
  120252. */
  120253. shadowLights: Nullable<IShadowLight[]>;
  120254. protected _shadowLevel: float;
  120255. /**
  120256. * Helps adjusting the shadow to a softer level if required.
  120257. * 0 means black shadows and 1 means no shadows.
  120258. */
  120259. shadowLevel: float;
  120260. protected _sceneCenter: Vector3;
  120261. /**
  120262. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  120263. * It is usually zero but might be interesting to modify according to your setup.
  120264. */
  120265. sceneCenter: Vector3;
  120266. protected _opacityFresnel: boolean;
  120267. /**
  120268. * This helps specifying that the material is falling off to the sky box at grazing angle.
  120269. * This helps ensuring a nice transition when the camera goes under the ground.
  120270. */
  120271. opacityFresnel: boolean;
  120272. protected _reflectionFresnel: boolean;
  120273. /**
  120274. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  120275. * This helps adding a mirror texture on the ground.
  120276. */
  120277. reflectionFresnel: boolean;
  120278. protected _reflectionFalloffDistance: number;
  120279. /**
  120280. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  120281. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  120282. */
  120283. reflectionFalloffDistance: number;
  120284. protected _reflectionAmount: number;
  120285. /**
  120286. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  120287. */
  120288. reflectionAmount: number;
  120289. protected _reflectionReflectance0: number;
  120290. /**
  120291. * This specifies the weight of the reflection at grazing angle.
  120292. */
  120293. reflectionReflectance0: number;
  120294. protected _reflectionReflectance90: number;
  120295. /**
  120296. * This specifies the weight of the reflection at a perpendicular point of view.
  120297. */
  120298. reflectionReflectance90: number;
  120299. /**
  120300. * Sets the reflection reflectance fresnel values according to the default standard
  120301. * empirically know to work well :-)
  120302. */
  120303. set reflectionStandardFresnelWeight(value: number);
  120304. protected _useRGBColor: boolean;
  120305. /**
  120306. * Helps to directly use the maps channels instead of their level.
  120307. */
  120308. useRGBColor: boolean;
  120309. protected _enableNoise: boolean;
  120310. /**
  120311. * This helps reducing the banding effect that could occur on the background.
  120312. */
  120313. enableNoise: boolean;
  120314. /**
  120315. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  120316. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  120317. * Recommended to be keep at 1.0 except for special cases.
  120318. */
  120319. get fovMultiplier(): number;
  120320. set fovMultiplier(value: number);
  120321. private _fovMultiplier;
  120322. /**
  120323. * Enable the FOV adjustment feature controlled by fovMultiplier.
  120324. */
  120325. useEquirectangularFOV: boolean;
  120326. private _maxSimultaneousLights;
  120327. /**
  120328. * Number of Simultaneous lights allowed on the material.
  120329. */
  120330. maxSimultaneousLights: int;
  120331. /**
  120332. * Default configuration related to image processing available in the Background Material.
  120333. */
  120334. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120335. /**
  120336. * Keep track of the image processing observer to allow dispose and replace.
  120337. */
  120338. private _imageProcessingObserver;
  120339. /**
  120340. * Attaches a new image processing configuration to the PBR Material.
  120341. * @param configuration (if null the scene configuration will be use)
  120342. */
  120343. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120344. /**
  120345. * Gets the image processing configuration used either in this material.
  120346. */
  120347. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  120348. /**
  120349. * Sets the Default image processing configuration used either in the this material.
  120350. *
  120351. * If sets to null, the scene one is in use.
  120352. */
  120353. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  120354. /**
  120355. * Gets wether the color curves effect is enabled.
  120356. */
  120357. get cameraColorCurvesEnabled(): boolean;
  120358. /**
  120359. * Sets wether the color curves effect is enabled.
  120360. */
  120361. set cameraColorCurvesEnabled(value: boolean);
  120362. /**
  120363. * Gets wether the color grading effect is enabled.
  120364. */
  120365. get cameraColorGradingEnabled(): boolean;
  120366. /**
  120367. * Gets wether the color grading effect is enabled.
  120368. */
  120369. set cameraColorGradingEnabled(value: boolean);
  120370. /**
  120371. * Gets wether tonemapping is enabled or not.
  120372. */
  120373. get cameraToneMappingEnabled(): boolean;
  120374. /**
  120375. * Sets wether tonemapping is enabled or not
  120376. */
  120377. set cameraToneMappingEnabled(value: boolean);
  120378. /**
  120379. * The camera exposure used on this material.
  120380. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  120381. * This corresponds to a photographic exposure.
  120382. */
  120383. get cameraExposure(): float;
  120384. /**
  120385. * The camera exposure used on this material.
  120386. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  120387. * This corresponds to a photographic exposure.
  120388. */
  120389. set cameraExposure(value: float);
  120390. /**
  120391. * Gets The camera contrast used on this material.
  120392. */
  120393. get cameraContrast(): float;
  120394. /**
  120395. * Sets The camera contrast used on this material.
  120396. */
  120397. set cameraContrast(value: float);
  120398. /**
  120399. * Gets the Color Grading 2D Lookup Texture.
  120400. */
  120401. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  120402. /**
  120403. * Sets the Color Grading 2D Lookup Texture.
  120404. */
  120405. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  120406. /**
  120407. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  120408. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  120409. * 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;
  120410. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  120411. */
  120412. get cameraColorCurves(): Nullable<ColorCurves>;
  120413. /**
  120414. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  120415. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  120416. * 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;
  120417. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  120418. */
  120419. set cameraColorCurves(value: Nullable<ColorCurves>);
  120420. /**
  120421. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  120422. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  120423. */
  120424. switchToBGR: boolean;
  120425. private _renderTargets;
  120426. private _reflectionControls;
  120427. private _white;
  120428. private _primaryShadowColor;
  120429. private _primaryHighlightColor;
  120430. /**
  120431. * Instantiates a Background Material in the given scene
  120432. * @param name The friendly name of the material
  120433. * @param scene The scene to add the material to
  120434. */
  120435. constructor(name: string, scene: Scene);
  120436. /**
  120437. * Gets a boolean indicating that current material needs to register RTT
  120438. */
  120439. get hasRenderTargetTextures(): boolean;
  120440. /**
  120441. * The entire material has been created in order to prevent overdraw.
  120442. * @returns false
  120443. */
  120444. needAlphaTesting(): boolean;
  120445. /**
  120446. * The entire material has been created in order to prevent overdraw.
  120447. * @returns true if blending is enable
  120448. */
  120449. needAlphaBlending(): boolean;
  120450. /**
  120451. * Checks wether the material is ready to be rendered for a given mesh.
  120452. * @param mesh The mesh to render
  120453. * @param subMesh The submesh to check against
  120454. * @param useInstances Specify wether or not the material is used with instances
  120455. * @returns true if all the dependencies are ready (Textures, Effects...)
  120456. */
  120457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120458. /**
  120459. * Compute the primary color according to the chosen perceptual color.
  120460. */
  120461. private _computePrimaryColorFromPerceptualColor;
  120462. /**
  120463. * Compute the highlights and shadow colors according to their chosen levels.
  120464. */
  120465. private _computePrimaryColors;
  120466. /**
  120467. * Build the uniform buffer used in the material.
  120468. */
  120469. buildUniformLayout(): void;
  120470. /**
  120471. * Unbind the material.
  120472. */
  120473. unbind(): void;
  120474. /**
  120475. * Bind only the world matrix to the material.
  120476. * @param world The world matrix to bind.
  120477. */
  120478. bindOnlyWorldMatrix(world: Matrix): void;
  120479. /**
  120480. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  120481. * @param world The world matrix to bind.
  120482. * @param subMesh The submesh to bind for.
  120483. */
  120484. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120485. /**
  120486. * Checks to see if a texture is used in the material.
  120487. * @param texture - Base texture to use.
  120488. * @returns - Boolean specifying if a texture is used in the material.
  120489. */
  120490. hasTexture(texture: BaseTexture): boolean;
  120491. /**
  120492. * Dispose the material.
  120493. * @param forceDisposeEffect Force disposal of the associated effect.
  120494. * @param forceDisposeTextures Force disposal of the associated textures.
  120495. */
  120496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  120497. /**
  120498. * Clones the material.
  120499. * @param name The cloned name.
  120500. * @returns The cloned material.
  120501. */
  120502. clone(name: string): BackgroundMaterial;
  120503. /**
  120504. * Serializes the current material to its JSON representation.
  120505. * @returns The JSON representation.
  120506. */
  120507. serialize(): any;
  120508. /**
  120509. * Gets the class name of the material
  120510. * @returns "BackgroundMaterial"
  120511. */
  120512. getClassName(): string;
  120513. /**
  120514. * Parse a JSON input to create back a background material.
  120515. * @param source The JSON data to parse
  120516. * @param scene The scene to create the parsed material in
  120517. * @param rootUrl The root url of the assets the material depends upon
  120518. * @returns the instantiated BackgroundMaterial.
  120519. */
  120520. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  120521. }
  120522. }
  120523. declare module BABYLON {
  120524. /**
  120525. * Represents the different options available during the creation of
  120526. * a Environment helper.
  120527. *
  120528. * This can control the default ground, skybox and image processing setup of your scene.
  120529. */
  120530. export interface IEnvironmentHelperOptions {
  120531. /**
  120532. * Specifies wether or not to create a ground.
  120533. * True by default.
  120534. */
  120535. createGround: boolean;
  120536. /**
  120537. * Specifies the ground size.
  120538. * 15 by default.
  120539. */
  120540. groundSize: number;
  120541. /**
  120542. * The texture used on the ground for the main color.
  120543. * Comes from the BabylonJS CDN by default.
  120544. *
  120545. * Remarks: Can be either a texture or a url.
  120546. */
  120547. groundTexture: string | BaseTexture;
  120548. /**
  120549. * The color mixed in the ground texture by default.
  120550. * BabylonJS clearColor by default.
  120551. */
  120552. groundColor: Color3;
  120553. /**
  120554. * Specifies the ground opacity.
  120555. * 1 by default.
  120556. */
  120557. groundOpacity: number;
  120558. /**
  120559. * Enables the ground to receive shadows.
  120560. * True by default.
  120561. */
  120562. enableGroundShadow: boolean;
  120563. /**
  120564. * Helps preventing the shadow to be fully black on the ground.
  120565. * 0.5 by default.
  120566. */
  120567. groundShadowLevel: number;
  120568. /**
  120569. * Creates a mirror texture attach to the ground.
  120570. * false by default.
  120571. */
  120572. enableGroundMirror: boolean;
  120573. /**
  120574. * Specifies the ground mirror size ratio.
  120575. * 0.3 by default as the default kernel is 64.
  120576. */
  120577. groundMirrorSizeRatio: number;
  120578. /**
  120579. * Specifies the ground mirror blur kernel size.
  120580. * 64 by default.
  120581. */
  120582. groundMirrorBlurKernel: number;
  120583. /**
  120584. * Specifies the ground mirror visibility amount.
  120585. * 1 by default
  120586. */
  120587. groundMirrorAmount: number;
  120588. /**
  120589. * Specifies the ground mirror reflectance weight.
  120590. * This uses the standard weight of the background material to setup the fresnel effect
  120591. * of the mirror.
  120592. * 1 by default.
  120593. */
  120594. groundMirrorFresnelWeight: number;
  120595. /**
  120596. * Specifies the ground mirror Falloff distance.
  120597. * This can helps reducing the size of the reflection.
  120598. * 0 by Default.
  120599. */
  120600. groundMirrorFallOffDistance: number;
  120601. /**
  120602. * Specifies the ground mirror texture type.
  120603. * Unsigned Int by Default.
  120604. */
  120605. groundMirrorTextureType: number;
  120606. /**
  120607. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  120608. * the shown objects.
  120609. */
  120610. groundYBias: number;
  120611. /**
  120612. * Specifies wether or not to create a skybox.
  120613. * True by default.
  120614. */
  120615. createSkybox: boolean;
  120616. /**
  120617. * Specifies the skybox size.
  120618. * 20 by default.
  120619. */
  120620. skyboxSize: number;
  120621. /**
  120622. * The texture used on the skybox for the main color.
  120623. * Comes from the BabylonJS CDN by default.
  120624. *
  120625. * Remarks: Can be either a texture or a url.
  120626. */
  120627. skyboxTexture: string | BaseTexture;
  120628. /**
  120629. * The color mixed in the skybox texture by default.
  120630. * BabylonJS clearColor by default.
  120631. */
  120632. skyboxColor: Color3;
  120633. /**
  120634. * The background rotation around the Y axis of the scene.
  120635. * This helps aligning the key lights of your scene with the background.
  120636. * 0 by default.
  120637. */
  120638. backgroundYRotation: number;
  120639. /**
  120640. * Compute automatically the size of the elements to best fit with the scene.
  120641. */
  120642. sizeAuto: boolean;
  120643. /**
  120644. * Default position of the rootMesh if autoSize is not true.
  120645. */
  120646. rootPosition: Vector3;
  120647. /**
  120648. * Sets up the image processing in the scene.
  120649. * true by default.
  120650. */
  120651. setupImageProcessing: boolean;
  120652. /**
  120653. * The texture used as your environment texture in the scene.
  120654. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  120655. *
  120656. * Remarks: Can be either a texture or a url.
  120657. */
  120658. environmentTexture: string | BaseTexture;
  120659. /**
  120660. * The value of the exposure to apply to the scene.
  120661. * 0.6 by default if setupImageProcessing is true.
  120662. */
  120663. cameraExposure: number;
  120664. /**
  120665. * The value of the contrast to apply to the scene.
  120666. * 1.6 by default if setupImageProcessing is true.
  120667. */
  120668. cameraContrast: number;
  120669. /**
  120670. * Specifies wether or not tonemapping should be enabled in the scene.
  120671. * true by default if setupImageProcessing is true.
  120672. */
  120673. toneMappingEnabled: boolean;
  120674. }
  120675. /**
  120676. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  120677. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  120678. * It also helps with the default setup of your imageProcessing configuration.
  120679. */
  120680. export class EnvironmentHelper {
  120681. /**
  120682. * Default ground texture URL.
  120683. */
  120684. private static _groundTextureCDNUrl;
  120685. /**
  120686. * Default skybox texture URL.
  120687. */
  120688. private static _skyboxTextureCDNUrl;
  120689. /**
  120690. * Default environment texture URL.
  120691. */
  120692. private static _environmentTextureCDNUrl;
  120693. /**
  120694. * Creates the default options for the helper.
  120695. */
  120696. private static _getDefaultOptions;
  120697. private _rootMesh;
  120698. /**
  120699. * Gets the root mesh created by the helper.
  120700. */
  120701. get rootMesh(): Mesh;
  120702. private _skybox;
  120703. /**
  120704. * Gets the skybox created by the helper.
  120705. */
  120706. get skybox(): Nullable<Mesh>;
  120707. private _skyboxTexture;
  120708. /**
  120709. * Gets the skybox texture created by the helper.
  120710. */
  120711. get skyboxTexture(): Nullable<BaseTexture>;
  120712. private _skyboxMaterial;
  120713. /**
  120714. * Gets the skybox material created by the helper.
  120715. */
  120716. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  120717. private _ground;
  120718. /**
  120719. * Gets the ground mesh created by the helper.
  120720. */
  120721. get ground(): Nullable<Mesh>;
  120722. private _groundTexture;
  120723. /**
  120724. * Gets the ground texture created by the helper.
  120725. */
  120726. get groundTexture(): Nullable<BaseTexture>;
  120727. private _groundMirror;
  120728. /**
  120729. * Gets the ground mirror created by the helper.
  120730. */
  120731. get groundMirror(): Nullable<MirrorTexture>;
  120732. /**
  120733. * Gets the ground mirror render list to helps pushing the meshes
  120734. * you wish in the ground reflection.
  120735. */
  120736. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  120737. private _groundMaterial;
  120738. /**
  120739. * Gets the ground material created by the helper.
  120740. */
  120741. get groundMaterial(): Nullable<BackgroundMaterial>;
  120742. /**
  120743. * Stores the creation options.
  120744. */
  120745. private readonly _scene;
  120746. private _options;
  120747. /**
  120748. * This observable will be notified with any error during the creation of the environment,
  120749. * mainly texture creation errors.
  120750. */
  120751. onErrorObservable: Observable<{
  120752. message?: string;
  120753. exception?: any;
  120754. }>;
  120755. /**
  120756. * constructor
  120757. * @param options Defines the options we want to customize the helper
  120758. * @param scene The scene to add the material to
  120759. */
  120760. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  120761. /**
  120762. * Updates the background according to the new options
  120763. * @param options
  120764. */
  120765. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  120766. /**
  120767. * Sets the primary color of all the available elements.
  120768. * @param color the main color to affect to the ground and the background
  120769. */
  120770. setMainColor(color: Color3): void;
  120771. /**
  120772. * Setup the image processing according to the specified options.
  120773. */
  120774. private _setupImageProcessing;
  120775. /**
  120776. * Setup the environment texture according to the specified options.
  120777. */
  120778. private _setupEnvironmentTexture;
  120779. /**
  120780. * Setup the background according to the specified options.
  120781. */
  120782. private _setupBackground;
  120783. /**
  120784. * Get the scene sizes according to the setup.
  120785. */
  120786. private _getSceneSize;
  120787. /**
  120788. * Setup the ground according to the specified options.
  120789. */
  120790. private _setupGround;
  120791. /**
  120792. * Setup the ground material according to the specified options.
  120793. */
  120794. private _setupGroundMaterial;
  120795. /**
  120796. * Setup the ground diffuse texture according to the specified options.
  120797. */
  120798. private _setupGroundDiffuseTexture;
  120799. /**
  120800. * Setup the ground mirror texture according to the specified options.
  120801. */
  120802. private _setupGroundMirrorTexture;
  120803. /**
  120804. * Setup the ground to receive the mirror texture.
  120805. */
  120806. private _setupMirrorInGroundMaterial;
  120807. /**
  120808. * Setup the skybox according to the specified options.
  120809. */
  120810. private _setupSkybox;
  120811. /**
  120812. * Setup the skybox material according to the specified options.
  120813. */
  120814. private _setupSkyboxMaterial;
  120815. /**
  120816. * Setup the skybox reflection texture according to the specified options.
  120817. */
  120818. private _setupSkyboxReflectionTexture;
  120819. private _errorHandler;
  120820. /**
  120821. * Dispose all the elements created by the Helper.
  120822. */
  120823. dispose(): void;
  120824. }
  120825. }
  120826. declare module BABYLON {
  120827. /**
  120828. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  120829. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  120830. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  120831. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  120832. */
  120833. export class PhotoDome extends TransformNode {
  120834. /**
  120835. * Define the image as a Monoscopic panoramic 360 image.
  120836. */
  120837. static readonly MODE_MONOSCOPIC: number;
  120838. /**
  120839. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  120840. */
  120841. static readonly MODE_TOPBOTTOM: number;
  120842. /**
  120843. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  120844. */
  120845. static readonly MODE_SIDEBYSIDE: number;
  120846. private _useDirectMapping;
  120847. /**
  120848. * The texture being displayed on the sphere
  120849. */
  120850. protected _photoTexture: Texture;
  120851. /**
  120852. * Gets or sets the texture being displayed on the sphere
  120853. */
  120854. get photoTexture(): Texture;
  120855. set photoTexture(value: Texture);
  120856. /**
  120857. * Observable raised when an error occured while loading the 360 image
  120858. */
  120859. onLoadErrorObservable: Observable<string>;
  120860. /**
  120861. * The skybox material
  120862. */
  120863. protected _material: BackgroundMaterial;
  120864. /**
  120865. * The surface used for the skybox
  120866. */
  120867. protected _mesh: Mesh;
  120868. /**
  120869. * Gets the mesh used for the skybox.
  120870. */
  120871. get mesh(): Mesh;
  120872. /**
  120873. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  120874. * Also see the options.resolution property.
  120875. */
  120876. get fovMultiplier(): number;
  120877. set fovMultiplier(value: number);
  120878. private _imageMode;
  120879. /**
  120880. * Gets or set the current video mode for the video. It can be:
  120881. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  120882. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  120883. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  120884. */
  120885. get imageMode(): number;
  120886. set imageMode(value: number);
  120887. /**
  120888. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  120889. * @param name Element's name, child elements will append suffixes for their own names.
  120890. * @param urlsOfPhoto defines the url of the photo to display
  120891. * @param options defines an object containing optional or exposed sub element properties
  120892. * @param onError defines a callback called when an error occured while loading the texture
  120893. */
  120894. constructor(name: string, urlOfPhoto: string, options: {
  120895. resolution?: number;
  120896. size?: number;
  120897. useDirectMapping?: boolean;
  120898. faceForward?: boolean;
  120899. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  120900. private _onBeforeCameraRenderObserver;
  120901. private _changeImageMode;
  120902. /**
  120903. * Releases resources associated with this node.
  120904. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  120905. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  120906. */
  120907. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  120908. }
  120909. }
  120910. declare module BABYLON {
  120911. /**
  120912. * Class used to host RGBD texture specific utilities
  120913. */
  120914. export class RGBDTextureTools {
  120915. /**
  120916. * Expand the RGBD Texture from RGBD to Half Float if possible.
  120917. * @param texture the texture to expand.
  120918. */
  120919. static ExpandRGBDTexture(texture: Texture): void;
  120920. }
  120921. }
  120922. declare module BABYLON {
  120923. /**
  120924. * Class used to host texture specific utilities
  120925. */
  120926. export class BRDFTextureTools {
  120927. /**
  120928. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  120929. * @param scene defines the hosting scene
  120930. * @returns the environment BRDF texture
  120931. */
  120932. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  120933. private static _environmentBRDFBase64Texture;
  120934. }
  120935. }
  120936. declare module BABYLON {
  120937. /**
  120938. * @hidden
  120939. */
  120940. export interface IMaterialClearCoatDefines {
  120941. CLEARCOAT: boolean;
  120942. CLEARCOAT_DEFAULTIOR: boolean;
  120943. CLEARCOAT_TEXTURE: boolean;
  120944. CLEARCOAT_TEXTUREDIRECTUV: number;
  120945. CLEARCOAT_BUMP: boolean;
  120946. CLEARCOAT_BUMPDIRECTUV: number;
  120947. CLEARCOAT_TINT: boolean;
  120948. CLEARCOAT_TINT_TEXTURE: boolean;
  120949. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120950. /** @hidden */
  120951. _areTexturesDirty: boolean;
  120952. }
  120953. /**
  120954. * Define the code related to the clear coat parameters of the pbr material.
  120955. */
  120956. export class PBRClearCoatConfiguration {
  120957. /**
  120958. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  120959. * The default fits with a polyurethane material.
  120960. */
  120961. private static readonly _DefaultIndexOfRefraction;
  120962. private _isEnabled;
  120963. /**
  120964. * Defines if the clear coat is enabled in the material.
  120965. */
  120966. isEnabled: boolean;
  120967. /**
  120968. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  120969. */
  120970. intensity: number;
  120971. /**
  120972. * Defines the clear coat layer roughness.
  120973. */
  120974. roughness: number;
  120975. private _indexOfRefraction;
  120976. /**
  120977. * Defines the index of refraction of the clear coat.
  120978. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  120979. * The default fits with a polyurethane material.
  120980. * Changing the default value is more performance intensive.
  120981. */
  120982. indexOfRefraction: number;
  120983. private _texture;
  120984. /**
  120985. * Stores the clear coat values in a texture.
  120986. */
  120987. texture: Nullable<BaseTexture>;
  120988. private _bumpTexture;
  120989. /**
  120990. * Define the clear coat specific bump texture.
  120991. */
  120992. bumpTexture: Nullable<BaseTexture>;
  120993. private _isTintEnabled;
  120994. /**
  120995. * Defines if the clear coat tint is enabled in the material.
  120996. */
  120997. isTintEnabled: boolean;
  120998. /**
  120999. * Defines the clear coat tint of the material.
  121000. * This is only use if tint is enabled
  121001. */
  121002. tintColor: Color3;
  121003. /**
  121004. * Defines the distance at which the tint color should be found in the
  121005. * clear coat media.
  121006. * This is only use if tint is enabled
  121007. */
  121008. tintColorAtDistance: number;
  121009. /**
  121010. * Defines the clear coat layer thickness.
  121011. * This is only use if tint is enabled
  121012. */
  121013. tintThickness: number;
  121014. private _tintTexture;
  121015. /**
  121016. * Stores the clear tint values in a texture.
  121017. * rgb is tint
  121018. * a is a thickness factor
  121019. */
  121020. tintTexture: Nullable<BaseTexture>;
  121021. /** @hidden */
  121022. private _internalMarkAllSubMeshesAsTexturesDirty;
  121023. /** @hidden */
  121024. _markAllSubMeshesAsTexturesDirty(): void;
  121025. /**
  121026. * Instantiate a new istance of clear coat configuration.
  121027. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121028. */
  121029. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121030. /**
  121031. * Gets wehter the submesh is ready to be used or not.
  121032. * @param defines the list of "defines" to update.
  121033. * @param scene defines the scene the material belongs to.
  121034. * @param engine defines the engine the material belongs to.
  121035. * @param disableBumpMap defines wether the material disables bump or not.
  121036. * @returns - boolean indicating that the submesh is ready or not.
  121037. */
  121038. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  121039. /**
  121040. * Checks to see if a texture is used in the material.
  121041. * @param defines the list of "defines" to update.
  121042. * @param scene defines the scene to the material belongs to.
  121043. */
  121044. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  121045. /**
  121046. * Binds the material data.
  121047. * @param uniformBuffer defines the Uniform buffer to fill in.
  121048. * @param scene defines the scene the material belongs to.
  121049. * @param engine defines the engine the material belongs to.
  121050. * @param disableBumpMap defines wether the material disables bump or not.
  121051. * @param isFrozen defines wether the material is frozen or not.
  121052. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  121053. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  121054. */
  121055. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  121056. /**
  121057. * Checks to see if a texture is used in the material.
  121058. * @param texture - Base texture to use.
  121059. * @returns - Boolean specifying if a texture is used in the material.
  121060. */
  121061. hasTexture(texture: BaseTexture): boolean;
  121062. /**
  121063. * Returns an array of the actively used textures.
  121064. * @param activeTextures Array of BaseTextures
  121065. */
  121066. getActiveTextures(activeTextures: BaseTexture[]): void;
  121067. /**
  121068. * Returns the animatable textures.
  121069. * @param animatables Array of animatable textures.
  121070. */
  121071. getAnimatables(animatables: IAnimatable[]): void;
  121072. /**
  121073. * Disposes the resources of the material.
  121074. * @param forceDisposeTextures - Forces the disposal of all textures.
  121075. */
  121076. dispose(forceDisposeTextures?: boolean): void;
  121077. /**
  121078. * Get the current class name of the texture useful for serialization or dynamic coding.
  121079. * @returns "PBRClearCoatConfiguration"
  121080. */
  121081. getClassName(): string;
  121082. /**
  121083. * Add fallbacks to the effect fallbacks list.
  121084. * @param defines defines the Base texture to use.
  121085. * @param fallbacks defines the current fallback list.
  121086. * @param currentRank defines the current fallback rank.
  121087. * @returns the new fallback rank.
  121088. */
  121089. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121090. /**
  121091. * Add the required uniforms to the current list.
  121092. * @param uniforms defines the current uniform list.
  121093. */
  121094. static AddUniforms(uniforms: string[]): void;
  121095. /**
  121096. * Add the required samplers to the current list.
  121097. * @param samplers defines the current sampler list.
  121098. */
  121099. static AddSamplers(samplers: string[]): void;
  121100. /**
  121101. * Add the required uniforms to the current buffer.
  121102. * @param uniformBuffer defines the current uniform buffer.
  121103. */
  121104. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121105. /**
  121106. * Makes a duplicate of the current configuration into another one.
  121107. * @param clearCoatConfiguration define the config where to copy the info
  121108. */
  121109. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  121110. /**
  121111. * Serializes this clear coat configuration.
  121112. * @returns - An object with the serialized config.
  121113. */
  121114. serialize(): any;
  121115. /**
  121116. * Parses a anisotropy Configuration from a serialized object.
  121117. * @param source - Serialized object.
  121118. * @param scene Defines the scene we are parsing for
  121119. * @param rootUrl Defines the rootUrl to load from
  121120. */
  121121. parse(source: any, scene: Scene, rootUrl: string): void;
  121122. }
  121123. }
  121124. declare module BABYLON {
  121125. /**
  121126. * @hidden
  121127. */
  121128. export interface IMaterialAnisotropicDefines {
  121129. ANISOTROPIC: boolean;
  121130. ANISOTROPIC_TEXTURE: boolean;
  121131. ANISOTROPIC_TEXTUREDIRECTUV: number;
  121132. MAINUV1: boolean;
  121133. _areTexturesDirty: boolean;
  121134. _needUVs: boolean;
  121135. }
  121136. /**
  121137. * Define the code related to the anisotropic parameters of the pbr material.
  121138. */
  121139. export class PBRAnisotropicConfiguration {
  121140. private _isEnabled;
  121141. /**
  121142. * Defines if the anisotropy is enabled in the material.
  121143. */
  121144. isEnabled: boolean;
  121145. /**
  121146. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  121147. */
  121148. intensity: number;
  121149. /**
  121150. * Defines if the effect is along the tangents, bitangents or in between.
  121151. * By default, the effect is "strectching" the highlights along the tangents.
  121152. */
  121153. direction: Vector2;
  121154. private _texture;
  121155. /**
  121156. * Stores the anisotropy values in a texture.
  121157. * rg is direction (like normal from -1 to 1)
  121158. * b is a intensity
  121159. */
  121160. texture: Nullable<BaseTexture>;
  121161. /** @hidden */
  121162. private _internalMarkAllSubMeshesAsTexturesDirty;
  121163. /** @hidden */
  121164. _markAllSubMeshesAsTexturesDirty(): void;
  121165. /**
  121166. * Instantiate a new istance of anisotropy configuration.
  121167. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121168. */
  121169. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121170. /**
  121171. * Specifies that the submesh is ready to be used.
  121172. * @param defines the list of "defines" to update.
  121173. * @param scene defines the scene the material belongs to.
  121174. * @returns - boolean indicating that the submesh is ready or not.
  121175. */
  121176. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  121177. /**
  121178. * Checks to see if a texture is used in the material.
  121179. * @param defines the list of "defines" to update.
  121180. * @param mesh the mesh we are preparing the defines for.
  121181. * @param scene defines the scene the material belongs to.
  121182. */
  121183. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  121184. /**
  121185. * Binds the material data.
  121186. * @param uniformBuffer defines the Uniform buffer to fill in.
  121187. * @param scene defines the scene the material belongs to.
  121188. * @param isFrozen defines wether the material is frozen or not.
  121189. */
  121190. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  121191. /**
  121192. * Checks to see if a texture is used in the material.
  121193. * @param texture - Base texture to use.
  121194. * @returns - Boolean specifying if a texture is used in the material.
  121195. */
  121196. hasTexture(texture: BaseTexture): boolean;
  121197. /**
  121198. * Returns an array of the actively used textures.
  121199. * @param activeTextures Array of BaseTextures
  121200. */
  121201. getActiveTextures(activeTextures: BaseTexture[]): void;
  121202. /**
  121203. * Returns the animatable textures.
  121204. * @param animatables Array of animatable textures.
  121205. */
  121206. getAnimatables(animatables: IAnimatable[]): void;
  121207. /**
  121208. * Disposes the resources of the material.
  121209. * @param forceDisposeTextures - Forces the disposal of all textures.
  121210. */
  121211. dispose(forceDisposeTextures?: boolean): void;
  121212. /**
  121213. * Get the current class name of the texture useful for serialization or dynamic coding.
  121214. * @returns "PBRAnisotropicConfiguration"
  121215. */
  121216. getClassName(): string;
  121217. /**
  121218. * Add fallbacks to the effect fallbacks list.
  121219. * @param defines defines the Base texture to use.
  121220. * @param fallbacks defines the current fallback list.
  121221. * @param currentRank defines the current fallback rank.
  121222. * @returns the new fallback rank.
  121223. */
  121224. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121225. /**
  121226. * Add the required uniforms to the current list.
  121227. * @param uniforms defines the current uniform list.
  121228. */
  121229. static AddUniforms(uniforms: string[]): void;
  121230. /**
  121231. * Add the required uniforms to the current buffer.
  121232. * @param uniformBuffer defines the current uniform buffer.
  121233. */
  121234. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121235. /**
  121236. * Add the required samplers to the current list.
  121237. * @param samplers defines the current sampler list.
  121238. */
  121239. static AddSamplers(samplers: string[]): void;
  121240. /**
  121241. * Makes a duplicate of the current configuration into another one.
  121242. * @param anisotropicConfiguration define the config where to copy the info
  121243. */
  121244. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  121245. /**
  121246. * Serializes this anisotropy configuration.
  121247. * @returns - An object with the serialized config.
  121248. */
  121249. serialize(): any;
  121250. /**
  121251. * Parses a anisotropy Configuration from a serialized object.
  121252. * @param source - Serialized object.
  121253. * @param scene Defines the scene we are parsing for
  121254. * @param rootUrl Defines the rootUrl to load from
  121255. */
  121256. parse(source: any, scene: Scene, rootUrl: string): void;
  121257. }
  121258. }
  121259. declare module BABYLON {
  121260. /**
  121261. * @hidden
  121262. */
  121263. export interface IMaterialBRDFDefines {
  121264. BRDF_V_HEIGHT_CORRELATED: boolean;
  121265. MS_BRDF_ENERGY_CONSERVATION: boolean;
  121266. SPHERICAL_HARMONICS: boolean;
  121267. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  121268. /** @hidden */
  121269. _areMiscDirty: boolean;
  121270. }
  121271. /**
  121272. * Define the code related to the BRDF parameters of the pbr material.
  121273. */
  121274. export class PBRBRDFConfiguration {
  121275. /**
  121276. * Default value used for the energy conservation.
  121277. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  121278. */
  121279. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  121280. /**
  121281. * Default value used for the Smith Visibility Height Correlated mode.
  121282. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  121283. */
  121284. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  121285. /**
  121286. * Default value used for the IBL diffuse part.
  121287. * This can help switching back to the polynomials mode globally which is a tiny bit
  121288. * less GPU intensive at the drawback of a lower quality.
  121289. */
  121290. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  121291. /**
  121292. * Default value used for activating energy conservation for the specular workflow.
  121293. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  121294. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  121295. */
  121296. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  121297. private _useEnergyConservation;
  121298. /**
  121299. * Defines if the material uses energy conservation.
  121300. */
  121301. useEnergyConservation: boolean;
  121302. private _useSmithVisibilityHeightCorrelated;
  121303. /**
  121304. * LEGACY Mode set to false
  121305. * Defines if the material uses height smith correlated visibility term.
  121306. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  121307. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  121308. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  121309. * Not relying on height correlated will also disable energy conservation.
  121310. */
  121311. useSmithVisibilityHeightCorrelated: boolean;
  121312. private _useSphericalHarmonics;
  121313. /**
  121314. * LEGACY Mode set to false
  121315. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  121316. * diffuse part of the IBL.
  121317. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  121318. * to the ground truth.
  121319. */
  121320. useSphericalHarmonics: boolean;
  121321. private _useSpecularGlossinessInputEnergyConservation;
  121322. /**
  121323. * Defines if the material uses energy conservation, when the specular workflow is active.
  121324. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  121325. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  121326. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  121327. */
  121328. useSpecularGlossinessInputEnergyConservation: boolean;
  121329. /** @hidden */
  121330. private _internalMarkAllSubMeshesAsMiscDirty;
  121331. /** @hidden */
  121332. _markAllSubMeshesAsMiscDirty(): void;
  121333. /**
  121334. * Instantiate a new istance of clear coat configuration.
  121335. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  121336. */
  121337. constructor(markAllSubMeshesAsMiscDirty: () => void);
  121338. /**
  121339. * Checks to see if a texture is used in the material.
  121340. * @param defines the list of "defines" to update.
  121341. */
  121342. prepareDefines(defines: IMaterialBRDFDefines): void;
  121343. /**
  121344. * Get the current class name of the texture useful for serialization or dynamic coding.
  121345. * @returns "PBRClearCoatConfiguration"
  121346. */
  121347. getClassName(): string;
  121348. /**
  121349. * Makes a duplicate of the current configuration into another one.
  121350. * @param brdfConfiguration define the config where to copy the info
  121351. */
  121352. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  121353. /**
  121354. * Serializes this BRDF configuration.
  121355. * @returns - An object with the serialized config.
  121356. */
  121357. serialize(): any;
  121358. /**
  121359. * Parses a anisotropy Configuration from a serialized object.
  121360. * @param source - Serialized object.
  121361. * @param scene Defines the scene we are parsing for
  121362. * @param rootUrl Defines the rootUrl to load from
  121363. */
  121364. parse(source: any, scene: Scene, rootUrl: string): void;
  121365. }
  121366. }
  121367. declare module BABYLON {
  121368. /**
  121369. * @hidden
  121370. */
  121371. export interface IMaterialSheenDefines {
  121372. SHEEN: boolean;
  121373. SHEEN_TEXTURE: boolean;
  121374. SHEEN_TEXTUREDIRECTUV: number;
  121375. SHEEN_LINKWITHALBEDO: boolean;
  121376. /** @hidden */
  121377. _areTexturesDirty: boolean;
  121378. }
  121379. /**
  121380. * Define the code related to the Sheen parameters of the pbr material.
  121381. */
  121382. export class PBRSheenConfiguration {
  121383. private _isEnabled;
  121384. /**
  121385. * Defines if the material uses sheen.
  121386. */
  121387. isEnabled: boolean;
  121388. private _linkSheenWithAlbedo;
  121389. /**
  121390. * Defines if the sheen is linked to the sheen color.
  121391. */
  121392. linkSheenWithAlbedo: boolean;
  121393. /**
  121394. * Defines the sheen intensity.
  121395. */
  121396. intensity: number;
  121397. /**
  121398. * Defines the sheen color.
  121399. */
  121400. color: Color3;
  121401. private _texture;
  121402. /**
  121403. * Stores the sheen tint values in a texture.
  121404. * rgb is tint
  121405. * a is a intensity
  121406. */
  121407. texture: Nullable<BaseTexture>;
  121408. /** @hidden */
  121409. private _internalMarkAllSubMeshesAsTexturesDirty;
  121410. /** @hidden */
  121411. _markAllSubMeshesAsTexturesDirty(): void;
  121412. /**
  121413. * Instantiate a new istance of clear coat configuration.
  121414. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121415. */
  121416. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121417. /**
  121418. * Specifies that the submesh is ready to be used.
  121419. * @param defines the list of "defines" to update.
  121420. * @param scene defines the scene the material belongs to.
  121421. * @returns - boolean indicating that the submesh is ready or not.
  121422. */
  121423. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  121424. /**
  121425. * Checks to see if a texture is used in the material.
  121426. * @param defines the list of "defines" to update.
  121427. * @param scene defines the scene the material belongs to.
  121428. */
  121429. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  121430. /**
  121431. * Binds the material data.
  121432. * @param uniformBuffer defines the Uniform buffer to fill in.
  121433. * @param scene defines the scene the material belongs to.
  121434. * @param isFrozen defines wether the material is frozen or not.
  121435. */
  121436. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  121437. /**
  121438. * Checks to see if a texture is used in the material.
  121439. * @param texture - Base texture to use.
  121440. * @returns - Boolean specifying if a texture is used in the material.
  121441. */
  121442. hasTexture(texture: BaseTexture): boolean;
  121443. /**
  121444. * Returns an array of the actively used textures.
  121445. * @param activeTextures Array of BaseTextures
  121446. */
  121447. getActiveTextures(activeTextures: BaseTexture[]): void;
  121448. /**
  121449. * Returns the animatable textures.
  121450. * @param animatables Array of animatable textures.
  121451. */
  121452. getAnimatables(animatables: IAnimatable[]): void;
  121453. /**
  121454. * Disposes the resources of the material.
  121455. * @param forceDisposeTextures - Forces the disposal of all textures.
  121456. */
  121457. dispose(forceDisposeTextures?: boolean): void;
  121458. /**
  121459. * Get the current class name of the texture useful for serialization or dynamic coding.
  121460. * @returns "PBRSheenConfiguration"
  121461. */
  121462. getClassName(): string;
  121463. /**
  121464. * Add fallbacks to the effect fallbacks list.
  121465. * @param defines defines the Base texture to use.
  121466. * @param fallbacks defines the current fallback list.
  121467. * @param currentRank defines the current fallback rank.
  121468. * @returns the new fallback rank.
  121469. */
  121470. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121471. /**
  121472. * Add the required uniforms to the current list.
  121473. * @param uniforms defines the current uniform list.
  121474. */
  121475. static AddUniforms(uniforms: string[]): void;
  121476. /**
  121477. * Add the required uniforms to the current buffer.
  121478. * @param uniformBuffer defines the current uniform buffer.
  121479. */
  121480. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121481. /**
  121482. * Add the required samplers to the current list.
  121483. * @param samplers defines the current sampler list.
  121484. */
  121485. static AddSamplers(samplers: string[]): void;
  121486. /**
  121487. * Makes a duplicate of the current configuration into another one.
  121488. * @param sheenConfiguration define the config where to copy the info
  121489. */
  121490. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  121491. /**
  121492. * Serializes this BRDF configuration.
  121493. * @returns - An object with the serialized config.
  121494. */
  121495. serialize(): any;
  121496. /**
  121497. * Parses a anisotropy Configuration from a serialized object.
  121498. * @param source - Serialized object.
  121499. * @param scene Defines the scene we are parsing for
  121500. * @param rootUrl Defines the rootUrl to load from
  121501. */
  121502. parse(source: any, scene: Scene, rootUrl: string): void;
  121503. }
  121504. }
  121505. declare module BABYLON {
  121506. /**
  121507. * @hidden
  121508. */
  121509. export interface IMaterialSubSurfaceDefines {
  121510. SUBSURFACE: boolean;
  121511. SS_REFRACTION: boolean;
  121512. SS_TRANSLUCENCY: boolean;
  121513. SS_SCATERRING: boolean;
  121514. SS_THICKNESSANDMASK_TEXTURE: boolean;
  121515. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  121516. SS_REFRACTIONMAP_3D: boolean;
  121517. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  121518. SS_LODINREFRACTIONALPHA: boolean;
  121519. SS_GAMMAREFRACTION: boolean;
  121520. SS_RGBDREFRACTION: boolean;
  121521. SS_LINEARSPECULARREFRACTION: boolean;
  121522. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  121523. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  121524. /** @hidden */
  121525. _areTexturesDirty: boolean;
  121526. }
  121527. /**
  121528. * Define the code related to the sub surface parameters of the pbr material.
  121529. */
  121530. export class PBRSubSurfaceConfiguration {
  121531. private _isRefractionEnabled;
  121532. /**
  121533. * Defines if the refraction is enabled in the material.
  121534. */
  121535. isRefractionEnabled: boolean;
  121536. private _isTranslucencyEnabled;
  121537. /**
  121538. * Defines if the translucency is enabled in the material.
  121539. */
  121540. isTranslucencyEnabled: boolean;
  121541. private _isScatteringEnabled;
  121542. /**
  121543. * Defines the refraction intensity of the material.
  121544. * The refraction when enabled replaces the Diffuse part of the material.
  121545. * The intensity helps transitionning between diffuse and refraction.
  121546. */
  121547. refractionIntensity: number;
  121548. /**
  121549. * Defines the translucency intensity of the material.
  121550. * When translucency has been enabled, this defines how much of the "translucency"
  121551. * is addded to the diffuse part of the material.
  121552. */
  121553. translucencyIntensity: number;
  121554. /**
  121555. * Defines the scattering intensity of the material.
  121556. * When scattering has been enabled, this defines how much of the "scattered light"
  121557. * is addded to the diffuse part of the material.
  121558. */
  121559. scatteringIntensity: number;
  121560. private _thicknessTexture;
  121561. /**
  121562. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  121563. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  121564. * 0 would mean minimumThickness
  121565. * 1 would mean maximumThickness
  121566. * The other channels might be use as a mask to vary the different effects intensity.
  121567. */
  121568. thicknessTexture: Nullable<BaseTexture>;
  121569. private _refractionTexture;
  121570. /**
  121571. * Defines the texture to use for refraction.
  121572. */
  121573. refractionTexture: Nullable<BaseTexture>;
  121574. private _indexOfRefraction;
  121575. /**
  121576. * Defines the index of refraction used in the material.
  121577. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  121578. */
  121579. indexOfRefraction: number;
  121580. private _invertRefractionY;
  121581. /**
  121582. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121583. */
  121584. invertRefractionY: boolean;
  121585. private _linkRefractionWithTransparency;
  121586. /**
  121587. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121588. * Materials half opaque for instance using refraction could benefit from this control.
  121589. */
  121590. linkRefractionWithTransparency: boolean;
  121591. /**
  121592. * Defines the minimum thickness stored in the thickness map.
  121593. * If no thickness map is defined, this value will be used to simulate thickness.
  121594. */
  121595. minimumThickness: number;
  121596. /**
  121597. * Defines the maximum thickness stored in the thickness map.
  121598. */
  121599. maximumThickness: number;
  121600. /**
  121601. * Defines the volume tint of the material.
  121602. * This is used for both translucency and scattering.
  121603. */
  121604. tintColor: Color3;
  121605. /**
  121606. * Defines the distance at which the tint color should be found in the media.
  121607. * This is used for refraction only.
  121608. */
  121609. tintColorAtDistance: number;
  121610. /**
  121611. * Defines how far each channel transmit through the media.
  121612. * It is defined as a color to simplify it selection.
  121613. */
  121614. diffusionDistance: Color3;
  121615. private _useMaskFromThicknessTexture;
  121616. /**
  121617. * Stores the intensity of the different subsurface effects in the thickness texture.
  121618. * * the green channel is the translucency intensity.
  121619. * * the blue channel is the scattering intensity.
  121620. * * the alpha channel is the refraction intensity.
  121621. */
  121622. useMaskFromThicknessTexture: boolean;
  121623. /** @hidden */
  121624. private _internalMarkAllSubMeshesAsTexturesDirty;
  121625. /** @hidden */
  121626. _markAllSubMeshesAsTexturesDirty(): void;
  121627. /**
  121628. * Instantiate a new istance of sub surface configuration.
  121629. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121630. */
  121631. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121632. /**
  121633. * Gets wehter the submesh is ready to be used or not.
  121634. * @param defines the list of "defines" to update.
  121635. * @param scene defines the scene the material belongs to.
  121636. * @returns - boolean indicating that the submesh is ready or not.
  121637. */
  121638. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  121639. /**
  121640. * Checks to see if a texture is used in the material.
  121641. * @param defines the list of "defines" to update.
  121642. * @param scene defines the scene to the material belongs to.
  121643. */
  121644. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  121645. /**
  121646. * Binds the material data.
  121647. * @param uniformBuffer defines the Uniform buffer to fill in.
  121648. * @param scene defines the scene the material belongs to.
  121649. * @param engine defines the engine the material belongs to.
  121650. * @param isFrozen defines wether the material is frozen or not.
  121651. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  121652. */
  121653. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  121654. /**
  121655. * Unbinds the material from the mesh.
  121656. * @param activeEffect defines the effect that should be unbound from.
  121657. * @returns true if unbound, otherwise false
  121658. */
  121659. unbind(activeEffect: Effect): boolean;
  121660. /**
  121661. * Returns the texture used for refraction or null if none is used.
  121662. * @param scene defines the scene the material belongs to.
  121663. * @returns - Refraction texture if present. If no refraction texture and refraction
  121664. * is linked with transparency, returns environment texture. Otherwise, returns null.
  121665. */
  121666. private _getRefractionTexture;
  121667. /**
  121668. * Returns true if alpha blending should be disabled.
  121669. */
  121670. get disableAlphaBlending(): boolean;
  121671. /**
  121672. * Fills the list of render target textures.
  121673. * @param renderTargets the list of render targets to update
  121674. */
  121675. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  121676. /**
  121677. * Checks to see if a texture is used in the material.
  121678. * @param texture - Base texture to use.
  121679. * @returns - Boolean specifying if a texture is used in the material.
  121680. */
  121681. hasTexture(texture: BaseTexture): boolean;
  121682. /**
  121683. * Gets a boolean indicating that current material needs to register RTT
  121684. * @returns true if this uses a render target otherwise false.
  121685. */
  121686. hasRenderTargetTextures(): boolean;
  121687. /**
  121688. * Returns an array of the actively used textures.
  121689. * @param activeTextures Array of BaseTextures
  121690. */
  121691. getActiveTextures(activeTextures: BaseTexture[]): void;
  121692. /**
  121693. * Returns the animatable textures.
  121694. * @param animatables Array of animatable textures.
  121695. */
  121696. getAnimatables(animatables: IAnimatable[]): void;
  121697. /**
  121698. * Disposes the resources of the material.
  121699. * @param forceDisposeTextures - Forces the disposal of all textures.
  121700. */
  121701. dispose(forceDisposeTextures?: boolean): void;
  121702. /**
  121703. * Get the current class name of the texture useful for serialization or dynamic coding.
  121704. * @returns "PBRSubSurfaceConfiguration"
  121705. */
  121706. getClassName(): string;
  121707. /**
  121708. * Add fallbacks to the effect fallbacks list.
  121709. * @param defines defines the Base texture to use.
  121710. * @param fallbacks defines the current fallback list.
  121711. * @param currentRank defines the current fallback rank.
  121712. * @returns the new fallback rank.
  121713. */
  121714. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121715. /**
  121716. * Add the required uniforms to the current list.
  121717. * @param uniforms defines the current uniform list.
  121718. */
  121719. static AddUniforms(uniforms: string[]): void;
  121720. /**
  121721. * Add the required samplers to the current list.
  121722. * @param samplers defines the current sampler list.
  121723. */
  121724. static AddSamplers(samplers: string[]): void;
  121725. /**
  121726. * Add the required uniforms to the current buffer.
  121727. * @param uniformBuffer defines the current uniform buffer.
  121728. */
  121729. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121730. /**
  121731. * Makes a duplicate of the current configuration into another one.
  121732. * @param configuration define the config where to copy the info
  121733. */
  121734. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  121735. /**
  121736. * Serializes this Sub Surface configuration.
  121737. * @returns - An object with the serialized config.
  121738. */
  121739. serialize(): any;
  121740. /**
  121741. * Parses a anisotropy Configuration from a serialized object.
  121742. * @param source - Serialized object.
  121743. * @param scene Defines the scene we are parsing for
  121744. * @param rootUrl Defines the rootUrl to load from
  121745. */
  121746. parse(source: any, scene: Scene, rootUrl: string): void;
  121747. }
  121748. }
  121749. declare module BABYLON {
  121750. /** @hidden */
  121751. export var pbrFragmentDeclaration: {
  121752. name: string;
  121753. shader: string;
  121754. };
  121755. }
  121756. declare module BABYLON {
  121757. /** @hidden */
  121758. export var pbrUboDeclaration: {
  121759. name: string;
  121760. shader: string;
  121761. };
  121762. }
  121763. declare module BABYLON {
  121764. /** @hidden */
  121765. export var pbrFragmentExtraDeclaration: {
  121766. name: string;
  121767. shader: string;
  121768. };
  121769. }
  121770. declare module BABYLON {
  121771. /** @hidden */
  121772. export var pbrFragmentSamplersDeclaration: {
  121773. name: string;
  121774. shader: string;
  121775. };
  121776. }
  121777. declare module BABYLON {
  121778. /** @hidden */
  121779. export var pbrHelperFunctions: {
  121780. name: string;
  121781. shader: string;
  121782. };
  121783. }
  121784. declare module BABYLON {
  121785. /** @hidden */
  121786. export var harmonicsFunctions: {
  121787. name: string;
  121788. shader: string;
  121789. };
  121790. }
  121791. declare module BABYLON {
  121792. /** @hidden */
  121793. export var pbrDirectLightingSetupFunctions: {
  121794. name: string;
  121795. shader: string;
  121796. };
  121797. }
  121798. declare module BABYLON {
  121799. /** @hidden */
  121800. export var pbrDirectLightingFalloffFunctions: {
  121801. name: string;
  121802. shader: string;
  121803. };
  121804. }
  121805. declare module BABYLON {
  121806. /** @hidden */
  121807. export var pbrBRDFFunctions: {
  121808. name: string;
  121809. shader: string;
  121810. };
  121811. }
  121812. declare module BABYLON {
  121813. /** @hidden */
  121814. export var pbrDirectLightingFunctions: {
  121815. name: string;
  121816. shader: string;
  121817. };
  121818. }
  121819. declare module BABYLON {
  121820. /** @hidden */
  121821. export var pbrIBLFunctions: {
  121822. name: string;
  121823. shader: string;
  121824. };
  121825. }
  121826. declare module BABYLON {
  121827. /** @hidden */
  121828. export var pbrDebug: {
  121829. name: string;
  121830. shader: string;
  121831. };
  121832. }
  121833. declare module BABYLON {
  121834. /** @hidden */
  121835. export var pbrPixelShader: {
  121836. name: string;
  121837. shader: string;
  121838. };
  121839. }
  121840. declare module BABYLON {
  121841. /** @hidden */
  121842. export var pbrVertexDeclaration: {
  121843. name: string;
  121844. shader: string;
  121845. };
  121846. }
  121847. declare module BABYLON {
  121848. /** @hidden */
  121849. export var pbrVertexShader: {
  121850. name: string;
  121851. shader: string;
  121852. };
  121853. }
  121854. declare module BABYLON {
  121855. /**
  121856. * Manages the defines for the PBR Material.
  121857. * @hidden
  121858. */
  121859. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  121860. PBR: boolean;
  121861. MAINUV1: boolean;
  121862. MAINUV2: boolean;
  121863. UV1: boolean;
  121864. UV2: boolean;
  121865. ALBEDO: boolean;
  121866. ALBEDODIRECTUV: number;
  121867. VERTEXCOLOR: boolean;
  121868. AMBIENT: boolean;
  121869. AMBIENTDIRECTUV: number;
  121870. AMBIENTINGRAYSCALE: boolean;
  121871. OPACITY: boolean;
  121872. VERTEXALPHA: boolean;
  121873. OPACITYDIRECTUV: number;
  121874. OPACITYRGB: boolean;
  121875. ALPHATEST: boolean;
  121876. DEPTHPREPASS: boolean;
  121877. ALPHABLEND: boolean;
  121878. ALPHAFROMALBEDO: boolean;
  121879. ALPHATESTVALUE: string;
  121880. SPECULAROVERALPHA: boolean;
  121881. RADIANCEOVERALPHA: boolean;
  121882. ALPHAFRESNEL: boolean;
  121883. LINEARALPHAFRESNEL: boolean;
  121884. PREMULTIPLYALPHA: boolean;
  121885. EMISSIVE: boolean;
  121886. EMISSIVEDIRECTUV: number;
  121887. REFLECTIVITY: boolean;
  121888. REFLECTIVITYDIRECTUV: number;
  121889. SPECULARTERM: boolean;
  121890. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  121891. MICROSURFACEAUTOMATIC: boolean;
  121892. LODBASEDMICROSFURACE: boolean;
  121893. MICROSURFACEMAP: boolean;
  121894. MICROSURFACEMAPDIRECTUV: number;
  121895. METALLICWORKFLOW: boolean;
  121896. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  121897. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  121898. METALLNESSSTOREINMETALMAPBLUE: boolean;
  121899. AOSTOREINMETALMAPRED: boolean;
  121900. METALLICF0FACTORFROMMETALLICMAP: boolean;
  121901. ENVIRONMENTBRDF: boolean;
  121902. ENVIRONMENTBRDF_RGBD: boolean;
  121903. NORMAL: boolean;
  121904. TANGENT: boolean;
  121905. BUMP: boolean;
  121906. BUMPDIRECTUV: number;
  121907. OBJECTSPACE_NORMALMAP: boolean;
  121908. PARALLAX: boolean;
  121909. PARALLAXOCCLUSION: boolean;
  121910. NORMALXYSCALE: boolean;
  121911. LIGHTMAP: boolean;
  121912. LIGHTMAPDIRECTUV: number;
  121913. USELIGHTMAPASSHADOWMAP: boolean;
  121914. GAMMALIGHTMAP: boolean;
  121915. RGBDLIGHTMAP: boolean;
  121916. REFLECTION: boolean;
  121917. REFLECTIONMAP_3D: boolean;
  121918. REFLECTIONMAP_SPHERICAL: boolean;
  121919. REFLECTIONMAP_PLANAR: boolean;
  121920. REFLECTIONMAP_CUBIC: boolean;
  121921. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  121922. REFLECTIONMAP_PROJECTION: boolean;
  121923. REFLECTIONMAP_SKYBOX: boolean;
  121924. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  121925. REFLECTIONMAP_EXPLICIT: boolean;
  121926. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  121927. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  121928. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  121929. INVERTCUBICMAP: boolean;
  121930. USESPHERICALFROMREFLECTIONMAP: boolean;
  121931. USEIRRADIANCEMAP: boolean;
  121932. SPHERICAL_HARMONICS: boolean;
  121933. USESPHERICALINVERTEX: boolean;
  121934. REFLECTIONMAP_OPPOSITEZ: boolean;
  121935. LODINREFLECTIONALPHA: boolean;
  121936. GAMMAREFLECTION: boolean;
  121937. RGBDREFLECTION: boolean;
  121938. LINEARSPECULARREFLECTION: boolean;
  121939. RADIANCEOCCLUSION: boolean;
  121940. HORIZONOCCLUSION: boolean;
  121941. INSTANCES: boolean;
  121942. NUM_BONE_INFLUENCERS: number;
  121943. BonesPerMesh: number;
  121944. BONETEXTURE: boolean;
  121945. NONUNIFORMSCALING: boolean;
  121946. MORPHTARGETS: boolean;
  121947. MORPHTARGETS_NORMAL: boolean;
  121948. MORPHTARGETS_TANGENT: boolean;
  121949. MORPHTARGETS_UV: boolean;
  121950. NUM_MORPH_INFLUENCERS: number;
  121951. IMAGEPROCESSING: boolean;
  121952. VIGNETTE: boolean;
  121953. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121954. VIGNETTEBLENDMODEOPAQUE: boolean;
  121955. TONEMAPPING: boolean;
  121956. TONEMAPPING_ACES: boolean;
  121957. CONTRAST: boolean;
  121958. COLORCURVES: boolean;
  121959. COLORGRADING: boolean;
  121960. COLORGRADING3D: boolean;
  121961. SAMPLER3DGREENDEPTH: boolean;
  121962. SAMPLER3DBGRMAP: boolean;
  121963. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121964. EXPOSURE: boolean;
  121965. MULTIVIEW: boolean;
  121966. USEPHYSICALLIGHTFALLOFF: boolean;
  121967. USEGLTFLIGHTFALLOFF: boolean;
  121968. TWOSIDEDLIGHTING: boolean;
  121969. SHADOWFLOAT: boolean;
  121970. CLIPPLANE: boolean;
  121971. CLIPPLANE2: boolean;
  121972. CLIPPLANE3: boolean;
  121973. CLIPPLANE4: boolean;
  121974. CLIPPLANE5: boolean;
  121975. CLIPPLANE6: boolean;
  121976. POINTSIZE: boolean;
  121977. FOG: boolean;
  121978. LOGARITHMICDEPTH: boolean;
  121979. FORCENORMALFORWARD: boolean;
  121980. SPECULARAA: boolean;
  121981. CLEARCOAT: boolean;
  121982. CLEARCOAT_DEFAULTIOR: boolean;
  121983. CLEARCOAT_TEXTURE: boolean;
  121984. CLEARCOAT_TEXTUREDIRECTUV: number;
  121985. CLEARCOAT_BUMP: boolean;
  121986. CLEARCOAT_BUMPDIRECTUV: number;
  121987. CLEARCOAT_TINT: boolean;
  121988. CLEARCOAT_TINT_TEXTURE: boolean;
  121989. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  121990. ANISOTROPIC: boolean;
  121991. ANISOTROPIC_TEXTURE: boolean;
  121992. ANISOTROPIC_TEXTUREDIRECTUV: number;
  121993. BRDF_V_HEIGHT_CORRELATED: boolean;
  121994. MS_BRDF_ENERGY_CONSERVATION: boolean;
  121995. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  121996. SHEEN: boolean;
  121997. SHEEN_TEXTURE: boolean;
  121998. SHEEN_TEXTUREDIRECTUV: number;
  121999. SHEEN_LINKWITHALBEDO: boolean;
  122000. SUBSURFACE: boolean;
  122001. SS_REFRACTION: boolean;
  122002. SS_TRANSLUCENCY: boolean;
  122003. SS_SCATERRING: boolean;
  122004. SS_THICKNESSANDMASK_TEXTURE: boolean;
  122005. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  122006. SS_REFRACTIONMAP_3D: boolean;
  122007. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  122008. SS_LODINREFRACTIONALPHA: boolean;
  122009. SS_GAMMAREFRACTION: boolean;
  122010. SS_RGBDREFRACTION: boolean;
  122011. SS_LINEARSPECULARREFRACTION: boolean;
  122012. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  122013. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  122014. UNLIT: boolean;
  122015. DEBUGMODE: number;
  122016. /**
  122017. * Initializes the PBR Material defines.
  122018. */
  122019. constructor();
  122020. /**
  122021. * Resets the PBR Material defines.
  122022. */
  122023. reset(): void;
  122024. }
  122025. /**
  122026. * The Physically based material base class of BJS.
  122027. *
  122028. * This offers the main features of a standard PBR material.
  122029. * For more information, please refer to the documentation :
  122030. * https://doc.babylonjs.com/how_to/physically_based_rendering
  122031. */
  122032. export abstract class PBRBaseMaterial extends PushMaterial {
  122033. /**
  122034. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  122035. */
  122036. static readonly PBRMATERIAL_OPAQUE: number;
  122037. /**
  122038. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  122039. */
  122040. static readonly PBRMATERIAL_ALPHATEST: number;
  122041. /**
  122042. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122043. */
  122044. static readonly PBRMATERIAL_ALPHABLEND: number;
  122045. /**
  122046. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122047. * They are also discarded below the alpha cutoff threshold to improve performances.
  122048. */
  122049. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  122050. /**
  122051. * Defines the default value of how much AO map is occluding the analytical lights
  122052. * (point spot...).
  122053. */
  122054. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  122055. /**
  122056. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  122057. */
  122058. static readonly LIGHTFALLOFF_PHYSICAL: number;
  122059. /**
  122060. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  122061. * to enhance interoperability with other engines.
  122062. */
  122063. static readonly LIGHTFALLOFF_GLTF: number;
  122064. /**
  122065. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  122066. * to enhance interoperability with other materials.
  122067. */
  122068. static readonly LIGHTFALLOFF_STANDARD: number;
  122069. /**
  122070. * Intensity of the direct lights e.g. the four lights available in your scene.
  122071. * This impacts both the direct diffuse and specular highlights.
  122072. */
  122073. protected _directIntensity: number;
  122074. /**
  122075. * Intensity of the emissive part of the material.
  122076. * This helps controlling the emissive effect without modifying the emissive color.
  122077. */
  122078. protected _emissiveIntensity: number;
  122079. /**
  122080. * Intensity of the environment e.g. how much the environment will light the object
  122081. * either through harmonics for rough material or through the refelction for shiny ones.
  122082. */
  122083. protected _environmentIntensity: number;
  122084. /**
  122085. * This is a special control allowing the reduction of the specular highlights coming from the
  122086. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  122087. */
  122088. protected _specularIntensity: number;
  122089. /**
  122090. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  122091. */
  122092. private _lightingInfos;
  122093. /**
  122094. * Debug Control allowing disabling the bump map on this material.
  122095. */
  122096. protected _disableBumpMap: boolean;
  122097. /**
  122098. * AKA Diffuse Texture in standard nomenclature.
  122099. */
  122100. protected _albedoTexture: Nullable<BaseTexture>;
  122101. /**
  122102. * AKA Occlusion Texture in other nomenclature.
  122103. */
  122104. protected _ambientTexture: Nullable<BaseTexture>;
  122105. /**
  122106. * AKA Occlusion Texture Intensity in other nomenclature.
  122107. */
  122108. protected _ambientTextureStrength: number;
  122109. /**
  122110. * Defines how much the AO map is occluding the analytical lights (point spot...).
  122111. * 1 means it completely occludes it
  122112. * 0 mean it has no impact
  122113. */
  122114. protected _ambientTextureImpactOnAnalyticalLights: number;
  122115. /**
  122116. * Stores the alpha values in a texture.
  122117. */
  122118. protected _opacityTexture: Nullable<BaseTexture>;
  122119. /**
  122120. * Stores the reflection values in a texture.
  122121. */
  122122. protected _reflectionTexture: Nullable<BaseTexture>;
  122123. /**
  122124. * Stores the emissive values in a texture.
  122125. */
  122126. protected _emissiveTexture: Nullable<BaseTexture>;
  122127. /**
  122128. * AKA Specular texture in other nomenclature.
  122129. */
  122130. protected _reflectivityTexture: Nullable<BaseTexture>;
  122131. /**
  122132. * Used to switch from specular/glossiness to metallic/roughness workflow.
  122133. */
  122134. protected _metallicTexture: Nullable<BaseTexture>;
  122135. /**
  122136. * Specifies the metallic scalar of the metallic/roughness workflow.
  122137. * Can also be used to scale the metalness values of the metallic texture.
  122138. */
  122139. protected _metallic: Nullable<number>;
  122140. /**
  122141. * Specifies the roughness scalar of the metallic/roughness workflow.
  122142. * Can also be used to scale the roughness values of the metallic texture.
  122143. */
  122144. protected _roughness: Nullable<number>;
  122145. /**
  122146. * Specifies the an F0 factor to help configuring the material F0.
  122147. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  122148. * to 0.5 the previously hard coded value stays the same.
  122149. * Can also be used to scale the F0 values of the metallic texture.
  122150. */
  122151. protected _metallicF0Factor: number;
  122152. /**
  122153. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  122154. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  122155. * your expectation as it multiplies with the texture data.
  122156. */
  122157. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  122158. /**
  122159. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  122160. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  122161. */
  122162. protected _microSurfaceTexture: Nullable<BaseTexture>;
  122163. /**
  122164. * Stores surface normal data used to displace a mesh in a texture.
  122165. */
  122166. protected _bumpTexture: Nullable<BaseTexture>;
  122167. /**
  122168. * Stores the pre-calculated light information of a mesh in a texture.
  122169. */
  122170. protected _lightmapTexture: Nullable<BaseTexture>;
  122171. /**
  122172. * The color of a material in ambient lighting.
  122173. */
  122174. protected _ambientColor: Color3;
  122175. /**
  122176. * AKA Diffuse Color in other nomenclature.
  122177. */
  122178. protected _albedoColor: Color3;
  122179. /**
  122180. * AKA Specular Color in other nomenclature.
  122181. */
  122182. protected _reflectivityColor: Color3;
  122183. /**
  122184. * The color applied when light is reflected from a material.
  122185. */
  122186. protected _reflectionColor: Color3;
  122187. /**
  122188. * The color applied when light is emitted from a material.
  122189. */
  122190. protected _emissiveColor: Color3;
  122191. /**
  122192. * AKA Glossiness in other nomenclature.
  122193. */
  122194. protected _microSurface: number;
  122195. /**
  122196. * Specifies that the material will use the light map as a show map.
  122197. */
  122198. protected _useLightmapAsShadowmap: boolean;
  122199. /**
  122200. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  122201. * makes the reflect vector face the model (under horizon).
  122202. */
  122203. protected _useHorizonOcclusion: boolean;
  122204. /**
  122205. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  122206. * too much the area relying on ambient texture to define their ambient occlusion.
  122207. */
  122208. protected _useRadianceOcclusion: boolean;
  122209. /**
  122210. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  122211. */
  122212. protected _useAlphaFromAlbedoTexture: boolean;
  122213. /**
  122214. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  122215. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  122216. */
  122217. protected _useSpecularOverAlpha: boolean;
  122218. /**
  122219. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  122220. */
  122221. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  122222. /**
  122223. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  122224. */
  122225. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  122226. /**
  122227. * Specifies if the metallic texture contains the roughness information in its green channel.
  122228. */
  122229. protected _useRoughnessFromMetallicTextureGreen: boolean;
  122230. /**
  122231. * Specifies if the metallic texture contains the metallness information in its blue channel.
  122232. */
  122233. protected _useMetallnessFromMetallicTextureBlue: boolean;
  122234. /**
  122235. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  122236. */
  122237. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  122238. /**
  122239. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  122240. */
  122241. protected _useAmbientInGrayScale: boolean;
  122242. /**
  122243. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  122244. * The material will try to infer what glossiness each pixel should be.
  122245. */
  122246. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  122247. /**
  122248. * Defines the falloff type used in this material.
  122249. * It by default is Physical.
  122250. */
  122251. protected _lightFalloff: number;
  122252. /**
  122253. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  122254. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  122255. */
  122256. protected _useRadianceOverAlpha: boolean;
  122257. /**
  122258. * Allows using an object space normal map (instead of tangent space).
  122259. */
  122260. protected _useObjectSpaceNormalMap: boolean;
  122261. /**
  122262. * Allows using the bump map in parallax mode.
  122263. */
  122264. protected _useParallax: boolean;
  122265. /**
  122266. * Allows using the bump map in parallax occlusion mode.
  122267. */
  122268. protected _useParallaxOcclusion: boolean;
  122269. /**
  122270. * Controls the scale bias of the parallax mode.
  122271. */
  122272. protected _parallaxScaleBias: number;
  122273. /**
  122274. * If sets to true, disables all the lights affecting the material.
  122275. */
  122276. protected _disableLighting: boolean;
  122277. /**
  122278. * Number of Simultaneous lights allowed on the material.
  122279. */
  122280. protected _maxSimultaneousLights: number;
  122281. /**
  122282. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  122283. */
  122284. protected _invertNormalMapX: boolean;
  122285. /**
  122286. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  122287. */
  122288. protected _invertNormalMapY: boolean;
  122289. /**
  122290. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  122291. */
  122292. protected _twoSidedLighting: boolean;
  122293. /**
  122294. * Defines the alpha limits in alpha test mode.
  122295. */
  122296. protected _alphaCutOff: number;
  122297. /**
  122298. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  122299. */
  122300. protected _forceAlphaTest: boolean;
  122301. /**
  122302. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122303. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  122304. */
  122305. protected _useAlphaFresnel: boolean;
  122306. /**
  122307. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122308. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  122309. */
  122310. protected _useLinearAlphaFresnel: boolean;
  122311. /**
  122312. * The transparency mode of the material.
  122313. */
  122314. protected _transparencyMode: Nullable<number>;
  122315. /**
  122316. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  122317. * from cos thetav and roughness:
  122318. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  122319. */
  122320. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  122321. /**
  122322. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  122323. */
  122324. protected _forceIrradianceInFragment: boolean;
  122325. /**
  122326. * Force normal to face away from face.
  122327. */
  122328. protected _forceNormalForward: boolean;
  122329. /**
  122330. * Enables specular anti aliasing in the PBR shader.
  122331. * It will both interacts on the Geometry for analytical and IBL lighting.
  122332. * It also prefilter the roughness map based on the bump values.
  122333. */
  122334. protected _enableSpecularAntiAliasing: boolean;
  122335. /**
  122336. * Default configuration related to image processing available in the PBR Material.
  122337. */
  122338. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122339. /**
  122340. * Keep track of the image processing observer to allow dispose and replace.
  122341. */
  122342. private _imageProcessingObserver;
  122343. /**
  122344. * Attaches a new image processing configuration to the PBR Material.
  122345. * @param configuration
  122346. */
  122347. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122348. /**
  122349. * Stores the available render targets.
  122350. */
  122351. private _renderTargets;
  122352. /**
  122353. * Sets the global ambient color for the material used in lighting calculations.
  122354. */
  122355. private _globalAmbientColor;
  122356. /**
  122357. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  122358. */
  122359. private _useLogarithmicDepth;
  122360. /**
  122361. * If set to true, no lighting calculations will be applied.
  122362. */
  122363. private _unlit;
  122364. private _debugMode;
  122365. /**
  122366. * @hidden
  122367. * This is reserved for the inspector.
  122368. * Defines the material debug mode.
  122369. * It helps seeing only some components of the material while troubleshooting.
  122370. */
  122371. debugMode: number;
  122372. /**
  122373. * @hidden
  122374. * This is reserved for the inspector.
  122375. * Specify from where on screen the debug mode should start.
  122376. * The value goes from -1 (full screen) to 1 (not visible)
  122377. * It helps with side by side comparison against the final render
  122378. * This defaults to -1
  122379. */
  122380. private debugLimit;
  122381. /**
  122382. * @hidden
  122383. * This is reserved for the inspector.
  122384. * As the default viewing range might not be enough (if the ambient is really small for instance)
  122385. * You can use the factor to better multiply the final value.
  122386. */
  122387. private debugFactor;
  122388. /**
  122389. * Defines the clear coat layer parameters for the material.
  122390. */
  122391. readonly clearCoat: PBRClearCoatConfiguration;
  122392. /**
  122393. * Defines the anisotropic parameters for the material.
  122394. */
  122395. readonly anisotropy: PBRAnisotropicConfiguration;
  122396. /**
  122397. * Defines the BRDF parameters for the material.
  122398. */
  122399. readonly brdf: PBRBRDFConfiguration;
  122400. /**
  122401. * Defines the Sheen parameters for the material.
  122402. */
  122403. readonly sheen: PBRSheenConfiguration;
  122404. /**
  122405. * Defines the SubSurface parameters for the material.
  122406. */
  122407. readonly subSurface: PBRSubSurfaceConfiguration;
  122408. /**
  122409. * Custom callback helping to override the default shader used in the material.
  122410. */
  122411. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  122412. protected _rebuildInParallel: boolean;
  122413. /**
  122414. * Instantiates a new PBRMaterial instance.
  122415. *
  122416. * @param name The material name
  122417. * @param scene The scene the material will be use in.
  122418. */
  122419. constructor(name: string, scene: Scene);
  122420. /**
  122421. * Gets a boolean indicating that current material needs to register RTT
  122422. */
  122423. get hasRenderTargetTextures(): boolean;
  122424. /**
  122425. * Gets the name of the material class.
  122426. */
  122427. getClassName(): string;
  122428. /**
  122429. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  122430. */
  122431. get useLogarithmicDepth(): boolean;
  122432. /**
  122433. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  122434. */
  122435. set useLogarithmicDepth(value: boolean);
  122436. /**
  122437. * Gets the current transparency mode.
  122438. */
  122439. get transparencyMode(): Nullable<number>;
  122440. /**
  122441. * Sets the transparency mode of the material.
  122442. *
  122443. * | Value | Type | Description |
  122444. * | ----- | ----------------------------------- | ----------- |
  122445. * | 0 | OPAQUE | |
  122446. * | 1 | ALPHATEST | |
  122447. * | 2 | ALPHABLEND | |
  122448. * | 3 | ALPHATESTANDBLEND | |
  122449. *
  122450. */
  122451. set transparencyMode(value: Nullable<number>);
  122452. /**
  122453. * Returns true if alpha blending should be disabled.
  122454. */
  122455. private get _disableAlphaBlending();
  122456. /**
  122457. * Specifies whether or not this material should be rendered in alpha blend mode.
  122458. */
  122459. needAlphaBlending(): boolean;
  122460. /**
  122461. * Specifies if the mesh will require alpha blending.
  122462. * @param mesh - BJS mesh.
  122463. */
  122464. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  122465. /**
  122466. * Specifies whether or not this material should be rendered in alpha test mode.
  122467. */
  122468. needAlphaTesting(): boolean;
  122469. /**
  122470. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  122471. */
  122472. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  122473. /**
  122474. * Gets the texture used for the alpha test.
  122475. */
  122476. getAlphaTestTexture(): Nullable<BaseTexture>;
  122477. /**
  122478. * Specifies that the submesh is ready to be used.
  122479. * @param mesh - BJS mesh.
  122480. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  122481. * @param useInstances - Specifies that instances should be used.
  122482. * @returns - boolean indicating that the submesh is ready or not.
  122483. */
  122484. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122485. /**
  122486. * Specifies if the material uses metallic roughness workflow.
  122487. * @returns boolean specifiying if the material uses metallic roughness workflow.
  122488. */
  122489. isMetallicWorkflow(): boolean;
  122490. private _prepareEffect;
  122491. private _prepareDefines;
  122492. /**
  122493. * Force shader compilation
  122494. */
  122495. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  122496. /**
  122497. * Initializes the uniform buffer layout for the shader.
  122498. */
  122499. buildUniformLayout(): void;
  122500. /**
  122501. * Unbinds the material from the mesh
  122502. */
  122503. unbind(): void;
  122504. /**
  122505. * Binds the submesh data.
  122506. * @param world - The world matrix.
  122507. * @param mesh - The BJS mesh.
  122508. * @param subMesh - A submesh of the BJS mesh.
  122509. */
  122510. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122511. /**
  122512. * Returns the animatable textures.
  122513. * @returns - Array of animatable textures.
  122514. */
  122515. getAnimatables(): IAnimatable[];
  122516. /**
  122517. * Returns the texture used for reflections.
  122518. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  122519. */
  122520. private _getReflectionTexture;
  122521. /**
  122522. * Returns an array of the actively used textures.
  122523. * @returns - Array of BaseTextures
  122524. */
  122525. getActiveTextures(): BaseTexture[];
  122526. /**
  122527. * Checks to see if a texture is used in the material.
  122528. * @param texture - Base texture to use.
  122529. * @returns - Boolean specifying if a texture is used in the material.
  122530. */
  122531. hasTexture(texture: BaseTexture): boolean;
  122532. /**
  122533. * Disposes the resources of the material.
  122534. * @param forceDisposeEffect - Forces the disposal of effects.
  122535. * @param forceDisposeTextures - Forces the disposal of all textures.
  122536. */
  122537. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122538. }
  122539. }
  122540. declare module BABYLON {
  122541. /**
  122542. * The Physically based material of BJS.
  122543. *
  122544. * This offers the main features of a standard PBR material.
  122545. * For more information, please refer to the documentation :
  122546. * https://doc.babylonjs.com/how_to/physically_based_rendering
  122547. */
  122548. export class PBRMaterial extends PBRBaseMaterial {
  122549. /**
  122550. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  122551. */
  122552. static readonly PBRMATERIAL_OPAQUE: number;
  122553. /**
  122554. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  122555. */
  122556. static readonly PBRMATERIAL_ALPHATEST: number;
  122557. /**
  122558. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122559. */
  122560. static readonly PBRMATERIAL_ALPHABLEND: number;
  122561. /**
  122562. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122563. * They are also discarded below the alpha cutoff threshold to improve performances.
  122564. */
  122565. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  122566. /**
  122567. * Defines the default value of how much AO map is occluding the analytical lights
  122568. * (point spot...).
  122569. */
  122570. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  122571. /**
  122572. * Intensity of the direct lights e.g. the four lights available in your scene.
  122573. * This impacts both the direct diffuse and specular highlights.
  122574. */
  122575. directIntensity: number;
  122576. /**
  122577. * Intensity of the emissive part of the material.
  122578. * This helps controlling the emissive effect without modifying the emissive color.
  122579. */
  122580. emissiveIntensity: number;
  122581. /**
  122582. * Intensity of the environment e.g. how much the environment will light the object
  122583. * either through harmonics for rough material or through the refelction for shiny ones.
  122584. */
  122585. environmentIntensity: number;
  122586. /**
  122587. * This is a special control allowing the reduction of the specular highlights coming from the
  122588. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  122589. */
  122590. specularIntensity: number;
  122591. /**
  122592. * Debug Control allowing disabling the bump map on this material.
  122593. */
  122594. disableBumpMap: boolean;
  122595. /**
  122596. * AKA Diffuse Texture in standard nomenclature.
  122597. */
  122598. albedoTexture: BaseTexture;
  122599. /**
  122600. * AKA Occlusion Texture in other nomenclature.
  122601. */
  122602. ambientTexture: BaseTexture;
  122603. /**
  122604. * AKA Occlusion Texture Intensity in other nomenclature.
  122605. */
  122606. ambientTextureStrength: number;
  122607. /**
  122608. * Defines how much the AO map is occluding the analytical lights (point spot...).
  122609. * 1 means it completely occludes it
  122610. * 0 mean it has no impact
  122611. */
  122612. ambientTextureImpactOnAnalyticalLights: number;
  122613. /**
  122614. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  122615. */
  122616. opacityTexture: BaseTexture;
  122617. /**
  122618. * Stores the reflection values in a texture.
  122619. */
  122620. reflectionTexture: Nullable<BaseTexture>;
  122621. /**
  122622. * Stores the emissive values in a texture.
  122623. */
  122624. emissiveTexture: BaseTexture;
  122625. /**
  122626. * AKA Specular texture in other nomenclature.
  122627. */
  122628. reflectivityTexture: BaseTexture;
  122629. /**
  122630. * Used to switch from specular/glossiness to metallic/roughness workflow.
  122631. */
  122632. metallicTexture: BaseTexture;
  122633. /**
  122634. * Specifies the metallic scalar of the metallic/roughness workflow.
  122635. * Can also be used to scale the metalness values of the metallic texture.
  122636. */
  122637. metallic: Nullable<number>;
  122638. /**
  122639. * Specifies the roughness scalar of the metallic/roughness workflow.
  122640. * Can also be used to scale the roughness values of the metallic texture.
  122641. */
  122642. roughness: Nullable<number>;
  122643. /**
  122644. * Specifies the an F0 factor to help configuring the material F0.
  122645. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  122646. * to 0.5 the previously hard coded value stays the same.
  122647. * Can also be used to scale the F0 values of the metallic texture.
  122648. */
  122649. metallicF0Factor: number;
  122650. /**
  122651. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  122652. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  122653. * your expectation as it multiplies with the texture data.
  122654. */
  122655. useMetallicF0FactorFromMetallicTexture: boolean;
  122656. /**
  122657. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  122658. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  122659. */
  122660. microSurfaceTexture: BaseTexture;
  122661. /**
  122662. * Stores surface normal data used to displace a mesh in a texture.
  122663. */
  122664. bumpTexture: BaseTexture;
  122665. /**
  122666. * Stores the pre-calculated light information of a mesh in a texture.
  122667. */
  122668. lightmapTexture: BaseTexture;
  122669. /**
  122670. * Stores the refracted light information in a texture.
  122671. */
  122672. get refractionTexture(): Nullable<BaseTexture>;
  122673. set refractionTexture(value: Nullable<BaseTexture>);
  122674. /**
  122675. * The color of a material in ambient lighting.
  122676. */
  122677. ambientColor: Color3;
  122678. /**
  122679. * AKA Diffuse Color in other nomenclature.
  122680. */
  122681. albedoColor: Color3;
  122682. /**
  122683. * AKA Specular Color in other nomenclature.
  122684. */
  122685. reflectivityColor: Color3;
  122686. /**
  122687. * The color reflected from the material.
  122688. */
  122689. reflectionColor: Color3;
  122690. /**
  122691. * The color emitted from the material.
  122692. */
  122693. emissiveColor: Color3;
  122694. /**
  122695. * AKA Glossiness in other nomenclature.
  122696. */
  122697. microSurface: number;
  122698. /**
  122699. * source material index of refraction (IOR)' / 'destination material IOR.
  122700. */
  122701. get indexOfRefraction(): number;
  122702. set indexOfRefraction(value: number);
  122703. /**
  122704. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  122705. */
  122706. get invertRefractionY(): boolean;
  122707. set invertRefractionY(value: boolean);
  122708. /**
  122709. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  122710. * Materials half opaque for instance using refraction could benefit from this control.
  122711. */
  122712. get linkRefractionWithTransparency(): boolean;
  122713. set linkRefractionWithTransparency(value: boolean);
  122714. /**
  122715. * If true, the light map contains occlusion information instead of lighting info.
  122716. */
  122717. useLightmapAsShadowmap: boolean;
  122718. /**
  122719. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  122720. */
  122721. useAlphaFromAlbedoTexture: boolean;
  122722. /**
  122723. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  122724. */
  122725. forceAlphaTest: boolean;
  122726. /**
  122727. * Defines the alpha limits in alpha test mode.
  122728. */
  122729. alphaCutOff: number;
  122730. /**
  122731. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  122732. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  122733. */
  122734. useSpecularOverAlpha: boolean;
  122735. /**
  122736. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  122737. */
  122738. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  122739. /**
  122740. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  122741. */
  122742. useRoughnessFromMetallicTextureAlpha: boolean;
  122743. /**
  122744. * Specifies if the metallic texture contains the roughness information in its green channel.
  122745. */
  122746. useRoughnessFromMetallicTextureGreen: boolean;
  122747. /**
  122748. * Specifies if the metallic texture contains the metallness information in its blue channel.
  122749. */
  122750. useMetallnessFromMetallicTextureBlue: boolean;
  122751. /**
  122752. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  122753. */
  122754. useAmbientOcclusionFromMetallicTextureRed: boolean;
  122755. /**
  122756. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  122757. */
  122758. useAmbientInGrayScale: boolean;
  122759. /**
  122760. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  122761. * The material will try to infer what glossiness each pixel should be.
  122762. */
  122763. useAutoMicroSurfaceFromReflectivityMap: boolean;
  122764. /**
  122765. * BJS is using an harcoded light falloff based on a manually sets up range.
  122766. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  122767. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  122768. */
  122769. get usePhysicalLightFalloff(): boolean;
  122770. /**
  122771. * BJS is using an harcoded light falloff based on a manually sets up range.
  122772. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  122773. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  122774. */
  122775. set usePhysicalLightFalloff(value: boolean);
  122776. /**
  122777. * In order to support the falloff compatibility with gltf, a special mode has been added
  122778. * to reproduce the gltf light falloff.
  122779. */
  122780. get useGLTFLightFalloff(): boolean;
  122781. /**
  122782. * In order to support the falloff compatibility with gltf, a special mode has been added
  122783. * to reproduce the gltf light falloff.
  122784. */
  122785. set useGLTFLightFalloff(value: boolean);
  122786. /**
  122787. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  122788. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  122789. */
  122790. useRadianceOverAlpha: boolean;
  122791. /**
  122792. * Allows using an object space normal map (instead of tangent space).
  122793. */
  122794. useObjectSpaceNormalMap: boolean;
  122795. /**
  122796. * Allows using the bump map in parallax mode.
  122797. */
  122798. useParallax: boolean;
  122799. /**
  122800. * Allows using the bump map in parallax occlusion mode.
  122801. */
  122802. useParallaxOcclusion: boolean;
  122803. /**
  122804. * Controls the scale bias of the parallax mode.
  122805. */
  122806. parallaxScaleBias: number;
  122807. /**
  122808. * If sets to true, disables all the lights affecting the material.
  122809. */
  122810. disableLighting: boolean;
  122811. /**
  122812. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  122813. */
  122814. forceIrradianceInFragment: boolean;
  122815. /**
  122816. * Number of Simultaneous lights allowed on the material.
  122817. */
  122818. maxSimultaneousLights: number;
  122819. /**
  122820. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  122821. */
  122822. invertNormalMapX: boolean;
  122823. /**
  122824. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  122825. */
  122826. invertNormalMapY: boolean;
  122827. /**
  122828. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  122829. */
  122830. twoSidedLighting: boolean;
  122831. /**
  122832. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122833. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  122834. */
  122835. useAlphaFresnel: boolean;
  122836. /**
  122837. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122838. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  122839. */
  122840. useLinearAlphaFresnel: boolean;
  122841. /**
  122842. * Let user defines the brdf lookup texture used for IBL.
  122843. * A default 8bit version is embedded but you could point at :
  122844. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  122845. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  122846. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  122847. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  122848. */
  122849. environmentBRDFTexture: Nullable<BaseTexture>;
  122850. /**
  122851. * Force normal to face away from face.
  122852. */
  122853. forceNormalForward: boolean;
  122854. /**
  122855. * Enables specular anti aliasing in the PBR shader.
  122856. * It will both interacts on the Geometry for analytical and IBL lighting.
  122857. * It also prefilter the roughness map based on the bump values.
  122858. */
  122859. enableSpecularAntiAliasing: boolean;
  122860. /**
  122861. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  122862. * makes the reflect vector face the model (under horizon).
  122863. */
  122864. useHorizonOcclusion: boolean;
  122865. /**
  122866. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  122867. * too much the area relying on ambient texture to define their ambient occlusion.
  122868. */
  122869. useRadianceOcclusion: boolean;
  122870. /**
  122871. * If set to true, no lighting calculations will be applied.
  122872. */
  122873. unlit: boolean;
  122874. /**
  122875. * Gets the image processing configuration used either in this material.
  122876. */
  122877. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122878. /**
  122879. * Sets the Default image processing configuration used either in the this material.
  122880. *
  122881. * If sets to null, the scene one is in use.
  122882. */
  122883. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122884. /**
  122885. * Gets wether the color curves effect is enabled.
  122886. */
  122887. get cameraColorCurvesEnabled(): boolean;
  122888. /**
  122889. * Sets wether the color curves effect is enabled.
  122890. */
  122891. set cameraColorCurvesEnabled(value: boolean);
  122892. /**
  122893. * Gets wether the color grading effect is enabled.
  122894. */
  122895. get cameraColorGradingEnabled(): boolean;
  122896. /**
  122897. * Gets wether the color grading effect is enabled.
  122898. */
  122899. set cameraColorGradingEnabled(value: boolean);
  122900. /**
  122901. * Gets wether tonemapping is enabled or not.
  122902. */
  122903. get cameraToneMappingEnabled(): boolean;
  122904. /**
  122905. * Sets wether tonemapping is enabled or not
  122906. */
  122907. set cameraToneMappingEnabled(value: boolean);
  122908. /**
  122909. * The camera exposure used on this material.
  122910. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122911. * This corresponds to a photographic exposure.
  122912. */
  122913. get cameraExposure(): number;
  122914. /**
  122915. * The camera exposure used on this material.
  122916. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122917. * This corresponds to a photographic exposure.
  122918. */
  122919. set cameraExposure(value: number);
  122920. /**
  122921. * Gets The camera contrast used on this material.
  122922. */
  122923. get cameraContrast(): number;
  122924. /**
  122925. * Sets The camera contrast used on this material.
  122926. */
  122927. set cameraContrast(value: number);
  122928. /**
  122929. * Gets the Color Grading 2D Lookup Texture.
  122930. */
  122931. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122932. /**
  122933. * Sets the Color Grading 2D Lookup Texture.
  122934. */
  122935. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122936. /**
  122937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122939. * 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;
  122940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122941. */
  122942. get cameraColorCurves(): Nullable<ColorCurves>;
  122943. /**
  122944. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122945. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122946. * 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;
  122947. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122948. */
  122949. set cameraColorCurves(value: Nullable<ColorCurves>);
  122950. /**
  122951. * Instantiates a new PBRMaterial instance.
  122952. *
  122953. * @param name The material name
  122954. * @param scene The scene the material will be use in.
  122955. */
  122956. constructor(name: string, scene: Scene);
  122957. /**
  122958. * Returns the name of this material class.
  122959. */
  122960. getClassName(): string;
  122961. /**
  122962. * Makes a duplicate of the current material.
  122963. * @param name - name to use for the new material.
  122964. */
  122965. clone(name: string): PBRMaterial;
  122966. /**
  122967. * Serializes this PBR Material.
  122968. * @returns - An object with the serialized material.
  122969. */
  122970. serialize(): any;
  122971. /**
  122972. * Parses a PBR Material from a serialized object.
  122973. * @param source - Serialized object.
  122974. * @param scene - BJS scene instance.
  122975. * @param rootUrl - url for the scene object
  122976. * @returns - PBRMaterial
  122977. */
  122978. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  122979. }
  122980. }
  122981. declare module BABYLON {
  122982. /**
  122983. * Direct draw surface info
  122984. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  122985. */
  122986. export interface DDSInfo {
  122987. /**
  122988. * Width of the texture
  122989. */
  122990. width: number;
  122991. /**
  122992. * Width of the texture
  122993. */
  122994. height: number;
  122995. /**
  122996. * Number of Mipmaps for the texture
  122997. * @see https://en.wikipedia.org/wiki/Mipmap
  122998. */
  122999. mipmapCount: number;
  123000. /**
  123001. * If the textures format is a known fourCC format
  123002. * @see https://www.fourcc.org/
  123003. */
  123004. isFourCC: boolean;
  123005. /**
  123006. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  123007. */
  123008. isRGB: boolean;
  123009. /**
  123010. * If the texture is a lumincance format
  123011. */
  123012. isLuminance: boolean;
  123013. /**
  123014. * If this is a cube texture
  123015. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  123016. */
  123017. isCube: boolean;
  123018. /**
  123019. * If the texture is a compressed format eg. FOURCC_DXT1
  123020. */
  123021. isCompressed: boolean;
  123022. /**
  123023. * The dxgiFormat of the texture
  123024. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  123025. */
  123026. dxgiFormat: number;
  123027. /**
  123028. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  123029. */
  123030. textureType: number;
  123031. /**
  123032. * Sphericle polynomial created for the dds texture
  123033. */
  123034. sphericalPolynomial?: SphericalPolynomial;
  123035. }
  123036. /**
  123037. * Class used to provide DDS decompression tools
  123038. */
  123039. export class DDSTools {
  123040. /**
  123041. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  123042. */
  123043. static StoreLODInAlphaChannel: boolean;
  123044. /**
  123045. * Gets DDS information from an array buffer
  123046. * @param arrayBuffer defines the array buffer to read data from
  123047. * @returns the DDS information
  123048. */
  123049. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  123050. private static _FloatView;
  123051. private static _Int32View;
  123052. private static _ToHalfFloat;
  123053. private static _FromHalfFloat;
  123054. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  123055. private static _GetHalfFloatRGBAArrayBuffer;
  123056. private static _GetFloatRGBAArrayBuffer;
  123057. private static _GetFloatAsUIntRGBAArrayBuffer;
  123058. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  123059. private static _GetRGBAArrayBuffer;
  123060. private static _ExtractLongWordOrder;
  123061. private static _GetRGBArrayBuffer;
  123062. private static _GetLuminanceArrayBuffer;
  123063. /**
  123064. * Uploads DDS Levels to a Babylon Texture
  123065. * @hidden
  123066. */
  123067. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  123068. }
  123069. interface ThinEngine {
  123070. /**
  123071. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  123072. * @param rootUrl defines the url where the file to load is located
  123073. * @param scene defines the current scene
  123074. * @param lodScale defines scale to apply to the mip map selection
  123075. * @param lodOffset defines offset to apply to the mip map selection
  123076. * @param onLoad defines an optional callback raised when the texture is loaded
  123077. * @param onError defines an optional callback raised if there is an issue to load the texture
  123078. * @param format defines the format of the data
  123079. * @param forcedExtension defines the extension to use to pick the right loader
  123080. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  123081. * @returns the cube texture as an InternalTexture
  123082. */
  123083. 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;
  123084. }
  123085. }
  123086. declare module BABYLON {
  123087. /**
  123088. * Implementation of the DDS Texture Loader.
  123089. * @hidden
  123090. */
  123091. export class _DDSTextureLoader implements IInternalTextureLoader {
  123092. /**
  123093. * Defines wether the loader supports cascade loading the different faces.
  123094. */
  123095. readonly supportCascades: boolean;
  123096. /**
  123097. * This returns if the loader support the current file information.
  123098. * @param extension defines the file extension of the file being loaded
  123099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123100. * @param fallback defines the fallback internal texture if any
  123101. * @param isBase64 defines whether the texture is encoded as a base64
  123102. * @param isBuffer defines whether the texture data are stored as a buffer
  123103. * @returns true if the loader can load the specified file
  123104. */
  123105. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123106. /**
  123107. * Transform the url before loading if required.
  123108. * @param rootUrl the url of the texture
  123109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123110. * @returns the transformed texture
  123111. */
  123112. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123113. /**
  123114. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123115. * @param rootUrl the url of the texture
  123116. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123117. * @returns the fallback texture
  123118. */
  123119. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123120. /**
  123121. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123122. * @param data contains the texture data
  123123. * @param texture defines the BabylonJS internal texture
  123124. * @param createPolynomials will be true if polynomials have been requested
  123125. * @param onLoad defines the callback to trigger once the texture is ready
  123126. * @param onError defines the callback to trigger in case of error
  123127. */
  123128. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123129. /**
  123130. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123131. * @param data contains the texture data
  123132. * @param texture defines the BabylonJS internal texture
  123133. * @param callback defines the method to call once ready to upload
  123134. */
  123135. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  123136. }
  123137. }
  123138. declare module BABYLON {
  123139. /**
  123140. * Implementation of the ENV Texture Loader.
  123141. * @hidden
  123142. */
  123143. export class _ENVTextureLoader implements IInternalTextureLoader {
  123144. /**
  123145. * Defines wether the loader supports cascade loading the different faces.
  123146. */
  123147. readonly supportCascades: boolean;
  123148. /**
  123149. * This returns if the loader support the current file information.
  123150. * @param extension defines the file extension of the file being loaded
  123151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123152. * @param fallback defines the fallback internal texture if any
  123153. * @param isBase64 defines whether the texture is encoded as a base64
  123154. * @param isBuffer defines whether the texture data are stored as a buffer
  123155. * @returns true if the loader can load the specified file
  123156. */
  123157. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123158. /**
  123159. * Transform the url before loading if required.
  123160. * @param rootUrl the url of the texture
  123161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123162. * @returns the transformed texture
  123163. */
  123164. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123165. /**
  123166. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123167. * @param rootUrl the url of the texture
  123168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123169. * @returns the fallback texture
  123170. */
  123171. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123172. /**
  123173. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123174. * @param data contains the texture data
  123175. * @param texture defines the BabylonJS internal texture
  123176. * @param createPolynomials will be true if polynomials have been requested
  123177. * @param onLoad defines the callback to trigger once the texture is ready
  123178. * @param onError defines the callback to trigger in case of error
  123179. */
  123180. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123181. /**
  123182. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123183. * @param data contains the texture data
  123184. * @param texture defines the BabylonJS internal texture
  123185. * @param callback defines the method to call once ready to upload
  123186. */
  123187. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  123188. }
  123189. }
  123190. declare module BABYLON {
  123191. /**
  123192. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  123193. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  123194. */
  123195. export class KhronosTextureContainer {
  123196. /** contents of the KTX container file */
  123197. arrayBuffer: any;
  123198. private static HEADER_LEN;
  123199. private static COMPRESSED_2D;
  123200. private static COMPRESSED_3D;
  123201. private static TEX_2D;
  123202. private static TEX_3D;
  123203. /**
  123204. * Gets the openGL type
  123205. */
  123206. glType: number;
  123207. /**
  123208. * Gets the openGL type size
  123209. */
  123210. glTypeSize: number;
  123211. /**
  123212. * Gets the openGL format
  123213. */
  123214. glFormat: number;
  123215. /**
  123216. * Gets the openGL internal format
  123217. */
  123218. glInternalFormat: number;
  123219. /**
  123220. * Gets the base internal format
  123221. */
  123222. glBaseInternalFormat: number;
  123223. /**
  123224. * Gets image width in pixel
  123225. */
  123226. pixelWidth: number;
  123227. /**
  123228. * Gets image height in pixel
  123229. */
  123230. pixelHeight: number;
  123231. /**
  123232. * Gets image depth in pixels
  123233. */
  123234. pixelDepth: number;
  123235. /**
  123236. * Gets the number of array elements
  123237. */
  123238. numberOfArrayElements: number;
  123239. /**
  123240. * Gets the number of faces
  123241. */
  123242. numberOfFaces: number;
  123243. /**
  123244. * Gets the number of mipmap levels
  123245. */
  123246. numberOfMipmapLevels: number;
  123247. /**
  123248. * Gets the bytes of key value data
  123249. */
  123250. bytesOfKeyValueData: number;
  123251. /**
  123252. * Gets the load type
  123253. */
  123254. loadType: number;
  123255. /**
  123256. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  123257. */
  123258. isInvalid: boolean;
  123259. /**
  123260. * Creates a new KhronosTextureContainer
  123261. * @param arrayBuffer contents of the KTX container file
  123262. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  123263. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  123264. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  123265. */
  123266. constructor(
  123267. /** contents of the KTX container file */
  123268. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  123269. /**
  123270. * Uploads KTX content to a Babylon Texture.
  123271. * It is assumed that the texture has already been created & is currently bound
  123272. * @hidden
  123273. */
  123274. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  123275. private _upload2DCompressedLevels;
  123276. }
  123277. }
  123278. declare module BABYLON {
  123279. /**
  123280. * Implementation of the KTX Texture Loader.
  123281. * @hidden
  123282. */
  123283. export class _KTXTextureLoader implements IInternalTextureLoader {
  123284. /**
  123285. * Defines wether the loader supports cascade loading the different faces.
  123286. */
  123287. readonly supportCascades: boolean;
  123288. /**
  123289. * This returns if the loader support the current file information.
  123290. * @param extension defines the file extension of the file being loaded
  123291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123292. * @param fallback defines the fallback internal texture if any
  123293. * @param isBase64 defines whether the texture is encoded as a base64
  123294. * @param isBuffer defines whether the texture data are stored as a buffer
  123295. * @returns true if the loader can load the specified file
  123296. */
  123297. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123298. /**
  123299. * Transform the url before loading if required.
  123300. * @param rootUrl the url of the texture
  123301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123302. * @returns the transformed texture
  123303. */
  123304. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123305. /**
  123306. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123307. * @param rootUrl the url of the texture
  123308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123309. * @returns the fallback texture
  123310. */
  123311. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123312. /**
  123313. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123314. * @param data contains the texture data
  123315. * @param texture defines the BabylonJS internal texture
  123316. * @param createPolynomials will be true if polynomials have been requested
  123317. * @param onLoad defines the callback to trigger once the texture is ready
  123318. * @param onError defines the callback to trigger in case of error
  123319. */
  123320. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123321. /**
  123322. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123323. * @param data contains the texture data
  123324. * @param texture defines the BabylonJS internal texture
  123325. * @param callback defines the method to call once ready to upload
  123326. */
  123327. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  123328. }
  123329. }
  123330. declare module BABYLON {
  123331. /** @hidden */
  123332. export var _forceSceneHelpersToBundle: boolean;
  123333. interface Scene {
  123334. /**
  123335. * Creates a default light for the scene.
  123336. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  123337. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  123338. */
  123339. createDefaultLight(replace?: boolean): void;
  123340. /**
  123341. * Creates a default camera for the scene.
  123342. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  123343. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  123344. * @param replace has default false, when true replaces the active camera in the scene
  123345. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  123346. */
  123347. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  123348. /**
  123349. * Creates a default camera and a default light.
  123350. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  123351. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  123352. * @param replace has the default false, when true replaces the active camera/light in the scene
  123353. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  123354. */
  123355. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  123356. /**
  123357. * Creates a new sky box
  123358. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  123359. * @param environmentTexture defines the texture to use as environment texture
  123360. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  123361. * @param scale defines the overall scale of the skybox
  123362. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  123363. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  123364. * @returns a new mesh holding the sky box
  123365. */
  123366. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  123367. /**
  123368. * Creates a new environment
  123369. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  123370. * @param options defines the options you can use to configure the environment
  123371. * @returns the new EnvironmentHelper
  123372. */
  123373. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  123374. /**
  123375. * Creates a new VREXperienceHelper
  123376. * @see http://doc.babylonjs.com/how_to/webvr_helper
  123377. * @param webVROptions defines the options used to create the new VREXperienceHelper
  123378. * @returns a new VREXperienceHelper
  123379. */
  123380. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  123381. /**
  123382. * Creates a new WebXRDefaultExperience
  123383. * @see http://doc.babylonjs.com/how_to/webxr
  123384. * @param options experience options
  123385. * @returns a promise for a new WebXRDefaultExperience
  123386. */
  123387. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  123388. }
  123389. }
  123390. declare module BABYLON {
  123391. /**
  123392. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  123393. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  123394. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  123395. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123396. */
  123397. export class VideoDome extends TransformNode {
  123398. /**
  123399. * Define the video source as a Monoscopic panoramic 360 video.
  123400. */
  123401. static readonly MODE_MONOSCOPIC: number;
  123402. /**
  123403. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  123404. */
  123405. static readonly MODE_TOPBOTTOM: number;
  123406. /**
  123407. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  123408. */
  123409. static readonly MODE_SIDEBYSIDE: number;
  123410. private _halfDome;
  123411. private _useDirectMapping;
  123412. /**
  123413. * The video texture being displayed on the sphere
  123414. */
  123415. protected _videoTexture: VideoTexture;
  123416. /**
  123417. * Gets the video texture being displayed on the sphere
  123418. */
  123419. get videoTexture(): VideoTexture;
  123420. /**
  123421. * The skybox material
  123422. */
  123423. protected _material: BackgroundMaterial;
  123424. /**
  123425. * The surface used for the skybox
  123426. */
  123427. protected _mesh: Mesh;
  123428. /**
  123429. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  123430. */
  123431. private _halfDomeMask;
  123432. /**
  123433. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123434. * Also see the options.resolution property.
  123435. */
  123436. get fovMultiplier(): number;
  123437. set fovMultiplier(value: number);
  123438. private _videoMode;
  123439. /**
  123440. * Gets or set the current video mode for the video. It can be:
  123441. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  123442. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  123443. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  123444. */
  123445. get videoMode(): number;
  123446. set videoMode(value: number);
  123447. /**
  123448. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  123449. *
  123450. */
  123451. get halfDome(): boolean;
  123452. /**
  123453. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  123454. */
  123455. set halfDome(enabled: boolean);
  123456. /**
  123457. * Oberserver used in Stereoscopic VR Mode.
  123458. */
  123459. private _onBeforeCameraRenderObserver;
  123460. /**
  123461. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  123462. * @param name Element's name, child elements will append suffixes for their own names.
  123463. * @param urlsOrVideo defines the url(s) or the video element to use
  123464. * @param options An object containing optional or exposed sub element properties
  123465. */
  123466. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  123467. resolution?: number;
  123468. clickToPlay?: boolean;
  123469. autoPlay?: boolean;
  123470. loop?: boolean;
  123471. size?: number;
  123472. poster?: string;
  123473. faceForward?: boolean;
  123474. useDirectMapping?: boolean;
  123475. halfDomeMode?: boolean;
  123476. }, scene: Scene);
  123477. private _changeVideoMode;
  123478. /**
  123479. * Releases resources associated with this node.
  123480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123482. */
  123483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123484. }
  123485. }
  123486. declare module BABYLON {
  123487. /**
  123488. * This class can be used to get instrumentation data from a Babylon engine
  123489. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  123490. */
  123491. export class EngineInstrumentation implements IDisposable {
  123492. /**
  123493. * Define the instrumented engine.
  123494. */
  123495. engine: Engine;
  123496. private _captureGPUFrameTime;
  123497. private _gpuFrameTimeToken;
  123498. private _gpuFrameTime;
  123499. private _captureShaderCompilationTime;
  123500. private _shaderCompilationTime;
  123501. private _onBeginFrameObserver;
  123502. private _onEndFrameObserver;
  123503. private _onBeforeShaderCompilationObserver;
  123504. private _onAfterShaderCompilationObserver;
  123505. /**
  123506. * Gets the perf counter used for GPU frame time
  123507. */
  123508. get gpuFrameTimeCounter(): PerfCounter;
  123509. /**
  123510. * Gets the GPU frame time capture status
  123511. */
  123512. get captureGPUFrameTime(): boolean;
  123513. /**
  123514. * Enable or disable the GPU frame time capture
  123515. */
  123516. set captureGPUFrameTime(value: boolean);
  123517. /**
  123518. * Gets the perf counter used for shader compilation time
  123519. */
  123520. get shaderCompilationTimeCounter(): PerfCounter;
  123521. /**
  123522. * Gets the shader compilation time capture status
  123523. */
  123524. get captureShaderCompilationTime(): boolean;
  123525. /**
  123526. * Enable or disable the shader compilation time capture
  123527. */
  123528. set captureShaderCompilationTime(value: boolean);
  123529. /**
  123530. * Instantiates a new engine instrumentation.
  123531. * This class can be used to get instrumentation data from a Babylon engine
  123532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  123533. * @param engine Defines the engine to instrument
  123534. */
  123535. constructor(
  123536. /**
  123537. * Define the instrumented engine.
  123538. */
  123539. engine: Engine);
  123540. /**
  123541. * Dispose and release associated resources.
  123542. */
  123543. dispose(): void;
  123544. }
  123545. }
  123546. declare module BABYLON {
  123547. /**
  123548. * This class can be used to get instrumentation data from a Babylon engine
  123549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  123550. */
  123551. export class SceneInstrumentation implements IDisposable {
  123552. /**
  123553. * Defines the scene to instrument
  123554. */
  123555. scene: Scene;
  123556. private _captureActiveMeshesEvaluationTime;
  123557. private _activeMeshesEvaluationTime;
  123558. private _captureRenderTargetsRenderTime;
  123559. private _renderTargetsRenderTime;
  123560. private _captureFrameTime;
  123561. private _frameTime;
  123562. private _captureRenderTime;
  123563. private _renderTime;
  123564. private _captureInterFrameTime;
  123565. private _interFrameTime;
  123566. private _captureParticlesRenderTime;
  123567. private _particlesRenderTime;
  123568. private _captureSpritesRenderTime;
  123569. private _spritesRenderTime;
  123570. private _capturePhysicsTime;
  123571. private _physicsTime;
  123572. private _captureAnimationsTime;
  123573. private _animationsTime;
  123574. private _captureCameraRenderTime;
  123575. private _cameraRenderTime;
  123576. private _onBeforeActiveMeshesEvaluationObserver;
  123577. private _onAfterActiveMeshesEvaluationObserver;
  123578. private _onBeforeRenderTargetsRenderObserver;
  123579. private _onAfterRenderTargetsRenderObserver;
  123580. private _onAfterRenderObserver;
  123581. private _onBeforeDrawPhaseObserver;
  123582. private _onAfterDrawPhaseObserver;
  123583. private _onBeforeAnimationsObserver;
  123584. private _onBeforeParticlesRenderingObserver;
  123585. private _onAfterParticlesRenderingObserver;
  123586. private _onBeforeSpritesRenderingObserver;
  123587. private _onAfterSpritesRenderingObserver;
  123588. private _onBeforePhysicsObserver;
  123589. private _onAfterPhysicsObserver;
  123590. private _onAfterAnimationsObserver;
  123591. private _onBeforeCameraRenderObserver;
  123592. private _onAfterCameraRenderObserver;
  123593. /**
  123594. * Gets the perf counter used for active meshes evaluation time
  123595. */
  123596. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  123597. /**
  123598. * Gets the active meshes evaluation time capture status
  123599. */
  123600. get captureActiveMeshesEvaluationTime(): boolean;
  123601. /**
  123602. * Enable or disable the active meshes evaluation time capture
  123603. */
  123604. set captureActiveMeshesEvaluationTime(value: boolean);
  123605. /**
  123606. * Gets the perf counter used for render targets render time
  123607. */
  123608. get renderTargetsRenderTimeCounter(): PerfCounter;
  123609. /**
  123610. * Gets the render targets render time capture status
  123611. */
  123612. get captureRenderTargetsRenderTime(): boolean;
  123613. /**
  123614. * Enable or disable the render targets render time capture
  123615. */
  123616. set captureRenderTargetsRenderTime(value: boolean);
  123617. /**
  123618. * Gets the perf counter used for particles render time
  123619. */
  123620. get particlesRenderTimeCounter(): PerfCounter;
  123621. /**
  123622. * Gets the particles render time capture status
  123623. */
  123624. get captureParticlesRenderTime(): boolean;
  123625. /**
  123626. * Enable or disable the particles render time capture
  123627. */
  123628. set captureParticlesRenderTime(value: boolean);
  123629. /**
  123630. * Gets the perf counter used for sprites render time
  123631. */
  123632. get spritesRenderTimeCounter(): PerfCounter;
  123633. /**
  123634. * Gets the sprites render time capture status
  123635. */
  123636. get captureSpritesRenderTime(): boolean;
  123637. /**
  123638. * Enable or disable the sprites render time capture
  123639. */
  123640. set captureSpritesRenderTime(value: boolean);
  123641. /**
  123642. * Gets the perf counter used for physics time
  123643. */
  123644. get physicsTimeCounter(): PerfCounter;
  123645. /**
  123646. * Gets the physics time capture status
  123647. */
  123648. get capturePhysicsTime(): boolean;
  123649. /**
  123650. * Enable or disable the physics time capture
  123651. */
  123652. set capturePhysicsTime(value: boolean);
  123653. /**
  123654. * Gets the perf counter used for animations time
  123655. */
  123656. get animationsTimeCounter(): PerfCounter;
  123657. /**
  123658. * Gets the animations time capture status
  123659. */
  123660. get captureAnimationsTime(): boolean;
  123661. /**
  123662. * Enable or disable the animations time capture
  123663. */
  123664. set captureAnimationsTime(value: boolean);
  123665. /**
  123666. * Gets the perf counter used for frame time capture
  123667. */
  123668. get frameTimeCounter(): PerfCounter;
  123669. /**
  123670. * Gets the frame time capture status
  123671. */
  123672. get captureFrameTime(): boolean;
  123673. /**
  123674. * Enable or disable the frame time capture
  123675. */
  123676. set captureFrameTime(value: boolean);
  123677. /**
  123678. * Gets the perf counter used for inter-frames time capture
  123679. */
  123680. get interFrameTimeCounter(): PerfCounter;
  123681. /**
  123682. * Gets the inter-frames time capture status
  123683. */
  123684. get captureInterFrameTime(): boolean;
  123685. /**
  123686. * Enable or disable the inter-frames time capture
  123687. */
  123688. set captureInterFrameTime(value: boolean);
  123689. /**
  123690. * Gets the perf counter used for render time capture
  123691. */
  123692. get renderTimeCounter(): PerfCounter;
  123693. /**
  123694. * Gets the render time capture status
  123695. */
  123696. get captureRenderTime(): boolean;
  123697. /**
  123698. * Enable or disable the render time capture
  123699. */
  123700. set captureRenderTime(value: boolean);
  123701. /**
  123702. * Gets the perf counter used for camera render time capture
  123703. */
  123704. get cameraRenderTimeCounter(): PerfCounter;
  123705. /**
  123706. * Gets the camera render time capture status
  123707. */
  123708. get captureCameraRenderTime(): boolean;
  123709. /**
  123710. * Enable or disable the camera render time capture
  123711. */
  123712. set captureCameraRenderTime(value: boolean);
  123713. /**
  123714. * Gets the perf counter used for draw calls
  123715. */
  123716. get drawCallsCounter(): PerfCounter;
  123717. /**
  123718. * Instantiates a new scene instrumentation.
  123719. * This class can be used to get instrumentation data from a Babylon engine
  123720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  123721. * @param scene Defines the scene to instrument
  123722. */
  123723. constructor(
  123724. /**
  123725. * Defines the scene to instrument
  123726. */
  123727. scene: Scene);
  123728. /**
  123729. * Dispose and release associated resources.
  123730. */
  123731. dispose(): void;
  123732. }
  123733. }
  123734. declare module BABYLON {
  123735. /** @hidden */
  123736. export var glowMapGenerationPixelShader: {
  123737. name: string;
  123738. shader: string;
  123739. };
  123740. }
  123741. declare module BABYLON {
  123742. /** @hidden */
  123743. export var glowMapGenerationVertexShader: {
  123744. name: string;
  123745. shader: string;
  123746. };
  123747. }
  123748. declare module BABYLON {
  123749. /**
  123750. * Effect layer options. This helps customizing the behaviour
  123751. * of the effect layer.
  123752. */
  123753. export interface IEffectLayerOptions {
  123754. /**
  123755. * Multiplication factor apply to the canvas size to compute the render target size
  123756. * used to generated the objects (the smaller the faster).
  123757. */
  123758. mainTextureRatio: number;
  123759. /**
  123760. * Enforces a fixed size texture to ensure effect stability across devices.
  123761. */
  123762. mainTextureFixedSize?: number;
  123763. /**
  123764. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  123765. */
  123766. alphaBlendingMode: number;
  123767. /**
  123768. * The camera attached to the layer.
  123769. */
  123770. camera: Nullable<Camera>;
  123771. /**
  123772. * The rendering group to draw the layer in.
  123773. */
  123774. renderingGroupId: number;
  123775. }
  123776. /**
  123777. * The effect layer Helps adding post process effect blended with the main pass.
  123778. *
  123779. * This can be for instance use to generate glow or higlight effects on the scene.
  123780. *
  123781. * The effect layer class can not be used directly and is intented to inherited from to be
  123782. * customized per effects.
  123783. */
  123784. export abstract class EffectLayer {
  123785. private _vertexBuffers;
  123786. private _indexBuffer;
  123787. private _cachedDefines;
  123788. private _effectLayerMapGenerationEffect;
  123789. private _effectLayerOptions;
  123790. private _mergeEffect;
  123791. protected _scene: Scene;
  123792. protected _engine: Engine;
  123793. protected _maxSize: number;
  123794. protected _mainTextureDesiredSize: ISize;
  123795. protected _mainTexture: RenderTargetTexture;
  123796. protected _shouldRender: boolean;
  123797. protected _postProcesses: PostProcess[];
  123798. protected _textures: BaseTexture[];
  123799. protected _emissiveTextureAndColor: {
  123800. texture: Nullable<BaseTexture>;
  123801. color: Color4;
  123802. };
  123803. /**
  123804. * The name of the layer
  123805. */
  123806. name: string;
  123807. /**
  123808. * The clear color of the texture used to generate the glow map.
  123809. */
  123810. neutralColor: Color4;
  123811. /**
  123812. * Specifies wether the highlight layer is enabled or not.
  123813. */
  123814. isEnabled: boolean;
  123815. /**
  123816. * Gets the camera attached to the layer.
  123817. */
  123818. get camera(): Nullable<Camera>;
  123819. /**
  123820. * Gets the rendering group id the layer should render in.
  123821. */
  123822. get renderingGroupId(): number;
  123823. set renderingGroupId(renderingGroupId: number);
  123824. /**
  123825. * An event triggered when the effect layer has been disposed.
  123826. */
  123827. onDisposeObservable: Observable<EffectLayer>;
  123828. /**
  123829. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  123830. */
  123831. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  123832. /**
  123833. * An event triggered when the generated texture is being merged in the scene.
  123834. */
  123835. onBeforeComposeObservable: Observable<EffectLayer>;
  123836. /**
  123837. * An event triggered when the mesh is rendered into the effect render target.
  123838. */
  123839. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  123840. /**
  123841. * An event triggered after the mesh has been rendered into the effect render target.
  123842. */
  123843. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  123844. /**
  123845. * An event triggered when the generated texture has been merged in the scene.
  123846. */
  123847. onAfterComposeObservable: Observable<EffectLayer>;
  123848. /**
  123849. * An event triggered when the efffect layer changes its size.
  123850. */
  123851. onSizeChangedObservable: Observable<EffectLayer>;
  123852. /** @hidden */
  123853. static _SceneComponentInitialization: (scene: Scene) => void;
  123854. /**
  123855. * Instantiates a new effect Layer and references it in the scene.
  123856. * @param name The name of the layer
  123857. * @param scene The scene to use the layer in
  123858. */
  123859. constructor(
  123860. /** The Friendly of the effect in the scene */
  123861. name: string, scene: Scene);
  123862. /**
  123863. * Get the effect name of the layer.
  123864. * @return The effect name
  123865. */
  123866. abstract getEffectName(): string;
  123867. /**
  123868. * Checks for the readiness of the element composing the layer.
  123869. * @param subMesh the mesh to check for
  123870. * @param useInstances specify wether or not to use instances to render the mesh
  123871. * @return true if ready otherwise, false
  123872. */
  123873. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123874. /**
  123875. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  123876. * @returns true if the effect requires stencil during the main canvas render pass.
  123877. */
  123878. abstract needStencil(): boolean;
  123879. /**
  123880. * Create the merge effect. This is the shader use to blit the information back
  123881. * to the main canvas at the end of the scene rendering.
  123882. * @returns The effect containing the shader used to merge the effect on the main canvas
  123883. */
  123884. protected abstract _createMergeEffect(): Effect;
  123885. /**
  123886. * Creates the render target textures and post processes used in the effect layer.
  123887. */
  123888. protected abstract _createTextureAndPostProcesses(): void;
  123889. /**
  123890. * Implementation specific of rendering the generating effect on the main canvas.
  123891. * @param effect The effect used to render through
  123892. */
  123893. protected abstract _internalRender(effect: Effect): void;
  123894. /**
  123895. * Sets the required values for both the emissive texture and and the main color.
  123896. */
  123897. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  123898. /**
  123899. * Free any resources and references associated to a mesh.
  123900. * Internal use
  123901. * @param mesh The mesh to free.
  123902. */
  123903. abstract _disposeMesh(mesh: Mesh): void;
  123904. /**
  123905. * Serializes this layer (Glow or Highlight for example)
  123906. * @returns a serialized layer object
  123907. */
  123908. abstract serialize?(): any;
  123909. /**
  123910. * Initializes the effect layer with the required options.
  123911. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  123912. */
  123913. protected _init(options: Partial<IEffectLayerOptions>): void;
  123914. /**
  123915. * Generates the index buffer of the full screen quad blending to the main canvas.
  123916. */
  123917. private _generateIndexBuffer;
  123918. /**
  123919. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  123920. */
  123921. private _generateVertexBuffer;
  123922. /**
  123923. * Sets the main texture desired size which is the closest power of two
  123924. * of the engine canvas size.
  123925. */
  123926. private _setMainTextureSize;
  123927. /**
  123928. * Creates the main texture for the effect layer.
  123929. */
  123930. protected _createMainTexture(): void;
  123931. /**
  123932. * Adds specific effects defines.
  123933. * @param defines The defines to add specifics to.
  123934. */
  123935. protected _addCustomEffectDefines(defines: string[]): void;
  123936. /**
  123937. * Checks for the readiness of the element composing the layer.
  123938. * @param subMesh the mesh to check for
  123939. * @param useInstances specify wether or not to use instances to render the mesh
  123940. * @param emissiveTexture the associated emissive texture used to generate the glow
  123941. * @return true if ready otherwise, false
  123942. */
  123943. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  123944. /**
  123945. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  123946. */
  123947. render(): void;
  123948. /**
  123949. * Determine if a given mesh will be used in the current effect.
  123950. * @param mesh mesh to test
  123951. * @returns true if the mesh will be used
  123952. */
  123953. hasMesh(mesh: AbstractMesh): boolean;
  123954. /**
  123955. * Returns true if the layer contains information to display, otherwise false.
  123956. * @returns true if the glow layer should be rendered
  123957. */
  123958. shouldRender(): boolean;
  123959. /**
  123960. * Returns true if the mesh should render, otherwise false.
  123961. * @param mesh The mesh to render
  123962. * @returns true if it should render otherwise false
  123963. */
  123964. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  123965. /**
  123966. * Returns true if the mesh can be rendered, otherwise false.
  123967. * @param mesh The mesh to render
  123968. * @param material The material used on the mesh
  123969. * @returns true if it can be rendered otherwise false
  123970. */
  123971. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  123972. /**
  123973. * Returns true if the mesh should render, otherwise false.
  123974. * @param mesh The mesh to render
  123975. * @returns true if it should render otherwise false
  123976. */
  123977. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  123978. /**
  123979. * Renders the submesh passed in parameter to the generation map.
  123980. */
  123981. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  123982. /**
  123983. * Defines wether the current material of the mesh should be use to render the effect.
  123984. * @param mesh defines the current mesh to render
  123985. */
  123986. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  123987. /**
  123988. * Rebuild the required buffers.
  123989. * @hidden Internal use only.
  123990. */
  123991. _rebuild(): void;
  123992. /**
  123993. * Dispose only the render target textures and post process.
  123994. */
  123995. private _disposeTextureAndPostProcesses;
  123996. /**
  123997. * Dispose the highlight layer and free resources.
  123998. */
  123999. dispose(): void;
  124000. /**
  124001. * Gets the class name of the effect layer
  124002. * @returns the string with the class name of the effect layer
  124003. */
  124004. getClassName(): string;
  124005. /**
  124006. * Creates an effect layer from parsed effect layer data
  124007. * @param parsedEffectLayer defines effect layer data
  124008. * @param scene defines the current scene
  124009. * @param rootUrl defines the root URL containing the effect layer information
  124010. * @returns a parsed effect Layer
  124011. */
  124012. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  124013. }
  124014. }
  124015. declare module BABYLON {
  124016. interface AbstractScene {
  124017. /**
  124018. * The list of effect layers (highlights/glow) added to the scene
  124019. * @see http://doc.babylonjs.com/how_to/highlight_layer
  124020. * @see http://doc.babylonjs.com/how_to/glow_layer
  124021. */
  124022. effectLayers: Array<EffectLayer>;
  124023. /**
  124024. * Removes the given effect layer from this scene.
  124025. * @param toRemove defines the effect layer to remove
  124026. * @returns the index of the removed effect layer
  124027. */
  124028. removeEffectLayer(toRemove: EffectLayer): number;
  124029. /**
  124030. * Adds the given effect layer to this scene
  124031. * @param newEffectLayer defines the effect layer to add
  124032. */
  124033. addEffectLayer(newEffectLayer: EffectLayer): void;
  124034. }
  124035. /**
  124036. * Defines the layer scene component responsible to manage any effect layers
  124037. * in a given scene.
  124038. */
  124039. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  124040. /**
  124041. * The component name helpfull to identify the component in the list of scene components.
  124042. */
  124043. readonly name: string;
  124044. /**
  124045. * The scene the component belongs to.
  124046. */
  124047. scene: Scene;
  124048. private _engine;
  124049. private _renderEffects;
  124050. private _needStencil;
  124051. private _previousStencilState;
  124052. /**
  124053. * Creates a new instance of the component for the given scene
  124054. * @param scene Defines the scene to register the component in
  124055. */
  124056. constructor(scene: Scene);
  124057. /**
  124058. * Registers the component in a given scene
  124059. */
  124060. register(): void;
  124061. /**
  124062. * Rebuilds the elements related to this component in case of
  124063. * context lost for instance.
  124064. */
  124065. rebuild(): void;
  124066. /**
  124067. * Serializes the component data to the specified json object
  124068. * @param serializationObject The object to serialize to
  124069. */
  124070. serialize(serializationObject: any): void;
  124071. /**
  124072. * Adds all the elements from the container to the scene
  124073. * @param container the container holding the elements
  124074. */
  124075. addFromContainer(container: AbstractScene): void;
  124076. /**
  124077. * Removes all the elements in the container from the scene
  124078. * @param container contains the elements to remove
  124079. * @param dispose if the removed element should be disposed (default: false)
  124080. */
  124081. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  124082. /**
  124083. * Disposes the component and the associated ressources.
  124084. */
  124085. dispose(): void;
  124086. private _isReadyForMesh;
  124087. private _renderMainTexture;
  124088. private _setStencil;
  124089. private _setStencilBack;
  124090. private _draw;
  124091. private _drawCamera;
  124092. private _drawRenderingGroup;
  124093. }
  124094. }
  124095. declare module BABYLON {
  124096. /** @hidden */
  124097. export var glowMapMergePixelShader: {
  124098. name: string;
  124099. shader: string;
  124100. };
  124101. }
  124102. declare module BABYLON {
  124103. /** @hidden */
  124104. export var glowMapMergeVertexShader: {
  124105. name: string;
  124106. shader: string;
  124107. };
  124108. }
  124109. declare module BABYLON {
  124110. interface AbstractScene {
  124111. /**
  124112. * Return a the first highlight layer of the scene with a given name.
  124113. * @param name The name of the highlight layer to look for.
  124114. * @return The highlight layer if found otherwise null.
  124115. */
  124116. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  124117. }
  124118. /**
  124119. * Glow layer options. This helps customizing the behaviour
  124120. * of the glow layer.
  124121. */
  124122. export interface IGlowLayerOptions {
  124123. /**
  124124. * Multiplication factor apply to the canvas size to compute the render target size
  124125. * used to generated the glowing objects (the smaller the faster).
  124126. */
  124127. mainTextureRatio: number;
  124128. /**
  124129. * Enforces a fixed size texture to ensure resize independant blur.
  124130. */
  124131. mainTextureFixedSize?: number;
  124132. /**
  124133. * How big is the kernel of the blur texture.
  124134. */
  124135. blurKernelSize: number;
  124136. /**
  124137. * The camera attached to the layer.
  124138. */
  124139. camera: Nullable<Camera>;
  124140. /**
  124141. * Enable MSAA by chosing the number of samples.
  124142. */
  124143. mainTextureSamples?: number;
  124144. /**
  124145. * The rendering group to draw the layer in.
  124146. */
  124147. renderingGroupId: number;
  124148. }
  124149. /**
  124150. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  124151. *
  124152. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  124153. *
  124154. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  124155. */
  124156. export class GlowLayer extends EffectLayer {
  124157. /**
  124158. * Effect Name of the layer.
  124159. */
  124160. static readonly EffectName: string;
  124161. /**
  124162. * The default blur kernel size used for the glow.
  124163. */
  124164. static DefaultBlurKernelSize: number;
  124165. /**
  124166. * The default texture size ratio used for the glow.
  124167. */
  124168. static DefaultTextureRatio: number;
  124169. /**
  124170. * Sets the kernel size of the blur.
  124171. */
  124172. set blurKernelSize(value: number);
  124173. /**
  124174. * Gets the kernel size of the blur.
  124175. */
  124176. get blurKernelSize(): number;
  124177. /**
  124178. * Sets the glow intensity.
  124179. */
  124180. set intensity(value: number);
  124181. /**
  124182. * Gets the glow intensity.
  124183. */
  124184. get intensity(): number;
  124185. private _options;
  124186. private _intensity;
  124187. private _horizontalBlurPostprocess1;
  124188. private _verticalBlurPostprocess1;
  124189. private _horizontalBlurPostprocess2;
  124190. private _verticalBlurPostprocess2;
  124191. private _blurTexture1;
  124192. private _blurTexture2;
  124193. private _postProcesses1;
  124194. private _postProcesses2;
  124195. private _includedOnlyMeshes;
  124196. private _excludedMeshes;
  124197. private _meshesUsingTheirOwnMaterials;
  124198. /**
  124199. * Callback used to let the user override the color selection on a per mesh basis
  124200. */
  124201. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  124202. /**
  124203. * Callback used to let the user override the texture selection on a per mesh basis
  124204. */
  124205. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  124206. /**
  124207. * Instantiates a new glow Layer and references it to the scene.
  124208. * @param name The name of the layer
  124209. * @param scene The scene to use the layer in
  124210. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  124211. */
  124212. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  124213. /**
  124214. * Get the effect name of the layer.
  124215. * @return The effect name
  124216. */
  124217. getEffectName(): string;
  124218. /**
  124219. * Create the merge effect. This is the shader use to blit the information back
  124220. * to the main canvas at the end of the scene rendering.
  124221. */
  124222. protected _createMergeEffect(): Effect;
  124223. /**
  124224. * Creates the render target textures and post processes used in the glow layer.
  124225. */
  124226. protected _createTextureAndPostProcesses(): void;
  124227. /**
  124228. * Checks for the readiness of the element composing the layer.
  124229. * @param subMesh the mesh to check for
  124230. * @param useInstances specify wether or not to use instances to render the mesh
  124231. * @param emissiveTexture the associated emissive texture used to generate the glow
  124232. * @return true if ready otherwise, false
  124233. */
  124234. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124235. /**
  124236. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  124237. */
  124238. needStencil(): boolean;
  124239. /**
  124240. * Returns true if the mesh can be rendered, otherwise false.
  124241. * @param mesh The mesh to render
  124242. * @param material The material used on the mesh
  124243. * @returns true if it can be rendered otherwise false
  124244. */
  124245. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  124246. /**
  124247. * Implementation specific of rendering the generating effect on the main canvas.
  124248. * @param effect The effect used to render through
  124249. */
  124250. protected _internalRender(effect: Effect): void;
  124251. /**
  124252. * Sets the required values for both the emissive texture and and the main color.
  124253. */
  124254. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  124255. /**
  124256. * Returns true if the mesh should render, otherwise false.
  124257. * @param mesh The mesh to render
  124258. * @returns true if it should render otherwise false
  124259. */
  124260. protected _shouldRenderMesh(mesh: Mesh): boolean;
  124261. /**
  124262. * Adds specific effects defines.
  124263. * @param defines The defines to add specifics to.
  124264. */
  124265. protected _addCustomEffectDefines(defines: string[]): void;
  124266. /**
  124267. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  124268. * @param mesh The mesh to exclude from the glow layer
  124269. */
  124270. addExcludedMesh(mesh: Mesh): void;
  124271. /**
  124272. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  124273. * @param mesh The mesh to remove
  124274. */
  124275. removeExcludedMesh(mesh: Mesh): void;
  124276. /**
  124277. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  124278. * @param mesh The mesh to include in the glow layer
  124279. */
  124280. addIncludedOnlyMesh(mesh: Mesh): void;
  124281. /**
  124282. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  124283. * @param mesh The mesh to remove
  124284. */
  124285. removeIncludedOnlyMesh(mesh: Mesh): void;
  124286. /**
  124287. * Determine if a given mesh will be used in the glow layer
  124288. * @param mesh The mesh to test
  124289. * @returns true if the mesh will be highlighted by the current glow layer
  124290. */
  124291. hasMesh(mesh: AbstractMesh): boolean;
  124292. /**
  124293. * Defines wether the current material of the mesh should be use to render the effect.
  124294. * @param mesh defines the current mesh to render
  124295. */
  124296. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  124297. /**
  124298. * Add a mesh to be rendered through its own material and not with emissive only.
  124299. * @param mesh The mesh for which we need to use its material
  124300. */
  124301. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  124302. /**
  124303. * Remove a mesh from being rendered through its own material and not with emissive only.
  124304. * @param mesh The mesh for which we need to not use its material
  124305. */
  124306. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  124307. /**
  124308. * Free any resources and references associated to a mesh.
  124309. * Internal use
  124310. * @param mesh The mesh to free.
  124311. * @hidden
  124312. */
  124313. _disposeMesh(mesh: Mesh): void;
  124314. /**
  124315. * Gets the class name of the effect layer
  124316. * @returns the string with the class name of the effect layer
  124317. */
  124318. getClassName(): string;
  124319. /**
  124320. * Serializes this glow layer
  124321. * @returns a serialized glow layer object
  124322. */
  124323. serialize(): any;
  124324. /**
  124325. * Creates a Glow Layer from parsed glow layer data
  124326. * @param parsedGlowLayer defines glow layer data
  124327. * @param scene defines the current scene
  124328. * @param rootUrl defines the root URL containing the glow layer information
  124329. * @returns a parsed Glow Layer
  124330. */
  124331. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  124332. }
  124333. }
  124334. declare module BABYLON {
  124335. /** @hidden */
  124336. export var glowBlurPostProcessPixelShader: {
  124337. name: string;
  124338. shader: string;
  124339. };
  124340. }
  124341. declare module BABYLON {
  124342. interface AbstractScene {
  124343. /**
  124344. * Return a the first highlight layer of the scene with a given name.
  124345. * @param name The name of the highlight layer to look for.
  124346. * @return The highlight layer if found otherwise null.
  124347. */
  124348. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  124349. }
  124350. /**
  124351. * Highlight layer options. This helps customizing the behaviour
  124352. * of the highlight layer.
  124353. */
  124354. export interface IHighlightLayerOptions {
  124355. /**
  124356. * Multiplication factor apply to the canvas size to compute the render target size
  124357. * used to generated the glowing objects (the smaller the faster).
  124358. */
  124359. mainTextureRatio: number;
  124360. /**
  124361. * Enforces a fixed size texture to ensure resize independant blur.
  124362. */
  124363. mainTextureFixedSize?: number;
  124364. /**
  124365. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  124366. * of the picture to blur (the smaller the faster).
  124367. */
  124368. blurTextureSizeRatio: number;
  124369. /**
  124370. * How big in texel of the blur texture is the vertical blur.
  124371. */
  124372. blurVerticalSize: number;
  124373. /**
  124374. * How big in texel of the blur texture is the horizontal blur.
  124375. */
  124376. blurHorizontalSize: number;
  124377. /**
  124378. * Alpha blending mode used to apply the blur. Default is combine.
  124379. */
  124380. alphaBlendingMode: number;
  124381. /**
  124382. * The camera attached to the layer.
  124383. */
  124384. camera: Nullable<Camera>;
  124385. /**
  124386. * Should we display highlight as a solid stroke?
  124387. */
  124388. isStroke?: boolean;
  124389. /**
  124390. * The rendering group to draw the layer in.
  124391. */
  124392. renderingGroupId: number;
  124393. }
  124394. /**
  124395. * The highlight layer Helps adding a glow effect around a mesh.
  124396. *
  124397. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  124398. * glowy meshes to your scene.
  124399. *
  124400. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  124401. */
  124402. export class HighlightLayer extends EffectLayer {
  124403. name: string;
  124404. /**
  124405. * Effect Name of the highlight layer.
  124406. */
  124407. static readonly EffectName: string;
  124408. /**
  124409. * The neutral color used during the preparation of the glow effect.
  124410. * This is black by default as the blend operation is a blend operation.
  124411. */
  124412. static NeutralColor: Color4;
  124413. /**
  124414. * Stencil value used for glowing meshes.
  124415. */
  124416. static GlowingMeshStencilReference: number;
  124417. /**
  124418. * Stencil value used for the other meshes in the scene.
  124419. */
  124420. static NormalMeshStencilReference: number;
  124421. /**
  124422. * Specifies whether or not the inner glow is ACTIVE in the layer.
  124423. */
  124424. innerGlow: boolean;
  124425. /**
  124426. * Specifies whether or not the outer glow is ACTIVE in the layer.
  124427. */
  124428. outerGlow: boolean;
  124429. /**
  124430. * Specifies the horizontal size of the blur.
  124431. */
  124432. set blurHorizontalSize(value: number);
  124433. /**
  124434. * Specifies the vertical size of the blur.
  124435. */
  124436. set blurVerticalSize(value: number);
  124437. /**
  124438. * Gets the horizontal size of the blur.
  124439. */
  124440. get blurHorizontalSize(): number;
  124441. /**
  124442. * Gets the vertical size of the blur.
  124443. */
  124444. get blurVerticalSize(): number;
  124445. /**
  124446. * An event triggered when the highlight layer is being blurred.
  124447. */
  124448. onBeforeBlurObservable: Observable<HighlightLayer>;
  124449. /**
  124450. * An event triggered when the highlight layer has been blurred.
  124451. */
  124452. onAfterBlurObservable: Observable<HighlightLayer>;
  124453. private _instanceGlowingMeshStencilReference;
  124454. private _options;
  124455. private _downSamplePostprocess;
  124456. private _horizontalBlurPostprocess;
  124457. private _verticalBlurPostprocess;
  124458. private _blurTexture;
  124459. private _meshes;
  124460. private _excludedMeshes;
  124461. /**
  124462. * Instantiates a new highlight Layer and references it to the scene..
  124463. * @param name The name of the layer
  124464. * @param scene The scene to use the layer in
  124465. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  124466. */
  124467. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  124468. /**
  124469. * Get the effect name of the layer.
  124470. * @return The effect name
  124471. */
  124472. getEffectName(): string;
  124473. /**
  124474. * Create the merge effect. This is the shader use to blit the information back
  124475. * to the main canvas at the end of the scene rendering.
  124476. */
  124477. protected _createMergeEffect(): Effect;
  124478. /**
  124479. * Creates the render target textures and post processes used in the highlight layer.
  124480. */
  124481. protected _createTextureAndPostProcesses(): void;
  124482. /**
  124483. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  124484. */
  124485. needStencil(): boolean;
  124486. /**
  124487. * Checks for the readiness of the element composing the layer.
  124488. * @param subMesh the mesh to check for
  124489. * @param useInstances specify wether or not to use instances to render the mesh
  124490. * @param emissiveTexture the associated emissive texture used to generate the glow
  124491. * @return true if ready otherwise, false
  124492. */
  124493. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124494. /**
  124495. * Implementation specific of rendering the generating effect on the main canvas.
  124496. * @param effect The effect used to render through
  124497. */
  124498. protected _internalRender(effect: Effect): void;
  124499. /**
  124500. * Returns true if the layer contains information to display, otherwise false.
  124501. */
  124502. shouldRender(): boolean;
  124503. /**
  124504. * Returns true if the mesh should render, otherwise false.
  124505. * @param mesh The mesh to render
  124506. * @returns true if it should render otherwise false
  124507. */
  124508. protected _shouldRenderMesh(mesh: Mesh): boolean;
  124509. /**
  124510. * Sets the required values for both the emissive texture and and the main color.
  124511. */
  124512. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  124513. /**
  124514. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  124515. * @param mesh The mesh to exclude from the highlight layer
  124516. */
  124517. addExcludedMesh(mesh: Mesh): void;
  124518. /**
  124519. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  124520. * @param mesh The mesh to highlight
  124521. */
  124522. removeExcludedMesh(mesh: Mesh): void;
  124523. /**
  124524. * Determine if a given mesh will be highlighted by the current HighlightLayer
  124525. * @param mesh mesh to test
  124526. * @returns true if the mesh will be highlighted by the current HighlightLayer
  124527. */
  124528. hasMesh(mesh: AbstractMesh): boolean;
  124529. /**
  124530. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  124531. * @param mesh The mesh to highlight
  124532. * @param color The color of the highlight
  124533. * @param glowEmissiveOnly Extract the glow from the emissive texture
  124534. */
  124535. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  124536. /**
  124537. * Remove a mesh from the highlight layer in order to make it stop glowing.
  124538. * @param mesh The mesh to highlight
  124539. */
  124540. removeMesh(mesh: Mesh): void;
  124541. /**
  124542. * Force the stencil to the normal expected value for none glowing parts
  124543. */
  124544. private _defaultStencilReference;
  124545. /**
  124546. * Free any resources and references associated to a mesh.
  124547. * Internal use
  124548. * @param mesh The mesh to free.
  124549. * @hidden
  124550. */
  124551. _disposeMesh(mesh: Mesh): void;
  124552. /**
  124553. * Dispose the highlight layer and free resources.
  124554. */
  124555. dispose(): void;
  124556. /**
  124557. * Gets the class name of the effect layer
  124558. * @returns the string with the class name of the effect layer
  124559. */
  124560. getClassName(): string;
  124561. /**
  124562. * Serializes this Highlight layer
  124563. * @returns a serialized Highlight layer object
  124564. */
  124565. serialize(): any;
  124566. /**
  124567. * Creates a Highlight layer from parsed Highlight layer data
  124568. * @param parsedHightlightLayer defines the Highlight layer data
  124569. * @param scene defines the current scene
  124570. * @param rootUrl defines the root URL containing the Highlight layer information
  124571. * @returns a parsed Highlight layer
  124572. */
  124573. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  124574. }
  124575. }
  124576. declare module BABYLON {
  124577. interface AbstractScene {
  124578. /**
  124579. * The list of layers (background and foreground) of the scene
  124580. */
  124581. layers: Array<Layer>;
  124582. }
  124583. /**
  124584. * Defines the layer scene component responsible to manage any layers
  124585. * in a given scene.
  124586. */
  124587. export class LayerSceneComponent implements ISceneComponent {
  124588. /**
  124589. * The component name helpfull to identify the component in the list of scene components.
  124590. */
  124591. readonly name: string;
  124592. /**
  124593. * The scene the component belongs to.
  124594. */
  124595. scene: Scene;
  124596. private _engine;
  124597. /**
  124598. * Creates a new instance of the component for the given scene
  124599. * @param scene Defines the scene to register the component in
  124600. */
  124601. constructor(scene: Scene);
  124602. /**
  124603. * Registers the component in a given scene
  124604. */
  124605. register(): void;
  124606. /**
  124607. * Rebuilds the elements related to this component in case of
  124608. * context lost for instance.
  124609. */
  124610. rebuild(): void;
  124611. /**
  124612. * Disposes the component and the associated ressources.
  124613. */
  124614. dispose(): void;
  124615. private _draw;
  124616. private _drawCameraPredicate;
  124617. private _drawCameraBackground;
  124618. private _drawCameraForeground;
  124619. private _drawRenderTargetPredicate;
  124620. private _drawRenderTargetBackground;
  124621. private _drawRenderTargetForeground;
  124622. /**
  124623. * Adds all the elements from the container to the scene
  124624. * @param container the container holding the elements
  124625. */
  124626. addFromContainer(container: AbstractScene): void;
  124627. /**
  124628. * Removes all the elements in the container from the scene
  124629. * @param container contains the elements to remove
  124630. * @param dispose if the removed element should be disposed (default: false)
  124631. */
  124632. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  124633. }
  124634. }
  124635. declare module BABYLON {
  124636. /** @hidden */
  124637. export var layerPixelShader: {
  124638. name: string;
  124639. shader: string;
  124640. };
  124641. }
  124642. declare module BABYLON {
  124643. /** @hidden */
  124644. export var layerVertexShader: {
  124645. name: string;
  124646. shader: string;
  124647. };
  124648. }
  124649. declare module BABYLON {
  124650. /**
  124651. * This represents a full screen 2d layer.
  124652. * This can be useful to display a picture in the background of your scene for instance.
  124653. * @see https://www.babylonjs-playground.com/#08A2BS#1
  124654. */
  124655. export class Layer {
  124656. /**
  124657. * Define the name of the layer.
  124658. */
  124659. name: string;
  124660. /**
  124661. * Define the texture the layer should display.
  124662. */
  124663. texture: Nullable<Texture>;
  124664. /**
  124665. * Is the layer in background or foreground.
  124666. */
  124667. isBackground: boolean;
  124668. /**
  124669. * Define the color of the layer (instead of texture).
  124670. */
  124671. color: Color4;
  124672. /**
  124673. * Define the scale of the layer in order to zoom in out of the texture.
  124674. */
  124675. scale: Vector2;
  124676. /**
  124677. * Define an offset for the layer in order to shift the texture.
  124678. */
  124679. offset: Vector2;
  124680. /**
  124681. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  124682. */
  124683. alphaBlendingMode: number;
  124684. /**
  124685. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  124686. * Alpha test will not mix with the background color in case of transparency.
  124687. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  124688. */
  124689. alphaTest: boolean;
  124690. /**
  124691. * Define a mask to restrict the layer to only some of the scene cameras.
  124692. */
  124693. layerMask: number;
  124694. /**
  124695. * Define the list of render target the layer is visible into.
  124696. */
  124697. renderTargetTextures: RenderTargetTexture[];
  124698. /**
  124699. * Define if the layer is only used in renderTarget or if it also
  124700. * renders in the main frame buffer of the canvas.
  124701. */
  124702. renderOnlyInRenderTargetTextures: boolean;
  124703. private _scene;
  124704. private _vertexBuffers;
  124705. private _indexBuffer;
  124706. private _effect;
  124707. private _previousDefines;
  124708. /**
  124709. * An event triggered when the layer is disposed.
  124710. */
  124711. onDisposeObservable: Observable<Layer>;
  124712. private _onDisposeObserver;
  124713. /**
  124714. * Back compatibility with callback before the onDisposeObservable existed.
  124715. * The set callback will be triggered when the layer has been disposed.
  124716. */
  124717. set onDispose(callback: () => void);
  124718. /**
  124719. * An event triggered before rendering the scene
  124720. */
  124721. onBeforeRenderObservable: Observable<Layer>;
  124722. private _onBeforeRenderObserver;
  124723. /**
  124724. * Back compatibility with callback before the onBeforeRenderObservable existed.
  124725. * The set callback will be triggered just before rendering the layer.
  124726. */
  124727. set onBeforeRender(callback: () => void);
  124728. /**
  124729. * An event triggered after rendering the scene
  124730. */
  124731. onAfterRenderObservable: Observable<Layer>;
  124732. private _onAfterRenderObserver;
  124733. /**
  124734. * Back compatibility with callback before the onAfterRenderObservable existed.
  124735. * The set callback will be triggered just after rendering the layer.
  124736. */
  124737. set onAfterRender(callback: () => void);
  124738. /**
  124739. * Instantiates a new layer.
  124740. * This represents a full screen 2d layer.
  124741. * This can be useful to display a picture in the background of your scene for instance.
  124742. * @see https://www.babylonjs-playground.com/#08A2BS#1
  124743. * @param name Define the name of the layer in the scene
  124744. * @param imgUrl Define the url of the texture to display in the layer
  124745. * @param scene Define the scene the layer belongs to
  124746. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  124747. * @param color Defines a color for the layer
  124748. */
  124749. constructor(
  124750. /**
  124751. * Define the name of the layer.
  124752. */
  124753. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  124754. private _createIndexBuffer;
  124755. /** @hidden */
  124756. _rebuild(): void;
  124757. /**
  124758. * Renders the layer in the scene.
  124759. */
  124760. render(): void;
  124761. /**
  124762. * Disposes and releases the associated ressources.
  124763. */
  124764. dispose(): void;
  124765. }
  124766. }
  124767. declare module BABYLON {
  124768. /** @hidden */
  124769. export var lensFlarePixelShader: {
  124770. name: string;
  124771. shader: string;
  124772. };
  124773. }
  124774. declare module BABYLON {
  124775. /** @hidden */
  124776. export var lensFlareVertexShader: {
  124777. name: string;
  124778. shader: string;
  124779. };
  124780. }
  124781. declare module BABYLON {
  124782. /**
  124783. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  124784. * It is usually composed of several `lensFlare`.
  124785. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124786. */
  124787. export class LensFlareSystem {
  124788. /**
  124789. * Define the name of the lens flare system
  124790. */
  124791. name: string;
  124792. /**
  124793. * List of lens flares used in this system.
  124794. */
  124795. lensFlares: LensFlare[];
  124796. /**
  124797. * Define a limit from the border the lens flare can be visible.
  124798. */
  124799. borderLimit: number;
  124800. /**
  124801. * Define a viewport border we do not want to see the lens flare in.
  124802. */
  124803. viewportBorder: number;
  124804. /**
  124805. * Define a predicate which could limit the list of meshes able to occlude the effect.
  124806. */
  124807. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  124808. /**
  124809. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  124810. */
  124811. layerMask: number;
  124812. /**
  124813. * Define the id of the lens flare system in the scene.
  124814. * (equal to name by default)
  124815. */
  124816. id: string;
  124817. private _scene;
  124818. private _emitter;
  124819. private _vertexBuffers;
  124820. private _indexBuffer;
  124821. private _effect;
  124822. private _positionX;
  124823. private _positionY;
  124824. private _isEnabled;
  124825. /** @hidden */
  124826. static _SceneComponentInitialization: (scene: Scene) => void;
  124827. /**
  124828. * Instantiates a lens flare system.
  124829. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  124830. * It is usually composed of several `lensFlare`.
  124831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124832. * @param name Define the name of the lens flare system in the scene
  124833. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  124834. * @param scene Define the scene the lens flare system belongs to
  124835. */
  124836. constructor(
  124837. /**
  124838. * Define the name of the lens flare system
  124839. */
  124840. name: string, emitter: any, scene: Scene);
  124841. /**
  124842. * Define if the lens flare system is enabled.
  124843. */
  124844. get isEnabled(): boolean;
  124845. set isEnabled(value: boolean);
  124846. /**
  124847. * Get the scene the effects belongs to.
  124848. * @returns the scene holding the lens flare system
  124849. */
  124850. getScene(): Scene;
  124851. /**
  124852. * Get the emitter of the lens flare system.
  124853. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  124854. * @returns the emitter of the lens flare system
  124855. */
  124856. getEmitter(): any;
  124857. /**
  124858. * Set the emitter of the lens flare system.
  124859. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  124860. * @param newEmitter Define the new emitter of the system
  124861. */
  124862. setEmitter(newEmitter: any): void;
  124863. /**
  124864. * Get the lens flare system emitter position.
  124865. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  124866. * @returns the position
  124867. */
  124868. getEmitterPosition(): Vector3;
  124869. /**
  124870. * @hidden
  124871. */
  124872. computeEffectivePosition(globalViewport: Viewport): boolean;
  124873. /** @hidden */
  124874. _isVisible(): boolean;
  124875. /**
  124876. * @hidden
  124877. */
  124878. render(): boolean;
  124879. /**
  124880. * Dispose and release the lens flare with its associated resources.
  124881. */
  124882. dispose(): void;
  124883. /**
  124884. * Parse a lens flare system from a JSON repressentation
  124885. * @param parsedLensFlareSystem Define the JSON to parse
  124886. * @param scene Define the scene the parsed system should be instantiated in
  124887. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  124888. * @returns the parsed system
  124889. */
  124890. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  124891. /**
  124892. * Serialize the current Lens Flare System into a JSON representation.
  124893. * @returns the serialized JSON
  124894. */
  124895. serialize(): any;
  124896. }
  124897. }
  124898. declare module BABYLON {
  124899. /**
  124900. * This represents one of the lens effect in a `lensFlareSystem`.
  124901. * It controls one of the indiviual texture used in the effect.
  124902. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124903. */
  124904. export class LensFlare {
  124905. /**
  124906. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  124907. */
  124908. size: number;
  124909. /**
  124910. * 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.
  124911. */
  124912. position: number;
  124913. /**
  124914. * Define the lens color.
  124915. */
  124916. color: Color3;
  124917. /**
  124918. * Define the lens texture.
  124919. */
  124920. texture: Nullable<Texture>;
  124921. /**
  124922. * Define the alpha mode to render this particular lens.
  124923. */
  124924. alphaMode: number;
  124925. private _system;
  124926. /**
  124927. * Creates a new Lens Flare.
  124928. * This represents one of the lens effect in a `lensFlareSystem`.
  124929. * It controls one of the indiviual texture used in the effect.
  124930. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124931. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  124932. * @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.
  124933. * @param color Define the lens color
  124934. * @param imgUrl Define the lens texture url
  124935. * @param system Define the `lensFlareSystem` this flare is part of
  124936. * @returns The newly created Lens Flare
  124937. */
  124938. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  124939. /**
  124940. * Instantiates a new Lens Flare.
  124941. * This represents one of the lens effect in a `lensFlareSystem`.
  124942. * It controls one of the indiviual texture used in the effect.
  124943. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124944. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  124945. * @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.
  124946. * @param color Define the lens color
  124947. * @param imgUrl Define the lens texture url
  124948. * @param system Define the `lensFlareSystem` this flare is part of
  124949. */
  124950. constructor(
  124951. /**
  124952. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  124953. */
  124954. size: number,
  124955. /**
  124956. * 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.
  124957. */
  124958. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  124959. /**
  124960. * Dispose and release the lens flare with its associated resources.
  124961. */
  124962. dispose(): void;
  124963. }
  124964. }
  124965. declare module BABYLON {
  124966. interface AbstractScene {
  124967. /**
  124968. * The list of lens flare system added to the scene
  124969. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124970. */
  124971. lensFlareSystems: Array<LensFlareSystem>;
  124972. /**
  124973. * Removes the given lens flare system from this scene.
  124974. * @param toRemove The lens flare system to remove
  124975. * @returns The index of the removed lens flare system
  124976. */
  124977. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  124978. /**
  124979. * Adds the given lens flare system to this scene
  124980. * @param newLensFlareSystem The lens flare system to add
  124981. */
  124982. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  124983. /**
  124984. * Gets a lens flare system using its name
  124985. * @param name defines the name to look for
  124986. * @returns the lens flare system or null if not found
  124987. */
  124988. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  124989. /**
  124990. * Gets a lens flare system using its id
  124991. * @param id defines the id to look for
  124992. * @returns the lens flare system or null if not found
  124993. */
  124994. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  124995. }
  124996. /**
  124997. * Defines the lens flare scene component responsible to manage any lens flares
  124998. * in a given scene.
  124999. */
  125000. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  125001. /**
  125002. * The component name helpfull to identify the component in the list of scene components.
  125003. */
  125004. readonly name: string;
  125005. /**
  125006. * The scene the component belongs to.
  125007. */
  125008. scene: Scene;
  125009. /**
  125010. * Creates a new instance of the component for the given scene
  125011. * @param scene Defines the scene to register the component in
  125012. */
  125013. constructor(scene: Scene);
  125014. /**
  125015. * Registers the component in a given scene
  125016. */
  125017. register(): void;
  125018. /**
  125019. * Rebuilds the elements related to this component in case of
  125020. * context lost for instance.
  125021. */
  125022. rebuild(): void;
  125023. /**
  125024. * Adds all the elements from the container to the scene
  125025. * @param container the container holding the elements
  125026. */
  125027. addFromContainer(container: AbstractScene): void;
  125028. /**
  125029. * Removes all the elements in the container from the scene
  125030. * @param container contains the elements to remove
  125031. * @param dispose if the removed element should be disposed (default: false)
  125032. */
  125033. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125034. /**
  125035. * Serializes the component data to the specified json object
  125036. * @param serializationObject The object to serialize to
  125037. */
  125038. serialize(serializationObject: any): void;
  125039. /**
  125040. * Disposes the component and the associated ressources.
  125041. */
  125042. dispose(): void;
  125043. private _draw;
  125044. }
  125045. }
  125046. declare module BABYLON {
  125047. /**
  125048. * Defines the shadow generator component responsible to manage any shadow generators
  125049. * in a given scene.
  125050. */
  125051. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  125052. /**
  125053. * The component name helpfull to identify the component in the list of scene components.
  125054. */
  125055. readonly name: string;
  125056. /**
  125057. * The scene the component belongs to.
  125058. */
  125059. scene: Scene;
  125060. /**
  125061. * Creates a new instance of the component for the given scene
  125062. * @param scene Defines the scene to register the component in
  125063. */
  125064. constructor(scene: Scene);
  125065. /**
  125066. * Registers the component in a given scene
  125067. */
  125068. register(): void;
  125069. /**
  125070. * Rebuilds the elements related to this component in case of
  125071. * context lost for instance.
  125072. */
  125073. rebuild(): void;
  125074. /**
  125075. * Serializes the component data to the specified json object
  125076. * @param serializationObject The object to serialize to
  125077. */
  125078. serialize(serializationObject: any): void;
  125079. /**
  125080. * Adds all the elements from the container to the scene
  125081. * @param container the container holding the elements
  125082. */
  125083. addFromContainer(container: AbstractScene): void;
  125084. /**
  125085. * Removes all the elements in the container from the scene
  125086. * @param container contains the elements to remove
  125087. * @param dispose if the removed element should be disposed (default: false)
  125088. */
  125089. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125090. /**
  125091. * Rebuilds the elements related to this component in case of
  125092. * context lost for instance.
  125093. */
  125094. dispose(): void;
  125095. private _gatherRenderTargets;
  125096. }
  125097. }
  125098. declare module BABYLON {
  125099. /**
  125100. * A point light is a light defined by an unique point in world space.
  125101. * The light is emitted in every direction from this point.
  125102. * A good example of a point light is a standard light bulb.
  125103. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125104. */
  125105. export class PointLight extends ShadowLight {
  125106. private _shadowAngle;
  125107. /**
  125108. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125109. * This specifies what angle the shadow will use to be created.
  125110. *
  125111. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  125112. */
  125113. get shadowAngle(): number;
  125114. /**
  125115. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125116. * This specifies what angle the shadow will use to be created.
  125117. *
  125118. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  125119. */
  125120. set shadowAngle(value: number);
  125121. /**
  125122. * Gets the direction if it has been set.
  125123. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125124. */
  125125. get direction(): Vector3;
  125126. /**
  125127. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125128. */
  125129. set direction(value: Vector3);
  125130. /**
  125131. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  125132. * A PointLight emits the light in every direction.
  125133. * It can cast shadows.
  125134. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  125135. * ```javascript
  125136. * var pointLight = new PointLight("pl", camera.position, scene);
  125137. * ```
  125138. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125139. * @param name The light friendly name
  125140. * @param position The position of the point light in the scene
  125141. * @param scene The scene the lights belongs to
  125142. */
  125143. constructor(name: string, position: Vector3, scene: Scene);
  125144. /**
  125145. * Returns the string "PointLight"
  125146. * @returns the class name
  125147. */
  125148. getClassName(): string;
  125149. /**
  125150. * Returns the integer 0.
  125151. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125152. */
  125153. getTypeID(): number;
  125154. /**
  125155. * Specifies wether or not the shadowmap should be a cube texture.
  125156. * @returns true if the shadowmap needs to be a cube texture.
  125157. */
  125158. needCube(): boolean;
  125159. /**
  125160. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  125161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  125162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  125163. */
  125164. getShadowDirection(faceIndex?: number): Vector3;
  125165. /**
  125166. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  125167. * - fov = PI / 2
  125168. * - aspect ratio : 1.0
  125169. * - z-near and far equal to the active camera minZ and maxZ.
  125170. * Returns the PointLight.
  125171. */
  125172. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125173. protected _buildUniformLayout(): void;
  125174. /**
  125175. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  125176. * @param effect The effect to update
  125177. * @param lightIndex The index of the light in the effect to update
  125178. * @returns The point light
  125179. */
  125180. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  125181. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125182. /**
  125183. * Prepares the list of defines specific to the light type.
  125184. * @param defines the list of defines
  125185. * @param lightIndex defines the index of the light for the effect
  125186. */
  125187. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125188. }
  125189. }
  125190. declare module BABYLON {
  125191. /**
  125192. * Header information of HDR texture files.
  125193. */
  125194. export interface HDRInfo {
  125195. /**
  125196. * The height of the texture in pixels.
  125197. */
  125198. height: number;
  125199. /**
  125200. * The width of the texture in pixels.
  125201. */
  125202. width: number;
  125203. /**
  125204. * The index of the beginning of the data in the binary file.
  125205. */
  125206. dataPosition: number;
  125207. }
  125208. /**
  125209. * This groups tools to convert HDR texture to native colors array.
  125210. */
  125211. export class HDRTools {
  125212. private static Ldexp;
  125213. private static Rgbe2float;
  125214. private static readStringLine;
  125215. /**
  125216. * Reads header information from an RGBE texture stored in a native array.
  125217. * More information on this format are available here:
  125218. * https://en.wikipedia.org/wiki/RGBE_image_format
  125219. *
  125220. * @param uint8array The binary file stored in native array.
  125221. * @return The header information.
  125222. */
  125223. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  125224. /**
  125225. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  125226. * This RGBE texture needs to store the information as a panorama.
  125227. *
  125228. * More information on this format are available here:
  125229. * https://en.wikipedia.org/wiki/RGBE_image_format
  125230. *
  125231. * @param buffer The binary file stored in an array buffer.
  125232. * @param size The expected size of the extracted cubemap.
  125233. * @return The Cube Map information.
  125234. */
  125235. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  125236. /**
  125237. * Returns the pixels data extracted from an RGBE texture.
  125238. * This pixels will be stored left to right up to down in the R G B order in one array.
  125239. *
  125240. * More information on this format are available here:
  125241. * https://en.wikipedia.org/wiki/RGBE_image_format
  125242. *
  125243. * @param uint8array The binary file stored in an array buffer.
  125244. * @param hdrInfo The header information of the file.
  125245. * @return The pixels data in RGB right to left up to down order.
  125246. */
  125247. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  125248. private static RGBE_ReadPixels_RLE;
  125249. }
  125250. }
  125251. declare module BABYLON {
  125252. /**
  125253. * This represents a texture coming from an HDR input.
  125254. *
  125255. * The only supported format is currently panorama picture stored in RGBE format.
  125256. * Example of such files can be found on HDRLib: http://hdrlib.com/
  125257. */
  125258. export class HDRCubeTexture extends BaseTexture {
  125259. private static _facesMapping;
  125260. private _generateHarmonics;
  125261. private _noMipmap;
  125262. private _textureMatrix;
  125263. private _size;
  125264. private _onLoad;
  125265. private _onError;
  125266. /**
  125267. * The texture URL.
  125268. */
  125269. url: string;
  125270. /**
  125271. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  125272. */
  125273. coordinatesMode: number;
  125274. protected _isBlocking: boolean;
  125275. /**
  125276. * Sets wether or not the texture is blocking during loading.
  125277. */
  125278. set isBlocking(value: boolean);
  125279. /**
  125280. * Gets wether or not the texture is blocking during loading.
  125281. */
  125282. get isBlocking(): boolean;
  125283. protected _rotationY: number;
  125284. /**
  125285. * Sets texture matrix rotation angle around Y axis in radians.
  125286. */
  125287. set rotationY(value: number);
  125288. /**
  125289. * Gets texture matrix rotation angle around Y axis radians.
  125290. */
  125291. get rotationY(): number;
  125292. /**
  125293. * Gets or sets the center of the bounding box associated with the cube texture
  125294. * It must define where the camera used to render the texture was set
  125295. */
  125296. boundingBoxPosition: Vector3;
  125297. private _boundingBoxSize;
  125298. /**
  125299. * Gets or sets the size of the bounding box associated with the cube texture
  125300. * When defined, the cubemap will switch to local mode
  125301. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  125302. * @example https://www.babylonjs-playground.com/#RNASML
  125303. */
  125304. set boundingBoxSize(value: Vector3);
  125305. get boundingBoxSize(): Vector3;
  125306. /**
  125307. * Instantiates an HDRTexture from the following parameters.
  125308. *
  125309. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  125310. * @param scene The scene the texture will be used in
  125311. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  125312. * @param noMipmap Forces to not generate the mipmap if true
  125313. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  125314. * @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)
  125315. * @param reserved Reserved flag for internal use.
  125316. */
  125317. 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>);
  125318. /**
  125319. * Get the current class name of the texture useful for serialization or dynamic coding.
  125320. * @returns "HDRCubeTexture"
  125321. */
  125322. getClassName(): string;
  125323. /**
  125324. * Occurs when the file is raw .hdr file.
  125325. */
  125326. private loadTexture;
  125327. clone(): HDRCubeTexture;
  125328. delayLoad(): void;
  125329. /**
  125330. * Get the texture reflection matrix used to rotate/transform the reflection.
  125331. * @returns the reflection matrix
  125332. */
  125333. getReflectionTextureMatrix(): Matrix;
  125334. /**
  125335. * Set the texture reflection matrix used to rotate/transform the reflection.
  125336. * @param value Define the reflection matrix to set
  125337. */
  125338. setReflectionTextureMatrix(value: Matrix): void;
  125339. /**
  125340. * Parses a JSON representation of an HDR Texture in order to create the texture
  125341. * @param parsedTexture Define the JSON representation
  125342. * @param scene Define the scene the texture should be created in
  125343. * @param rootUrl Define the root url in case we need to load relative dependencies
  125344. * @returns the newly created texture after parsing
  125345. */
  125346. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  125347. serialize(): any;
  125348. }
  125349. }
  125350. declare module BABYLON {
  125351. /**
  125352. * Class used to control physics engine
  125353. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125354. */
  125355. export class PhysicsEngine implements IPhysicsEngine {
  125356. private _physicsPlugin;
  125357. /**
  125358. * Global value used to control the smallest number supported by the simulation
  125359. */
  125360. static Epsilon: number;
  125361. private _impostors;
  125362. private _joints;
  125363. private _subTimeStep;
  125364. /**
  125365. * Gets the gravity vector used by the simulation
  125366. */
  125367. gravity: Vector3;
  125368. /**
  125369. * Factory used to create the default physics plugin.
  125370. * @returns The default physics plugin
  125371. */
  125372. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  125373. /**
  125374. * Creates a new Physics Engine
  125375. * @param gravity defines the gravity vector used by the simulation
  125376. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  125377. */
  125378. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  125379. /**
  125380. * Sets the gravity vector used by the simulation
  125381. * @param gravity defines the gravity vector to use
  125382. */
  125383. setGravity(gravity: Vector3): void;
  125384. /**
  125385. * Set the time step of the physics engine.
  125386. * Default is 1/60.
  125387. * To slow it down, enter 1/600 for example.
  125388. * To speed it up, 1/30
  125389. * @param newTimeStep defines the new timestep to apply to this world.
  125390. */
  125391. setTimeStep(newTimeStep?: number): void;
  125392. /**
  125393. * Get the time step of the physics engine.
  125394. * @returns the current time step
  125395. */
  125396. getTimeStep(): number;
  125397. /**
  125398. * Set the sub time step of the physics engine.
  125399. * Default is 0 meaning there is no sub steps
  125400. * To increase physics resolution precision, set a small value (like 1 ms)
  125401. * @param subTimeStep defines the new sub timestep used for physics resolution.
  125402. */
  125403. setSubTimeStep(subTimeStep?: number): void;
  125404. /**
  125405. * Get the sub time step of the physics engine.
  125406. * @returns the current sub time step
  125407. */
  125408. getSubTimeStep(): number;
  125409. /**
  125410. * Release all resources
  125411. */
  125412. dispose(): void;
  125413. /**
  125414. * Gets the name of the current physics plugin
  125415. * @returns the name of the plugin
  125416. */
  125417. getPhysicsPluginName(): string;
  125418. /**
  125419. * Adding a new impostor for the impostor tracking.
  125420. * This will be done by the impostor itself.
  125421. * @param impostor the impostor to add
  125422. */
  125423. addImpostor(impostor: PhysicsImpostor): void;
  125424. /**
  125425. * Remove an impostor from the engine.
  125426. * This impostor and its mesh will not longer be updated by the physics engine.
  125427. * @param impostor the impostor to remove
  125428. */
  125429. removeImpostor(impostor: PhysicsImpostor): void;
  125430. /**
  125431. * Add a joint to the physics engine
  125432. * @param mainImpostor defines the main impostor to which the joint is added.
  125433. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  125434. * @param joint defines the joint that will connect both impostors.
  125435. */
  125436. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  125437. /**
  125438. * Removes a joint from the simulation
  125439. * @param mainImpostor defines the impostor used with the joint
  125440. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  125441. * @param joint defines the joint to remove
  125442. */
  125443. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  125444. /**
  125445. * Called by the scene. No need to call it.
  125446. * @param delta defines the timespam between frames
  125447. */
  125448. _step(delta: number): void;
  125449. /**
  125450. * Gets the current plugin used to run the simulation
  125451. * @returns current plugin
  125452. */
  125453. getPhysicsPlugin(): IPhysicsEnginePlugin;
  125454. /**
  125455. * Gets the list of physic impostors
  125456. * @returns an array of PhysicsImpostor
  125457. */
  125458. getImpostors(): Array<PhysicsImpostor>;
  125459. /**
  125460. * Gets the impostor for a physics enabled object
  125461. * @param object defines the object impersonated by the impostor
  125462. * @returns the PhysicsImpostor or null if not found
  125463. */
  125464. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  125465. /**
  125466. * Gets the impostor for a physics body object
  125467. * @param body defines physics body used by the impostor
  125468. * @returns the PhysicsImpostor or null if not found
  125469. */
  125470. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  125471. /**
  125472. * Does a raycast in the physics world
  125473. * @param from when should the ray start?
  125474. * @param to when should the ray end?
  125475. * @returns PhysicsRaycastResult
  125476. */
  125477. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  125478. }
  125479. }
  125480. declare module BABYLON {
  125481. /** @hidden */
  125482. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  125483. private _useDeltaForWorldStep;
  125484. world: any;
  125485. name: string;
  125486. private _physicsMaterials;
  125487. private _fixedTimeStep;
  125488. private _cannonRaycastResult;
  125489. private _raycastResult;
  125490. private _physicsBodysToRemoveAfterStep;
  125491. BJSCANNON: any;
  125492. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  125493. setGravity(gravity: Vector3): void;
  125494. setTimeStep(timeStep: number): void;
  125495. getTimeStep(): number;
  125496. executeStep(delta: number): void;
  125497. private _removeMarkedPhysicsBodiesFromWorld;
  125498. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125499. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125500. generatePhysicsBody(impostor: PhysicsImpostor): void;
  125501. private _processChildMeshes;
  125502. removePhysicsBody(impostor: PhysicsImpostor): void;
  125503. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  125504. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  125505. private _addMaterial;
  125506. private _checkWithEpsilon;
  125507. private _createShape;
  125508. private _createHeightmap;
  125509. private _minus90X;
  125510. private _plus90X;
  125511. private _tmpPosition;
  125512. private _tmpDeltaPosition;
  125513. private _tmpUnityRotation;
  125514. private _updatePhysicsBodyTransformation;
  125515. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  125516. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  125517. isSupported(): boolean;
  125518. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125519. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125520. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125521. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125522. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  125523. getBodyMass(impostor: PhysicsImpostor): number;
  125524. getBodyFriction(impostor: PhysicsImpostor): number;
  125525. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  125526. getBodyRestitution(impostor: PhysicsImpostor): number;
  125527. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  125528. sleepBody(impostor: PhysicsImpostor): void;
  125529. wakeUpBody(impostor: PhysicsImpostor): void;
  125530. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  125531. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  125532. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  125533. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  125534. getRadius(impostor: PhysicsImpostor): number;
  125535. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  125536. dispose(): void;
  125537. private _extendNamespace;
  125538. /**
  125539. * Does a raycast in the physics world
  125540. * @param from when should the ray start?
  125541. * @param to when should the ray end?
  125542. * @returns PhysicsRaycastResult
  125543. */
  125544. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  125545. }
  125546. }
  125547. declare module BABYLON {
  125548. /** @hidden */
  125549. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  125550. world: any;
  125551. name: string;
  125552. BJSOIMO: any;
  125553. private _raycastResult;
  125554. constructor(iterations?: number, oimoInjection?: any);
  125555. setGravity(gravity: Vector3): void;
  125556. setTimeStep(timeStep: number): void;
  125557. getTimeStep(): number;
  125558. private _tmpImpostorsArray;
  125559. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  125560. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125561. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125562. generatePhysicsBody(impostor: PhysicsImpostor): void;
  125563. private _tmpPositionVector;
  125564. removePhysicsBody(impostor: PhysicsImpostor): void;
  125565. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  125566. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  125567. isSupported(): boolean;
  125568. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  125569. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  125570. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125571. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125572. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125573. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125574. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  125575. getBodyMass(impostor: PhysicsImpostor): number;
  125576. getBodyFriction(impostor: PhysicsImpostor): number;
  125577. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  125578. getBodyRestitution(impostor: PhysicsImpostor): number;
  125579. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  125580. sleepBody(impostor: PhysicsImpostor): void;
  125581. wakeUpBody(impostor: PhysicsImpostor): void;
  125582. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  125583. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  125584. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  125585. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  125586. getRadius(impostor: PhysicsImpostor): number;
  125587. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  125588. dispose(): void;
  125589. /**
  125590. * Does a raycast in the physics world
  125591. * @param from when should the ray start?
  125592. * @param to when should the ray end?
  125593. * @returns PhysicsRaycastResult
  125594. */
  125595. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  125596. }
  125597. }
  125598. declare module BABYLON {
  125599. /**
  125600. * Class containing static functions to help procedurally build meshes
  125601. */
  125602. export class RibbonBuilder {
  125603. /**
  125604. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125605. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125606. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125607. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125608. * * 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
  125609. * * 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
  125610. * * 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
  125611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125613. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125614. * * 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
  125615. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125616. * * 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
  125617. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125619. * @param name defines the name of the mesh
  125620. * @param options defines the options used to create the mesh
  125621. * @param scene defines the hosting scene
  125622. * @returns the ribbon mesh
  125623. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125624. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125625. */
  125626. static CreateRibbon(name: string, options: {
  125627. pathArray: Vector3[][];
  125628. closeArray?: boolean;
  125629. closePath?: boolean;
  125630. offset?: number;
  125631. updatable?: boolean;
  125632. sideOrientation?: number;
  125633. frontUVs?: Vector4;
  125634. backUVs?: Vector4;
  125635. instance?: Mesh;
  125636. invertUV?: boolean;
  125637. uvs?: Vector2[];
  125638. colors?: Color4[];
  125639. }, scene?: Nullable<Scene>): Mesh;
  125640. }
  125641. }
  125642. declare module BABYLON {
  125643. /**
  125644. * Class containing static functions to help procedurally build meshes
  125645. */
  125646. export class ShapeBuilder {
  125647. /**
  125648. * 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.
  125649. * * 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.
  125650. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125651. * * 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.
  125652. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125653. * * 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
  125654. * * 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
  125655. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125660. * @param name defines the name of the mesh
  125661. * @param options defines the options used to create the mesh
  125662. * @param scene defines the hosting scene
  125663. * @returns the extruded shape mesh
  125664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125666. */
  125667. static ExtrudeShape(name: string, options: {
  125668. shape: Vector3[];
  125669. path: Vector3[];
  125670. scale?: number;
  125671. rotation?: number;
  125672. cap?: number;
  125673. updatable?: boolean;
  125674. sideOrientation?: number;
  125675. frontUVs?: Vector4;
  125676. backUVs?: Vector4;
  125677. instance?: Mesh;
  125678. invertUV?: boolean;
  125679. }, scene?: Nullable<Scene>): Mesh;
  125680. /**
  125681. * Creates an custom extruded shape mesh.
  125682. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125683. * * 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.
  125684. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125685. * * 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
  125686. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125687. * * 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
  125688. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125689. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125690. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125691. * * 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
  125692. * * 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
  125693. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125698. * @param name defines the name of the mesh
  125699. * @param options defines the options used to create the mesh
  125700. * @param scene defines the hosting scene
  125701. * @returns the custom extruded shape mesh
  125702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125703. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125705. */
  125706. static ExtrudeShapeCustom(name: string, options: {
  125707. shape: Vector3[];
  125708. path: Vector3[];
  125709. scaleFunction?: any;
  125710. rotationFunction?: any;
  125711. ribbonCloseArray?: boolean;
  125712. ribbonClosePath?: boolean;
  125713. cap?: number;
  125714. updatable?: boolean;
  125715. sideOrientation?: number;
  125716. frontUVs?: Vector4;
  125717. backUVs?: Vector4;
  125718. instance?: Mesh;
  125719. invertUV?: boolean;
  125720. }, scene?: Nullable<Scene>): Mesh;
  125721. private static _ExtrudeShapeGeneric;
  125722. }
  125723. }
  125724. declare module BABYLON {
  125725. /**
  125726. * AmmoJS Physics plugin
  125727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  125728. * @see https://github.com/kripken/ammo.js/
  125729. */
  125730. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  125731. private _useDeltaForWorldStep;
  125732. /**
  125733. * Reference to the Ammo library
  125734. */
  125735. bjsAMMO: any;
  125736. /**
  125737. * Created ammoJS world which physics bodies are added to
  125738. */
  125739. world: any;
  125740. /**
  125741. * Name of the plugin
  125742. */
  125743. name: string;
  125744. private _timeStep;
  125745. private _fixedTimeStep;
  125746. private _maxSteps;
  125747. private _tmpQuaternion;
  125748. private _tmpAmmoTransform;
  125749. private _tmpAmmoQuaternion;
  125750. private _tmpAmmoConcreteContactResultCallback;
  125751. private _collisionConfiguration;
  125752. private _dispatcher;
  125753. private _overlappingPairCache;
  125754. private _solver;
  125755. private _softBodySolver;
  125756. private _tmpAmmoVectorA;
  125757. private _tmpAmmoVectorB;
  125758. private _tmpAmmoVectorC;
  125759. private _tmpAmmoVectorD;
  125760. private _tmpContactCallbackResult;
  125761. private _tmpAmmoVectorRCA;
  125762. private _tmpAmmoVectorRCB;
  125763. private _raycastResult;
  125764. private static readonly DISABLE_COLLISION_FLAG;
  125765. private static readonly KINEMATIC_FLAG;
  125766. private static readonly DISABLE_DEACTIVATION_FLAG;
  125767. /**
  125768. * Initializes the ammoJS plugin
  125769. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  125770. * @param ammoInjection can be used to inject your own ammo reference
  125771. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  125772. */
  125773. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  125774. /**
  125775. * Sets the gravity of the physics world (m/(s^2))
  125776. * @param gravity Gravity to set
  125777. */
  125778. setGravity(gravity: Vector3): void;
  125779. /**
  125780. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  125781. * @param timeStep timestep to use in seconds
  125782. */
  125783. setTimeStep(timeStep: number): void;
  125784. /**
  125785. * 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)
  125786. * @param fixedTimeStep fixedTimeStep to use in seconds
  125787. */
  125788. setFixedTimeStep(fixedTimeStep: number): void;
  125789. /**
  125790. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  125791. * @param maxSteps the maximum number of steps by the physics engine per frame
  125792. */
  125793. setMaxSteps(maxSteps: number): void;
  125794. /**
  125795. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  125796. * @returns the current timestep in seconds
  125797. */
  125798. getTimeStep(): number;
  125799. /**
  125800. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  125801. */
  125802. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  125803. private _isImpostorInContact;
  125804. private _isImpostorPairInContact;
  125805. private _stepSimulation;
  125806. /**
  125807. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  125808. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  125809. * After the step the babylon meshes are set to the position of the physics imposters
  125810. * @param delta amount of time to step forward
  125811. * @param impostors array of imposters to update before/after the step
  125812. */
  125813. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  125814. /**
  125815. * Update babylon mesh to match physics world object
  125816. * @param impostor imposter to match
  125817. */
  125818. private _afterSoftStep;
  125819. /**
  125820. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  125821. * @param impostor imposter to match
  125822. */
  125823. private _ropeStep;
  125824. /**
  125825. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  125826. * @param impostor imposter to match
  125827. */
  125828. private _softbodyOrClothStep;
  125829. private _tmpVector;
  125830. private _tmpMatrix;
  125831. /**
  125832. * Applies an impulse on the imposter
  125833. * @param impostor imposter to apply impulse to
  125834. * @param force amount of force to be applied to the imposter
  125835. * @param contactPoint the location to apply the impulse on the imposter
  125836. */
  125837. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125838. /**
  125839. * Applies a force on the imposter
  125840. * @param impostor imposter to apply force
  125841. * @param force amount of force to be applied to the imposter
  125842. * @param contactPoint the location to apply the force on the imposter
  125843. */
  125844. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125845. /**
  125846. * Creates a physics body using the plugin
  125847. * @param impostor the imposter to create the physics body on
  125848. */
  125849. generatePhysicsBody(impostor: PhysicsImpostor): void;
  125850. /**
  125851. * Removes the physics body from the imposter and disposes of the body's memory
  125852. * @param impostor imposter to remove the physics body from
  125853. */
  125854. removePhysicsBody(impostor: PhysicsImpostor): void;
  125855. /**
  125856. * Generates a joint
  125857. * @param impostorJoint the imposter joint to create the joint with
  125858. */
  125859. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  125860. /**
  125861. * Removes a joint
  125862. * @param impostorJoint the imposter joint to remove the joint from
  125863. */
  125864. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  125865. private _addMeshVerts;
  125866. /**
  125867. * Initialise the soft body vertices to match its object's (mesh) vertices
  125868. * Softbody vertices (nodes) are in world space and to match this
  125869. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  125870. * @param impostor to create the softbody for
  125871. */
  125872. private _softVertexData;
  125873. /**
  125874. * Create an impostor's soft body
  125875. * @param impostor to create the softbody for
  125876. */
  125877. private _createSoftbody;
  125878. /**
  125879. * Create cloth for an impostor
  125880. * @param impostor to create the softbody for
  125881. */
  125882. private _createCloth;
  125883. /**
  125884. * Create rope for an impostor
  125885. * @param impostor to create the softbody for
  125886. */
  125887. private _createRope;
  125888. /**
  125889. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  125890. * @param impostor to create the custom physics shape for
  125891. */
  125892. private _createCustom;
  125893. private _addHullVerts;
  125894. private _createShape;
  125895. /**
  125896. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  125897. * @param impostor imposter containing the physics body and babylon object
  125898. */
  125899. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  125900. /**
  125901. * Sets the babylon object's position/rotation from the physics body's position/rotation
  125902. * @param impostor imposter containing the physics body and babylon object
  125903. * @param newPosition new position
  125904. * @param newRotation new rotation
  125905. */
  125906. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  125907. /**
  125908. * If this plugin is supported
  125909. * @returns true if its supported
  125910. */
  125911. isSupported(): boolean;
  125912. /**
  125913. * Sets the linear velocity of the physics body
  125914. * @param impostor imposter to set the velocity on
  125915. * @param velocity velocity to set
  125916. */
  125917. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125918. /**
  125919. * Sets the angular velocity of the physics body
  125920. * @param impostor imposter to set the velocity on
  125921. * @param velocity velocity to set
  125922. */
  125923. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125924. /**
  125925. * gets the linear velocity
  125926. * @param impostor imposter to get linear velocity from
  125927. * @returns linear velocity
  125928. */
  125929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125930. /**
  125931. * gets the angular velocity
  125932. * @param impostor imposter to get angular velocity from
  125933. * @returns angular velocity
  125934. */
  125935. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125936. /**
  125937. * Sets the mass of physics body
  125938. * @param impostor imposter to set the mass on
  125939. * @param mass mass to set
  125940. */
  125941. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  125942. /**
  125943. * Gets the mass of the physics body
  125944. * @param impostor imposter to get the mass from
  125945. * @returns mass
  125946. */
  125947. getBodyMass(impostor: PhysicsImpostor): number;
  125948. /**
  125949. * Gets friction of the impostor
  125950. * @param impostor impostor to get friction from
  125951. * @returns friction value
  125952. */
  125953. getBodyFriction(impostor: PhysicsImpostor): number;
  125954. /**
  125955. * Sets friction of the impostor
  125956. * @param impostor impostor to set friction on
  125957. * @param friction friction value
  125958. */
  125959. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  125960. /**
  125961. * Gets restitution of the impostor
  125962. * @param impostor impostor to get restitution from
  125963. * @returns restitution value
  125964. */
  125965. getBodyRestitution(impostor: PhysicsImpostor): number;
  125966. /**
  125967. * Sets resitution of the impostor
  125968. * @param impostor impostor to set resitution on
  125969. * @param restitution resitution value
  125970. */
  125971. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  125972. /**
  125973. * Gets pressure inside the impostor
  125974. * @param impostor impostor to get pressure from
  125975. * @returns pressure value
  125976. */
  125977. getBodyPressure(impostor: PhysicsImpostor): number;
  125978. /**
  125979. * Sets pressure inside a soft body impostor
  125980. * Cloth and rope must remain 0 pressure
  125981. * @param impostor impostor to set pressure on
  125982. * @param pressure pressure value
  125983. */
  125984. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  125985. /**
  125986. * Gets stiffness of the impostor
  125987. * @param impostor impostor to get stiffness from
  125988. * @returns pressure value
  125989. */
  125990. getBodyStiffness(impostor: PhysicsImpostor): number;
  125991. /**
  125992. * Sets stiffness of the impostor
  125993. * @param impostor impostor to set stiffness on
  125994. * @param stiffness stiffness value from 0 to 1
  125995. */
  125996. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  125997. /**
  125998. * Gets velocityIterations of the impostor
  125999. * @param impostor impostor to get velocity iterations from
  126000. * @returns velocityIterations value
  126001. */
  126002. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  126003. /**
  126004. * Sets velocityIterations of the impostor
  126005. * @param impostor impostor to set velocity iterations on
  126006. * @param velocityIterations velocityIterations value
  126007. */
  126008. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  126009. /**
  126010. * Gets positionIterations of the impostor
  126011. * @param impostor impostor to get position iterations from
  126012. * @returns positionIterations value
  126013. */
  126014. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  126015. /**
  126016. * Sets positionIterations of the impostor
  126017. * @param impostor impostor to set position on
  126018. * @param positionIterations positionIterations value
  126019. */
  126020. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  126021. /**
  126022. * Append an anchor to a cloth object
  126023. * @param impostor is the cloth impostor to add anchor to
  126024. * @param otherImpostor is the rigid impostor to anchor to
  126025. * @param width ratio across width from 0 to 1
  126026. * @param height ratio up height from 0 to 1
  126027. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  126028. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  126029. */
  126030. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  126031. /**
  126032. * Append an hook to a rope object
  126033. * @param impostor is the rope impostor to add hook to
  126034. * @param otherImpostor is the rigid impostor to hook to
  126035. * @param length ratio along the rope from 0 to 1
  126036. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  126037. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  126038. */
  126039. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  126040. /**
  126041. * Sleeps the physics body and stops it from being active
  126042. * @param impostor impostor to sleep
  126043. */
  126044. sleepBody(impostor: PhysicsImpostor): void;
  126045. /**
  126046. * Activates the physics body
  126047. * @param impostor impostor to activate
  126048. */
  126049. wakeUpBody(impostor: PhysicsImpostor): void;
  126050. /**
  126051. * Updates the distance parameters of the joint
  126052. * @param joint joint to update
  126053. * @param maxDistance maximum distance of the joint
  126054. * @param minDistance minimum distance of the joint
  126055. */
  126056. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  126057. /**
  126058. * Sets a motor on the joint
  126059. * @param joint joint to set motor on
  126060. * @param speed speed of the motor
  126061. * @param maxForce maximum force of the motor
  126062. * @param motorIndex index of the motor
  126063. */
  126064. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  126065. /**
  126066. * Sets the motors limit
  126067. * @param joint joint to set limit on
  126068. * @param upperLimit upper limit
  126069. * @param lowerLimit lower limit
  126070. */
  126071. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  126072. /**
  126073. * Syncs the position and rotation of a mesh with the impostor
  126074. * @param mesh mesh to sync
  126075. * @param impostor impostor to update the mesh with
  126076. */
  126077. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  126078. /**
  126079. * Gets the radius of the impostor
  126080. * @param impostor impostor to get radius from
  126081. * @returns the radius
  126082. */
  126083. getRadius(impostor: PhysicsImpostor): number;
  126084. /**
  126085. * Gets the box size of the impostor
  126086. * @param impostor impostor to get box size from
  126087. * @param result the resulting box size
  126088. */
  126089. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  126090. /**
  126091. * Disposes of the impostor
  126092. */
  126093. dispose(): void;
  126094. /**
  126095. * Does a raycast in the physics world
  126096. * @param from when should the ray start?
  126097. * @param to when should the ray end?
  126098. * @returns PhysicsRaycastResult
  126099. */
  126100. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  126101. }
  126102. }
  126103. declare module BABYLON {
  126104. interface AbstractScene {
  126105. /**
  126106. * The list of reflection probes added to the scene
  126107. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  126108. */
  126109. reflectionProbes: Array<ReflectionProbe>;
  126110. /**
  126111. * Removes the given reflection probe from this scene.
  126112. * @param toRemove The reflection probe to remove
  126113. * @returns The index of the removed reflection probe
  126114. */
  126115. removeReflectionProbe(toRemove: ReflectionProbe): number;
  126116. /**
  126117. * Adds the given reflection probe to this scene.
  126118. * @param newReflectionProbe The reflection probe to add
  126119. */
  126120. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  126121. }
  126122. /**
  126123. * Class used to generate realtime reflection / refraction cube textures
  126124. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  126125. */
  126126. export class ReflectionProbe {
  126127. /** defines the name of the probe */
  126128. name: string;
  126129. private _scene;
  126130. private _renderTargetTexture;
  126131. private _projectionMatrix;
  126132. private _viewMatrix;
  126133. private _target;
  126134. private _add;
  126135. private _attachedMesh;
  126136. private _invertYAxis;
  126137. /** Gets or sets probe position (center of the cube map) */
  126138. position: Vector3;
  126139. /**
  126140. * Creates a new reflection probe
  126141. * @param name defines the name of the probe
  126142. * @param size defines the texture resolution (for each face)
  126143. * @param scene defines the hosting scene
  126144. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  126145. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  126146. */
  126147. constructor(
  126148. /** defines the name of the probe */
  126149. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  126150. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  126151. get samples(): number;
  126152. set samples(value: number);
  126153. /** Gets or sets the refresh rate to use (on every frame by default) */
  126154. get refreshRate(): number;
  126155. set refreshRate(value: number);
  126156. /**
  126157. * Gets the hosting scene
  126158. * @returns a Scene
  126159. */
  126160. getScene(): Scene;
  126161. /** Gets the internal CubeTexture used to render to */
  126162. get cubeTexture(): RenderTargetTexture;
  126163. /** Gets the list of meshes to render */
  126164. get renderList(): Nullable<AbstractMesh[]>;
  126165. /**
  126166. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  126167. * @param mesh defines the mesh to attach to
  126168. */
  126169. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  126170. /**
  126171. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  126172. * @param renderingGroupId The rendering group id corresponding to its index
  126173. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126174. */
  126175. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  126176. /**
  126177. * Clean all associated resources
  126178. */
  126179. dispose(): void;
  126180. /**
  126181. * Converts the reflection probe information to a readable string for debug purpose.
  126182. * @param fullDetails Supports for multiple levels of logging within scene loading
  126183. * @returns the human readable reflection probe info
  126184. */
  126185. toString(fullDetails?: boolean): string;
  126186. /**
  126187. * Get the class name of the relfection probe.
  126188. * @returns "ReflectionProbe"
  126189. */
  126190. getClassName(): string;
  126191. /**
  126192. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  126193. * @returns The JSON representation of the texture
  126194. */
  126195. serialize(): any;
  126196. /**
  126197. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  126198. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  126199. * @param scene Define the scene the parsed reflection probe should be instantiated in
  126200. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  126201. * @returns The parsed reflection probe if successful
  126202. */
  126203. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  126204. }
  126205. }
  126206. declare module BABYLON {
  126207. /** @hidden */
  126208. export var _BabylonLoaderRegistered: boolean;
  126209. /**
  126210. * Helps setting up some configuration for the babylon file loader.
  126211. */
  126212. export class BabylonFileLoaderConfiguration {
  126213. /**
  126214. * The loader does not allow injecting custom physix engine into the plugins.
  126215. * Unfortunately in ES6, we need to manually inject them into the plugin.
  126216. * So you could set this variable to your engine import to make it work.
  126217. */
  126218. static LoaderInjectedPhysicsEngine: any;
  126219. }
  126220. }
  126221. declare module BABYLON {
  126222. /**
  126223. * The Physically based simple base material of BJS.
  126224. *
  126225. * This enables better naming and convention enforcements on top of the pbrMaterial.
  126226. * It is used as the base class for both the specGloss and metalRough conventions.
  126227. */
  126228. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  126229. /**
  126230. * Number of Simultaneous lights allowed on the material.
  126231. */
  126232. maxSimultaneousLights: number;
  126233. /**
  126234. * If sets to true, disables all the lights affecting the material.
  126235. */
  126236. disableLighting: boolean;
  126237. /**
  126238. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  126239. */
  126240. environmentTexture: BaseTexture;
  126241. /**
  126242. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126243. */
  126244. invertNormalMapX: boolean;
  126245. /**
  126246. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126247. */
  126248. invertNormalMapY: boolean;
  126249. /**
  126250. * Normal map used in the model.
  126251. */
  126252. normalTexture: BaseTexture;
  126253. /**
  126254. * Emissivie color used to self-illuminate the model.
  126255. */
  126256. emissiveColor: Color3;
  126257. /**
  126258. * Emissivie texture used to self-illuminate the model.
  126259. */
  126260. emissiveTexture: BaseTexture;
  126261. /**
  126262. * Occlusion Channel Strenght.
  126263. */
  126264. occlusionStrength: number;
  126265. /**
  126266. * Occlusion Texture of the material (adding extra occlusion effects).
  126267. */
  126268. occlusionTexture: BaseTexture;
  126269. /**
  126270. * Defines the alpha limits in alpha test mode.
  126271. */
  126272. alphaCutOff: number;
  126273. /**
  126274. * Gets the current double sided mode.
  126275. */
  126276. get doubleSided(): boolean;
  126277. /**
  126278. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126279. */
  126280. set doubleSided(value: boolean);
  126281. /**
  126282. * Stores the pre-calculated light information of a mesh in a texture.
  126283. */
  126284. lightmapTexture: BaseTexture;
  126285. /**
  126286. * If true, the light map contains occlusion information instead of lighting info.
  126287. */
  126288. useLightmapAsShadowmap: boolean;
  126289. /**
  126290. * Instantiates a new PBRMaterial instance.
  126291. *
  126292. * @param name The material name
  126293. * @param scene The scene the material will be use in.
  126294. */
  126295. constructor(name: string, scene: Scene);
  126296. getClassName(): string;
  126297. }
  126298. }
  126299. declare module BABYLON {
  126300. /**
  126301. * The PBR material of BJS following the metal roughness convention.
  126302. *
  126303. * This fits to the PBR convention in the GLTF definition:
  126304. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  126305. */
  126306. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  126307. /**
  126308. * The base color has two different interpretations depending on the value of metalness.
  126309. * When the material is a metal, the base color is the specific measured reflectance value
  126310. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  126311. * of the material.
  126312. */
  126313. baseColor: Color3;
  126314. /**
  126315. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  126316. * well as opacity information in the alpha channel.
  126317. */
  126318. baseTexture: BaseTexture;
  126319. /**
  126320. * Specifies the metallic scalar value of the material.
  126321. * Can also be used to scale the metalness values of the metallic texture.
  126322. */
  126323. metallic: number;
  126324. /**
  126325. * Specifies the roughness scalar value of the material.
  126326. * Can also be used to scale the roughness values of the metallic texture.
  126327. */
  126328. roughness: number;
  126329. /**
  126330. * Texture containing both the metallic value in the B channel and the
  126331. * roughness value in the G channel to keep better precision.
  126332. */
  126333. metallicRoughnessTexture: BaseTexture;
  126334. /**
  126335. * Instantiates a new PBRMetalRoughnessMaterial instance.
  126336. *
  126337. * @param name The material name
  126338. * @param scene The scene the material will be use in.
  126339. */
  126340. constructor(name: string, scene: Scene);
  126341. /**
  126342. * Return the currrent class name of the material.
  126343. */
  126344. getClassName(): string;
  126345. /**
  126346. * Makes a duplicate of the current material.
  126347. * @param name - name to use for the new material.
  126348. */
  126349. clone(name: string): PBRMetallicRoughnessMaterial;
  126350. /**
  126351. * Serialize the material to a parsable JSON object.
  126352. */
  126353. serialize(): any;
  126354. /**
  126355. * Parses a JSON object correponding to the serialize function.
  126356. */
  126357. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  126358. }
  126359. }
  126360. declare module BABYLON {
  126361. /**
  126362. * The PBR material of BJS following the specular glossiness convention.
  126363. *
  126364. * This fits to the PBR convention in the GLTF definition:
  126365. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  126366. */
  126367. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  126368. /**
  126369. * Specifies the diffuse color of the material.
  126370. */
  126371. diffuseColor: Color3;
  126372. /**
  126373. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  126374. * channel.
  126375. */
  126376. diffuseTexture: BaseTexture;
  126377. /**
  126378. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  126379. */
  126380. specularColor: Color3;
  126381. /**
  126382. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  126383. */
  126384. glossiness: number;
  126385. /**
  126386. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  126387. */
  126388. specularGlossinessTexture: BaseTexture;
  126389. /**
  126390. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  126391. *
  126392. * @param name The material name
  126393. * @param scene The scene the material will be use in.
  126394. */
  126395. constructor(name: string, scene: Scene);
  126396. /**
  126397. * Return the currrent class name of the material.
  126398. */
  126399. getClassName(): string;
  126400. /**
  126401. * Makes a duplicate of the current material.
  126402. * @param name - name to use for the new material.
  126403. */
  126404. clone(name: string): PBRSpecularGlossinessMaterial;
  126405. /**
  126406. * Serialize the material to a parsable JSON object.
  126407. */
  126408. serialize(): any;
  126409. /**
  126410. * Parses a JSON object correponding to the serialize function.
  126411. */
  126412. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  126413. }
  126414. }
  126415. declare module BABYLON {
  126416. /**
  126417. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  126418. * It can help converting any input color in a desired output one. This can then be used to create effects
  126419. * from sepia, black and white to sixties or futuristic rendering...
  126420. *
  126421. * The only supported format is currently 3dl.
  126422. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  126423. */
  126424. export class ColorGradingTexture extends BaseTexture {
  126425. /**
  126426. * The current texture matrix. (will always be identity in color grading texture)
  126427. */
  126428. private _textureMatrix;
  126429. /**
  126430. * The texture URL.
  126431. */
  126432. url: string;
  126433. /**
  126434. * Empty line regex stored for GC.
  126435. */
  126436. private static _noneEmptyLineRegex;
  126437. private _engine;
  126438. /**
  126439. * Instantiates a ColorGradingTexture from the following parameters.
  126440. *
  126441. * @param url The location of the color gradind data (currently only supporting 3dl)
  126442. * @param scene The scene the texture will be used in
  126443. */
  126444. constructor(url: string, scene: Scene);
  126445. /**
  126446. * Returns the texture matrix used in most of the material.
  126447. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  126448. */
  126449. getTextureMatrix(): Matrix;
  126450. /**
  126451. * Occurs when the file being loaded is a .3dl LUT file.
  126452. */
  126453. private load3dlTexture;
  126454. /**
  126455. * Starts the loading process of the texture.
  126456. */
  126457. private loadTexture;
  126458. /**
  126459. * Clones the color gradind texture.
  126460. */
  126461. clone(): ColorGradingTexture;
  126462. /**
  126463. * Called during delayed load for textures.
  126464. */
  126465. delayLoad(): void;
  126466. /**
  126467. * Parses a color grading texture serialized by Babylon.
  126468. * @param parsedTexture The texture information being parsedTexture
  126469. * @param scene The scene to load the texture in
  126470. * @param rootUrl The root url of the data assets to load
  126471. * @return A color gradind texture
  126472. */
  126473. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  126474. /**
  126475. * Serializes the LUT texture to json format.
  126476. */
  126477. serialize(): any;
  126478. }
  126479. }
  126480. declare module BABYLON {
  126481. /**
  126482. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  126483. */
  126484. export class EquiRectangularCubeTexture extends BaseTexture {
  126485. /** The six faces of the cube. */
  126486. private static _FacesMapping;
  126487. private _noMipmap;
  126488. private _onLoad;
  126489. private _onError;
  126490. /** The size of the cubemap. */
  126491. private _size;
  126492. /** The buffer of the image. */
  126493. private _buffer;
  126494. /** The width of the input image. */
  126495. private _width;
  126496. /** The height of the input image. */
  126497. private _height;
  126498. /** The URL to the image. */
  126499. url: string;
  126500. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  126501. coordinatesMode: number;
  126502. /**
  126503. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  126504. * @param url The location of the image
  126505. * @param scene The scene the texture will be used in
  126506. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  126507. * @param noMipmap Forces to not generate the mipmap if true
  126508. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  126509. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  126510. * @param onLoad — defines a callback called when texture is loaded
  126511. * @param onError — defines a callback called if there is an error
  126512. */
  126513. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  126514. /**
  126515. * Load the image data, by putting the image on a canvas and extracting its buffer.
  126516. */
  126517. private loadImage;
  126518. /**
  126519. * Convert the image buffer into a cubemap and create a CubeTexture.
  126520. */
  126521. private loadTexture;
  126522. /**
  126523. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  126524. * @param buffer The ArrayBuffer that should be converted.
  126525. * @returns The buffer as Float32Array.
  126526. */
  126527. private getFloat32ArrayFromArrayBuffer;
  126528. /**
  126529. * Get the current class name of the texture useful for serialization or dynamic coding.
  126530. * @returns "EquiRectangularCubeTexture"
  126531. */
  126532. getClassName(): string;
  126533. /**
  126534. * Create a clone of the current EquiRectangularCubeTexture and return it.
  126535. * @returns A clone of the current EquiRectangularCubeTexture.
  126536. */
  126537. clone(): EquiRectangularCubeTexture;
  126538. }
  126539. }
  126540. declare module BABYLON {
  126541. /**
  126542. * Based on jsTGALoader - Javascript loader for TGA file
  126543. * By Vincent Thibault
  126544. * @see http://blog.robrowser.com/javascript-tga-loader.html
  126545. */
  126546. export class TGATools {
  126547. private static _TYPE_INDEXED;
  126548. private static _TYPE_RGB;
  126549. private static _TYPE_GREY;
  126550. private static _TYPE_RLE_INDEXED;
  126551. private static _TYPE_RLE_RGB;
  126552. private static _TYPE_RLE_GREY;
  126553. private static _ORIGIN_MASK;
  126554. private static _ORIGIN_SHIFT;
  126555. private static _ORIGIN_BL;
  126556. private static _ORIGIN_BR;
  126557. private static _ORIGIN_UL;
  126558. private static _ORIGIN_UR;
  126559. /**
  126560. * Gets the header of a TGA file
  126561. * @param data defines the TGA data
  126562. * @returns the header
  126563. */
  126564. static GetTGAHeader(data: Uint8Array): any;
  126565. /**
  126566. * Uploads TGA content to a Babylon Texture
  126567. * @hidden
  126568. */
  126569. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  126570. /** @hidden */
  126571. 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;
  126572. /** @hidden */
  126573. 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;
  126574. /** @hidden */
  126575. 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;
  126576. /** @hidden */
  126577. 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;
  126578. /** @hidden */
  126579. 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;
  126580. /** @hidden */
  126581. 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;
  126582. }
  126583. }
  126584. declare module BABYLON {
  126585. /**
  126586. * Implementation of the TGA Texture Loader.
  126587. * @hidden
  126588. */
  126589. export class _TGATextureLoader implements IInternalTextureLoader {
  126590. /**
  126591. * Defines wether the loader supports cascade loading the different faces.
  126592. */
  126593. readonly supportCascades: boolean;
  126594. /**
  126595. * This returns if the loader support the current file information.
  126596. * @param extension defines the file extension of the file being loaded
  126597. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126598. * @param fallback defines the fallback internal texture if any
  126599. * @param isBase64 defines whether the texture is encoded as a base64
  126600. * @param isBuffer defines whether the texture data are stored as a buffer
  126601. * @returns true if the loader can load the specified file
  126602. */
  126603. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  126604. /**
  126605. * Transform the url before loading if required.
  126606. * @param rootUrl the url of the texture
  126607. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126608. * @returns the transformed texture
  126609. */
  126610. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  126611. /**
  126612. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  126613. * @param rootUrl the url of the texture
  126614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126615. * @returns the fallback texture
  126616. */
  126617. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  126618. /**
  126619. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  126620. * @param data contains the texture data
  126621. * @param texture defines the BabylonJS internal texture
  126622. * @param createPolynomials will be true if polynomials have been requested
  126623. * @param onLoad defines the callback to trigger once the texture is ready
  126624. * @param onError defines the callback to trigger in case of error
  126625. */
  126626. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126627. /**
  126628. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  126629. * @param data contains the texture data
  126630. * @param texture defines the BabylonJS internal texture
  126631. * @param callback defines the method to call once ready to upload
  126632. */
  126633. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126634. }
  126635. }
  126636. declare module BABYLON {
  126637. /**
  126638. * Info about the .basis files
  126639. */
  126640. class BasisFileInfo {
  126641. /**
  126642. * If the file has alpha
  126643. */
  126644. hasAlpha: boolean;
  126645. /**
  126646. * Info about each image of the basis file
  126647. */
  126648. images: Array<{
  126649. levels: Array<{
  126650. width: number;
  126651. height: number;
  126652. transcodedPixels: ArrayBufferView;
  126653. }>;
  126654. }>;
  126655. }
  126656. /**
  126657. * Result of transcoding a basis file
  126658. */
  126659. class TranscodeResult {
  126660. /**
  126661. * Info about the .basis file
  126662. */
  126663. fileInfo: BasisFileInfo;
  126664. /**
  126665. * Format to use when loading the file
  126666. */
  126667. format: number;
  126668. }
  126669. /**
  126670. * Configuration options for the Basis transcoder
  126671. */
  126672. export class BasisTranscodeConfiguration {
  126673. /**
  126674. * Supported compression formats used to determine the supported output format of the transcoder
  126675. */
  126676. supportedCompressionFormats?: {
  126677. /**
  126678. * etc1 compression format
  126679. */
  126680. etc1?: boolean;
  126681. /**
  126682. * s3tc compression format
  126683. */
  126684. s3tc?: boolean;
  126685. /**
  126686. * pvrtc compression format
  126687. */
  126688. pvrtc?: boolean;
  126689. /**
  126690. * etc2 compression format
  126691. */
  126692. etc2?: boolean;
  126693. };
  126694. /**
  126695. * If mipmap levels should be loaded for transcoded images (Default: true)
  126696. */
  126697. loadMipmapLevels?: boolean;
  126698. /**
  126699. * Index of a single image to load (Default: all images)
  126700. */
  126701. loadSingleImage?: number;
  126702. }
  126703. /**
  126704. * Used to load .Basis files
  126705. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  126706. */
  126707. export class BasisTools {
  126708. private static _IgnoreSupportedFormats;
  126709. /**
  126710. * URL to use when loading the basis transcoder
  126711. */
  126712. static JSModuleURL: string;
  126713. /**
  126714. * URL to use when loading the wasm module for the transcoder
  126715. */
  126716. static WasmModuleURL: string;
  126717. /**
  126718. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  126719. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  126720. * @returns internal format corresponding to the Basis format
  126721. */
  126722. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  126723. private static _WorkerPromise;
  126724. private static _Worker;
  126725. private static _actionId;
  126726. private static _CreateWorkerAsync;
  126727. /**
  126728. * Transcodes a loaded image file to compressed pixel data
  126729. * @param imageData image data to transcode
  126730. * @param config configuration options for the transcoding
  126731. * @returns a promise resulting in the transcoded image
  126732. */
  126733. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  126734. /**
  126735. * Loads a texture from the transcode result
  126736. * @param texture texture load to
  126737. * @param transcodeResult the result of transcoding the basis file to load from
  126738. */
  126739. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  126740. }
  126741. }
  126742. declare module BABYLON {
  126743. /**
  126744. * Loader for .basis file format
  126745. */
  126746. export class _BasisTextureLoader implements IInternalTextureLoader {
  126747. /**
  126748. * Defines whether the loader supports cascade loading the different faces.
  126749. */
  126750. readonly supportCascades: boolean;
  126751. /**
  126752. * This returns if the loader support the current file information.
  126753. * @param extension defines the file extension of the file being loaded
  126754. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126755. * @param fallback defines the fallback internal texture if any
  126756. * @param isBase64 defines whether the texture is encoded as a base64
  126757. * @param isBuffer defines whether the texture data are stored as a buffer
  126758. * @returns true if the loader can load the specified file
  126759. */
  126760. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  126761. /**
  126762. * Transform the url before loading if required.
  126763. * @param rootUrl the url of the texture
  126764. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126765. * @returns the transformed texture
  126766. */
  126767. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  126768. /**
  126769. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  126770. * @param rootUrl the url of the texture
  126771. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126772. * @returns the fallback texture
  126773. */
  126774. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  126775. /**
  126776. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  126777. * @param data contains the texture data
  126778. * @param texture defines the BabylonJS internal texture
  126779. * @param createPolynomials will be true if polynomials have been requested
  126780. * @param onLoad defines the callback to trigger once the texture is ready
  126781. * @param onError defines the callback to trigger in case of error
  126782. */
  126783. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126784. /**
  126785. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  126786. * @param data contains the texture data
  126787. * @param texture defines the BabylonJS internal texture
  126788. * @param callback defines the method to call once ready to upload
  126789. */
  126790. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126791. }
  126792. }
  126793. declare module BABYLON {
  126794. /**
  126795. * 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.
  126796. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  126797. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  126798. */
  126799. export class CustomProceduralTexture extends ProceduralTexture {
  126800. private _animate;
  126801. private _time;
  126802. private _config;
  126803. private _texturePath;
  126804. /**
  126805. * Instantiates a new Custom Procedural Texture.
  126806. * 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.
  126807. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  126808. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  126809. * @param name Define the name of the texture
  126810. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  126811. * @param size Define the size of the texture to create
  126812. * @param scene Define the scene the texture belongs to
  126813. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  126814. * @param generateMipMaps Define if the texture should creates mip maps or not
  126815. */
  126816. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  126817. private _loadJson;
  126818. /**
  126819. * Is the texture ready to be used ? (rendered at least once)
  126820. * @returns true if ready, otherwise, false.
  126821. */
  126822. isReady(): boolean;
  126823. /**
  126824. * Render the texture to its associated render target.
  126825. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  126826. */
  126827. render(useCameraPostProcess?: boolean): void;
  126828. /**
  126829. * Update the list of dependant textures samplers in the shader.
  126830. */
  126831. updateTextures(): void;
  126832. /**
  126833. * Update the uniform values of the procedural texture in the shader.
  126834. */
  126835. updateShaderUniforms(): void;
  126836. /**
  126837. * Define if the texture animates or not.
  126838. */
  126839. get animate(): boolean;
  126840. set animate(value: boolean);
  126841. }
  126842. }
  126843. declare module BABYLON {
  126844. /** @hidden */
  126845. export var noisePixelShader: {
  126846. name: string;
  126847. shader: string;
  126848. };
  126849. }
  126850. declare module BABYLON {
  126851. /**
  126852. * Class used to generate noise procedural textures
  126853. */
  126854. export class NoiseProceduralTexture extends ProceduralTexture {
  126855. private _time;
  126856. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  126857. brightness: number;
  126858. /** Defines the number of octaves to process */
  126859. octaves: number;
  126860. /** Defines the level of persistence (0.8 by default) */
  126861. persistence: number;
  126862. /** Gets or sets animation speed factor (default is 1) */
  126863. animationSpeedFactor: number;
  126864. /**
  126865. * Creates a new NoiseProceduralTexture
  126866. * @param name defines the name fo the texture
  126867. * @param size defines the size of the texture (default is 256)
  126868. * @param scene defines the hosting scene
  126869. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  126870. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  126871. */
  126872. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  126873. private _updateShaderUniforms;
  126874. protected _getDefines(): string;
  126875. /** Generate the current state of the procedural texture */
  126876. render(useCameraPostProcess?: boolean): void;
  126877. /**
  126878. * Serializes this noise procedural texture
  126879. * @returns a serialized noise procedural texture object
  126880. */
  126881. serialize(): any;
  126882. /**
  126883. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  126884. * @param parsedTexture defines parsed texture data
  126885. * @param scene defines the current scene
  126886. * @param rootUrl defines the root URL containing noise procedural texture information
  126887. * @returns a parsed NoiseProceduralTexture
  126888. */
  126889. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  126890. }
  126891. }
  126892. declare module BABYLON {
  126893. /**
  126894. * Raw cube texture where the raw buffers are passed in
  126895. */
  126896. export class RawCubeTexture extends CubeTexture {
  126897. /**
  126898. * Creates a cube texture where the raw buffers are passed in.
  126899. * @param scene defines the scene the texture is attached to
  126900. * @param data defines the array of data to use to create each face
  126901. * @param size defines the size of the textures
  126902. * @param format defines the format of the data
  126903. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  126904. * @param generateMipMaps defines if the engine should generate the mip levels
  126905. * @param invertY defines if data must be stored with Y axis inverted
  126906. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  126907. * @param compression defines the compression used (null by default)
  126908. */
  126909. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  126910. /**
  126911. * Updates the raw cube texture.
  126912. * @param data defines the data to store
  126913. * @param format defines the data format
  126914. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  126915. * @param invertY defines if data must be stored with Y axis inverted
  126916. * @param compression defines the compression used (null by default)
  126917. * @param level defines which level of the texture to update
  126918. */
  126919. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  126920. /**
  126921. * Updates a raw cube texture with RGBD encoded data.
  126922. * @param data defines the array of data [mipmap][face] to use to create each face
  126923. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  126924. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  126925. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  126926. * @returns a promsie that resolves when the operation is complete
  126927. */
  126928. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  126929. /**
  126930. * Clones the raw cube texture.
  126931. * @return a new cube texture
  126932. */
  126933. clone(): CubeTexture;
  126934. /** @hidden */
  126935. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  126936. }
  126937. }
  126938. declare module BABYLON {
  126939. /**
  126940. * Class used to store 3D textures containing user data
  126941. */
  126942. export class RawTexture3D extends Texture {
  126943. /** Gets or sets the texture format to use */
  126944. format: number;
  126945. private _engine;
  126946. /**
  126947. * Create a new RawTexture3D
  126948. * @param data defines the data of the texture
  126949. * @param width defines the width of the texture
  126950. * @param height defines the height of the texture
  126951. * @param depth defines the depth of the texture
  126952. * @param format defines the texture format to use
  126953. * @param scene defines the hosting scene
  126954. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  126955. * @param invertY defines if texture must be stored with Y axis inverted
  126956. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  126957. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  126958. */
  126959. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  126960. /** Gets or sets the texture format to use */
  126961. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  126962. /**
  126963. * Update the texture with new data
  126964. * @param data defines the data to store in the texture
  126965. */
  126966. update(data: ArrayBufferView): void;
  126967. }
  126968. }
  126969. declare module BABYLON {
  126970. /**
  126971. * Class used to store 2D array textures containing user data
  126972. */
  126973. export class RawTexture2DArray extends Texture {
  126974. /** Gets or sets the texture format to use */
  126975. format: number;
  126976. private _engine;
  126977. /**
  126978. * Create a new RawTexture2DArray
  126979. * @param data defines the data of the texture
  126980. * @param width defines the width of the texture
  126981. * @param height defines the height of the texture
  126982. * @param depth defines the number of layers of the texture
  126983. * @param format defines the texture format to use
  126984. * @param scene defines the hosting scene
  126985. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  126986. * @param invertY defines if texture must be stored with Y axis inverted
  126987. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  126988. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  126989. */
  126990. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  126991. /** Gets or sets the texture format to use */
  126992. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  126993. /**
  126994. * Update the texture with new data
  126995. * @param data defines the data to store in the texture
  126996. */
  126997. update(data: ArrayBufferView): void;
  126998. }
  126999. }
  127000. declare module BABYLON {
  127001. /**
  127002. * Creates a refraction texture used by refraction channel of the standard material.
  127003. * It is like a mirror but to see through a material.
  127004. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  127005. */
  127006. export class RefractionTexture extends RenderTargetTexture {
  127007. /**
  127008. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  127009. * 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.
  127010. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  127011. */
  127012. refractionPlane: Plane;
  127013. /**
  127014. * Define how deep under the surface we should see.
  127015. */
  127016. depth: number;
  127017. /**
  127018. * Creates a refraction texture used by refraction channel of the standard material.
  127019. * It is like a mirror but to see through a material.
  127020. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  127021. * @param name Define the texture name
  127022. * @param size Define the size of the underlying texture
  127023. * @param scene Define the scene the refraction belongs to
  127024. * @param generateMipMaps Define if we need to generate mips level for the refraction
  127025. */
  127026. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  127027. /**
  127028. * Clone the refraction texture.
  127029. * @returns the cloned texture
  127030. */
  127031. clone(): RefractionTexture;
  127032. /**
  127033. * Serialize the texture to a JSON representation you could use in Parse later on
  127034. * @returns the serialized JSON representation
  127035. */
  127036. serialize(): any;
  127037. }
  127038. }
  127039. declare module BABYLON {
  127040. /**
  127041. * Defines the options related to the creation of an HtmlElementTexture
  127042. */
  127043. export interface IHtmlElementTextureOptions {
  127044. /**
  127045. * Defines wether mip maps should be created or not.
  127046. */
  127047. generateMipMaps?: boolean;
  127048. /**
  127049. * Defines the sampling mode of the texture.
  127050. */
  127051. samplingMode?: number;
  127052. /**
  127053. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  127054. */
  127055. engine: Nullable<ThinEngine>;
  127056. /**
  127057. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  127058. */
  127059. scene: Nullable<Scene>;
  127060. }
  127061. /**
  127062. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  127063. * To be as efficient as possible depending on your constraints nothing aside the first upload
  127064. * is automatically managed.
  127065. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  127066. * in your application.
  127067. *
  127068. * As the update is not automatic, you need to call them manually.
  127069. */
  127070. export class HtmlElementTexture extends BaseTexture {
  127071. /**
  127072. * The texture URL.
  127073. */
  127074. element: HTMLVideoElement | HTMLCanvasElement;
  127075. private static readonly DefaultOptions;
  127076. private _textureMatrix;
  127077. private _engine;
  127078. private _isVideo;
  127079. private _generateMipMaps;
  127080. private _samplingMode;
  127081. /**
  127082. * Instantiates a HtmlElementTexture from the following parameters.
  127083. *
  127084. * @param name Defines the name of the texture
  127085. * @param element Defines the video or canvas the texture is filled with
  127086. * @param options Defines the other none mandatory texture creation options
  127087. */
  127088. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  127089. private _createInternalTexture;
  127090. /**
  127091. * Returns the texture matrix used in most of the material.
  127092. */
  127093. getTextureMatrix(): Matrix;
  127094. /**
  127095. * Updates the content of the texture.
  127096. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  127097. */
  127098. update(invertY?: Nullable<boolean>): void;
  127099. }
  127100. }
  127101. declare module BABYLON {
  127102. /**
  127103. * Enum used to define the target of a block
  127104. */
  127105. export enum NodeMaterialBlockTargets {
  127106. /** Vertex shader */
  127107. Vertex = 1,
  127108. /** Fragment shader */
  127109. Fragment = 2,
  127110. /** Neutral */
  127111. Neutral = 4,
  127112. /** Vertex and Fragment */
  127113. VertexAndFragment = 3
  127114. }
  127115. }
  127116. declare module BABYLON {
  127117. /**
  127118. * Defines the kind of connection point for node based material
  127119. */
  127120. export enum NodeMaterialBlockConnectionPointTypes {
  127121. /** Float */
  127122. Float = 1,
  127123. /** Int */
  127124. Int = 2,
  127125. /** Vector2 */
  127126. Vector2 = 4,
  127127. /** Vector3 */
  127128. Vector3 = 8,
  127129. /** Vector4 */
  127130. Vector4 = 16,
  127131. /** Color3 */
  127132. Color3 = 32,
  127133. /** Color4 */
  127134. Color4 = 64,
  127135. /** Matrix */
  127136. Matrix = 128,
  127137. /** Detect type based on connection */
  127138. AutoDetect = 1024,
  127139. /** Output type that will be defined by input type */
  127140. BasedOnInput = 2048
  127141. }
  127142. }
  127143. declare module BABYLON {
  127144. /**
  127145. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  127146. */
  127147. export enum NodeMaterialBlockConnectionPointMode {
  127148. /** Value is an uniform */
  127149. Uniform = 0,
  127150. /** Value is a mesh attribute */
  127151. Attribute = 1,
  127152. /** Value is a varying between vertex and fragment shaders */
  127153. Varying = 2,
  127154. /** Mode is undefined */
  127155. Undefined = 3
  127156. }
  127157. }
  127158. declare module BABYLON {
  127159. /**
  127160. * Enum used to define system values e.g. values automatically provided by the system
  127161. */
  127162. export enum NodeMaterialSystemValues {
  127163. /** World */
  127164. World = 1,
  127165. /** View */
  127166. View = 2,
  127167. /** Projection */
  127168. Projection = 3,
  127169. /** ViewProjection */
  127170. ViewProjection = 4,
  127171. /** WorldView */
  127172. WorldView = 5,
  127173. /** WorldViewProjection */
  127174. WorldViewProjection = 6,
  127175. /** CameraPosition */
  127176. CameraPosition = 7,
  127177. /** Fog Color */
  127178. FogColor = 8,
  127179. /** Delta time */
  127180. DeltaTime = 9
  127181. }
  127182. }
  127183. declare module BABYLON {
  127184. /**
  127185. * Root class for all node material optimizers
  127186. */
  127187. export class NodeMaterialOptimizer {
  127188. /**
  127189. * Function used to optimize a NodeMaterial graph
  127190. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  127191. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  127192. */
  127193. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  127194. }
  127195. }
  127196. declare module BABYLON {
  127197. /**
  127198. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  127199. */
  127200. export class TransformBlock extends NodeMaterialBlock {
  127201. /**
  127202. * Defines the value to use to complement W value to transform it to a Vector4
  127203. */
  127204. complementW: number;
  127205. /**
  127206. * Defines the value to use to complement z value to transform it to a Vector4
  127207. */
  127208. complementZ: number;
  127209. /**
  127210. * Creates a new TransformBlock
  127211. * @param name defines the block name
  127212. */
  127213. constructor(name: string);
  127214. /**
  127215. * Gets the current class name
  127216. * @returns the class name
  127217. */
  127218. getClassName(): string;
  127219. /**
  127220. * Gets the vector input
  127221. */
  127222. get vector(): NodeMaterialConnectionPoint;
  127223. /**
  127224. * Gets the output component
  127225. */
  127226. get output(): NodeMaterialConnectionPoint;
  127227. /**
  127228. * Gets the matrix transform input
  127229. */
  127230. get transform(): NodeMaterialConnectionPoint;
  127231. protected _buildBlock(state: NodeMaterialBuildState): this;
  127232. serialize(): any;
  127233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127234. protected _dumpPropertiesCode(): string;
  127235. }
  127236. }
  127237. declare module BABYLON {
  127238. /**
  127239. * Block used to output the vertex position
  127240. */
  127241. export class VertexOutputBlock extends NodeMaterialBlock {
  127242. /**
  127243. * Creates a new VertexOutputBlock
  127244. * @param name defines the block name
  127245. */
  127246. constructor(name: string);
  127247. /**
  127248. * Gets the current class name
  127249. * @returns the class name
  127250. */
  127251. getClassName(): string;
  127252. /**
  127253. * Gets the vector input component
  127254. */
  127255. get vector(): NodeMaterialConnectionPoint;
  127256. protected _buildBlock(state: NodeMaterialBuildState): this;
  127257. }
  127258. }
  127259. declare module BABYLON {
  127260. /**
  127261. * Block used to output the final color
  127262. */
  127263. export class FragmentOutputBlock extends NodeMaterialBlock {
  127264. /**
  127265. * Create a new FragmentOutputBlock
  127266. * @param name defines the block name
  127267. */
  127268. constructor(name: string);
  127269. /**
  127270. * Gets the current class name
  127271. * @returns the class name
  127272. */
  127273. getClassName(): string;
  127274. /**
  127275. * Gets the rgba input component
  127276. */
  127277. get rgba(): NodeMaterialConnectionPoint;
  127278. /**
  127279. * Gets the rgb input component
  127280. */
  127281. get rgb(): NodeMaterialConnectionPoint;
  127282. /**
  127283. * Gets the a input component
  127284. */
  127285. get a(): NodeMaterialConnectionPoint;
  127286. protected _buildBlock(state: NodeMaterialBuildState): this;
  127287. }
  127288. }
  127289. declare module BABYLON {
  127290. /**
  127291. * Block used to read a reflection texture from a sampler
  127292. */
  127293. export class ReflectionTextureBlock extends NodeMaterialBlock {
  127294. private _define3DName;
  127295. private _defineCubicName;
  127296. private _defineExplicitName;
  127297. private _defineProjectionName;
  127298. private _defineLocalCubicName;
  127299. private _defineSphericalName;
  127300. private _definePlanarName;
  127301. private _defineEquirectangularName;
  127302. private _defineMirroredEquirectangularFixedName;
  127303. private _defineEquirectangularFixedName;
  127304. private _defineSkyboxName;
  127305. private _cubeSamplerName;
  127306. private _2DSamplerName;
  127307. private _positionUVWName;
  127308. private _directionWName;
  127309. private _reflectionCoordsName;
  127310. private _reflection2DCoordsName;
  127311. private _reflectionColorName;
  127312. private _reflectionMatrixName;
  127313. /**
  127314. * Gets or sets the texture associated with the node
  127315. */
  127316. texture: Nullable<BaseTexture>;
  127317. /**
  127318. * Create a new TextureBlock
  127319. * @param name defines the block name
  127320. */
  127321. constructor(name: string);
  127322. /**
  127323. * Gets the current class name
  127324. * @returns the class name
  127325. */
  127326. getClassName(): string;
  127327. /**
  127328. * Gets the world position input component
  127329. */
  127330. get position(): NodeMaterialConnectionPoint;
  127331. /**
  127332. * Gets the world position input component
  127333. */
  127334. get worldPosition(): NodeMaterialConnectionPoint;
  127335. /**
  127336. * Gets the world normal input component
  127337. */
  127338. get worldNormal(): NodeMaterialConnectionPoint;
  127339. /**
  127340. * Gets the world input component
  127341. */
  127342. get world(): NodeMaterialConnectionPoint;
  127343. /**
  127344. * Gets the camera (or eye) position component
  127345. */
  127346. get cameraPosition(): NodeMaterialConnectionPoint;
  127347. /**
  127348. * Gets the view input component
  127349. */
  127350. get view(): NodeMaterialConnectionPoint;
  127351. /**
  127352. * Gets the rgb output component
  127353. */
  127354. get rgb(): NodeMaterialConnectionPoint;
  127355. /**
  127356. * Gets the r output component
  127357. */
  127358. get r(): NodeMaterialConnectionPoint;
  127359. /**
  127360. * Gets the g output component
  127361. */
  127362. get g(): NodeMaterialConnectionPoint;
  127363. /**
  127364. * Gets the b output component
  127365. */
  127366. get b(): NodeMaterialConnectionPoint;
  127367. autoConfigure(material: NodeMaterial): void;
  127368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127369. isReady(): boolean;
  127370. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127371. private _injectVertexCode;
  127372. private _writeOutput;
  127373. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127374. protected _dumpPropertiesCode(): string;
  127375. serialize(): any;
  127376. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127377. }
  127378. }
  127379. declare module BABYLON {
  127380. /**
  127381. * Interface used to configure the node material editor
  127382. */
  127383. export interface INodeMaterialEditorOptions {
  127384. /** Define the URl to load node editor script */
  127385. editorURL?: string;
  127386. }
  127387. /** @hidden */
  127388. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  127389. /** BONES */
  127390. NUM_BONE_INFLUENCERS: number;
  127391. BonesPerMesh: number;
  127392. BONETEXTURE: boolean;
  127393. /** MORPH TARGETS */
  127394. MORPHTARGETS: boolean;
  127395. MORPHTARGETS_NORMAL: boolean;
  127396. MORPHTARGETS_TANGENT: boolean;
  127397. MORPHTARGETS_UV: boolean;
  127398. NUM_MORPH_INFLUENCERS: number;
  127399. /** IMAGE PROCESSING */
  127400. IMAGEPROCESSING: boolean;
  127401. VIGNETTE: boolean;
  127402. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127403. VIGNETTEBLENDMODEOPAQUE: boolean;
  127404. TONEMAPPING: boolean;
  127405. TONEMAPPING_ACES: boolean;
  127406. CONTRAST: boolean;
  127407. EXPOSURE: boolean;
  127408. COLORCURVES: boolean;
  127409. COLORGRADING: boolean;
  127410. COLORGRADING3D: boolean;
  127411. SAMPLER3DGREENDEPTH: boolean;
  127412. SAMPLER3DBGRMAP: boolean;
  127413. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127414. /** MISC. */
  127415. BUMPDIRECTUV: number;
  127416. constructor();
  127417. setValue(name: string, value: boolean): void;
  127418. }
  127419. /**
  127420. * Class used to configure NodeMaterial
  127421. */
  127422. export interface INodeMaterialOptions {
  127423. /**
  127424. * Defines if blocks should emit comments
  127425. */
  127426. emitComments: boolean;
  127427. }
  127428. /**
  127429. * Class used to create a node based material built by assembling shader blocks
  127430. */
  127431. export class NodeMaterial extends PushMaterial {
  127432. private static _BuildIdGenerator;
  127433. private _options;
  127434. private _vertexCompilationState;
  127435. private _fragmentCompilationState;
  127436. private _sharedData;
  127437. private _buildId;
  127438. private _buildWasSuccessful;
  127439. private _cachedWorldViewMatrix;
  127440. private _cachedWorldViewProjectionMatrix;
  127441. private _optimizers;
  127442. private _animationFrame;
  127443. /** Define the URl to load node editor script */
  127444. static EditorURL: string;
  127445. private BJSNODEMATERIALEDITOR;
  127446. /** Get the inspector from bundle or global */
  127447. private _getGlobalNodeMaterialEditor;
  127448. /**
  127449. * Gets or sets data used by visual editor
  127450. * @see https://nme.babylonjs.com
  127451. */
  127452. editorData: any;
  127453. /**
  127454. * 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)
  127455. */
  127456. ignoreAlpha: boolean;
  127457. /**
  127458. * Defines the maximum number of lights that can be used in the material
  127459. */
  127460. maxSimultaneousLights: number;
  127461. /**
  127462. * Observable raised when the material is built
  127463. */
  127464. onBuildObservable: Observable<NodeMaterial>;
  127465. /**
  127466. * Gets or sets the root nodes of the material vertex shader
  127467. */
  127468. _vertexOutputNodes: NodeMaterialBlock[];
  127469. /**
  127470. * Gets or sets the root nodes of the material fragment (pixel) shader
  127471. */
  127472. _fragmentOutputNodes: NodeMaterialBlock[];
  127473. /** Gets or sets options to control the node material overall behavior */
  127474. get options(): INodeMaterialOptions;
  127475. set options(options: INodeMaterialOptions);
  127476. /**
  127477. * Default configuration related to image processing available in the standard Material.
  127478. */
  127479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  127480. /**
  127481. * Gets the image processing configuration used either in this material.
  127482. */
  127483. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  127484. /**
  127485. * Sets the Default image processing configuration used either in the this material.
  127486. *
  127487. * If sets to null, the scene one is in use.
  127488. */
  127489. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  127490. /**
  127491. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  127492. */
  127493. attachedBlocks: NodeMaterialBlock[];
  127494. /**
  127495. * Create a new node based material
  127496. * @param name defines the material name
  127497. * @param scene defines the hosting scene
  127498. * @param options defines creation option
  127499. */
  127500. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  127501. /**
  127502. * Gets the current class name of the material e.g. "NodeMaterial"
  127503. * @returns the class name
  127504. */
  127505. getClassName(): string;
  127506. /**
  127507. * Keep track of the image processing observer to allow dispose and replace.
  127508. */
  127509. private _imageProcessingObserver;
  127510. /**
  127511. * Attaches a new image processing configuration to the Standard Material.
  127512. * @param configuration
  127513. */
  127514. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  127515. /**
  127516. * Get a block by its name
  127517. * @param name defines the name of the block to retrieve
  127518. * @returns the required block or null if not found
  127519. */
  127520. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  127521. /**
  127522. * Get a block by its name
  127523. * @param predicate defines the predicate used to find the good candidate
  127524. * @returns the required block or null if not found
  127525. */
  127526. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  127527. /**
  127528. * Get an input block by its name
  127529. * @param predicate defines the predicate used to find the good candidate
  127530. * @returns the required input block or null if not found
  127531. */
  127532. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  127533. /**
  127534. * Gets the list of input blocks attached to this material
  127535. * @returns an array of InputBlocks
  127536. */
  127537. getInputBlocks(): InputBlock[];
  127538. /**
  127539. * Adds a new optimizer to the list of optimizers
  127540. * @param optimizer defines the optimizers to add
  127541. * @returns the current material
  127542. */
  127543. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  127544. /**
  127545. * Remove an optimizer from the list of optimizers
  127546. * @param optimizer defines the optimizers to remove
  127547. * @returns the current material
  127548. */
  127549. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  127550. /**
  127551. * Add a new block to the list of output nodes
  127552. * @param node defines the node to add
  127553. * @returns the current material
  127554. */
  127555. addOutputNode(node: NodeMaterialBlock): this;
  127556. /**
  127557. * Remove a block from the list of root nodes
  127558. * @param node defines the node to remove
  127559. * @returns the current material
  127560. */
  127561. removeOutputNode(node: NodeMaterialBlock): this;
  127562. private _addVertexOutputNode;
  127563. private _removeVertexOutputNode;
  127564. private _addFragmentOutputNode;
  127565. private _removeFragmentOutputNode;
  127566. /**
  127567. * Specifies if the material will require alpha blending
  127568. * @returns a boolean specifying if alpha blending is needed
  127569. */
  127570. needAlphaBlending(): boolean;
  127571. /**
  127572. * Specifies if this material should be rendered in alpha test mode
  127573. * @returns a boolean specifying if an alpha test is needed.
  127574. */
  127575. needAlphaTesting(): boolean;
  127576. private _initializeBlock;
  127577. private _resetDualBlocks;
  127578. /**
  127579. * Remove a block from the current node material
  127580. * @param block defines the block to remove
  127581. */
  127582. removeBlock(block: NodeMaterialBlock): void;
  127583. /**
  127584. * Build the material and generates the inner effect
  127585. * @param verbose defines if the build should log activity
  127586. */
  127587. build(verbose?: boolean): void;
  127588. /**
  127589. * Runs an otpimization phase to try to improve the shader code
  127590. */
  127591. optimize(): void;
  127592. private _prepareDefinesForAttributes;
  127593. /**
  127594. * Get if the submesh is ready to be used and all its information available.
  127595. * Child classes can use it to update shaders
  127596. * @param mesh defines the mesh to check
  127597. * @param subMesh defines which submesh to check
  127598. * @param useInstances specifies that instances should be used
  127599. * @returns a boolean indicating that the submesh is ready or not
  127600. */
  127601. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  127602. /**
  127603. * Get a string representing the shaders built by the current node graph
  127604. */
  127605. get compiledShaders(): string;
  127606. /**
  127607. * Binds the world matrix to the material
  127608. * @param world defines the world transformation matrix
  127609. */
  127610. bindOnlyWorldMatrix(world: Matrix): void;
  127611. /**
  127612. * Binds the submesh to this material by preparing the effect and shader to draw
  127613. * @param world defines the world transformation matrix
  127614. * @param mesh defines the mesh containing the submesh
  127615. * @param subMesh defines the submesh to bind the material to
  127616. */
  127617. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  127618. /**
  127619. * Gets the active textures from the material
  127620. * @returns an array of textures
  127621. */
  127622. getActiveTextures(): BaseTexture[];
  127623. /**
  127624. * Gets the list of texture blocks
  127625. * @returns an array of texture blocks
  127626. */
  127627. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  127628. /**
  127629. * Specifies if the material uses a texture
  127630. * @param texture defines the texture to check against the material
  127631. * @returns a boolean specifying if the material uses the texture
  127632. */
  127633. hasTexture(texture: BaseTexture): boolean;
  127634. /**
  127635. * Disposes the material
  127636. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  127637. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  127638. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  127639. */
  127640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  127641. /** Creates the node editor window. */
  127642. private _createNodeEditor;
  127643. /**
  127644. * Launch the node material editor
  127645. * @param config Define the configuration of the editor
  127646. * @return a promise fulfilled when the node editor is visible
  127647. */
  127648. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  127649. /**
  127650. * Clear the current material
  127651. */
  127652. clear(): void;
  127653. /**
  127654. * Clear the current material and set it to a default state
  127655. */
  127656. setToDefault(): void;
  127657. /**
  127658. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  127659. * @param url defines the url to load from
  127660. * @returns a promise that will fullfil when the material is fully loaded
  127661. */
  127662. loadAsync(url: string): Promise<void>;
  127663. private _gatherBlocks;
  127664. /**
  127665. * Generate a string containing the code declaration required to create an equivalent of this material
  127666. * @returns a string
  127667. */
  127668. generateCode(): string;
  127669. /**
  127670. * Serializes this material in a JSON representation
  127671. * @returns the serialized material object
  127672. */
  127673. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  127674. private _restoreConnections;
  127675. /**
  127676. * Clear the current graph and load a new one from a serialization object
  127677. * @param source defines the JSON representation of the material
  127678. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  127679. */
  127680. loadFromSerialization(source: any, rootUrl?: string): void;
  127681. /**
  127682. * Creates a node material from parsed material data
  127683. * @param source defines the JSON representation of the material
  127684. * @param scene defines the hosting scene
  127685. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  127686. * @returns a new node material
  127687. */
  127688. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  127689. /**
  127690. * Creates a new node material set to default basic configuration
  127691. * @param name defines the name of the material
  127692. * @param scene defines the hosting scene
  127693. * @returns a new NodeMaterial
  127694. */
  127695. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  127696. }
  127697. }
  127698. declare module BABYLON {
  127699. /**
  127700. * Block used to read a texture from a sampler
  127701. */
  127702. export class TextureBlock extends NodeMaterialBlock {
  127703. private _defineName;
  127704. private _linearDefineName;
  127705. private _tempTextureRead;
  127706. private _samplerName;
  127707. private _transformedUVName;
  127708. private _textureTransformName;
  127709. private _textureInfoName;
  127710. private _mainUVName;
  127711. private _mainUVDefineName;
  127712. /**
  127713. * Gets or sets the texture associated with the node
  127714. */
  127715. texture: Nullable<Texture>;
  127716. /**
  127717. * Create a new TextureBlock
  127718. * @param name defines the block name
  127719. */
  127720. constructor(name: string);
  127721. /**
  127722. * Gets the current class name
  127723. * @returns the class name
  127724. */
  127725. getClassName(): string;
  127726. /**
  127727. * Gets the uv input component
  127728. */
  127729. get uv(): NodeMaterialConnectionPoint;
  127730. /**
  127731. * Gets the rgba output component
  127732. */
  127733. get rgba(): NodeMaterialConnectionPoint;
  127734. /**
  127735. * Gets the rgb output component
  127736. */
  127737. get rgb(): NodeMaterialConnectionPoint;
  127738. /**
  127739. * Gets the r output component
  127740. */
  127741. get r(): NodeMaterialConnectionPoint;
  127742. /**
  127743. * Gets the g output component
  127744. */
  127745. get g(): NodeMaterialConnectionPoint;
  127746. /**
  127747. * Gets the b output component
  127748. */
  127749. get b(): NodeMaterialConnectionPoint;
  127750. /**
  127751. * Gets the a output component
  127752. */
  127753. get a(): NodeMaterialConnectionPoint;
  127754. get target(): NodeMaterialBlockTargets;
  127755. autoConfigure(material: NodeMaterial): void;
  127756. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127758. private _getTextureBase;
  127759. isReady(): boolean;
  127760. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127761. private get _isMixed();
  127762. private _injectVertexCode;
  127763. private _writeTextureRead;
  127764. private _writeOutput;
  127765. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127766. protected _dumpPropertiesCode(): string;
  127767. serialize(): any;
  127768. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127769. }
  127770. }
  127771. declare module BABYLON {
  127772. /**
  127773. * Class used to store shared data between 2 NodeMaterialBuildState
  127774. */
  127775. export class NodeMaterialBuildStateSharedData {
  127776. /**
  127777. * Gets the list of emitted varyings
  127778. */
  127779. temps: string[];
  127780. /**
  127781. * Gets the list of emitted varyings
  127782. */
  127783. varyings: string[];
  127784. /**
  127785. * Gets the varying declaration string
  127786. */
  127787. varyingDeclaration: string;
  127788. /**
  127789. * Input blocks
  127790. */
  127791. inputBlocks: InputBlock[];
  127792. /**
  127793. * Input blocks
  127794. */
  127795. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  127796. /**
  127797. * Bindable blocks (Blocks that need to set data to the effect)
  127798. */
  127799. bindableBlocks: NodeMaterialBlock[];
  127800. /**
  127801. * List of blocks that can provide a compilation fallback
  127802. */
  127803. blocksWithFallbacks: NodeMaterialBlock[];
  127804. /**
  127805. * List of blocks that can provide a define update
  127806. */
  127807. blocksWithDefines: NodeMaterialBlock[];
  127808. /**
  127809. * List of blocks that can provide a repeatable content
  127810. */
  127811. repeatableContentBlocks: NodeMaterialBlock[];
  127812. /**
  127813. * List of blocks that can provide a dynamic list of uniforms
  127814. */
  127815. dynamicUniformBlocks: NodeMaterialBlock[];
  127816. /**
  127817. * List of blocks that can block the isReady function for the material
  127818. */
  127819. blockingBlocks: NodeMaterialBlock[];
  127820. /**
  127821. * Gets the list of animated inputs
  127822. */
  127823. animatedInputs: InputBlock[];
  127824. /**
  127825. * Build Id used to avoid multiple recompilations
  127826. */
  127827. buildId: number;
  127828. /** List of emitted variables */
  127829. variableNames: {
  127830. [key: string]: number;
  127831. };
  127832. /** List of emitted defines */
  127833. defineNames: {
  127834. [key: string]: number;
  127835. };
  127836. /** Should emit comments? */
  127837. emitComments: boolean;
  127838. /** Emit build activity */
  127839. verbose: boolean;
  127840. /** Gets or sets the hosting scene */
  127841. scene: Scene;
  127842. /**
  127843. * Gets the compilation hints emitted at compilation time
  127844. */
  127845. hints: {
  127846. needWorldViewMatrix: boolean;
  127847. needWorldViewProjectionMatrix: boolean;
  127848. needAlphaBlending: boolean;
  127849. needAlphaTesting: boolean;
  127850. };
  127851. /**
  127852. * List of compilation checks
  127853. */
  127854. checks: {
  127855. emitVertex: boolean;
  127856. emitFragment: boolean;
  127857. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  127858. };
  127859. /** Creates a new shared data */
  127860. constructor();
  127861. /**
  127862. * Emits console errors and exceptions if there is a failing check
  127863. */
  127864. emitErrors(): void;
  127865. }
  127866. }
  127867. declare module BABYLON {
  127868. /**
  127869. * Class used to store node based material build state
  127870. */
  127871. export class NodeMaterialBuildState {
  127872. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  127873. supportUniformBuffers: boolean;
  127874. /**
  127875. * Gets the list of emitted attributes
  127876. */
  127877. attributes: string[];
  127878. /**
  127879. * Gets the list of emitted uniforms
  127880. */
  127881. uniforms: string[];
  127882. /**
  127883. * Gets the list of emitted constants
  127884. */
  127885. constants: string[];
  127886. /**
  127887. * Gets the list of emitted samplers
  127888. */
  127889. samplers: string[];
  127890. /**
  127891. * Gets the list of emitted functions
  127892. */
  127893. functions: {
  127894. [key: string]: string;
  127895. };
  127896. /**
  127897. * Gets the list of emitted extensions
  127898. */
  127899. extensions: {
  127900. [key: string]: string;
  127901. };
  127902. /**
  127903. * Gets the target of the compilation state
  127904. */
  127905. target: NodeMaterialBlockTargets;
  127906. /**
  127907. * Gets the list of emitted counters
  127908. */
  127909. counters: {
  127910. [key: string]: number;
  127911. };
  127912. /**
  127913. * Shared data between multiple NodeMaterialBuildState instances
  127914. */
  127915. sharedData: NodeMaterialBuildStateSharedData;
  127916. /** @hidden */
  127917. _vertexState: NodeMaterialBuildState;
  127918. /** @hidden */
  127919. _attributeDeclaration: string;
  127920. /** @hidden */
  127921. _uniformDeclaration: string;
  127922. /** @hidden */
  127923. _constantDeclaration: string;
  127924. /** @hidden */
  127925. _samplerDeclaration: string;
  127926. /** @hidden */
  127927. _varyingTransfer: string;
  127928. private _repeatableContentAnchorIndex;
  127929. /** @hidden */
  127930. _builtCompilationString: string;
  127931. /**
  127932. * Gets the emitted compilation strings
  127933. */
  127934. compilationString: string;
  127935. /**
  127936. * Finalize the compilation strings
  127937. * @param state defines the current compilation state
  127938. */
  127939. finalize(state: NodeMaterialBuildState): void;
  127940. /** @hidden */
  127941. get _repeatableContentAnchor(): string;
  127942. /** @hidden */
  127943. _getFreeVariableName(prefix: string): string;
  127944. /** @hidden */
  127945. _getFreeDefineName(prefix: string): string;
  127946. /** @hidden */
  127947. _excludeVariableName(name: string): void;
  127948. /** @hidden */
  127949. _emit2DSampler(name: string): void;
  127950. /** @hidden */
  127951. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  127952. /** @hidden */
  127953. _emitExtension(name: string, extension: string): void;
  127954. /** @hidden */
  127955. _emitFunction(name: string, code: string, comments: string): void;
  127956. /** @hidden */
  127957. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  127958. replaceStrings?: {
  127959. search: RegExp;
  127960. replace: string;
  127961. }[];
  127962. repeatKey?: string;
  127963. }): string;
  127964. /** @hidden */
  127965. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  127966. repeatKey?: string;
  127967. removeAttributes?: boolean;
  127968. removeUniforms?: boolean;
  127969. removeVaryings?: boolean;
  127970. removeIfDef?: boolean;
  127971. replaceStrings?: {
  127972. search: RegExp;
  127973. replace: string;
  127974. }[];
  127975. }, storeKey?: string): void;
  127976. /** @hidden */
  127977. _registerTempVariable(name: string): boolean;
  127978. /** @hidden */
  127979. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  127980. /** @hidden */
  127981. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  127982. /** @hidden */
  127983. _emitFloat(value: number): string;
  127984. }
  127985. }
  127986. declare module BABYLON {
  127987. /**
  127988. * Defines a block that can be used inside a node based material
  127989. */
  127990. export class NodeMaterialBlock {
  127991. private _buildId;
  127992. private _buildTarget;
  127993. private _target;
  127994. private _isFinalMerger;
  127995. private _isInput;
  127996. protected _isUnique: boolean;
  127997. /** @hidden */
  127998. _codeVariableName: string;
  127999. /** @hidden */
  128000. _inputs: NodeMaterialConnectionPoint[];
  128001. /** @hidden */
  128002. _outputs: NodeMaterialConnectionPoint[];
  128003. /** @hidden */
  128004. _preparationId: number;
  128005. /**
  128006. * Gets or sets the name of the block
  128007. */
  128008. name: string;
  128009. /**
  128010. * Gets or sets the unique id of the node
  128011. */
  128012. uniqueId: number;
  128013. /**
  128014. * Gets or sets the comments associated with this block
  128015. */
  128016. comments: string;
  128017. /**
  128018. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  128019. */
  128020. get isUnique(): boolean;
  128021. /**
  128022. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  128023. */
  128024. get isFinalMerger(): boolean;
  128025. /**
  128026. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  128027. */
  128028. get isInput(): boolean;
  128029. /**
  128030. * Gets or sets the build Id
  128031. */
  128032. get buildId(): number;
  128033. set buildId(value: number);
  128034. /**
  128035. * Gets or sets the target of the block
  128036. */
  128037. get target(): NodeMaterialBlockTargets;
  128038. set target(value: NodeMaterialBlockTargets);
  128039. /**
  128040. * Gets the list of input points
  128041. */
  128042. get inputs(): NodeMaterialConnectionPoint[];
  128043. /** Gets the list of output points */
  128044. get outputs(): NodeMaterialConnectionPoint[];
  128045. /**
  128046. * Find an input by its name
  128047. * @param name defines the name of the input to look for
  128048. * @returns the input or null if not found
  128049. */
  128050. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  128051. /**
  128052. * Find an output by its name
  128053. * @param name defines the name of the outputto look for
  128054. * @returns the output or null if not found
  128055. */
  128056. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  128057. /**
  128058. * Creates a new NodeMaterialBlock
  128059. * @param name defines the block name
  128060. * @param target defines the target of that block (Vertex by default)
  128061. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  128062. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  128063. */
  128064. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  128065. /**
  128066. * Initialize the block and prepare the context for build
  128067. * @param state defines the state that will be used for the build
  128068. */
  128069. initialize(state: NodeMaterialBuildState): void;
  128070. /**
  128071. * Bind data to effect. Will only be called for blocks with isBindable === true
  128072. * @param effect defines the effect to bind data to
  128073. * @param nodeMaterial defines the hosting NodeMaterial
  128074. * @param mesh defines the mesh that will be rendered
  128075. */
  128076. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128077. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  128078. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  128079. protected _writeFloat(value: number): string;
  128080. /**
  128081. * Gets the current class name e.g. "NodeMaterialBlock"
  128082. * @returns the class name
  128083. */
  128084. getClassName(): string;
  128085. /**
  128086. * Register a new input. Must be called inside a block constructor
  128087. * @param name defines the connection point name
  128088. * @param type defines the connection point type
  128089. * @param isOptional defines a boolean indicating that this input can be omitted
  128090. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  128091. * @returns the current block
  128092. */
  128093. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  128094. /**
  128095. * Register a new output. Must be called inside a block constructor
  128096. * @param name defines the connection point name
  128097. * @param type defines the connection point type
  128098. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  128099. * @returns the current block
  128100. */
  128101. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  128102. /**
  128103. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  128104. * @param forOutput defines an optional connection point to check compatibility with
  128105. * @returns the first available input or null
  128106. */
  128107. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  128108. /**
  128109. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  128110. * @param forBlock defines an optional block to check compatibility with
  128111. * @returns the first available input or null
  128112. */
  128113. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  128114. /**
  128115. * Gets the sibling of the given output
  128116. * @param current defines the current output
  128117. * @returns the next output in the list or null
  128118. */
  128119. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  128120. /**
  128121. * Connect current block with another block
  128122. * @param other defines the block to connect with
  128123. * @param options define the various options to help pick the right connections
  128124. * @returns the current block
  128125. */
  128126. connectTo(other: NodeMaterialBlock, options?: {
  128127. input?: string;
  128128. output?: string;
  128129. outputSwizzle?: string;
  128130. }): this | undefined;
  128131. protected _buildBlock(state: NodeMaterialBuildState): void;
  128132. /**
  128133. * Add uniforms, samplers and uniform buffers at compilation time
  128134. * @param state defines the state to update
  128135. * @param nodeMaterial defines the node material requesting the update
  128136. * @param defines defines the material defines to update
  128137. * @param uniformBuffers defines the list of uniform buffer names
  128138. */
  128139. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  128140. /**
  128141. * Add potential fallbacks if shader compilation fails
  128142. * @param mesh defines the mesh to be rendered
  128143. * @param fallbacks defines the current prioritized list of fallbacks
  128144. */
  128145. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  128146. /**
  128147. * Initialize defines for shader compilation
  128148. * @param mesh defines the mesh to be rendered
  128149. * @param nodeMaterial defines the node material requesting the update
  128150. * @param defines defines the material defines to update
  128151. * @param useInstances specifies that instances should be used
  128152. */
  128153. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  128154. /**
  128155. * Update defines for shader compilation
  128156. * @param mesh defines the mesh to be rendered
  128157. * @param nodeMaterial defines the node material requesting the update
  128158. * @param defines defines the material defines to update
  128159. * @param useInstances specifies that instances should be used
  128160. */
  128161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  128162. /**
  128163. * Lets the block try to connect some inputs automatically
  128164. * @param material defines the hosting NodeMaterial
  128165. */
  128166. autoConfigure(material: NodeMaterial): void;
  128167. /**
  128168. * Function called when a block is declared as repeatable content generator
  128169. * @param vertexShaderState defines the current compilation state for the vertex shader
  128170. * @param fragmentShaderState defines the current compilation state for the fragment shader
  128171. * @param mesh defines the mesh to be rendered
  128172. * @param defines defines the material defines to update
  128173. */
  128174. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  128175. /**
  128176. * Checks if the block is ready
  128177. * @param mesh defines the mesh to be rendered
  128178. * @param nodeMaterial defines the node material requesting the update
  128179. * @param defines defines the material defines to update
  128180. * @param useInstances specifies that instances should be used
  128181. * @returns true if the block is ready
  128182. */
  128183. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  128184. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  128185. private _processBuild;
  128186. /**
  128187. * Compile the current node and generate the shader code
  128188. * @param state defines the current compilation state (uniforms, samplers, current string)
  128189. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  128190. * @returns true if already built
  128191. */
  128192. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  128193. protected _inputRename(name: string): string;
  128194. protected _outputRename(name: string): string;
  128195. protected _dumpPropertiesCode(): string;
  128196. /** @hidden */
  128197. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  128198. /** @hidden */
  128199. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  128200. /**
  128201. * Clone the current block to a new identical block
  128202. * @param scene defines the hosting scene
  128203. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  128204. * @returns a copy of the current block
  128205. */
  128206. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  128207. /**
  128208. * Serializes this block in a JSON representation
  128209. * @returns the serialized block object
  128210. */
  128211. serialize(): any;
  128212. /** @hidden */
  128213. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128214. /**
  128215. * Release resources
  128216. */
  128217. dispose(): void;
  128218. }
  128219. }
  128220. declare module BABYLON {
  128221. /**
  128222. * Enum defining the type of animations supported by InputBlock
  128223. */
  128224. export enum AnimatedInputBlockTypes {
  128225. /** No animation */
  128226. None = 0,
  128227. /** Time based animation. Will only work for floats */
  128228. Time = 1
  128229. }
  128230. }
  128231. declare module BABYLON {
  128232. /**
  128233. * Block used to expose an input value
  128234. */
  128235. export class InputBlock extends NodeMaterialBlock {
  128236. private _mode;
  128237. private _associatedVariableName;
  128238. private _storedValue;
  128239. private _valueCallback;
  128240. private _type;
  128241. private _animationType;
  128242. /** Gets or set a value used to limit the range of float values */
  128243. min: number;
  128244. /** Gets or set a value used to limit the range of float values */
  128245. max: number;
  128246. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  128247. matrixMode: number;
  128248. /** @hidden */
  128249. _systemValue: Nullable<NodeMaterialSystemValues>;
  128250. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  128251. visibleInInspector: boolean;
  128252. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  128253. isConstant: boolean;
  128254. /** Gets or sets the group to use to display this block in the Inspector */
  128255. groupInInspector: string;
  128256. /**
  128257. * Gets or sets the connection point type (default is float)
  128258. */
  128259. get type(): NodeMaterialBlockConnectionPointTypes;
  128260. /**
  128261. * Creates a new InputBlock
  128262. * @param name defines the block name
  128263. * @param target defines the target of that block (Vertex by default)
  128264. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  128265. */
  128266. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  128267. /**
  128268. * Gets the output component
  128269. */
  128270. get output(): NodeMaterialConnectionPoint;
  128271. /**
  128272. * Set the source of this connection point to a vertex attribute
  128273. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  128274. * @returns the current connection point
  128275. */
  128276. setAsAttribute(attributeName?: string): InputBlock;
  128277. /**
  128278. * Set the source of this connection point to a system value
  128279. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  128280. * @returns the current connection point
  128281. */
  128282. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  128283. /**
  128284. * Gets or sets the value of that point.
  128285. * Please note that this value will be ignored if valueCallback is defined
  128286. */
  128287. get value(): any;
  128288. set value(value: any);
  128289. /**
  128290. * Gets or sets a callback used to get the value of that point.
  128291. * Please note that setting this value will force the connection point to ignore the value property
  128292. */
  128293. get valueCallback(): () => any;
  128294. set valueCallback(value: () => any);
  128295. /**
  128296. * Gets or sets the associated variable name in the shader
  128297. */
  128298. get associatedVariableName(): string;
  128299. set associatedVariableName(value: string);
  128300. /** Gets or sets the type of animation applied to the input */
  128301. get animationType(): AnimatedInputBlockTypes;
  128302. set animationType(value: AnimatedInputBlockTypes);
  128303. /**
  128304. * Gets a boolean indicating that this connection point not defined yet
  128305. */
  128306. get isUndefined(): boolean;
  128307. /**
  128308. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  128309. * In this case the connection point name must be the name of the uniform to use.
  128310. * Can only be set on inputs
  128311. */
  128312. get isUniform(): boolean;
  128313. set isUniform(value: boolean);
  128314. /**
  128315. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  128316. * In this case the connection point name must be the name of the attribute to use
  128317. * Can only be set on inputs
  128318. */
  128319. get isAttribute(): boolean;
  128320. set isAttribute(value: boolean);
  128321. /**
  128322. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  128323. * Can only be set on exit points
  128324. */
  128325. get isVarying(): boolean;
  128326. set isVarying(value: boolean);
  128327. /**
  128328. * Gets a boolean indicating that the current connection point is a system value
  128329. */
  128330. get isSystemValue(): boolean;
  128331. /**
  128332. * Gets or sets the current well known value or null if not defined as a system value
  128333. */
  128334. get systemValue(): Nullable<NodeMaterialSystemValues>;
  128335. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  128336. /**
  128337. * Gets the current class name
  128338. * @returns the class name
  128339. */
  128340. getClassName(): string;
  128341. /**
  128342. * Animate the input if animationType !== None
  128343. * @param scene defines the rendering scene
  128344. */
  128345. animate(scene: Scene): void;
  128346. private _emitDefine;
  128347. initialize(state: NodeMaterialBuildState): void;
  128348. /**
  128349. * Set the input block to its default value (based on its type)
  128350. */
  128351. setDefaultValue(): void;
  128352. private _emitConstant;
  128353. private _emit;
  128354. /** @hidden */
  128355. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  128356. /** @hidden */
  128357. _transmit(effect: Effect, scene: Scene): void;
  128358. protected _buildBlock(state: NodeMaterialBuildState): void;
  128359. protected _dumpPropertiesCode(): string;
  128360. serialize(): any;
  128361. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128362. }
  128363. }
  128364. declare module BABYLON {
  128365. /**
  128366. * Enum used to define the compatibility state between two connection points
  128367. */
  128368. export enum NodeMaterialConnectionPointCompatibilityStates {
  128369. /** Points are compatibles */
  128370. Compatible = 0,
  128371. /** Points are incompatible because of their types */
  128372. TypeIncompatible = 1,
  128373. /** Points are incompatible because of their targets (vertex vs fragment) */
  128374. TargetIncompatible = 2
  128375. }
  128376. /**
  128377. * Defines the direction of a connection point
  128378. */
  128379. export enum NodeMaterialConnectionPointDirection {
  128380. /** Input */
  128381. Input = 0,
  128382. /** Output */
  128383. Output = 1
  128384. }
  128385. /**
  128386. * Defines a connection point for a block
  128387. */
  128388. export class NodeMaterialConnectionPoint {
  128389. /** @hidden */
  128390. _ownerBlock: NodeMaterialBlock;
  128391. /** @hidden */
  128392. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  128393. private _endpoints;
  128394. private _associatedVariableName;
  128395. private _direction;
  128396. /** @hidden */
  128397. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  128398. /** @hidden */
  128399. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  128400. private _type;
  128401. /** @hidden */
  128402. _enforceAssociatedVariableName: boolean;
  128403. /** Gets the direction of the point */
  128404. get direction(): NodeMaterialConnectionPointDirection;
  128405. /**
  128406. * Gets or sets the additional types supported by this connection point
  128407. */
  128408. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  128409. /**
  128410. * Gets or sets the additional types excluded by this connection point
  128411. */
  128412. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  128413. /**
  128414. * Observable triggered when this point is connected
  128415. */
  128416. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  128417. /**
  128418. * Gets or sets the associated variable name in the shader
  128419. */
  128420. get associatedVariableName(): string;
  128421. set associatedVariableName(value: string);
  128422. /**
  128423. * Gets or sets the connection point type (default is float)
  128424. */
  128425. get type(): NodeMaterialBlockConnectionPointTypes;
  128426. set type(value: NodeMaterialBlockConnectionPointTypes);
  128427. /**
  128428. * Gets or sets the connection point name
  128429. */
  128430. name: string;
  128431. /**
  128432. * Gets or sets a boolean indicating that this connection point can be omitted
  128433. */
  128434. isOptional: boolean;
  128435. /**
  128436. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  128437. */
  128438. define: string;
  128439. /** @hidden */
  128440. _prioritizeVertex: boolean;
  128441. private _target;
  128442. /** Gets or sets the target of that connection point */
  128443. get target(): NodeMaterialBlockTargets;
  128444. set target(value: NodeMaterialBlockTargets);
  128445. /**
  128446. * Gets a boolean indicating that the current point is connected
  128447. */
  128448. get isConnected(): boolean;
  128449. /**
  128450. * Gets a boolean indicating that the current point is connected to an input block
  128451. */
  128452. get isConnectedToInputBlock(): boolean;
  128453. /**
  128454. * Gets a the connected input block (if any)
  128455. */
  128456. get connectInputBlock(): Nullable<InputBlock>;
  128457. /** Get the other side of the connection (if any) */
  128458. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  128459. /** Get the block that owns this connection point */
  128460. get ownerBlock(): NodeMaterialBlock;
  128461. /** Get the block connected on the other side of this connection (if any) */
  128462. get sourceBlock(): Nullable<NodeMaterialBlock>;
  128463. /** Get the block connected on the endpoints of this connection (if any) */
  128464. get connectedBlocks(): Array<NodeMaterialBlock>;
  128465. /** Gets the list of connected endpoints */
  128466. get endpoints(): NodeMaterialConnectionPoint[];
  128467. /** Gets a boolean indicating if that output point is connected to at least one input */
  128468. get hasEndpoints(): boolean;
  128469. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  128470. get isConnectedInVertexShader(): boolean;
  128471. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  128472. get isConnectedInFragmentShader(): boolean;
  128473. /**
  128474. * Creates a new connection point
  128475. * @param name defines the connection point name
  128476. * @param ownerBlock defines the block hosting this connection point
  128477. * @param direction defines the direction of the connection point
  128478. */
  128479. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  128480. /**
  128481. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  128482. * @returns the class name
  128483. */
  128484. getClassName(): string;
  128485. /**
  128486. * Gets a boolean indicating if the current point can be connected to another point
  128487. * @param connectionPoint defines the other connection point
  128488. * @returns a boolean
  128489. */
  128490. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  128491. /**
  128492. * Gets a number indicating if the current point can be connected to another point
  128493. * @param connectionPoint defines the other connection point
  128494. * @returns a number defining the compatibility state
  128495. */
  128496. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  128497. /**
  128498. * Connect this point to another connection point
  128499. * @param connectionPoint defines the other connection point
  128500. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  128501. * @returns the current connection point
  128502. */
  128503. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  128504. /**
  128505. * Disconnect this point from one of his endpoint
  128506. * @param endpoint defines the other connection point
  128507. * @returns the current connection point
  128508. */
  128509. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  128510. /**
  128511. * Serializes this point in a JSON representation
  128512. * @returns the serialized point object
  128513. */
  128514. serialize(): any;
  128515. /**
  128516. * Release resources
  128517. */
  128518. dispose(): void;
  128519. }
  128520. }
  128521. declare module BABYLON {
  128522. /**
  128523. * Block used to add support for vertex skinning (bones)
  128524. */
  128525. export class BonesBlock extends NodeMaterialBlock {
  128526. /**
  128527. * Creates a new BonesBlock
  128528. * @param name defines the block name
  128529. */
  128530. constructor(name: string);
  128531. /**
  128532. * Initialize the block and prepare the context for build
  128533. * @param state defines the state that will be used for the build
  128534. */
  128535. initialize(state: NodeMaterialBuildState): void;
  128536. /**
  128537. * Gets the current class name
  128538. * @returns the class name
  128539. */
  128540. getClassName(): string;
  128541. /**
  128542. * Gets the matrix indices input component
  128543. */
  128544. get matricesIndices(): NodeMaterialConnectionPoint;
  128545. /**
  128546. * Gets the matrix weights input component
  128547. */
  128548. get matricesWeights(): NodeMaterialConnectionPoint;
  128549. /**
  128550. * Gets the extra matrix indices input component
  128551. */
  128552. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  128553. /**
  128554. * Gets the extra matrix weights input component
  128555. */
  128556. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  128557. /**
  128558. * Gets the world input component
  128559. */
  128560. get world(): NodeMaterialConnectionPoint;
  128561. /**
  128562. * Gets the output component
  128563. */
  128564. get output(): NodeMaterialConnectionPoint;
  128565. autoConfigure(material: NodeMaterial): void;
  128566. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  128567. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128569. protected _buildBlock(state: NodeMaterialBuildState): this;
  128570. }
  128571. }
  128572. declare module BABYLON {
  128573. /**
  128574. * Block used to add support for instances
  128575. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  128576. */
  128577. export class InstancesBlock extends NodeMaterialBlock {
  128578. /**
  128579. * Creates a new InstancesBlock
  128580. * @param name defines the block name
  128581. */
  128582. constructor(name: string);
  128583. /**
  128584. * Gets the current class name
  128585. * @returns the class name
  128586. */
  128587. getClassName(): string;
  128588. /**
  128589. * Gets the first world row input component
  128590. */
  128591. get world0(): NodeMaterialConnectionPoint;
  128592. /**
  128593. * Gets the second world row input component
  128594. */
  128595. get world1(): NodeMaterialConnectionPoint;
  128596. /**
  128597. * Gets the third world row input component
  128598. */
  128599. get world2(): NodeMaterialConnectionPoint;
  128600. /**
  128601. * Gets the forth world row input component
  128602. */
  128603. get world3(): NodeMaterialConnectionPoint;
  128604. /**
  128605. * Gets the world input component
  128606. */
  128607. get world(): NodeMaterialConnectionPoint;
  128608. /**
  128609. * Gets the output component
  128610. */
  128611. get output(): NodeMaterialConnectionPoint;
  128612. autoConfigure(material: NodeMaterial): void;
  128613. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  128614. protected _buildBlock(state: NodeMaterialBuildState): this;
  128615. }
  128616. }
  128617. declare module BABYLON {
  128618. /**
  128619. * Block used to add morph targets support to vertex shader
  128620. */
  128621. export class MorphTargetsBlock extends NodeMaterialBlock {
  128622. private _repeatableContentAnchor;
  128623. private _repeatebleContentGenerated;
  128624. /**
  128625. * Create a new MorphTargetsBlock
  128626. * @param name defines the block name
  128627. */
  128628. constructor(name: string);
  128629. /**
  128630. * Gets the current class name
  128631. * @returns the class name
  128632. */
  128633. getClassName(): string;
  128634. /**
  128635. * Gets the position input component
  128636. */
  128637. get position(): NodeMaterialConnectionPoint;
  128638. /**
  128639. * Gets the normal input component
  128640. */
  128641. get normal(): NodeMaterialConnectionPoint;
  128642. /**
  128643. * Gets the tangent input component
  128644. */
  128645. get tangent(): NodeMaterialConnectionPoint;
  128646. /**
  128647. * Gets the tangent input component
  128648. */
  128649. get uv(): NodeMaterialConnectionPoint;
  128650. /**
  128651. * Gets the position output component
  128652. */
  128653. get positionOutput(): NodeMaterialConnectionPoint;
  128654. /**
  128655. * Gets the normal output component
  128656. */
  128657. get normalOutput(): NodeMaterialConnectionPoint;
  128658. /**
  128659. * Gets the tangent output component
  128660. */
  128661. get tangentOutput(): NodeMaterialConnectionPoint;
  128662. /**
  128663. * Gets the tangent output component
  128664. */
  128665. get uvOutput(): NodeMaterialConnectionPoint;
  128666. initialize(state: NodeMaterialBuildState): void;
  128667. autoConfigure(material: NodeMaterial): void;
  128668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128670. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  128671. protected _buildBlock(state: NodeMaterialBuildState): this;
  128672. }
  128673. }
  128674. declare module BABYLON {
  128675. /**
  128676. * Block used to get data information from a light
  128677. */
  128678. export class LightInformationBlock extends NodeMaterialBlock {
  128679. private _lightDataUniformName;
  128680. private _lightColorUniformName;
  128681. private _lightTypeDefineName;
  128682. /**
  128683. * Gets or sets the light associated with this block
  128684. */
  128685. light: Nullable<Light>;
  128686. /**
  128687. * Creates a new LightInformationBlock
  128688. * @param name defines the block name
  128689. */
  128690. constructor(name: string);
  128691. /**
  128692. * Gets the current class name
  128693. * @returns the class name
  128694. */
  128695. getClassName(): string;
  128696. /**
  128697. * Gets the world position input component
  128698. */
  128699. get worldPosition(): NodeMaterialConnectionPoint;
  128700. /**
  128701. * Gets the direction output component
  128702. */
  128703. get direction(): NodeMaterialConnectionPoint;
  128704. /**
  128705. * Gets the direction output component
  128706. */
  128707. get color(): NodeMaterialConnectionPoint;
  128708. /**
  128709. * Gets the direction output component
  128710. */
  128711. get intensity(): NodeMaterialConnectionPoint;
  128712. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128714. protected _buildBlock(state: NodeMaterialBuildState): this;
  128715. serialize(): any;
  128716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128717. }
  128718. }
  128719. declare module BABYLON {
  128720. /**
  128721. * Block used to add image processing support to fragment shader
  128722. */
  128723. export class ImageProcessingBlock extends NodeMaterialBlock {
  128724. /**
  128725. * Create a new ImageProcessingBlock
  128726. * @param name defines the block name
  128727. */
  128728. constructor(name: string);
  128729. /**
  128730. * Gets the current class name
  128731. * @returns the class name
  128732. */
  128733. getClassName(): string;
  128734. /**
  128735. * Gets the color input component
  128736. */
  128737. get color(): NodeMaterialConnectionPoint;
  128738. /**
  128739. * Gets the output component
  128740. */
  128741. get output(): NodeMaterialConnectionPoint;
  128742. /**
  128743. * Initialize the block and prepare the context for build
  128744. * @param state defines the state that will be used for the build
  128745. */
  128746. initialize(state: NodeMaterialBuildState): void;
  128747. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  128748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128749. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128750. protected _buildBlock(state: NodeMaterialBuildState): this;
  128751. }
  128752. }
  128753. declare module BABYLON {
  128754. /**
  128755. * Block used to pertub normals based on a normal map
  128756. */
  128757. export class PerturbNormalBlock extends NodeMaterialBlock {
  128758. private _tangentSpaceParameterName;
  128759. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128760. invertX: boolean;
  128761. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  128762. invertY: boolean;
  128763. /**
  128764. * Create a new PerturbNormalBlock
  128765. * @param name defines the block name
  128766. */
  128767. constructor(name: string);
  128768. /**
  128769. * Gets the current class name
  128770. * @returns the class name
  128771. */
  128772. getClassName(): string;
  128773. /**
  128774. * Gets the world position input component
  128775. */
  128776. get worldPosition(): NodeMaterialConnectionPoint;
  128777. /**
  128778. * Gets the world normal input component
  128779. */
  128780. get worldNormal(): NodeMaterialConnectionPoint;
  128781. /**
  128782. * Gets the uv input component
  128783. */
  128784. get uv(): NodeMaterialConnectionPoint;
  128785. /**
  128786. * Gets the normal map color input component
  128787. */
  128788. get normalMapColor(): NodeMaterialConnectionPoint;
  128789. /**
  128790. * Gets the strength input component
  128791. */
  128792. get strength(): NodeMaterialConnectionPoint;
  128793. /**
  128794. * Gets the output component
  128795. */
  128796. get output(): NodeMaterialConnectionPoint;
  128797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128799. autoConfigure(material: NodeMaterial): void;
  128800. protected _buildBlock(state: NodeMaterialBuildState): this;
  128801. protected _dumpPropertiesCode(): string;
  128802. serialize(): any;
  128803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128804. }
  128805. }
  128806. declare module BABYLON {
  128807. /**
  128808. * Block used to discard a pixel if a value is smaller than a cutoff
  128809. */
  128810. export class DiscardBlock extends NodeMaterialBlock {
  128811. /**
  128812. * Create a new DiscardBlock
  128813. * @param name defines the block name
  128814. */
  128815. constructor(name: string);
  128816. /**
  128817. * Gets the current class name
  128818. * @returns the class name
  128819. */
  128820. getClassName(): string;
  128821. /**
  128822. * Gets the color input component
  128823. */
  128824. get value(): NodeMaterialConnectionPoint;
  128825. /**
  128826. * Gets the cutoff input component
  128827. */
  128828. get cutoff(): NodeMaterialConnectionPoint;
  128829. protected _buildBlock(state: NodeMaterialBuildState): this;
  128830. }
  128831. }
  128832. declare module BABYLON {
  128833. /**
  128834. * Block used to test if the fragment shader is front facing
  128835. */
  128836. export class FrontFacingBlock extends NodeMaterialBlock {
  128837. /**
  128838. * Creates a new FrontFacingBlock
  128839. * @param name defines the block name
  128840. */
  128841. constructor(name: string);
  128842. /**
  128843. * Gets the current class name
  128844. * @returns the class name
  128845. */
  128846. getClassName(): string;
  128847. /**
  128848. * Gets the output component
  128849. */
  128850. get output(): NodeMaterialConnectionPoint;
  128851. protected _buildBlock(state: NodeMaterialBuildState): this;
  128852. }
  128853. }
  128854. declare module BABYLON {
  128855. /**
  128856. * Block used to get the derivative value on x and y of a given input
  128857. */
  128858. export class DerivativeBlock extends NodeMaterialBlock {
  128859. /**
  128860. * Create a new DerivativeBlock
  128861. * @param name defines the block name
  128862. */
  128863. constructor(name: string);
  128864. /**
  128865. * Gets the current class name
  128866. * @returns the class name
  128867. */
  128868. getClassName(): string;
  128869. /**
  128870. * Gets the input component
  128871. */
  128872. get input(): NodeMaterialConnectionPoint;
  128873. /**
  128874. * Gets the derivative output on x
  128875. */
  128876. get dx(): NodeMaterialConnectionPoint;
  128877. /**
  128878. * Gets the derivative output on y
  128879. */
  128880. get dy(): NodeMaterialConnectionPoint;
  128881. protected _buildBlock(state: NodeMaterialBuildState): this;
  128882. }
  128883. }
  128884. declare module BABYLON {
  128885. /**
  128886. * Block used to add support for scene fog
  128887. */
  128888. export class FogBlock extends NodeMaterialBlock {
  128889. private _fogDistanceName;
  128890. private _fogParameters;
  128891. /**
  128892. * Create a new FogBlock
  128893. * @param name defines the block name
  128894. */
  128895. constructor(name: string);
  128896. /**
  128897. * Gets the current class name
  128898. * @returns the class name
  128899. */
  128900. getClassName(): string;
  128901. /**
  128902. * Gets the world position input component
  128903. */
  128904. get worldPosition(): NodeMaterialConnectionPoint;
  128905. /**
  128906. * Gets the view input component
  128907. */
  128908. get view(): NodeMaterialConnectionPoint;
  128909. /**
  128910. * Gets the color input component
  128911. */
  128912. get input(): NodeMaterialConnectionPoint;
  128913. /**
  128914. * Gets the fog color input component
  128915. */
  128916. get fogColor(): NodeMaterialConnectionPoint;
  128917. /**
  128918. * Gets the output component
  128919. */
  128920. get output(): NodeMaterialConnectionPoint;
  128921. autoConfigure(material: NodeMaterial): void;
  128922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128923. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128924. protected _buildBlock(state: NodeMaterialBuildState): this;
  128925. }
  128926. }
  128927. declare module BABYLON {
  128928. /**
  128929. * Block used to add light in the fragment shader
  128930. */
  128931. export class LightBlock extends NodeMaterialBlock {
  128932. private _lightId;
  128933. /**
  128934. * Gets or sets the light associated with this block
  128935. */
  128936. light: Nullable<Light>;
  128937. /**
  128938. * Create a new LightBlock
  128939. * @param name defines the block name
  128940. */
  128941. constructor(name: string);
  128942. /**
  128943. * Gets the current class name
  128944. * @returns the class name
  128945. */
  128946. getClassName(): string;
  128947. /**
  128948. * Gets the world position input component
  128949. */
  128950. get worldPosition(): NodeMaterialConnectionPoint;
  128951. /**
  128952. * Gets the world normal input component
  128953. */
  128954. get worldNormal(): NodeMaterialConnectionPoint;
  128955. /**
  128956. * Gets the camera (or eye) position component
  128957. */
  128958. get cameraPosition(): NodeMaterialConnectionPoint;
  128959. /**
  128960. * Gets the glossiness component
  128961. */
  128962. get glossiness(): NodeMaterialConnectionPoint;
  128963. /**
  128964. * Gets the glossinness power component
  128965. */
  128966. get glossPower(): NodeMaterialConnectionPoint;
  128967. /**
  128968. * Gets the diffuse color component
  128969. */
  128970. get diffuseColor(): NodeMaterialConnectionPoint;
  128971. /**
  128972. * Gets the specular color component
  128973. */
  128974. get specularColor(): NodeMaterialConnectionPoint;
  128975. /**
  128976. * Gets the diffuse output component
  128977. */
  128978. get diffuseOutput(): NodeMaterialConnectionPoint;
  128979. /**
  128980. * Gets the specular output component
  128981. */
  128982. get specularOutput(): NodeMaterialConnectionPoint;
  128983. /**
  128984. * Gets the shadow output component
  128985. */
  128986. get shadow(): NodeMaterialConnectionPoint;
  128987. autoConfigure(material: NodeMaterial): void;
  128988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128989. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  128990. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128991. private _injectVertexCode;
  128992. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128993. serialize(): any;
  128994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128995. }
  128996. }
  128997. declare module BABYLON {
  128998. /**
  128999. * Block used to multiply 2 values
  129000. */
  129001. export class MultiplyBlock extends NodeMaterialBlock {
  129002. /**
  129003. * Creates a new MultiplyBlock
  129004. * @param name defines the block name
  129005. */
  129006. constructor(name: string);
  129007. /**
  129008. * Gets the current class name
  129009. * @returns the class name
  129010. */
  129011. getClassName(): string;
  129012. /**
  129013. * Gets the left operand input component
  129014. */
  129015. get left(): NodeMaterialConnectionPoint;
  129016. /**
  129017. * Gets the right operand input component
  129018. */
  129019. get right(): NodeMaterialConnectionPoint;
  129020. /**
  129021. * Gets the output component
  129022. */
  129023. get output(): NodeMaterialConnectionPoint;
  129024. protected _buildBlock(state: NodeMaterialBuildState): this;
  129025. }
  129026. }
  129027. declare module BABYLON {
  129028. /**
  129029. * Block used to add 2 vectors
  129030. */
  129031. export class AddBlock extends NodeMaterialBlock {
  129032. /**
  129033. * Creates a new AddBlock
  129034. * @param name defines the block name
  129035. */
  129036. constructor(name: string);
  129037. /**
  129038. * Gets the current class name
  129039. * @returns the class name
  129040. */
  129041. getClassName(): string;
  129042. /**
  129043. * Gets the left operand input component
  129044. */
  129045. get left(): NodeMaterialConnectionPoint;
  129046. /**
  129047. * Gets the right operand input component
  129048. */
  129049. get right(): NodeMaterialConnectionPoint;
  129050. /**
  129051. * Gets the output component
  129052. */
  129053. get output(): NodeMaterialConnectionPoint;
  129054. protected _buildBlock(state: NodeMaterialBuildState): this;
  129055. }
  129056. }
  129057. declare module BABYLON {
  129058. /**
  129059. * Block used to scale a vector by a float
  129060. */
  129061. export class ScaleBlock extends NodeMaterialBlock {
  129062. /**
  129063. * Creates a new ScaleBlock
  129064. * @param name defines the block name
  129065. */
  129066. constructor(name: string);
  129067. /**
  129068. * Gets the current class name
  129069. * @returns the class name
  129070. */
  129071. getClassName(): string;
  129072. /**
  129073. * Gets the input component
  129074. */
  129075. get input(): NodeMaterialConnectionPoint;
  129076. /**
  129077. * Gets the factor input component
  129078. */
  129079. get factor(): NodeMaterialConnectionPoint;
  129080. /**
  129081. * Gets the output component
  129082. */
  129083. get output(): NodeMaterialConnectionPoint;
  129084. protected _buildBlock(state: NodeMaterialBuildState): this;
  129085. }
  129086. }
  129087. declare module BABYLON {
  129088. /**
  129089. * Block used to clamp a float
  129090. */
  129091. export class ClampBlock extends NodeMaterialBlock {
  129092. /** Gets or sets the minimum range */
  129093. minimum: number;
  129094. /** Gets or sets the maximum range */
  129095. maximum: number;
  129096. /**
  129097. * Creates a new ClampBlock
  129098. * @param name defines the block name
  129099. */
  129100. constructor(name: string);
  129101. /**
  129102. * Gets the current class name
  129103. * @returns the class name
  129104. */
  129105. getClassName(): string;
  129106. /**
  129107. * Gets the value input component
  129108. */
  129109. get value(): NodeMaterialConnectionPoint;
  129110. /**
  129111. * Gets the output component
  129112. */
  129113. get output(): NodeMaterialConnectionPoint;
  129114. protected _buildBlock(state: NodeMaterialBuildState): this;
  129115. protected _dumpPropertiesCode(): string;
  129116. serialize(): any;
  129117. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129118. }
  129119. }
  129120. declare module BABYLON {
  129121. /**
  129122. * Block used to apply a cross product between 2 vectors
  129123. */
  129124. export class CrossBlock extends NodeMaterialBlock {
  129125. /**
  129126. * Creates a new CrossBlock
  129127. * @param name defines the block name
  129128. */
  129129. constructor(name: string);
  129130. /**
  129131. * Gets the current class name
  129132. * @returns the class name
  129133. */
  129134. getClassName(): string;
  129135. /**
  129136. * Gets the left operand input component
  129137. */
  129138. get left(): NodeMaterialConnectionPoint;
  129139. /**
  129140. * Gets the right operand input component
  129141. */
  129142. get right(): NodeMaterialConnectionPoint;
  129143. /**
  129144. * Gets the output component
  129145. */
  129146. get output(): NodeMaterialConnectionPoint;
  129147. protected _buildBlock(state: NodeMaterialBuildState): this;
  129148. }
  129149. }
  129150. declare module BABYLON {
  129151. /**
  129152. * Block used to apply a dot product between 2 vectors
  129153. */
  129154. export class DotBlock extends NodeMaterialBlock {
  129155. /**
  129156. * Creates a new DotBlock
  129157. * @param name defines the block name
  129158. */
  129159. constructor(name: string);
  129160. /**
  129161. * Gets the current class name
  129162. * @returns the class name
  129163. */
  129164. getClassName(): string;
  129165. /**
  129166. * Gets the left operand input component
  129167. */
  129168. get left(): NodeMaterialConnectionPoint;
  129169. /**
  129170. * Gets the right operand input component
  129171. */
  129172. get right(): NodeMaterialConnectionPoint;
  129173. /**
  129174. * Gets the output component
  129175. */
  129176. get output(): NodeMaterialConnectionPoint;
  129177. protected _buildBlock(state: NodeMaterialBuildState): this;
  129178. }
  129179. }
  129180. declare module BABYLON {
  129181. /**
  129182. * Block used to remap a float from a range to a new one
  129183. */
  129184. export class RemapBlock extends NodeMaterialBlock {
  129185. /**
  129186. * Gets or sets the source range
  129187. */
  129188. sourceRange: Vector2;
  129189. /**
  129190. * Gets or sets the target range
  129191. */
  129192. targetRange: Vector2;
  129193. /**
  129194. * Creates a new RemapBlock
  129195. * @param name defines the block name
  129196. */
  129197. constructor(name: string);
  129198. /**
  129199. * Gets the current class name
  129200. * @returns the class name
  129201. */
  129202. getClassName(): string;
  129203. /**
  129204. * Gets the input component
  129205. */
  129206. get input(): NodeMaterialConnectionPoint;
  129207. /**
  129208. * Gets the source min input component
  129209. */
  129210. get sourceMin(): NodeMaterialConnectionPoint;
  129211. /**
  129212. * Gets the source max input component
  129213. */
  129214. get sourceMax(): NodeMaterialConnectionPoint;
  129215. /**
  129216. * Gets the target min input component
  129217. */
  129218. get targetMin(): NodeMaterialConnectionPoint;
  129219. /**
  129220. * Gets the target max input component
  129221. */
  129222. get targetMax(): NodeMaterialConnectionPoint;
  129223. /**
  129224. * Gets the output component
  129225. */
  129226. get output(): NodeMaterialConnectionPoint;
  129227. protected _buildBlock(state: NodeMaterialBuildState): this;
  129228. protected _dumpPropertiesCode(): string;
  129229. serialize(): any;
  129230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129231. }
  129232. }
  129233. declare module BABYLON {
  129234. /**
  129235. * Block used to normalize a vector
  129236. */
  129237. export class NormalizeBlock extends NodeMaterialBlock {
  129238. /**
  129239. * Creates a new NormalizeBlock
  129240. * @param name defines the block name
  129241. */
  129242. constructor(name: string);
  129243. /**
  129244. * Gets the current class name
  129245. * @returns the class name
  129246. */
  129247. getClassName(): string;
  129248. /**
  129249. * Gets the input component
  129250. */
  129251. get input(): NodeMaterialConnectionPoint;
  129252. /**
  129253. * Gets the output component
  129254. */
  129255. get output(): NodeMaterialConnectionPoint;
  129256. protected _buildBlock(state: NodeMaterialBuildState): this;
  129257. }
  129258. }
  129259. declare module BABYLON {
  129260. /**
  129261. * Operations supported by the Trigonometry block
  129262. */
  129263. export enum TrigonometryBlockOperations {
  129264. /** Cos */
  129265. Cos = 0,
  129266. /** Sin */
  129267. Sin = 1,
  129268. /** Abs */
  129269. Abs = 2,
  129270. /** Exp */
  129271. Exp = 3,
  129272. /** Exp2 */
  129273. Exp2 = 4,
  129274. /** Round */
  129275. Round = 5,
  129276. /** Floor */
  129277. Floor = 6,
  129278. /** Ceiling */
  129279. Ceiling = 7,
  129280. /** Square root */
  129281. Sqrt = 8,
  129282. /** Log */
  129283. Log = 9,
  129284. /** Tangent */
  129285. Tan = 10,
  129286. /** Arc tangent */
  129287. ArcTan = 11,
  129288. /** Arc cosinus */
  129289. ArcCos = 12,
  129290. /** Arc sinus */
  129291. ArcSin = 13,
  129292. /** Fraction */
  129293. Fract = 14,
  129294. /** Sign */
  129295. Sign = 15,
  129296. /** To radians (from degrees) */
  129297. Radians = 16,
  129298. /** To degrees (from radians) */
  129299. Degrees = 17
  129300. }
  129301. /**
  129302. * Block used to apply trigonometry operation to floats
  129303. */
  129304. export class TrigonometryBlock extends NodeMaterialBlock {
  129305. /**
  129306. * Gets or sets the operation applied by the block
  129307. */
  129308. operation: TrigonometryBlockOperations;
  129309. /**
  129310. * Creates a new TrigonometryBlock
  129311. * @param name defines the block name
  129312. */
  129313. constructor(name: string);
  129314. /**
  129315. * Gets the current class name
  129316. * @returns the class name
  129317. */
  129318. getClassName(): string;
  129319. /**
  129320. * Gets the input component
  129321. */
  129322. get input(): NodeMaterialConnectionPoint;
  129323. /**
  129324. * Gets the output component
  129325. */
  129326. get output(): NodeMaterialConnectionPoint;
  129327. protected _buildBlock(state: NodeMaterialBuildState): this;
  129328. serialize(): any;
  129329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129330. protected _dumpPropertiesCode(): string;
  129331. }
  129332. }
  129333. declare module BABYLON {
  129334. /**
  129335. * Block used to create a Color3/4 out of individual inputs (one for each component)
  129336. */
  129337. export class ColorMergerBlock extends NodeMaterialBlock {
  129338. /**
  129339. * Create a new ColorMergerBlock
  129340. * @param name defines the block name
  129341. */
  129342. constructor(name: string);
  129343. /**
  129344. * Gets the current class name
  129345. * @returns the class name
  129346. */
  129347. getClassName(): string;
  129348. /**
  129349. * Gets the rgb component (input)
  129350. */
  129351. get rgbIn(): NodeMaterialConnectionPoint;
  129352. /**
  129353. * Gets the r component (input)
  129354. */
  129355. get r(): NodeMaterialConnectionPoint;
  129356. /**
  129357. * Gets the g component (input)
  129358. */
  129359. get g(): NodeMaterialConnectionPoint;
  129360. /**
  129361. * Gets the b component (input)
  129362. */
  129363. get b(): NodeMaterialConnectionPoint;
  129364. /**
  129365. * Gets the a component (input)
  129366. */
  129367. get a(): NodeMaterialConnectionPoint;
  129368. /**
  129369. * Gets the rgba component (output)
  129370. */
  129371. get rgba(): NodeMaterialConnectionPoint;
  129372. /**
  129373. * Gets the rgb component (output)
  129374. */
  129375. get rgbOut(): NodeMaterialConnectionPoint;
  129376. /**
  129377. * Gets the rgb component (output)
  129378. * @deprecated Please use rgbOut instead.
  129379. */
  129380. get rgb(): NodeMaterialConnectionPoint;
  129381. protected _buildBlock(state: NodeMaterialBuildState): this;
  129382. }
  129383. }
  129384. declare module BABYLON {
  129385. /**
  129386. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  129387. */
  129388. export class VectorMergerBlock extends NodeMaterialBlock {
  129389. /**
  129390. * Create a new VectorMergerBlock
  129391. * @param name defines the block name
  129392. */
  129393. constructor(name: string);
  129394. /**
  129395. * Gets the current class name
  129396. * @returns the class name
  129397. */
  129398. getClassName(): string;
  129399. /**
  129400. * Gets the xyz component (input)
  129401. */
  129402. get xyzIn(): NodeMaterialConnectionPoint;
  129403. /**
  129404. * Gets the xy component (input)
  129405. */
  129406. get xyIn(): NodeMaterialConnectionPoint;
  129407. /**
  129408. * Gets the x component (input)
  129409. */
  129410. get x(): NodeMaterialConnectionPoint;
  129411. /**
  129412. * Gets the y component (input)
  129413. */
  129414. get y(): NodeMaterialConnectionPoint;
  129415. /**
  129416. * Gets the z component (input)
  129417. */
  129418. get z(): NodeMaterialConnectionPoint;
  129419. /**
  129420. * Gets the w component (input)
  129421. */
  129422. get w(): NodeMaterialConnectionPoint;
  129423. /**
  129424. * Gets the xyzw component (output)
  129425. */
  129426. get xyzw(): NodeMaterialConnectionPoint;
  129427. /**
  129428. * Gets the xyz component (output)
  129429. */
  129430. get xyzOut(): NodeMaterialConnectionPoint;
  129431. /**
  129432. * Gets the xy component (output)
  129433. */
  129434. get xyOut(): NodeMaterialConnectionPoint;
  129435. /**
  129436. * Gets the xy component (output)
  129437. * @deprecated Please use xyOut instead.
  129438. */
  129439. get xy(): NodeMaterialConnectionPoint;
  129440. /**
  129441. * Gets the xyz component (output)
  129442. * @deprecated Please use xyzOut instead.
  129443. */
  129444. get xyz(): NodeMaterialConnectionPoint;
  129445. protected _buildBlock(state: NodeMaterialBuildState): this;
  129446. }
  129447. }
  129448. declare module BABYLON {
  129449. /**
  129450. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  129451. */
  129452. export class ColorSplitterBlock extends NodeMaterialBlock {
  129453. /**
  129454. * Create a new ColorSplitterBlock
  129455. * @param name defines the block name
  129456. */
  129457. constructor(name: string);
  129458. /**
  129459. * Gets the current class name
  129460. * @returns the class name
  129461. */
  129462. getClassName(): string;
  129463. /**
  129464. * Gets the rgba component (input)
  129465. */
  129466. get rgba(): NodeMaterialConnectionPoint;
  129467. /**
  129468. * Gets the rgb component (input)
  129469. */
  129470. get rgbIn(): NodeMaterialConnectionPoint;
  129471. /**
  129472. * Gets the rgb component (output)
  129473. */
  129474. get rgbOut(): NodeMaterialConnectionPoint;
  129475. /**
  129476. * Gets the r component (output)
  129477. */
  129478. get r(): NodeMaterialConnectionPoint;
  129479. /**
  129480. * Gets the g component (output)
  129481. */
  129482. get g(): NodeMaterialConnectionPoint;
  129483. /**
  129484. * Gets the b component (output)
  129485. */
  129486. get b(): NodeMaterialConnectionPoint;
  129487. /**
  129488. * Gets the a component (output)
  129489. */
  129490. get a(): NodeMaterialConnectionPoint;
  129491. protected _inputRename(name: string): string;
  129492. protected _outputRename(name: string): string;
  129493. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129494. }
  129495. }
  129496. declare module BABYLON {
  129497. /**
  129498. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  129499. */
  129500. export class VectorSplitterBlock extends NodeMaterialBlock {
  129501. /**
  129502. * Create a new VectorSplitterBlock
  129503. * @param name defines the block name
  129504. */
  129505. constructor(name: string);
  129506. /**
  129507. * Gets the current class name
  129508. * @returns the class name
  129509. */
  129510. getClassName(): string;
  129511. /**
  129512. * Gets the xyzw component (input)
  129513. */
  129514. get xyzw(): NodeMaterialConnectionPoint;
  129515. /**
  129516. * Gets the xyz component (input)
  129517. */
  129518. get xyzIn(): NodeMaterialConnectionPoint;
  129519. /**
  129520. * Gets the xy component (input)
  129521. */
  129522. get xyIn(): NodeMaterialConnectionPoint;
  129523. /**
  129524. * Gets the xyz component (output)
  129525. */
  129526. get xyzOut(): NodeMaterialConnectionPoint;
  129527. /**
  129528. * Gets the xy component (output)
  129529. */
  129530. get xyOut(): NodeMaterialConnectionPoint;
  129531. /**
  129532. * Gets the x component (output)
  129533. */
  129534. get x(): NodeMaterialConnectionPoint;
  129535. /**
  129536. * Gets the y component (output)
  129537. */
  129538. get y(): NodeMaterialConnectionPoint;
  129539. /**
  129540. * Gets the z component (output)
  129541. */
  129542. get z(): NodeMaterialConnectionPoint;
  129543. /**
  129544. * Gets the w component (output)
  129545. */
  129546. get w(): NodeMaterialConnectionPoint;
  129547. protected _inputRename(name: string): string;
  129548. protected _outputRename(name: string): string;
  129549. protected _buildBlock(state: NodeMaterialBuildState): this;
  129550. }
  129551. }
  129552. declare module BABYLON {
  129553. /**
  129554. * Block used to lerp between 2 values
  129555. */
  129556. export class LerpBlock extends NodeMaterialBlock {
  129557. /**
  129558. * Creates a new LerpBlock
  129559. * @param name defines the block name
  129560. */
  129561. constructor(name: string);
  129562. /**
  129563. * Gets the current class name
  129564. * @returns the class name
  129565. */
  129566. getClassName(): string;
  129567. /**
  129568. * Gets the left operand input component
  129569. */
  129570. get left(): NodeMaterialConnectionPoint;
  129571. /**
  129572. * Gets the right operand input component
  129573. */
  129574. get right(): NodeMaterialConnectionPoint;
  129575. /**
  129576. * Gets the gradient operand input component
  129577. */
  129578. get gradient(): NodeMaterialConnectionPoint;
  129579. /**
  129580. * Gets the output component
  129581. */
  129582. get output(): NodeMaterialConnectionPoint;
  129583. protected _buildBlock(state: NodeMaterialBuildState): this;
  129584. }
  129585. }
  129586. declare module BABYLON {
  129587. /**
  129588. * Block used to divide 2 vectors
  129589. */
  129590. export class DivideBlock extends NodeMaterialBlock {
  129591. /**
  129592. * Creates a new DivideBlock
  129593. * @param name defines the block name
  129594. */
  129595. constructor(name: string);
  129596. /**
  129597. * Gets the current class name
  129598. * @returns the class name
  129599. */
  129600. getClassName(): string;
  129601. /**
  129602. * Gets the left operand input component
  129603. */
  129604. get left(): NodeMaterialConnectionPoint;
  129605. /**
  129606. * Gets the right operand input component
  129607. */
  129608. get right(): NodeMaterialConnectionPoint;
  129609. /**
  129610. * Gets the output component
  129611. */
  129612. get output(): NodeMaterialConnectionPoint;
  129613. protected _buildBlock(state: NodeMaterialBuildState): this;
  129614. }
  129615. }
  129616. declare module BABYLON {
  129617. /**
  129618. * Block used to subtract 2 vectors
  129619. */
  129620. export class SubtractBlock extends NodeMaterialBlock {
  129621. /**
  129622. * Creates a new SubtractBlock
  129623. * @param name defines the block name
  129624. */
  129625. constructor(name: string);
  129626. /**
  129627. * Gets the current class name
  129628. * @returns the class name
  129629. */
  129630. getClassName(): string;
  129631. /**
  129632. * Gets the left operand input component
  129633. */
  129634. get left(): NodeMaterialConnectionPoint;
  129635. /**
  129636. * Gets the right operand input component
  129637. */
  129638. get right(): NodeMaterialConnectionPoint;
  129639. /**
  129640. * Gets the output component
  129641. */
  129642. get output(): NodeMaterialConnectionPoint;
  129643. protected _buildBlock(state: NodeMaterialBuildState): this;
  129644. }
  129645. }
  129646. declare module BABYLON {
  129647. /**
  129648. * Block used to step a value
  129649. */
  129650. export class StepBlock extends NodeMaterialBlock {
  129651. /**
  129652. * Creates a new StepBlock
  129653. * @param name defines the block name
  129654. */
  129655. constructor(name: string);
  129656. /**
  129657. * Gets the current class name
  129658. * @returns the class name
  129659. */
  129660. getClassName(): string;
  129661. /**
  129662. * Gets the value operand input component
  129663. */
  129664. get value(): NodeMaterialConnectionPoint;
  129665. /**
  129666. * Gets the edge operand input component
  129667. */
  129668. get edge(): NodeMaterialConnectionPoint;
  129669. /**
  129670. * Gets the output component
  129671. */
  129672. get output(): NodeMaterialConnectionPoint;
  129673. protected _buildBlock(state: NodeMaterialBuildState): this;
  129674. }
  129675. }
  129676. declare module BABYLON {
  129677. /**
  129678. * Block used to get the opposite (1 - x) of a value
  129679. */
  129680. export class OneMinusBlock extends NodeMaterialBlock {
  129681. /**
  129682. * Creates a new OneMinusBlock
  129683. * @param name defines the block name
  129684. */
  129685. constructor(name: string);
  129686. /**
  129687. * Gets the current class name
  129688. * @returns the class name
  129689. */
  129690. getClassName(): string;
  129691. /**
  129692. * Gets the input component
  129693. */
  129694. get input(): NodeMaterialConnectionPoint;
  129695. /**
  129696. * Gets the output component
  129697. */
  129698. get output(): NodeMaterialConnectionPoint;
  129699. protected _buildBlock(state: NodeMaterialBuildState): this;
  129700. }
  129701. }
  129702. declare module BABYLON {
  129703. /**
  129704. * Block used to get the view direction
  129705. */
  129706. export class ViewDirectionBlock extends NodeMaterialBlock {
  129707. /**
  129708. * Creates a new ViewDirectionBlock
  129709. * @param name defines the block name
  129710. */
  129711. constructor(name: string);
  129712. /**
  129713. * Gets the current class name
  129714. * @returns the class name
  129715. */
  129716. getClassName(): string;
  129717. /**
  129718. * Gets the world position component
  129719. */
  129720. get worldPosition(): NodeMaterialConnectionPoint;
  129721. /**
  129722. * Gets the camera position component
  129723. */
  129724. get cameraPosition(): NodeMaterialConnectionPoint;
  129725. /**
  129726. * Gets the output component
  129727. */
  129728. get output(): NodeMaterialConnectionPoint;
  129729. autoConfigure(material: NodeMaterial): void;
  129730. protected _buildBlock(state: NodeMaterialBuildState): this;
  129731. }
  129732. }
  129733. declare module BABYLON {
  129734. /**
  129735. * Block used to compute fresnel value
  129736. */
  129737. export class FresnelBlock extends NodeMaterialBlock {
  129738. /**
  129739. * Create a new FresnelBlock
  129740. * @param name defines the block name
  129741. */
  129742. constructor(name: string);
  129743. /**
  129744. * Gets the current class name
  129745. * @returns the class name
  129746. */
  129747. getClassName(): string;
  129748. /**
  129749. * Gets the world normal input component
  129750. */
  129751. get worldNormal(): NodeMaterialConnectionPoint;
  129752. /**
  129753. * Gets the view direction input component
  129754. */
  129755. get viewDirection(): NodeMaterialConnectionPoint;
  129756. /**
  129757. * Gets the bias input component
  129758. */
  129759. get bias(): NodeMaterialConnectionPoint;
  129760. /**
  129761. * Gets the camera (or eye) position component
  129762. */
  129763. get power(): NodeMaterialConnectionPoint;
  129764. /**
  129765. * Gets the fresnel output component
  129766. */
  129767. get fresnel(): NodeMaterialConnectionPoint;
  129768. autoConfigure(material: NodeMaterial): void;
  129769. protected _buildBlock(state: NodeMaterialBuildState): this;
  129770. }
  129771. }
  129772. declare module BABYLON {
  129773. /**
  129774. * Block used to get the max of 2 values
  129775. */
  129776. export class MaxBlock extends NodeMaterialBlock {
  129777. /**
  129778. * Creates a new MaxBlock
  129779. * @param name defines the block name
  129780. */
  129781. constructor(name: string);
  129782. /**
  129783. * Gets the current class name
  129784. * @returns the class name
  129785. */
  129786. getClassName(): string;
  129787. /**
  129788. * Gets the left operand input component
  129789. */
  129790. get left(): NodeMaterialConnectionPoint;
  129791. /**
  129792. * Gets the right operand input component
  129793. */
  129794. get right(): NodeMaterialConnectionPoint;
  129795. /**
  129796. * Gets the output component
  129797. */
  129798. get output(): NodeMaterialConnectionPoint;
  129799. protected _buildBlock(state: NodeMaterialBuildState): this;
  129800. }
  129801. }
  129802. declare module BABYLON {
  129803. /**
  129804. * Block used to get the min of 2 values
  129805. */
  129806. export class MinBlock extends NodeMaterialBlock {
  129807. /**
  129808. * Creates a new MinBlock
  129809. * @param name defines the block name
  129810. */
  129811. constructor(name: string);
  129812. /**
  129813. * Gets the current class name
  129814. * @returns the class name
  129815. */
  129816. getClassName(): string;
  129817. /**
  129818. * Gets the left operand input component
  129819. */
  129820. get left(): NodeMaterialConnectionPoint;
  129821. /**
  129822. * Gets the right operand input component
  129823. */
  129824. get right(): NodeMaterialConnectionPoint;
  129825. /**
  129826. * Gets the output component
  129827. */
  129828. get output(): NodeMaterialConnectionPoint;
  129829. protected _buildBlock(state: NodeMaterialBuildState): this;
  129830. }
  129831. }
  129832. declare module BABYLON {
  129833. /**
  129834. * Block used to get the distance between 2 values
  129835. */
  129836. export class DistanceBlock extends NodeMaterialBlock {
  129837. /**
  129838. * Creates a new DistanceBlock
  129839. * @param name defines the block name
  129840. */
  129841. constructor(name: string);
  129842. /**
  129843. * Gets the current class name
  129844. * @returns the class name
  129845. */
  129846. getClassName(): string;
  129847. /**
  129848. * Gets the left operand input component
  129849. */
  129850. get left(): NodeMaterialConnectionPoint;
  129851. /**
  129852. * Gets the right operand input component
  129853. */
  129854. get right(): NodeMaterialConnectionPoint;
  129855. /**
  129856. * Gets the output component
  129857. */
  129858. get output(): NodeMaterialConnectionPoint;
  129859. protected _buildBlock(state: NodeMaterialBuildState): this;
  129860. }
  129861. }
  129862. declare module BABYLON {
  129863. /**
  129864. * Block used to get the length of a vector
  129865. */
  129866. export class LengthBlock extends NodeMaterialBlock {
  129867. /**
  129868. * Creates a new LengthBlock
  129869. * @param name defines the block name
  129870. */
  129871. constructor(name: string);
  129872. /**
  129873. * Gets the current class name
  129874. * @returns the class name
  129875. */
  129876. getClassName(): string;
  129877. /**
  129878. * Gets the value input component
  129879. */
  129880. get value(): NodeMaterialConnectionPoint;
  129881. /**
  129882. * Gets the output component
  129883. */
  129884. get output(): NodeMaterialConnectionPoint;
  129885. protected _buildBlock(state: NodeMaterialBuildState): this;
  129886. }
  129887. }
  129888. declare module BABYLON {
  129889. /**
  129890. * Block used to get negative version of a value (i.e. x * -1)
  129891. */
  129892. export class NegateBlock extends NodeMaterialBlock {
  129893. /**
  129894. * Creates a new NegateBlock
  129895. * @param name defines the block name
  129896. */
  129897. constructor(name: string);
  129898. /**
  129899. * Gets the current class name
  129900. * @returns the class name
  129901. */
  129902. getClassName(): string;
  129903. /**
  129904. * Gets the value input component
  129905. */
  129906. get value(): NodeMaterialConnectionPoint;
  129907. /**
  129908. * Gets the output component
  129909. */
  129910. get output(): NodeMaterialConnectionPoint;
  129911. protected _buildBlock(state: NodeMaterialBuildState): this;
  129912. }
  129913. }
  129914. declare module BABYLON {
  129915. /**
  129916. * Block used to get the value of the first parameter raised to the power of the second
  129917. */
  129918. export class PowBlock extends NodeMaterialBlock {
  129919. /**
  129920. * Creates a new PowBlock
  129921. * @param name defines the block name
  129922. */
  129923. constructor(name: string);
  129924. /**
  129925. * Gets the current class name
  129926. * @returns the class name
  129927. */
  129928. getClassName(): string;
  129929. /**
  129930. * Gets the value operand input component
  129931. */
  129932. get value(): NodeMaterialConnectionPoint;
  129933. /**
  129934. * Gets the power operand input component
  129935. */
  129936. get power(): NodeMaterialConnectionPoint;
  129937. /**
  129938. * Gets the output component
  129939. */
  129940. get output(): NodeMaterialConnectionPoint;
  129941. protected _buildBlock(state: NodeMaterialBuildState): this;
  129942. }
  129943. }
  129944. declare module BABYLON {
  129945. /**
  129946. * Block used to get a random number
  129947. */
  129948. export class RandomNumberBlock extends NodeMaterialBlock {
  129949. /**
  129950. * Creates a new RandomNumberBlock
  129951. * @param name defines the block name
  129952. */
  129953. constructor(name: string);
  129954. /**
  129955. * Gets the current class name
  129956. * @returns the class name
  129957. */
  129958. getClassName(): string;
  129959. /**
  129960. * Gets the seed input component
  129961. */
  129962. get seed(): NodeMaterialConnectionPoint;
  129963. /**
  129964. * Gets the output component
  129965. */
  129966. get output(): NodeMaterialConnectionPoint;
  129967. protected _buildBlock(state: NodeMaterialBuildState): this;
  129968. }
  129969. }
  129970. declare module BABYLON {
  129971. /**
  129972. * Block used to compute arc tangent of 2 values
  129973. */
  129974. export class ArcTan2Block extends NodeMaterialBlock {
  129975. /**
  129976. * Creates a new ArcTan2Block
  129977. * @param name defines the block name
  129978. */
  129979. constructor(name: string);
  129980. /**
  129981. * Gets the current class name
  129982. * @returns the class name
  129983. */
  129984. getClassName(): string;
  129985. /**
  129986. * Gets the x operand input component
  129987. */
  129988. get x(): NodeMaterialConnectionPoint;
  129989. /**
  129990. * Gets the y operand input component
  129991. */
  129992. get y(): NodeMaterialConnectionPoint;
  129993. /**
  129994. * Gets the output component
  129995. */
  129996. get output(): NodeMaterialConnectionPoint;
  129997. protected _buildBlock(state: NodeMaterialBuildState): this;
  129998. }
  129999. }
  130000. declare module BABYLON {
  130001. /**
  130002. * Block used to smooth step a value
  130003. */
  130004. export class SmoothStepBlock extends NodeMaterialBlock {
  130005. /**
  130006. * Creates a new SmoothStepBlock
  130007. * @param name defines the block name
  130008. */
  130009. constructor(name: string);
  130010. /**
  130011. * Gets the current class name
  130012. * @returns the class name
  130013. */
  130014. getClassName(): string;
  130015. /**
  130016. * Gets the value operand input component
  130017. */
  130018. get value(): NodeMaterialConnectionPoint;
  130019. /**
  130020. * Gets the first edge operand input component
  130021. */
  130022. get edge0(): NodeMaterialConnectionPoint;
  130023. /**
  130024. * Gets the second edge operand input component
  130025. */
  130026. get edge1(): NodeMaterialConnectionPoint;
  130027. /**
  130028. * Gets the output component
  130029. */
  130030. get output(): NodeMaterialConnectionPoint;
  130031. protected _buildBlock(state: NodeMaterialBuildState): this;
  130032. }
  130033. }
  130034. declare module BABYLON {
  130035. /**
  130036. * Block used to get the reciprocal (1 / x) of a value
  130037. */
  130038. export class ReciprocalBlock extends NodeMaterialBlock {
  130039. /**
  130040. * Creates a new ReciprocalBlock
  130041. * @param name defines the block name
  130042. */
  130043. constructor(name: string);
  130044. /**
  130045. * Gets the current class name
  130046. * @returns the class name
  130047. */
  130048. getClassName(): string;
  130049. /**
  130050. * Gets the input component
  130051. */
  130052. get input(): NodeMaterialConnectionPoint;
  130053. /**
  130054. * Gets the output component
  130055. */
  130056. get output(): NodeMaterialConnectionPoint;
  130057. protected _buildBlock(state: NodeMaterialBuildState): this;
  130058. }
  130059. }
  130060. declare module BABYLON {
  130061. /**
  130062. * Block used to replace a color by another one
  130063. */
  130064. export class ReplaceColorBlock extends NodeMaterialBlock {
  130065. /**
  130066. * Creates a new ReplaceColorBlock
  130067. * @param name defines the block name
  130068. */
  130069. constructor(name: string);
  130070. /**
  130071. * Gets the current class name
  130072. * @returns the class name
  130073. */
  130074. getClassName(): string;
  130075. /**
  130076. * Gets the value input component
  130077. */
  130078. get value(): NodeMaterialConnectionPoint;
  130079. /**
  130080. * Gets the reference input component
  130081. */
  130082. get reference(): NodeMaterialConnectionPoint;
  130083. /**
  130084. * Gets the distance input component
  130085. */
  130086. get distance(): NodeMaterialConnectionPoint;
  130087. /**
  130088. * Gets the replacement input component
  130089. */
  130090. get replacement(): NodeMaterialConnectionPoint;
  130091. /**
  130092. * Gets the output component
  130093. */
  130094. get output(): NodeMaterialConnectionPoint;
  130095. protected _buildBlock(state: NodeMaterialBuildState): this;
  130096. }
  130097. }
  130098. declare module BABYLON {
  130099. /**
  130100. * Block used to posterize a value
  130101. * @see https://en.wikipedia.org/wiki/Posterization
  130102. */
  130103. export class PosterizeBlock extends NodeMaterialBlock {
  130104. /**
  130105. * Creates a new PosterizeBlock
  130106. * @param name defines the block name
  130107. */
  130108. constructor(name: string);
  130109. /**
  130110. * Gets the current class name
  130111. * @returns the class name
  130112. */
  130113. getClassName(): string;
  130114. /**
  130115. * Gets the value input component
  130116. */
  130117. get value(): NodeMaterialConnectionPoint;
  130118. /**
  130119. * Gets the steps input component
  130120. */
  130121. get steps(): NodeMaterialConnectionPoint;
  130122. /**
  130123. * Gets the output component
  130124. */
  130125. get output(): NodeMaterialConnectionPoint;
  130126. protected _buildBlock(state: NodeMaterialBuildState): this;
  130127. }
  130128. }
  130129. declare module BABYLON {
  130130. /**
  130131. * Operations supported by the Wave block
  130132. */
  130133. export enum WaveBlockKind {
  130134. /** SawTooth */
  130135. SawTooth = 0,
  130136. /** Square */
  130137. Square = 1,
  130138. /** Triangle */
  130139. Triangle = 2
  130140. }
  130141. /**
  130142. * Block used to apply wave operation to floats
  130143. */
  130144. export class WaveBlock extends NodeMaterialBlock {
  130145. /**
  130146. * Gets or sets the kibnd of wave to be applied by the block
  130147. */
  130148. kind: WaveBlockKind;
  130149. /**
  130150. * Creates a new WaveBlock
  130151. * @param name defines the block name
  130152. */
  130153. constructor(name: string);
  130154. /**
  130155. * Gets the current class name
  130156. * @returns the class name
  130157. */
  130158. getClassName(): string;
  130159. /**
  130160. * Gets the input component
  130161. */
  130162. get input(): NodeMaterialConnectionPoint;
  130163. /**
  130164. * Gets the output component
  130165. */
  130166. get output(): NodeMaterialConnectionPoint;
  130167. protected _buildBlock(state: NodeMaterialBuildState): this;
  130168. serialize(): any;
  130169. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130170. }
  130171. }
  130172. declare module BABYLON {
  130173. /**
  130174. * Class used to store a color step for the GradientBlock
  130175. */
  130176. export class GradientBlockColorStep {
  130177. /**
  130178. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  130179. */
  130180. step: number;
  130181. /**
  130182. * Gets or sets the color associated with this step
  130183. */
  130184. color: Color3;
  130185. /**
  130186. * Creates a new GradientBlockColorStep
  130187. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  130188. * @param color defines the color associated with this step
  130189. */
  130190. constructor(
  130191. /**
  130192. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  130193. */
  130194. step: number,
  130195. /**
  130196. * Gets or sets the color associated with this step
  130197. */
  130198. color: Color3);
  130199. }
  130200. /**
  130201. * Block used to return a color from a gradient based on an input value between 0 and 1
  130202. */
  130203. export class GradientBlock extends NodeMaterialBlock {
  130204. /**
  130205. * Gets or sets the list of color steps
  130206. */
  130207. colorSteps: GradientBlockColorStep[];
  130208. /**
  130209. * Creates a new GradientBlock
  130210. * @param name defines the block name
  130211. */
  130212. constructor(name: string);
  130213. /**
  130214. * Gets the current class name
  130215. * @returns the class name
  130216. */
  130217. getClassName(): string;
  130218. /**
  130219. * Gets the gradient input component
  130220. */
  130221. get gradient(): NodeMaterialConnectionPoint;
  130222. /**
  130223. * Gets the output component
  130224. */
  130225. get output(): NodeMaterialConnectionPoint;
  130226. private _writeColorConstant;
  130227. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130228. serialize(): any;
  130229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130230. protected _dumpPropertiesCode(): string;
  130231. }
  130232. }
  130233. declare module BABYLON {
  130234. /**
  130235. * Block used to normalize lerp between 2 values
  130236. */
  130237. export class NLerpBlock extends NodeMaterialBlock {
  130238. /**
  130239. * Creates a new NLerpBlock
  130240. * @param name defines the block name
  130241. */
  130242. constructor(name: string);
  130243. /**
  130244. * Gets the current class name
  130245. * @returns the class name
  130246. */
  130247. getClassName(): string;
  130248. /**
  130249. * Gets the left operand input component
  130250. */
  130251. get left(): NodeMaterialConnectionPoint;
  130252. /**
  130253. * Gets the right operand input component
  130254. */
  130255. get right(): NodeMaterialConnectionPoint;
  130256. /**
  130257. * Gets the gradient operand input component
  130258. */
  130259. get gradient(): NodeMaterialConnectionPoint;
  130260. /**
  130261. * Gets the output component
  130262. */
  130263. get output(): NodeMaterialConnectionPoint;
  130264. protected _buildBlock(state: NodeMaterialBuildState): this;
  130265. }
  130266. }
  130267. declare module BABYLON {
  130268. /**
  130269. * block used to Generate a Worley Noise 3D Noise Pattern
  130270. */
  130271. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  130272. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  130273. manhattanDistance: boolean;
  130274. /**
  130275. * Creates a new WorleyNoise3DBlock
  130276. * @param name defines the block name
  130277. */
  130278. constructor(name: string);
  130279. /**
  130280. * Gets the current class name
  130281. * @returns the class name
  130282. */
  130283. getClassName(): string;
  130284. /**
  130285. * Gets the seed input component
  130286. */
  130287. get seed(): NodeMaterialConnectionPoint;
  130288. /**
  130289. * Gets the jitter input component
  130290. */
  130291. get jitter(): NodeMaterialConnectionPoint;
  130292. /**
  130293. * Gets the output component
  130294. */
  130295. get output(): NodeMaterialConnectionPoint;
  130296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130297. /**
  130298. * Exposes the properties to the UI?
  130299. */
  130300. protected _dumpPropertiesCode(): string;
  130301. /**
  130302. * Exposes the properties to the Seralize?
  130303. */
  130304. serialize(): any;
  130305. /**
  130306. * Exposes the properties to the deseralize?
  130307. */
  130308. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130309. }
  130310. }
  130311. declare module BABYLON {
  130312. /**
  130313. * block used to Generate a Simplex Perlin 3d Noise Pattern
  130314. */
  130315. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  130316. /**
  130317. * Creates a new SimplexPerlin3DBlock
  130318. * @param name defines the block name
  130319. */
  130320. constructor(name: string);
  130321. /**
  130322. * Gets the current class name
  130323. * @returns the class name
  130324. */
  130325. getClassName(): string;
  130326. /**
  130327. * Gets the seed operand input component
  130328. */
  130329. get seed(): NodeMaterialConnectionPoint;
  130330. /**
  130331. * Gets the output component
  130332. */
  130333. get output(): NodeMaterialConnectionPoint;
  130334. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130335. }
  130336. }
  130337. declare module BABYLON {
  130338. /**
  130339. * Block used to blend normals
  130340. */
  130341. export class NormalBlendBlock extends NodeMaterialBlock {
  130342. /**
  130343. * Creates a new NormalBlendBlock
  130344. * @param name defines the block name
  130345. */
  130346. constructor(name: string);
  130347. /**
  130348. * Gets the current class name
  130349. * @returns the class name
  130350. */
  130351. getClassName(): string;
  130352. /**
  130353. * Gets the first input component
  130354. */
  130355. get normalMap0(): NodeMaterialConnectionPoint;
  130356. /**
  130357. * Gets the second input component
  130358. */
  130359. get normalMap1(): NodeMaterialConnectionPoint;
  130360. /**
  130361. * Gets the output component
  130362. */
  130363. get output(): NodeMaterialConnectionPoint;
  130364. protected _buildBlock(state: NodeMaterialBuildState): this;
  130365. }
  130366. }
  130367. declare module BABYLON {
  130368. /**
  130369. * Block used to rotate a 2d vector by a given angle
  130370. */
  130371. export class Rotate2dBlock extends NodeMaterialBlock {
  130372. /**
  130373. * Creates a new Rotate2dBlock
  130374. * @param name defines the block name
  130375. */
  130376. constructor(name: string);
  130377. /**
  130378. * Gets the current class name
  130379. * @returns the class name
  130380. */
  130381. getClassName(): string;
  130382. /**
  130383. * Gets the input vector
  130384. */
  130385. get input(): NodeMaterialConnectionPoint;
  130386. /**
  130387. * Gets the input angle
  130388. */
  130389. get angle(): NodeMaterialConnectionPoint;
  130390. /**
  130391. * Gets the output component
  130392. */
  130393. get output(): NodeMaterialConnectionPoint;
  130394. autoConfigure(material: NodeMaterial): void;
  130395. protected _buildBlock(state: NodeMaterialBuildState): this;
  130396. }
  130397. }
  130398. declare module BABYLON {
  130399. /**
  130400. * Block used to get the reflected vector from a direction and a normal
  130401. */
  130402. export class ReflectBlock extends NodeMaterialBlock {
  130403. /**
  130404. * Creates a new ReflectBlock
  130405. * @param name defines the block name
  130406. */
  130407. constructor(name: string);
  130408. /**
  130409. * Gets the current class name
  130410. * @returns the class name
  130411. */
  130412. getClassName(): string;
  130413. /**
  130414. * Gets the incident component
  130415. */
  130416. get incident(): NodeMaterialConnectionPoint;
  130417. /**
  130418. * Gets the normal component
  130419. */
  130420. get normal(): NodeMaterialConnectionPoint;
  130421. /**
  130422. * Gets the output component
  130423. */
  130424. get output(): NodeMaterialConnectionPoint;
  130425. protected _buildBlock(state: NodeMaterialBuildState): this;
  130426. }
  130427. }
  130428. declare module BABYLON {
  130429. /**
  130430. * Block used to get the refracted vector from a direction and a normal
  130431. */
  130432. export class RefractBlock extends NodeMaterialBlock {
  130433. /**
  130434. * Creates a new RefractBlock
  130435. * @param name defines the block name
  130436. */
  130437. constructor(name: string);
  130438. /**
  130439. * Gets the current class name
  130440. * @returns the class name
  130441. */
  130442. getClassName(): string;
  130443. /**
  130444. * Gets the incident component
  130445. */
  130446. get incident(): NodeMaterialConnectionPoint;
  130447. /**
  130448. * Gets the normal component
  130449. */
  130450. get normal(): NodeMaterialConnectionPoint;
  130451. /**
  130452. * Gets the index of refraction component
  130453. */
  130454. get ior(): NodeMaterialConnectionPoint;
  130455. /**
  130456. * Gets the output component
  130457. */
  130458. get output(): NodeMaterialConnectionPoint;
  130459. protected _buildBlock(state: NodeMaterialBuildState): this;
  130460. }
  130461. }
  130462. declare module BABYLON {
  130463. /**
  130464. * Block used to desaturate a color
  130465. */
  130466. export class DesaturateBlock extends NodeMaterialBlock {
  130467. /**
  130468. * Creates a new DesaturateBlock
  130469. * @param name defines the block name
  130470. */
  130471. constructor(name: string);
  130472. /**
  130473. * Gets the current class name
  130474. * @returns the class name
  130475. */
  130476. getClassName(): string;
  130477. /**
  130478. * Gets the color operand input component
  130479. */
  130480. get color(): NodeMaterialConnectionPoint;
  130481. /**
  130482. * Gets the level operand input component
  130483. */
  130484. get level(): NodeMaterialConnectionPoint;
  130485. /**
  130486. * Gets the output component
  130487. */
  130488. get output(): NodeMaterialConnectionPoint;
  130489. protected _buildBlock(state: NodeMaterialBuildState): this;
  130490. }
  130491. }
  130492. declare module BABYLON {
  130493. /**
  130494. * Effect Render Options
  130495. */
  130496. export interface IEffectRendererOptions {
  130497. /**
  130498. * Defines the vertices positions.
  130499. */
  130500. positions?: number[];
  130501. /**
  130502. * Defines the indices.
  130503. */
  130504. indices?: number[];
  130505. }
  130506. /**
  130507. * Helper class to render one or more effects
  130508. */
  130509. export class EffectRenderer {
  130510. private engine;
  130511. private static _DefaultOptions;
  130512. private _vertexBuffers;
  130513. private _indexBuffer;
  130514. private _ringBufferIndex;
  130515. private _ringScreenBuffer;
  130516. private _fullscreenViewport;
  130517. private _getNextFrameBuffer;
  130518. /**
  130519. * Creates an effect renderer
  130520. * @param engine the engine to use for rendering
  130521. * @param options defines the options of the effect renderer
  130522. */
  130523. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  130524. /**
  130525. * Sets the current viewport in normalized coordinates 0-1
  130526. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  130527. */
  130528. setViewport(viewport?: Viewport): void;
  130529. /**
  130530. * Binds the embedded attributes buffer to the effect.
  130531. * @param effect Defines the effect to bind the attributes for
  130532. */
  130533. bindBuffers(effect: Effect): void;
  130534. /**
  130535. * Sets the current effect wrapper to use during draw.
  130536. * The effect needs to be ready before calling this api.
  130537. * This also sets the default full screen position attribute.
  130538. * @param effectWrapper Defines the effect to draw with
  130539. */
  130540. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  130541. /**
  130542. * Draws a full screen quad.
  130543. */
  130544. draw(): void;
  130545. /**
  130546. * renders one or more effects to a specified texture
  130547. * @param effectWrappers list of effects to renderer
  130548. * @param outputTexture texture to draw to, if null it will render to the screen
  130549. */
  130550. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  130551. /**
  130552. * Disposes of the effect renderer
  130553. */
  130554. dispose(): void;
  130555. }
  130556. /**
  130557. * Options to create an EffectWrapper
  130558. */
  130559. interface EffectWrapperCreationOptions {
  130560. /**
  130561. * Engine to use to create the effect
  130562. */
  130563. engine: ThinEngine;
  130564. /**
  130565. * Fragment shader for the effect
  130566. */
  130567. fragmentShader: string;
  130568. /**
  130569. * Vertex shader for the effect
  130570. */
  130571. vertexShader?: string;
  130572. /**
  130573. * Attributes to use in the shader
  130574. */
  130575. attributeNames?: Array<string>;
  130576. /**
  130577. * Uniforms to use in the shader
  130578. */
  130579. uniformNames?: Array<string>;
  130580. /**
  130581. * Texture sampler names to use in the shader
  130582. */
  130583. samplerNames?: Array<string>;
  130584. /**
  130585. * The friendly name of the effect displayed in Spector.
  130586. */
  130587. name?: string;
  130588. }
  130589. /**
  130590. * Wraps an effect to be used for rendering
  130591. */
  130592. export class EffectWrapper {
  130593. /**
  130594. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  130595. */
  130596. onApplyObservable: Observable<{}>;
  130597. /**
  130598. * The underlying effect
  130599. */
  130600. effect: Effect;
  130601. /**
  130602. * Creates an effect to be renderer
  130603. * @param creationOptions options to create the effect
  130604. */
  130605. constructor(creationOptions: EffectWrapperCreationOptions);
  130606. /**
  130607. * Disposes of the effect wrapper
  130608. */
  130609. dispose(): void;
  130610. }
  130611. }
  130612. declare module BABYLON {
  130613. /**
  130614. * Helper class to push actions to a pool of workers.
  130615. */
  130616. export class WorkerPool implements IDisposable {
  130617. private _workerInfos;
  130618. private _pendingActions;
  130619. /**
  130620. * Constructor
  130621. * @param workers Array of workers to use for actions
  130622. */
  130623. constructor(workers: Array<Worker>);
  130624. /**
  130625. * Terminates all workers and clears any pending actions.
  130626. */
  130627. dispose(): void;
  130628. /**
  130629. * Pushes an action to the worker pool. If all the workers are active, the action will be
  130630. * pended until a worker has completed its action.
  130631. * @param action The action to perform. Call onComplete when the action is complete.
  130632. */
  130633. push(action: (worker: Worker, onComplete: () => void) => void): void;
  130634. private _execute;
  130635. }
  130636. }
  130637. declare module BABYLON {
  130638. /**
  130639. * Configuration for Draco compression
  130640. */
  130641. export interface IDracoCompressionConfiguration {
  130642. /**
  130643. * Configuration for the decoder.
  130644. */
  130645. decoder: {
  130646. /**
  130647. * The url to the WebAssembly module.
  130648. */
  130649. wasmUrl?: string;
  130650. /**
  130651. * The url to the WebAssembly binary.
  130652. */
  130653. wasmBinaryUrl?: string;
  130654. /**
  130655. * The url to the fallback JavaScript module.
  130656. */
  130657. fallbackUrl?: string;
  130658. };
  130659. }
  130660. /**
  130661. * Draco compression (https://google.github.io/draco/)
  130662. *
  130663. * This class wraps the Draco module.
  130664. *
  130665. * **Encoder**
  130666. *
  130667. * The encoder is not currently implemented.
  130668. *
  130669. * **Decoder**
  130670. *
  130671. * 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.
  130672. *
  130673. * To update the configuration, use the following code:
  130674. * ```javascript
  130675. * DracoCompression.Configuration = {
  130676. * decoder: {
  130677. * wasmUrl: "<url to the WebAssembly library>",
  130678. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  130679. * fallbackUrl: "<url to the fallback JavaScript library>",
  130680. * }
  130681. * };
  130682. * ```
  130683. *
  130684. * 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.
  130685. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  130686. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  130687. *
  130688. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  130689. * ```javascript
  130690. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  130691. * ```
  130692. *
  130693. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  130694. */
  130695. export class DracoCompression implements IDisposable {
  130696. private _workerPoolPromise?;
  130697. private _decoderModulePromise?;
  130698. /**
  130699. * The configuration. Defaults to the following urls:
  130700. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  130701. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  130702. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  130703. */
  130704. static Configuration: IDracoCompressionConfiguration;
  130705. /**
  130706. * Returns true if the decoder configuration is available.
  130707. */
  130708. static get DecoderAvailable(): boolean;
  130709. /**
  130710. * Default number of workers to create when creating the draco compression object.
  130711. */
  130712. static DefaultNumWorkers: number;
  130713. private static GetDefaultNumWorkers;
  130714. private static _Default;
  130715. /**
  130716. * Default instance for the draco compression object.
  130717. */
  130718. static get Default(): DracoCompression;
  130719. /**
  130720. * Constructor
  130721. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  130722. */
  130723. constructor(numWorkers?: number);
  130724. /**
  130725. * Stop all async operations and release resources.
  130726. */
  130727. dispose(): void;
  130728. /**
  130729. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  130730. * @returns a promise that resolves when ready
  130731. */
  130732. whenReadyAsync(): Promise<void>;
  130733. /**
  130734. * Decode Draco compressed mesh data to vertex data.
  130735. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  130736. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  130737. * @returns A promise that resolves with the decoded vertex data
  130738. */
  130739. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  130740. [kind: string]: number;
  130741. }): Promise<VertexData>;
  130742. }
  130743. }
  130744. declare module BABYLON {
  130745. /**
  130746. * Class for building Constructive Solid Geometry
  130747. */
  130748. export class CSG {
  130749. private polygons;
  130750. /**
  130751. * The world matrix
  130752. */
  130753. matrix: Matrix;
  130754. /**
  130755. * Stores the position
  130756. */
  130757. position: Vector3;
  130758. /**
  130759. * Stores the rotation
  130760. */
  130761. rotation: Vector3;
  130762. /**
  130763. * Stores the rotation quaternion
  130764. */
  130765. rotationQuaternion: Nullable<Quaternion>;
  130766. /**
  130767. * Stores the scaling vector
  130768. */
  130769. scaling: Vector3;
  130770. /**
  130771. * Convert the Mesh to CSG
  130772. * @param mesh The Mesh to convert to CSG
  130773. * @returns A new CSG from the Mesh
  130774. */
  130775. static FromMesh(mesh: Mesh): CSG;
  130776. /**
  130777. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  130778. * @param polygons Polygons used to construct a CSG solid
  130779. */
  130780. private static FromPolygons;
  130781. /**
  130782. * Clones, or makes a deep copy, of the CSG
  130783. * @returns A new CSG
  130784. */
  130785. clone(): CSG;
  130786. /**
  130787. * Unions this CSG with another CSG
  130788. * @param csg The CSG to union against this CSG
  130789. * @returns The unioned CSG
  130790. */
  130791. union(csg: CSG): CSG;
  130792. /**
  130793. * Unions this CSG with another CSG in place
  130794. * @param csg The CSG to union against this CSG
  130795. */
  130796. unionInPlace(csg: CSG): void;
  130797. /**
  130798. * Subtracts this CSG with another CSG
  130799. * @param csg The CSG to subtract against this CSG
  130800. * @returns A new CSG
  130801. */
  130802. subtract(csg: CSG): CSG;
  130803. /**
  130804. * Subtracts this CSG with another CSG in place
  130805. * @param csg The CSG to subtact against this CSG
  130806. */
  130807. subtractInPlace(csg: CSG): void;
  130808. /**
  130809. * Intersect this CSG with another CSG
  130810. * @param csg The CSG to intersect against this CSG
  130811. * @returns A new CSG
  130812. */
  130813. intersect(csg: CSG): CSG;
  130814. /**
  130815. * Intersects this CSG with another CSG in place
  130816. * @param csg The CSG to intersect against this CSG
  130817. */
  130818. intersectInPlace(csg: CSG): void;
  130819. /**
  130820. * Return a new CSG solid with solid and empty space switched. This solid is
  130821. * not modified.
  130822. * @returns A new CSG solid with solid and empty space switched
  130823. */
  130824. inverse(): CSG;
  130825. /**
  130826. * Inverses the CSG in place
  130827. */
  130828. inverseInPlace(): void;
  130829. /**
  130830. * This is used to keep meshes transformations so they can be restored
  130831. * when we build back a Babylon Mesh
  130832. * NB : All CSG operations are performed in world coordinates
  130833. * @param csg The CSG to copy the transform attributes from
  130834. * @returns This CSG
  130835. */
  130836. copyTransformAttributes(csg: CSG): CSG;
  130837. /**
  130838. * Build Raw mesh from CSG
  130839. * Coordinates here are in world space
  130840. * @param name The name of the mesh geometry
  130841. * @param scene The Scene
  130842. * @param keepSubMeshes Specifies if the submeshes should be kept
  130843. * @returns A new Mesh
  130844. */
  130845. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  130846. /**
  130847. * Build Mesh from CSG taking material and transforms into account
  130848. * @param name The name of the Mesh
  130849. * @param material The material of the Mesh
  130850. * @param scene The Scene
  130851. * @param keepSubMeshes Specifies if submeshes should be kept
  130852. * @returns The new Mesh
  130853. */
  130854. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  130855. }
  130856. }
  130857. declare module BABYLON {
  130858. /**
  130859. * Class used to create a trail following a mesh
  130860. */
  130861. export class TrailMesh extends Mesh {
  130862. private _generator;
  130863. private _autoStart;
  130864. private _running;
  130865. private _diameter;
  130866. private _length;
  130867. private _sectionPolygonPointsCount;
  130868. private _sectionVectors;
  130869. private _sectionNormalVectors;
  130870. private _beforeRenderObserver;
  130871. /**
  130872. * @constructor
  130873. * @param name The value used by scene.getMeshByName() to do a lookup.
  130874. * @param generator The mesh to generate a trail.
  130875. * @param scene The scene to add this mesh to.
  130876. * @param diameter Diameter of trailing mesh. Default is 1.
  130877. * @param length Length of trailing mesh. Default is 60.
  130878. * @param autoStart Automatically start trailing mesh. Default true.
  130879. */
  130880. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  130881. /**
  130882. * "TrailMesh"
  130883. * @returns "TrailMesh"
  130884. */
  130885. getClassName(): string;
  130886. private _createMesh;
  130887. /**
  130888. * Start trailing mesh.
  130889. */
  130890. start(): void;
  130891. /**
  130892. * Stop trailing mesh.
  130893. */
  130894. stop(): void;
  130895. /**
  130896. * Update trailing mesh geometry.
  130897. */
  130898. update(): void;
  130899. /**
  130900. * Returns a new TrailMesh object.
  130901. * @param name is a string, the name given to the new mesh
  130902. * @param newGenerator use new generator object for cloned trail mesh
  130903. * @returns a new mesh
  130904. */
  130905. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  130906. /**
  130907. * Serializes this trail mesh
  130908. * @param serializationObject object to write serialization to
  130909. */
  130910. serialize(serializationObject: any): void;
  130911. /**
  130912. * Parses a serialized trail mesh
  130913. * @param parsedMesh the serialized mesh
  130914. * @param scene the scene to create the trail mesh in
  130915. * @returns the created trail mesh
  130916. */
  130917. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  130918. }
  130919. }
  130920. declare module BABYLON {
  130921. /**
  130922. * Class containing static functions to help procedurally build meshes
  130923. */
  130924. export class TiledBoxBuilder {
  130925. /**
  130926. * Creates a box mesh
  130927. * 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)
  130928. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130932. * @param name defines the name of the mesh
  130933. * @param options defines the options used to create the mesh
  130934. * @param scene defines the hosting scene
  130935. * @returns the box mesh
  130936. */
  130937. static CreateTiledBox(name: string, options: {
  130938. pattern?: number;
  130939. width?: number;
  130940. height?: number;
  130941. depth?: number;
  130942. tileSize?: number;
  130943. tileWidth?: number;
  130944. tileHeight?: number;
  130945. alignHorizontal?: number;
  130946. alignVertical?: number;
  130947. faceUV?: Vector4[];
  130948. faceColors?: Color4[];
  130949. sideOrientation?: number;
  130950. updatable?: boolean;
  130951. }, scene?: Nullable<Scene>): Mesh;
  130952. }
  130953. }
  130954. declare module BABYLON {
  130955. /**
  130956. * Class containing static functions to help procedurally build meshes
  130957. */
  130958. export class TorusKnotBuilder {
  130959. /**
  130960. * Creates a torus knot mesh
  130961. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  130962. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  130963. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  130964. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  130965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130968. * @param name defines the name of the mesh
  130969. * @param options defines the options used to create the mesh
  130970. * @param scene defines the hosting scene
  130971. * @returns the torus knot mesh
  130972. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  130973. */
  130974. static CreateTorusKnot(name: string, options: {
  130975. radius?: number;
  130976. tube?: number;
  130977. radialSegments?: number;
  130978. tubularSegments?: number;
  130979. p?: number;
  130980. q?: number;
  130981. updatable?: boolean;
  130982. sideOrientation?: number;
  130983. frontUVs?: Vector4;
  130984. backUVs?: Vector4;
  130985. }, scene: any): Mesh;
  130986. }
  130987. }
  130988. declare module BABYLON {
  130989. /**
  130990. * Polygon
  130991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  130992. */
  130993. export class Polygon {
  130994. /**
  130995. * Creates a rectangle
  130996. * @param xmin bottom X coord
  130997. * @param ymin bottom Y coord
  130998. * @param xmax top X coord
  130999. * @param ymax top Y coord
  131000. * @returns points that make the resulting rectation
  131001. */
  131002. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  131003. /**
  131004. * Creates a circle
  131005. * @param radius radius of circle
  131006. * @param cx scale in x
  131007. * @param cy scale in y
  131008. * @param numberOfSides number of sides that make up the circle
  131009. * @returns points that make the resulting circle
  131010. */
  131011. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  131012. /**
  131013. * Creates a polygon from input string
  131014. * @param input Input polygon data
  131015. * @returns the parsed points
  131016. */
  131017. static Parse(input: string): Vector2[];
  131018. /**
  131019. * Starts building a polygon from x and y coordinates
  131020. * @param x x coordinate
  131021. * @param y y coordinate
  131022. * @returns the started path2
  131023. */
  131024. static StartingAt(x: number, y: number): Path2;
  131025. }
  131026. /**
  131027. * Builds a polygon
  131028. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  131029. */
  131030. export class PolygonMeshBuilder {
  131031. private _points;
  131032. private _outlinepoints;
  131033. private _holes;
  131034. private _name;
  131035. private _scene;
  131036. private _epoints;
  131037. private _eholes;
  131038. private _addToepoint;
  131039. /**
  131040. * Babylon reference to the earcut plugin.
  131041. */
  131042. bjsEarcut: any;
  131043. /**
  131044. * Creates a PolygonMeshBuilder
  131045. * @param name name of the builder
  131046. * @param contours Path of the polygon
  131047. * @param scene scene to add to when creating the mesh
  131048. * @param earcutInjection can be used to inject your own earcut reference
  131049. */
  131050. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  131051. /**
  131052. * Adds a whole within the polygon
  131053. * @param hole Array of points defining the hole
  131054. * @returns this
  131055. */
  131056. addHole(hole: Vector2[]): PolygonMeshBuilder;
  131057. /**
  131058. * Creates the polygon
  131059. * @param updatable If the mesh should be updatable
  131060. * @param depth The depth of the mesh created
  131061. * @returns the created mesh
  131062. */
  131063. build(updatable?: boolean, depth?: number): Mesh;
  131064. /**
  131065. * Creates the polygon
  131066. * @param depth The depth of the mesh created
  131067. * @returns the created VertexData
  131068. */
  131069. buildVertexData(depth?: number): VertexData;
  131070. /**
  131071. * Adds a side to the polygon
  131072. * @param positions points that make the polygon
  131073. * @param normals normals of the polygon
  131074. * @param uvs uvs of the polygon
  131075. * @param indices indices of the polygon
  131076. * @param bounds bounds of the polygon
  131077. * @param points points of the polygon
  131078. * @param depth depth of the polygon
  131079. * @param flip flip of the polygon
  131080. */
  131081. private addSide;
  131082. }
  131083. }
  131084. declare module BABYLON {
  131085. /**
  131086. * Class containing static functions to help procedurally build meshes
  131087. */
  131088. export class PolygonBuilder {
  131089. /**
  131090. * Creates a polygon mesh
  131091. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  131092. * * 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
  131093. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  131094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  131096. * * Remember you can only change the shape positions, not their number when updating a polygon
  131097. * @param name defines the name of the mesh
  131098. * @param options defines the options used to create the mesh
  131099. * @param scene defines the hosting scene
  131100. * @param earcutInjection can be used to inject your own earcut reference
  131101. * @returns the polygon mesh
  131102. */
  131103. static CreatePolygon(name: string, options: {
  131104. shape: Vector3[];
  131105. holes?: Vector3[][];
  131106. depth?: number;
  131107. faceUV?: Vector4[];
  131108. faceColors?: Color4[];
  131109. updatable?: boolean;
  131110. sideOrientation?: number;
  131111. frontUVs?: Vector4;
  131112. backUVs?: Vector4;
  131113. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131114. /**
  131115. * Creates an extruded polygon mesh, with depth in the Y direction.
  131116. * * 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)
  131117. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131118. * @param name defines the name of the mesh
  131119. * @param options defines the options used to create the mesh
  131120. * @param scene defines the hosting scene
  131121. * @param earcutInjection can be used to inject your own earcut reference
  131122. * @returns the polygon mesh
  131123. */
  131124. static ExtrudePolygon(name: string, options: {
  131125. shape: Vector3[];
  131126. holes?: Vector3[][];
  131127. depth?: number;
  131128. faceUV?: Vector4[];
  131129. faceColors?: Color4[];
  131130. updatable?: boolean;
  131131. sideOrientation?: number;
  131132. frontUVs?: Vector4;
  131133. backUVs?: Vector4;
  131134. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131135. }
  131136. }
  131137. declare module BABYLON {
  131138. /**
  131139. * Class containing static functions to help procedurally build meshes
  131140. */
  131141. export class LatheBuilder {
  131142. /**
  131143. * Creates lathe mesh.
  131144. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  131145. * * 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
  131146. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  131147. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  131148. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  131149. * * 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
  131150. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  131151. * * 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
  131152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131154. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131156. * @param name defines the name of the mesh
  131157. * @param options defines the options used to create the mesh
  131158. * @param scene defines the hosting scene
  131159. * @returns the lathe mesh
  131160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  131161. */
  131162. static CreateLathe(name: string, options: {
  131163. shape: Vector3[];
  131164. radius?: number;
  131165. tessellation?: number;
  131166. clip?: number;
  131167. arc?: number;
  131168. closed?: boolean;
  131169. updatable?: boolean;
  131170. sideOrientation?: number;
  131171. frontUVs?: Vector4;
  131172. backUVs?: Vector4;
  131173. cap?: number;
  131174. invertUV?: boolean;
  131175. }, scene?: Nullable<Scene>): Mesh;
  131176. }
  131177. }
  131178. declare module BABYLON {
  131179. /**
  131180. * Class containing static functions to help procedurally build meshes
  131181. */
  131182. export class TiledPlaneBuilder {
  131183. /**
  131184. * Creates a tiled plane mesh
  131185. * * The parameter `pattern` will, depending on value, do nothing or
  131186. * * * flip (reflect about central vertical) alternate tiles across and up
  131187. * * * flip every tile on alternate rows
  131188. * * * rotate (180 degs) alternate tiles across and up
  131189. * * * rotate every tile on alternate rows
  131190. * * * flip and rotate alternate tiles across and up
  131191. * * * flip and rotate every tile on alternate rows
  131192. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  131193. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  131194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  131196. * * 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)
  131197. * * 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)
  131198. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131199. * @param name defines the name of the mesh
  131200. * @param options defines the options used to create the mesh
  131201. * @param scene defines the hosting scene
  131202. * @returns the box mesh
  131203. */
  131204. static CreateTiledPlane(name: string, options: {
  131205. pattern?: number;
  131206. tileSize?: number;
  131207. tileWidth?: number;
  131208. tileHeight?: number;
  131209. size?: number;
  131210. width?: number;
  131211. height?: number;
  131212. alignHorizontal?: number;
  131213. alignVertical?: number;
  131214. sideOrientation?: number;
  131215. frontUVs?: Vector4;
  131216. backUVs?: Vector4;
  131217. updatable?: boolean;
  131218. }, scene?: Nullable<Scene>): Mesh;
  131219. }
  131220. }
  131221. declare module BABYLON {
  131222. /**
  131223. * Class containing static functions to help procedurally build meshes
  131224. */
  131225. export class TubeBuilder {
  131226. /**
  131227. * Creates a tube mesh.
  131228. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131229. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  131230. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  131231. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  131232. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  131233. * * 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)
  131234. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  131235. * * 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
  131236. * * 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
  131237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131241. * @param name defines the name of the mesh
  131242. * @param options defines the options used to create the mesh
  131243. * @param scene defines the hosting scene
  131244. * @returns the tube mesh
  131245. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131246. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  131247. */
  131248. static CreateTube(name: string, options: {
  131249. path: Vector3[];
  131250. radius?: number;
  131251. tessellation?: number;
  131252. radiusFunction?: {
  131253. (i: number, distance: number): number;
  131254. };
  131255. cap?: number;
  131256. arc?: number;
  131257. updatable?: boolean;
  131258. sideOrientation?: number;
  131259. frontUVs?: Vector4;
  131260. backUVs?: Vector4;
  131261. instance?: Mesh;
  131262. invertUV?: boolean;
  131263. }, scene?: Nullable<Scene>): Mesh;
  131264. }
  131265. }
  131266. declare module BABYLON {
  131267. /**
  131268. * Class containing static functions to help procedurally build meshes
  131269. */
  131270. export class IcoSphereBuilder {
  131271. /**
  131272. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  131273. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  131274. * * 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`)
  131275. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  131276. * * 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
  131277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131280. * @param name defines the name of the mesh
  131281. * @param options defines the options used to create the mesh
  131282. * @param scene defines the hosting scene
  131283. * @returns the icosahedron mesh
  131284. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  131285. */
  131286. static CreateIcoSphere(name: string, options: {
  131287. radius?: number;
  131288. radiusX?: number;
  131289. radiusY?: number;
  131290. radiusZ?: number;
  131291. flat?: boolean;
  131292. subdivisions?: number;
  131293. sideOrientation?: number;
  131294. frontUVs?: Vector4;
  131295. backUVs?: Vector4;
  131296. updatable?: boolean;
  131297. }, scene?: Nullable<Scene>): Mesh;
  131298. }
  131299. }
  131300. declare module BABYLON {
  131301. /**
  131302. * Class containing static functions to help procedurally build meshes
  131303. */
  131304. export class DecalBuilder {
  131305. /**
  131306. * Creates a decal mesh.
  131307. * 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
  131308. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  131309. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  131310. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  131311. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  131312. * @param name defines the name of the mesh
  131313. * @param sourceMesh defines the mesh where the decal must be applied
  131314. * @param options defines the options used to create the mesh
  131315. * @param scene defines the hosting scene
  131316. * @returns the decal mesh
  131317. * @see https://doc.babylonjs.com/how_to/decals
  131318. */
  131319. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  131320. position?: Vector3;
  131321. normal?: Vector3;
  131322. size?: Vector3;
  131323. angle?: number;
  131324. }): Mesh;
  131325. }
  131326. }
  131327. declare module BABYLON {
  131328. /**
  131329. * Class containing static functions to help procedurally build meshes
  131330. */
  131331. export class MeshBuilder {
  131332. /**
  131333. * Creates a box mesh
  131334. * * The parameter `size` sets the size (float) of each box side (default 1)
  131335. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131336. * * 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)
  131337. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131341. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131342. * @param name defines the name of the mesh
  131343. * @param options defines the options used to create the mesh
  131344. * @param scene defines the hosting scene
  131345. * @returns the box mesh
  131346. */
  131347. static CreateBox(name: string, options: {
  131348. size?: number;
  131349. width?: number;
  131350. height?: number;
  131351. depth?: number;
  131352. faceUV?: Vector4[];
  131353. faceColors?: Color4[];
  131354. sideOrientation?: number;
  131355. frontUVs?: Vector4;
  131356. backUVs?: Vector4;
  131357. updatable?: boolean;
  131358. }, scene?: Nullable<Scene>): Mesh;
  131359. /**
  131360. * Creates a tiled box mesh
  131361. * * faceTiles sets the pattern, tile size and number of tiles for a face
  131362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131363. * @param name defines the name of the mesh
  131364. * @param options defines the options used to create the mesh
  131365. * @param scene defines the hosting scene
  131366. * @returns the tiled box mesh
  131367. */
  131368. static CreateTiledBox(name: string, options: {
  131369. pattern?: number;
  131370. size?: number;
  131371. width?: number;
  131372. height?: number;
  131373. depth: number;
  131374. tileSize?: number;
  131375. tileWidth?: number;
  131376. tileHeight?: number;
  131377. faceUV?: Vector4[];
  131378. faceColors?: Color4[];
  131379. alignHorizontal?: number;
  131380. alignVertical?: number;
  131381. sideOrientation?: number;
  131382. updatable?: boolean;
  131383. }, scene?: Nullable<Scene>): Mesh;
  131384. /**
  131385. * Creates a sphere mesh
  131386. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  131387. * * 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`)
  131388. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  131389. * * 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
  131390. * * 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)
  131391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131394. * @param name defines the name of the mesh
  131395. * @param options defines the options used to create the mesh
  131396. * @param scene defines the hosting scene
  131397. * @returns the sphere mesh
  131398. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  131399. */
  131400. static CreateSphere(name: string, options: {
  131401. segments?: number;
  131402. diameter?: number;
  131403. diameterX?: number;
  131404. diameterY?: number;
  131405. diameterZ?: number;
  131406. arc?: number;
  131407. slice?: number;
  131408. sideOrientation?: number;
  131409. frontUVs?: Vector4;
  131410. backUVs?: Vector4;
  131411. updatable?: boolean;
  131412. }, scene?: Nullable<Scene>): Mesh;
  131413. /**
  131414. * Creates a plane polygonal mesh. By default, this is a disc
  131415. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  131416. * * 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
  131417. * * 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
  131418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131421. * @param name defines the name of the mesh
  131422. * @param options defines the options used to create the mesh
  131423. * @param scene defines the hosting scene
  131424. * @returns the plane polygonal mesh
  131425. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  131426. */
  131427. static CreateDisc(name: string, options: {
  131428. radius?: number;
  131429. tessellation?: number;
  131430. arc?: number;
  131431. updatable?: boolean;
  131432. sideOrientation?: number;
  131433. frontUVs?: Vector4;
  131434. backUVs?: Vector4;
  131435. }, scene?: Nullable<Scene>): Mesh;
  131436. /**
  131437. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  131438. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  131439. * * 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`)
  131440. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  131441. * * 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
  131442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131445. * @param name defines the name of the mesh
  131446. * @param options defines the options used to create the mesh
  131447. * @param scene defines the hosting scene
  131448. * @returns the icosahedron mesh
  131449. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  131450. */
  131451. static CreateIcoSphere(name: string, options: {
  131452. radius?: number;
  131453. radiusX?: number;
  131454. radiusY?: number;
  131455. radiusZ?: number;
  131456. flat?: boolean;
  131457. subdivisions?: number;
  131458. sideOrientation?: number;
  131459. frontUVs?: Vector4;
  131460. backUVs?: Vector4;
  131461. updatable?: boolean;
  131462. }, scene?: Nullable<Scene>): Mesh;
  131463. /**
  131464. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131465. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131466. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131467. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131468. * * 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
  131469. * * 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
  131470. * * 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
  131471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131474. * * 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
  131475. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131476. * * 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
  131477. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131479. * @param name defines the name of the mesh
  131480. * @param options defines the options used to create the mesh
  131481. * @param scene defines the hosting scene
  131482. * @returns the ribbon mesh
  131483. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131485. */
  131486. static CreateRibbon(name: string, options: {
  131487. pathArray: Vector3[][];
  131488. closeArray?: boolean;
  131489. closePath?: boolean;
  131490. offset?: number;
  131491. updatable?: boolean;
  131492. sideOrientation?: number;
  131493. frontUVs?: Vector4;
  131494. backUVs?: Vector4;
  131495. instance?: Mesh;
  131496. invertUV?: boolean;
  131497. uvs?: Vector2[];
  131498. colors?: Color4[];
  131499. }, scene?: Nullable<Scene>): Mesh;
  131500. /**
  131501. * Creates a cylinder or a cone mesh
  131502. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131503. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131504. * * 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.
  131505. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131506. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131507. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131508. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131509. * * 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).
  131510. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131511. * * 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).
  131512. * * 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
  131513. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131514. * * 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
  131515. * * 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.
  131516. * * If `enclose` is false, a ring surface is one element.
  131517. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131518. * * 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
  131519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131522. * @param name defines the name of the mesh
  131523. * @param options defines the options used to create the mesh
  131524. * @param scene defines the hosting scene
  131525. * @returns the cylinder mesh
  131526. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131527. */
  131528. static CreateCylinder(name: string, options: {
  131529. height?: number;
  131530. diameterTop?: number;
  131531. diameterBottom?: number;
  131532. diameter?: number;
  131533. tessellation?: number;
  131534. subdivisions?: number;
  131535. arc?: number;
  131536. faceColors?: Color4[];
  131537. faceUV?: Vector4[];
  131538. updatable?: boolean;
  131539. hasRings?: boolean;
  131540. enclose?: boolean;
  131541. cap?: number;
  131542. sideOrientation?: number;
  131543. frontUVs?: Vector4;
  131544. backUVs?: Vector4;
  131545. }, scene?: Nullable<Scene>): Mesh;
  131546. /**
  131547. * Creates a torus mesh
  131548. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131549. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131550. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131554. * @param name defines the name of the mesh
  131555. * @param options defines the options used to create the mesh
  131556. * @param scene defines the hosting scene
  131557. * @returns the torus mesh
  131558. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131559. */
  131560. static CreateTorus(name: string, options: {
  131561. diameter?: number;
  131562. thickness?: number;
  131563. tessellation?: number;
  131564. updatable?: boolean;
  131565. sideOrientation?: number;
  131566. frontUVs?: Vector4;
  131567. backUVs?: Vector4;
  131568. }, scene?: Nullable<Scene>): Mesh;
  131569. /**
  131570. * Creates a torus knot mesh
  131571. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  131572. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  131573. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  131574. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  131575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131578. * @param name defines the name of the mesh
  131579. * @param options defines the options used to create the mesh
  131580. * @param scene defines the hosting scene
  131581. * @returns the torus knot mesh
  131582. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  131583. */
  131584. static CreateTorusKnot(name: string, options: {
  131585. radius?: number;
  131586. tube?: number;
  131587. radialSegments?: number;
  131588. tubularSegments?: number;
  131589. p?: number;
  131590. q?: number;
  131591. updatable?: boolean;
  131592. sideOrientation?: number;
  131593. frontUVs?: Vector4;
  131594. backUVs?: Vector4;
  131595. }, scene?: Nullable<Scene>): Mesh;
  131596. /**
  131597. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  131598. * * 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
  131599. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  131600. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  131601. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  131602. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  131603. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  131604. * * 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
  131605. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  131606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  131608. * @param name defines the name of the new line system
  131609. * @param options defines the options used to create the line system
  131610. * @param scene defines the hosting scene
  131611. * @returns a new line system mesh
  131612. */
  131613. static CreateLineSystem(name: string, options: {
  131614. lines: Vector3[][];
  131615. updatable?: boolean;
  131616. instance?: Nullable<LinesMesh>;
  131617. colors?: Nullable<Color4[][]>;
  131618. useVertexAlpha?: boolean;
  131619. }, scene: Nullable<Scene>): LinesMesh;
  131620. /**
  131621. * Creates a line mesh
  131622. * 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
  131623. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  131624. * * The parameter `points` is an array successive Vector3
  131625. * * 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
  131626. * * The optional parameter `colors` is an array of successive Color4, one per line point
  131627. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  131628. * * When updating an instance, remember that only point positions can change, not the number of points
  131629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  131631. * @param name defines the name of the new line system
  131632. * @param options defines the options used to create the line system
  131633. * @param scene defines the hosting scene
  131634. * @returns a new line mesh
  131635. */
  131636. static CreateLines(name: string, options: {
  131637. points: Vector3[];
  131638. updatable?: boolean;
  131639. instance?: Nullable<LinesMesh>;
  131640. colors?: Color4[];
  131641. useVertexAlpha?: boolean;
  131642. }, scene?: Nullable<Scene>): LinesMesh;
  131643. /**
  131644. * Creates a dashed line mesh
  131645. * * 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
  131646. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  131647. * * The parameter `points` is an array successive Vector3
  131648. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  131649. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  131650. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  131651. * * 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
  131652. * * When updating an instance, remember that only point positions can change, not the number of points
  131653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131654. * @param name defines the name of the mesh
  131655. * @param options defines the options used to create the mesh
  131656. * @param scene defines the hosting scene
  131657. * @returns the dashed line mesh
  131658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  131659. */
  131660. static CreateDashedLines(name: string, options: {
  131661. points: Vector3[];
  131662. dashSize?: number;
  131663. gapSize?: number;
  131664. dashNb?: number;
  131665. updatable?: boolean;
  131666. instance?: LinesMesh;
  131667. }, scene?: Nullable<Scene>): LinesMesh;
  131668. /**
  131669. * 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.
  131670. * * 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.
  131671. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131672. * * 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.
  131673. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131674. * * 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
  131675. * * 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
  131676. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131679. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131681. * @param name defines the name of the mesh
  131682. * @param options defines the options used to create the mesh
  131683. * @param scene defines the hosting scene
  131684. * @returns the extruded shape mesh
  131685. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131687. */
  131688. static ExtrudeShape(name: string, options: {
  131689. shape: Vector3[];
  131690. path: Vector3[];
  131691. scale?: number;
  131692. rotation?: number;
  131693. cap?: number;
  131694. updatable?: boolean;
  131695. sideOrientation?: number;
  131696. frontUVs?: Vector4;
  131697. backUVs?: Vector4;
  131698. instance?: Mesh;
  131699. invertUV?: boolean;
  131700. }, scene?: Nullable<Scene>): Mesh;
  131701. /**
  131702. * Creates an custom extruded shape mesh.
  131703. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131704. * * 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.
  131705. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131706. * * 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
  131707. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131708. * * 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
  131709. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131710. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131711. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131712. * * 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
  131713. * * 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
  131714. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131717. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131719. * @param name defines the name of the mesh
  131720. * @param options defines the options used to create the mesh
  131721. * @param scene defines the hosting scene
  131722. * @returns the custom extruded shape mesh
  131723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131726. */
  131727. static ExtrudeShapeCustom(name: string, options: {
  131728. shape: Vector3[];
  131729. path: Vector3[];
  131730. scaleFunction?: any;
  131731. rotationFunction?: any;
  131732. ribbonCloseArray?: boolean;
  131733. ribbonClosePath?: boolean;
  131734. cap?: number;
  131735. updatable?: boolean;
  131736. sideOrientation?: number;
  131737. frontUVs?: Vector4;
  131738. backUVs?: Vector4;
  131739. instance?: Mesh;
  131740. invertUV?: boolean;
  131741. }, scene?: Nullable<Scene>): Mesh;
  131742. /**
  131743. * Creates lathe mesh.
  131744. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  131745. * * 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
  131746. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  131747. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  131748. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  131749. * * 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
  131750. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  131751. * * 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
  131752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131756. * @param name defines the name of the mesh
  131757. * @param options defines the options used to create the mesh
  131758. * @param scene defines the hosting scene
  131759. * @returns the lathe mesh
  131760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  131761. */
  131762. static CreateLathe(name: string, options: {
  131763. shape: Vector3[];
  131764. radius?: number;
  131765. tessellation?: number;
  131766. clip?: number;
  131767. arc?: number;
  131768. closed?: boolean;
  131769. updatable?: boolean;
  131770. sideOrientation?: number;
  131771. frontUVs?: Vector4;
  131772. backUVs?: Vector4;
  131773. cap?: number;
  131774. invertUV?: boolean;
  131775. }, scene?: Nullable<Scene>): Mesh;
  131776. /**
  131777. * Creates a tiled plane mesh
  131778. * * You can set a limited pattern arrangement with the tiles
  131779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131782. * @param name defines the name of the mesh
  131783. * @param options defines the options used to create the mesh
  131784. * @param scene defines the hosting scene
  131785. * @returns the plane mesh
  131786. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  131787. */
  131788. static CreateTiledPlane(name: string, options: {
  131789. pattern?: number;
  131790. tileSize?: number;
  131791. tileWidth?: number;
  131792. tileHeight?: number;
  131793. size?: number;
  131794. width?: number;
  131795. height?: number;
  131796. alignHorizontal?: number;
  131797. alignVertical?: number;
  131798. sideOrientation?: number;
  131799. frontUVs?: Vector4;
  131800. backUVs?: Vector4;
  131801. updatable?: boolean;
  131802. }, scene?: Nullable<Scene>): Mesh;
  131803. /**
  131804. * Creates a plane mesh
  131805. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  131806. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  131807. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  131808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131811. * @param name defines the name of the mesh
  131812. * @param options defines the options used to create the mesh
  131813. * @param scene defines the hosting scene
  131814. * @returns the plane mesh
  131815. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  131816. */
  131817. static CreatePlane(name: string, options: {
  131818. size?: number;
  131819. width?: number;
  131820. height?: number;
  131821. sideOrientation?: number;
  131822. frontUVs?: Vector4;
  131823. backUVs?: Vector4;
  131824. updatable?: boolean;
  131825. sourcePlane?: Plane;
  131826. }, scene?: Nullable<Scene>): Mesh;
  131827. /**
  131828. * Creates a ground mesh
  131829. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131830. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131832. * @param name defines the name of the mesh
  131833. * @param options defines the options used to create the mesh
  131834. * @param scene defines the hosting scene
  131835. * @returns the ground mesh
  131836. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131837. */
  131838. static CreateGround(name: string, options: {
  131839. width?: number;
  131840. height?: number;
  131841. subdivisions?: number;
  131842. subdivisionsX?: number;
  131843. subdivisionsY?: number;
  131844. updatable?: boolean;
  131845. }, scene?: Nullable<Scene>): Mesh;
  131846. /**
  131847. * Creates a tiled ground mesh
  131848. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131849. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131850. * * 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
  131851. * * 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
  131852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131853. * @param name defines the name of the mesh
  131854. * @param options defines the options used to create the mesh
  131855. * @param scene defines the hosting scene
  131856. * @returns the tiled ground mesh
  131857. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131858. */
  131859. static CreateTiledGround(name: string, options: {
  131860. xmin: number;
  131861. zmin: number;
  131862. xmax: number;
  131863. zmax: number;
  131864. subdivisions?: {
  131865. w: number;
  131866. h: number;
  131867. };
  131868. precision?: {
  131869. w: number;
  131870. h: number;
  131871. };
  131872. updatable?: boolean;
  131873. }, scene?: Nullable<Scene>): Mesh;
  131874. /**
  131875. * Creates a ground mesh from a height map
  131876. * * The parameter `url` sets the URL of the height map image resource.
  131877. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131878. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131879. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131880. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131881. * * 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.
  131882. * * 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).
  131883. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131885. * @param name defines the name of the mesh
  131886. * @param url defines the url to the height map
  131887. * @param options defines the options used to create the mesh
  131888. * @param scene defines the hosting scene
  131889. * @returns the ground mesh
  131890. * @see https://doc.babylonjs.com/babylon101/height_map
  131891. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131892. */
  131893. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131894. width?: number;
  131895. height?: number;
  131896. subdivisions?: number;
  131897. minHeight?: number;
  131898. maxHeight?: number;
  131899. colorFilter?: Color3;
  131900. alphaFilter?: number;
  131901. updatable?: boolean;
  131902. onReady?: (mesh: GroundMesh) => void;
  131903. }, scene?: Nullable<Scene>): GroundMesh;
  131904. /**
  131905. * Creates a polygon mesh
  131906. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  131907. * * 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
  131908. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  131909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  131911. * * Remember you can only change the shape positions, not their number when updating a polygon
  131912. * @param name defines the name of the mesh
  131913. * @param options defines the options used to create the mesh
  131914. * @param scene defines the hosting scene
  131915. * @param earcutInjection can be used to inject your own earcut reference
  131916. * @returns the polygon mesh
  131917. */
  131918. static CreatePolygon(name: string, options: {
  131919. shape: Vector3[];
  131920. holes?: Vector3[][];
  131921. depth?: number;
  131922. faceUV?: Vector4[];
  131923. faceColors?: Color4[];
  131924. updatable?: boolean;
  131925. sideOrientation?: number;
  131926. frontUVs?: Vector4;
  131927. backUVs?: Vector4;
  131928. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131929. /**
  131930. * Creates an extruded polygon mesh, with depth in the Y direction.
  131931. * * 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)
  131932. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131933. * @param name defines the name of the mesh
  131934. * @param options defines the options used to create the mesh
  131935. * @param scene defines the hosting scene
  131936. * @param earcutInjection can be used to inject your own earcut reference
  131937. * @returns the polygon mesh
  131938. */
  131939. static ExtrudePolygon(name: string, options: {
  131940. shape: Vector3[];
  131941. holes?: Vector3[][];
  131942. depth?: number;
  131943. faceUV?: Vector4[];
  131944. faceColors?: Color4[];
  131945. updatable?: boolean;
  131946. sideOrientation?: number;
  131947. frontUVs?: Vector4;
  131948. backUVs?: Vector4;
  131949. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131950. /**
  131951. * Creates a tube mesh.
  131952. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131953. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  131954. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  131955. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  131956. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  131957. * * 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)
  131958. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  131959. * * 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
  131960. * * 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
  131961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131963. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131965. * @param name defines the name of the mesh
  131966. * @param options defines the options used to create the mesh
  131967. * @param scene defines the hosting scene
  131968. * @returns the tube mesh
  131969. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131970. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  131971. */
  131972. static CreateTube(name: string, options: {
  131973. path: Vector3[];
  131974. radius?: number;
  131975. tessellation?: number;
  131976. radiusFunction?: {
  131977. (i: number, distance: number): number;
  131978. };
  131979. cap?: number;
  131980. arc?: number;
  131981. updatable?: boolean;
  131982. sideOrientation?: number;
  131983. frontUVs?: Vector4;
  131984. backUVs?: Vector4;
  131985. instance?: Mesh;
  131986. invertUV?: boolean;
  131987. }, scene?: Nullable<Scene>): Mesh;
  131988. /**
  131989. * Creates a polyhedron mesh
  131990. * * 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
  131991. * * The parameter `size` (positive float, default 1) sets the polygon size
  131992. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  131993. * * 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`
  131994. * * 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
  131995. * * 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)`)
  131996. * * 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
  131997. * * 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
  131998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132001. * @param name defines the name of the mesh
  132002. * @param options defines the options used to create the mesh
  132003. * @param scene defines the hosting scene
  132004. * @returns the polyhedron mesh
  132005. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132006. */
  132007. static CreatePolyhedron(name: string, options: {
  132008. type?: number;
  132009. size?: number;
  132010. sizeX?: number;
  132011. sizeY?: number;
  132012. sizeZ?: number;
  132013. custom?: any;
  132014. faceUV?: Vector4[];
  132015. faceColors?: Color4[];
  132016. flat?: boolean;
  132017. updatable?: boolean;
  132018. sideOrientation?: number;
  132019. frontUVs?: Vector4;
  132020. backUVs?: Vector4;
  132021. }, scene?: Nullable<Scene>): Mesh;
  132022. /**
  132023. * Creates a decal mesh.
  132024. * 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
  132025. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  132026. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  132027. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  132028. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  132029. * @param name defines the name of the mesh
  132030. * @param sourceMesh defines the mesh where the decal must be applied
  132031. * @param options defines the options used to create the mesh
  132032. * @param scene defines the hosting scene
  132033. * @returns the decal mesh
  132034. * @see https://doc.babylonjs.com/how_to/decals
  132035. */
  132036. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  132037. position?: Vector3;
  132038. normal?: Vector3;
  132039. size?: Vector3;
  132040. angle?: number;
  132041. }): Mesh;
  132042. }
  132043. }
  132044. declare module BABYLON {
  132045. /**
  132046. * A simplifier interface for future simplification implementations
  132047. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132048. */
  132049. export interface ISimplifier {
  132050. /**
  132051. * Simplification of a given mesh according to the given settings.
  132052. * Since this requires computation, it is assumed that the function runs async.
  132053. * @param settings The settings of the simplification, including quality and distance
  132054. * @param successCallback A callback that will be called after the mesh was simplified.
  132055. * @param errorCallback in case of an error, this callback will be called. optional.
  132056. */
  132057. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  132058. }
  132059. /**
  132060. * Expected simplification settings.
  132061. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  132062. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132063. */
  132064. export interface ISimplificationSettings {
  132065. /**
  132066. * Gets or sets the expected quality
  132067. */
  132068. quality: number;
  132069. /**
  132070. * Gets or sets the distance when this optimized version should be used
  132071. */
  132072. distance: number;
  132073. /**
  132074. * Gets an already optimized mesh
  132075. */
  132076. optimizeMesh?: boolean;
  132077. }
  132078. /**
  132079. * Class used to specify simplification options
  132080. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132081. */
  132082. export class SimplificationSettings implements ISimplificationSettings {
  132083. /** expected quality */
  132084. quality: number;
  132085. /** distance when this optimized version should be used */
  132086. distance: number;
  132087. /** already optimized mesh */
  132088. optimizeMesh?: boolean | undefined;
  132089. /**
  132090. * Creates a SimplificationSettings
  132091. * @param quality expected quality
  132092. * @param distance distance when this optimized version should be used
  132093. * @param optimizeMesh already optimized mesh
  132094. */
  132095. constructor(
  132096. /** expected quality */
  132097. quality: number,
  132098. /** distance when this optimized version should be used */
  132099. distance: number,
  132100. /** already optimized mesh */
  132101. optimizeMesh?: boolean | undefined);
  132102. }
  132103. /**
  132104. * Interface used to define a simplification task
  132105. */
  132106. export interface ISimplificationTask {
  132107. /**
  132108. * Array of settings
  132109. */
  132110. settings: Array<ISimplificationSettings>;
  132111. /**
  132112. * Simplification type
  132113. */
  132114. simplificationType: SimplificationType;
  132115. /**
  132116. * Mesh to simplify
  132117. */
  132118. mesh: Mesh;
  132119. /**
  132120. * Callback called on success
  132121. */
  132122. successCallback?: () => void;
  132123. /**
  132124. * Defines if parallel processing can be used
  132125. */
  132126. parallelProcessing: boolean;
  132127. }
  132128. /**
  132129. * Queue used to order the simplification tasks
  132130. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132131. */
  132132. export class SimplificationQueue {
  132133. private _simplificationArray;
  132134. /**
  132135. * Gets a boolean indicating that the process is still running
  132136. */
  132137. running: boolean;
  132138. /**
  132139. * Creates a new queue
  132140. */
  132141. constructor();
  132142. /**
  132143. * Adds a new simplification task
  132144. * @param task defines a task to add
  132145. */
  132146. addTask(task: ISimplificationTask): void;
  132147. /**
  132148. * Execute next task
  132149. */
  132150. executeNext(): void;
  132151. /**
  132152. * Execute a simplification task
  132153. * @param task defines the task to run
  132154. */
  132155. runSimplification(task: ISimplificationTask): void;
  132156. private getSimplifier;
  132157. }
  132158. /**
  132159. * The implemented types of simplification
  132160. * At the moment only Quadratic Error Decimation is implemented
  132161. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132162. */
  132163. export enum SimplificationType {
  132164. /** Quadratic error decimation */
  132165. QUADRATIC = 0
  132166. }
  132167. }
  132168. declare module BABYLON {
  132169. interface Scene {
  132170. /** @hidden (Backing field) */
  132171. _simplificationQueue: SimplificationQueue;
  132172. /**
  132173. * Gets or sets the simplification queue attached to the scene
  132174. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132175. */
  132176. simplificationQueue: SimplificationQueue;
  132177. }
  132178. interface Mesh {
  132179. /**
  132180. * Simplify the mesh according to the given array of settings.
  132181. * Function will return immediately and will simplify async
  132182. * @param settings a collection of simplification settings
  132183. * @param parallelProcessing should all levels calculate parallel or one after the other
  132184. * @param simplificationType the type of simplification to run
  132185. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  132186. * @returns the current mesh
  132187. */
  132188. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  132189. }
  132190. /**
  132191. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  132192. * created in a scene
  132193. */
  132194. export class SimplicationQueueSceneComponent implements ISceneComponent {
  132195. /**
  132196. * The component name helpfull to identify the component in the list of scene components.
  132197. */
  132198. readonly name: string;
  132199. /**
  132200. * The scene the component belongs to.
  132201. */
  132202. scene: Scene;
  132203. /**
  132204. * Creates a new instance of the component for the given scene
  132205. * @param scene Defines the scene to register the component in
  132206. */
  132207. constructor(scene: Scene);
  132208. /**
  132209. * Registers the component in a given scene
  132210. */
  132211. register(): void;
  132212. /**
  132213. * Rebuilds the elements related to this component in case of
  132214. * context lost for instance.
  132215. */
  132216. rebuild(): void;
  132217. /**
  132218. * Disposes the component and the associated ressources
  132219. */
  132220. dispose(): void;
  132221. private _beforeCameraUpdate;
  132222. }
  132223. }
  132224. declare module BABYLON {
  132225. /**
  132226. * Navigation plugin interface to add navigation constrained by a navigation mesh
  132227. */
  132228. export interface INavigationEnginePlugin {
  132229. /**
  132230. * plugin name
  132231. */
  132232. name: string;
  132233. /**
  132234. * Creates a navigation mesh
  132235. * @param meshes array of all the geometry used to compute the navigatio mesh
  132236. * @param parameters bunch of parameters used to filter geometry
  132237. */
  132238. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  132239. /**
  132240. * Create a navigation mesh debug mesh
  132241. * @param scene is where the mesh will be added
  132242. * @returns debug display mesh
  132243. */
  132244. createDebugNavMesh(scene: Scene): Mesh;
  132245. /**
  132246. * Get a navigation mesh constrained position, closest to the parameter position
  132247. * @param position world position
  132248. * @returns the closest point to position constrained by the navigation mesh
  132249. */
  132250. getClosestPoint(position: Vector3): Vector3;
  132251. /**
  132252. * Get a navigation mesh constrained position, within a particular radius
  132253. * @param position world position
  132254. * @param maxRadius the maximum distance to the constrained world position
  132255. * @returns the closest point to position constrained by the navigation mesh
  132256. */
  132257. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  132258. /**
  132259. * Compute the final position from a segment made of destination-position
  132260. * @param position world position
  132261. * @param destination world position
  132262. * @returns the resulting point along the navmesh
  132263. */
  132264. moveAlong(position: Vector3, destination: Vector3): Vector3;
  132265. /**
  132266. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  132267. * @param start world position
  132268. * @param end world position
  132269. * @returns array containing world position composing the path
  132270. */
  132271. computePath(start: Vector3, end: Vector3): Vector3[];
  132272. /**
  132273. * If this plugin is supported
  132274. * @returns true if plugin is supported
  132275. */
  132276. isSupported(): boolean;
  132277. /**
  132278. * Create a new Crowd so you can add agents
  132279. * @param maxAgents the maximum agent count in the crowd
  132280. * @param maxAgentRadius the maximum radius an agent can have
  132281. * @param scene to attach the crowd to
  132282. * @returns the crowd you can add agents to
  132283. */
  132284. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  132285. /**
  132286. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132287. * The queries will try to find a solution within those bounds
  132288. * default is (1,1,1)
  132289. * @param extent x,y,z value that define the extent around the queries point of reference
  132290. */
  132291. setDefaultQueryExtent(extent: Vector3): void;
  132292. /**
  132293. * Get the Bounding box extent specified by setDefaultQueryExtent
  132294. * @returns the box extent values
  132295. */
  132296. getDefaultQueryExtent(): Vector3;
  132297. /**
  132298. * Release all resources
  132299. */
  132300. dispose(): void;
  132301. }
  132302. /**
  132303. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  132304. */
  132305. export interface ICrowd {
  132306. /**
  132307. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  132308. * You can attach anything to that node. The node position is updated in the scene update tick.
  132309. * @param pos world position that will be constrained by the navigation mesh
  132310. * @param parameters agent parameters
  132311. * @param transform hooked to the agent that will be update by the scene
  132312. * @returns agent index
  132313. */
  132314. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  132315. /**
  132316. * Returns the agent position in world space
  132317. * @param index agent index returned by addAgent
  132318. * @returns world space position
  132319. */
  132320. getAgentPosition(index: number): Vector3;
  132321. /**
  132322. * Gets the agent velocity in world space
  132323. * @param index agent index returned by addAgent
  132324. * @returns world space velocity
  132325. */
  132326. getAgentVelocity(index: number): Vector3;
  132327. /**
  132328. * remove a particular agent previously created
  132329. * @param index agent index returned by addAgent
  132330. */
  132331. removeAgent(index: number): void;
  132332. /**
  132333. * get the list of all agents attached to this crowd
  132334. * @returns list of agent indices
  132335. */
  132336. getAgents(): number[];
  132337. /**
  132338. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  132339. * @param deltaTime in seconds
  132340. */
  132341. update(deltaTime: number): void;
  132342. /**
  132343. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  132344. * @param index agent index returned by addAgent
  132345. * @param destination targeted world position
  132346. */
  132347. agentGoto(index: number, destination: Vector3): void;
  132348. /**
  132349. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132350. * The queries will try to find a solution within those bounds
  132351. * default is (1,1,1)
  132352. * @param extent x,y,z value that define the extent around the queries point of reference
  132353. */
  132354. setDefaultQueryExtent(extent: Vector3): void;
  132355. /**
  132356. * Get the Bounding box extent specified by setDefaultQueryExtent
  132357. * @returns the box extent values
  132358. */
  132359. getDefaultQueryExtent(): Vector3;
  132360. /**
  132361. * Release all resources
  132362. */
  132363. dispose(): void;
  132364. }
  132365. /**
  132366. * Configures an agent
  132367. */
  132368. export interface IAgentParameters {
  132369. /**
  132370. * Agent radius. [Limit: >= 0]
  132371. */
  132372. radius: number;
  132373. /**
  132374. * Agent height. [Limit: > 0]
  132375. */
  132376. height: number;
  132377. /**
  132378. * Maximum allowed acceleration. [Limit: >= 0]
  132379. */
  132380. maxAcceleration: number;
  132381. /**
  132382. * Maximum allowed speed. [Limit: >= 0]
  132383. */
  132384. maxSpeed: number;
  132385. /**
  132386. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  132387. */
  132388. collisionQueryRange: number;
  132389. /**
  132390. * The path visibility optimization range. [Limit: > 0]
  132391. */
  132392. pathOptimizationRange: number;
  132393. /**
  132394. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  132395. */
  132396. separationWeight: number;
  132397. }
  132398. /**
  132399. * Configures the navigation mesh creation
  132400. */
  132401. export interface INavMeshParameters {
  132402. /**
  132403. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  132404. */
  132405. cs: number;
  132406. /**
  132407. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  132408. */
  132409. ch: number;
  132410. /**
  132411. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  132412. */
  132413. walkableSlopeAngle: number;
  132414. /**
  132415. * Minimum floor to 'ceiling' height that will still allow the floor area to
  132416. * be considered walkable. [Limit: >= 3] [Units: vx]
  132417. */
  132418. walkableHeight: number;
  132419. /**
  132420. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  132421. */
  132422. walkableClimb: number;
  132423. /**
  132424. * The distance to erode/shrink the walkable area of the heightfield away from
  132425. * obstructions. [Limit: >=0] [Units: vx]
  132426. */
  132427. walkableRadius: number;
  132428. /**
  132429. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  132430. */
  132431. maxEdgeLen: number;
  132432. /**
  132433. * The maximum distance a simplfied contour's border edges should deviate
  132434. * the original raw contour. [Limit: >=0] [Units: vx]
  132435. */
  132436. maxSimplificationError: number;
  132437. /**
  132438. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  132439. */
  132440. minRegionArea: number;
  132441. /**
  132442. * Any regions with a span count smaller than this value will, if possible,
  132443. * be merged with larger regions. [Limit: >=0] [Units: vx]
  132444. */
  132445. mergeRegionArea: number;
  132446. /**
  132447. * The maximum number of vertices allowed for polygons generated during the
  132448. * contour to polygon conversion process. [Limit: >= 3]
  132449. */
  132450. maxVertsPerPoly: number;
  132451. /**
  132452. * Sets the sampling distance to use when generating the detail mesh.
  132453. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  132454. */
  132455. detailSampleDist: number;
  132456. /**
  132457. * The maximum distance the detail mesh surface should deviate from heightfield
  132458. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  132459. */
  132460. detailSampleMaxError: number;
  132461. }
  132462. }
  132463. declare module BABYLON {
  132464. /**
  132465. * RecastJS navigation plugin
  132466. */
  132467. export class RecastJSPlugin implements INavigationEnginePlugin {
  132468. /**
  132469. * Reference to the Recast library
  132470. */
  132471. bjsRECAST: any;
  132472. /**
  132473. * plugin name
  132474. */
  132475. name: string;
  132476. /**
  132477. * the first navmesh created. We might extend this to support multiple navmeshes
  132478. */
  132479. navMesh: any;
  132480. /**
  132481. * Initializes the recastJS plugin
  132482. * @param recastInjection can be used to inject your own recast reference
  132483. */
  132484. constructor(recastInjection?: any);
  132485. /**
  132486. * Creates a navigation mesh
  132487. * @param meshes array of all the geometry used to compute the navigatio mesh
  132488. * @param parameters bunch of parameters used to filter geometry
  132489. */
  132490. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  132491. /**
  132492. * Create a navigation mesh debug mesh
  132493. * @param scene is where the mesh will be added
  132494. * @returns debug display mesh
  132495. */
  132496. createDebugNavMesh(scene: Scene): Mesh;
  132497. /**
  132498. * Get a navigation mesh constrained position, closest to the parameter position
  132499. * @param position world position
  132500. * @returns the closest point to position constrained by the navigation mesh
  132501. */
  132502. getClosestPoint(position: Vector3): Vector3;
  132503. /**
  132504. * Get a navigation mesh constrained position, within a particular radius
  132505. * @param position world position
  132506. * @param maxRadius the maximum distance to the constrained world position
  132507. * @returns the closest point to position constrained by the navigation mesh
  132508. */
  132509. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  132510. /**
  132511. * Compute the final position from a segment made of destination-position
  132512. * @param position world position
  132513. * @param destination world position
  132514. * @returns the resulting point along the navmesh
  132515. */
  132516. moveAlong(position: Vector3, destination: Vector3): Vector3;
  132517. /**
  132518. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  132519. * @param start world position
  132520. * @param end world position
  132521. * @returns array containing world position composing the path
  132522. */
  132523. computePath(start: Vector3, end: Vector3): Vector3[];
  132524. /**
  132525. * Create a new Crowd so you can add agents
  132526. * @param maxAgents the maximum agent count in the crowd
  132527. * @param maxAgentRadius the maximum radius an agent can have
  132528. * @param scene to attach the crowd to
  132529. * @returns the crowd you can add agents to
  132530. */
  132531. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  132532. /**
  132533. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132534. * The queries will try to find a solution within those bounds
  132535. * default is (1,1,1)
  132536. * @param extent x,y,z value that define the extent around the queries point of reference
  132537. */
  132538. setDefaultQueryExtent(extent: Vector3): void;
  132539. /**
  132540. * Get the Bounding box extent specified by setDefaultQueryExtent
  132541. * @returns the box extent values
  132542. */
  132543. getDefaultQueryExtent(): Vector3;
  132544. /**
  132545. * Disposes
  132546. */
  132547. dispose(): void;
  132548. /**
  132549. * If this plugin is supported
  132550. * @returns true if plugin is supported
  132551. */
  132552. isSupported(): boolean;
  132553. }
  132554. /**
  132555. * Recast detour crowd implementation
  132556. */
  132557. export class RecastJSCrowd implements ICrowd {
  132558. /**
  132559. * Recast/detour plugin
  132560. */
  132561. bjsRECASTPlugin: RecastJSPlugin;
  132562. /**
  132563. * Link to the detour crowd
  132564. */
  132565. recastCrowd: any;
  132566. /**
  132567. * One transform per agent
  132568. */
  132569. transforms: TransformNode[];
  132570. /**
  132571. * All agents created
  132572. */
  132573. agents: number[];
  132574. /**
  132575. * Link to the scene is kept to unregister the crowd from the scene
  132576. */
  132577. private _scene;
  132578. /**
  132579. * Observer for crowd updates
  132580. */
  132581. private _onBeforeAnimationsObserver;
  132582. /**
  132583. * Constructor
  132584. * @param plugin recastJS plugin
  132585. * @param maxAgents the maximum agent count in the crowd
  132586. * @param maxAgentRadius the maximum radius an agent can have
  132587. * @param scene to attach the crowd to
  132588. * @returns the crowd you can add agents to
  132589. */
  132590. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  132591. /**
  132592. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  132593. * You can attach anything to that node. The node position is updated in the scene update tick.
  132594. * @param pos world position that will be constrained by the navigation mesh
  132595. * @param parameters agent parameters
  132596. * @param transform hooked to the agent that will be update by the scene
  132597. * @returns agent index
  132598. */
  132599. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  132600. /**
  132601. * Returns the agent position in world space
  132602. * @param index agent index returned by addAgent
  132603. * @returns world space position
  132604. */
  132605. getAgentPosition(index: number): Vector3;
  132606. /**
  132607. * Returns the agent velocity in world space
  132608. * @param index agent index returned by addAgent
  132609. * @returns world space velocity
  132610. */
  132611. getAgentVelocity(index: number): Vector3;
  132612. /**
  132613. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  132614. * @param index agent index returned by addAgent
  132615. * @param destination targeted world position
  132616. */
  132617. agentGoto(index: number, destination: Vector3): void;
  132618. /**
  132619. * remove a particular agent previously created
  132620. * @param index agent index returned by addAgent
  132621. */
  132622. removeAgent(index: number): void;
  132623. /**
  132624. * get the list of all agents attached to this crowd
  132625. * @returns list of agent indices
  132626. */
  132627. getAgents(): number[];
  132628. /**
  132629. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  132630. * @param deltaTime in seconds
  132631. */
  132632. update(deltaTime: number): void;
  132633. /**
  132634. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132635. * The queries will try to find a solution within those bounds
  132636. * default is (1,1,1)
  132637. * @param extent x,y,z value that define the extent around the queries point of reference
  132638. */
  132639. setDefaultQueryExtent(extent: Vector3): void;
  132640. /**
  132641. * Get the Bounding box extent specified by setDefaultQueryExtent
  132642. * @returns the box extent values
  132643. */
  132644. getDefaultQueryExtent(): Vector3;
  132645. /**
  132646. * Release all resources
  132647. */
  132648. dispose(): void;
  132649. }
  132650. }
  132651. declare module BABYLON {
  132652. /**
  132653. * Class used to enable access to IndexedDB
  132654. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  132655. */
  132656. export class Database implements IOfflineProvider {
  132657. private _callbackManifestChecked;
  132658. private _currentSceneUrl;
  132659. private _db;
  132660. private _enableSceneOffline;
  132661. private _enableTexturesOffline;
  132662. private _manifestVersionFound;
  132663. private _mustUpdateRessources;
  132664. private _hasReachedQuota;
  132665. private _isSupported;
  132666. private _idbFactory;
  132667. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  132668. private static IsUASupportingBlobStorage;
  132669. /**
  132670. * Gets a boolean indicating if Database storate is enabled (off by default)
  132671. */
  132672. static IDBStorageEnabled: boolean;
  132673. /**
  132674. * Gets a boolean indicating if scene must be saved in the database
  132675. */
  132676. get enableSceneOffline(): boolean;
  132677. /**
  132678. * Gets a boolean indicating if textures must be saved in the database
  132679. */
  132680. get enableTexturesOffline(): boolean;
  132681. /**
  132682. * Creates a new Database
  132683. * @param urlToScene defines the url to load the scene
  132684. * @param callbackManifestChecked defines the callback to use when manifest is checked
  132685. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  132686. */
  132687. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  132688. private static _ParseURL;
  132689. private static _ReturnFullUrlLocation;
  132690. private _checkManifestFile;
  132691. /**
  132692. * Open the database and make it available
  132693. * @param successCallback defines the callback to call on success
  132694. * @param errorCallback defines the callback to call on error
  132695. */
  132696. open(successCallback: () => void, errorCallback: () => void): void;
  132697. /**
  132698. * Loads an image from the database
  132699. * @param url defines the url to load from
  132700. * @param image defines the target DOM image
  132701. */
  132702. loadImage(url: string, image: HTMLImageElement): void;
  132703. private _loadImageFromDBAsync;
  132704. private _saveImageIntoDBAsync;
  132705. private _checkVersionFromDB;
  132706. private _loadVersionFromDBAsync;
  132707. private _saveVersionIntoDBAsync;
  132708. /**
  132709. * Loads a file from database
  132710. * @param url defines the URL to load from
  132711. * @param sceneLoaded defines a callback to call on success
  132712. * @param progressCallBack defines a callback to call when progress changed
  132713. * @param errorCallback defines a callback to call on error
  132714. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  132715. */
  132716. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  132717. private _loadFileAsync;
  132718. private _saveFileAsync;
  132719. /**
  132720. * Validates if xhr data is correct
  132721. * @param xhr defines the request to validate
  132722. * @param dataType defines the expected data type
  132723. * @returns true if data is correct
  132724. */
  132725. private static _ValidateXHRData;
  132726. }
  132727. }
  132728. declare module BABYLON {
  132729. /** @hidden */
  132730. export var gpuUpdateParticlesPixelShader: {
  132731. name: string;
  132732. shader: string;
  132733. };
  132734. }
  132735. declare module BABYLON {
  132736. /** @hidden */
  132737. export var gpuUpdateParticlesVertexShader: {
  132738. name: string;
  132739. shader: string;
  132740. };
  132741. }
  132742. declare module BABYLON {
  132743. /** @hidden */
  132744. export var clipPlaneFragmentDeclaration2: {
  132745. name: string;
  132746. shader: string;
  132747. };
  132748. }
  132749. declare module BABYLON {
  132750. /** @hidden */
  132751. export var gpuRenderParticlesPixelShader: {
  132752. name: string;
  132753. shader: string;
  132754. };
  132755. }
  132756. declare module BABYLON {
  132757. /** @hidden */
  132758. export var clipPlaneVertexDeclaration2: {
  132759. name: string;
  132760. shader: string;
  132761. };
  132762. }
  132763. declare module BABYLON {
  132764. /** @hidden */
  132765. export var gpuRenderParticlesVertexShader: {
  132766. name: string;
  132767. shader: string;
  132768. };
  132769. }
  132770. declare module BABYLON {
  132771. /**
  132772. * This represents a GPU particle system in Babylon
  132773. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  132774. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  132775. */
  132776. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  132777. /**
  132778. * The layer mask we are rendering the particles through.
  132779. */
  132780. layerMask: number;
  132781. private _capacity;
  132782. private _activeCount;
  132783. private _currentActiveCount;
  132784. private _accumulatedCount;
  132785. private _renderEffect;
  132786. private _updateEffect;
  132787. private _buffer0;
  132788. private _buffer1;
  132789. private _spriteBuffer;
  132790. private _updateVAO;
  132791. private _renderVAO;
  132792. private _targetIndex;
  132793. private _sourceBuffer;
  132794. private _targetBuffer;
  132795. private _engine;
  132796. private _currentRenderId;
  132797. private _started;
  132798. private _stopped;
  132799. private _timeDelta;
  132800. private _randomTexture;
  132801. private _randomTexture2;
  132802. private _attributesStrideSize;
  132803. private _updateEffectOptions;
  132804. private _randomTextureSize;
  132805. private _actualFrame;
  132806. private readonly _rawTextureWidth;
  132807. /**
  132808. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  132809. */
  132810. static get IsSupported(): boolean;
  132811. /**
  132812. * An event triggered when the system is disposed.
  132813. */
  132814. onDisposeObservable: Observable<GPUParticleSystem>;
  132815. /**
  132816. * Gets the maximum number of particles active at the same time.
  132817. * @returns The max number of active particles.
  132818. */
  132819. getCapacity(): number;
  132820. /**
  132821. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  132822. * to override the particles.
  132823. */
  132824. forceDepthWrite: boolean;
  132825. /**
  132826. * Gets or set the number of active particles
  132827. */
  132828. get activeParticleCount(): number;
  132829. set activeParticleCount(value: number);
  132830. private _preWarmDone;
  132831. /**
  132832. * Is this system ready to be used/rendered
  132833. * @return true if the system is ready
  132834. */
  132835. isReady(): boolean;
  132836. /**
  132837. * Gets if the system has been started. (Note: this will still be true after stop is called)
  132838. * @returns True if it has been started, otherwise false.
  132839. */
  132840. isStarted(): boolean;
  132841. /**
  132842. * Starts the particle system and begins to emit
  132843. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  132844. */
  132845. start(delay?: number): void;
  132846. /**
  132847. * Stops the particle system.
  132848. */
  132849. stop(): void;
  132850. /**
  132851. * Remove all active particles
  132852. */
  132853. reset(): void;
  132854. /**
  132855. * Returns the string "GPUParticleSystem"
  132856. * @returns a string containing the class name
  132857. */
  132858. getClassName(): string;
  132859. private _colorGradientsTexture;
  132860. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  132861. /**
  132862. * Adds a new color gradient
  132863. * @param gradient defines the gradient to use (between 0 and 1)
  132864. * @param color1 defines the color to affect to the specified gradient
  132865. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  132866. * @returns the current particle system
  132867. */
  132868. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  132869. /**
  132870. * Remove a specific color gradient
  132871. * @param gradient defines the gradient to remove
  132872. * @returns the current particle system
  132873. */
  132874. removeColorGradient(gradient: number): GPUParticleSystem;
  132875. private _angularSpeedGradientsTexture;
  132876. private _sizeGradientsTexture;
  132877. private _velocityGradientsTexture;
  132878. private _limitVelocityGradientsTexture;
  132879. private _dragGradientsTexture;
  132880. private _addFactorGradient;
  132881. /**
  132882. * Adds a new size gradient
  132883. * @param gradient defines the gradient to use (between 0 and 1)
  132884. * @param factor defines the size factor to affect to the specified gradient
  132885. * @returns the current particle system
  132886. */
  132887. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  132888. /**
  132889. * Remove a specific size gradient
  132890. * @param gradient defines the gradient to remove
  132891. * @returns the current particle system
  132892. */
  132893. removeSizeGradient(gradient: number): GPUParticleSystem;
  132894. /**
  132895. * Adds a new angular speed gradient
  132896. * @param gradient defines the gradient to use (between 0 and 1)
  132897. * @param factor defines the angular speed to affect to the specified gradient
  132898. * @returns the current particle system
  132899. */
  132900. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  132901. /**
  132902. * Remove a specific angular speed gradient
  132903. * @param gradient defines the gradient to remove
  132904. * @returns the current particle system
  132905. */
  132906. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  132907. /**
  132908. * Adds a new velocity gradient
  132909. * @param gradient defines the gradient to use (between 0 and 1)
  132910. * @param factor defines the velocity to affect to the specified gradient
  132911. * @returns the current particle system
  132912. */
  132913. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  132914. /**
  132915. * Remove a specific velocity gradient
  132916. * @param gradient defines the gradient to remove
  132917. * @returns the current particle system
  132918. */
  132919. removeVelocityGradient(gradient: number): GPUParticleSystem;
  132920. /**
  132921. * Adds a new limit velocity gradient
  132922. * @param gradient defines the gradient to use (between 0 and 1)
  132923. * @param factor defines the limit velocity value to affect to the specified gradient
  132924. * @returns the current particle system
  132925. */
  132926. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  132927. /**
  132928. * Remove a specific limit velocity gradient
  132929. * @param gradient defines the gradient to remove
  132930. * @returns the current particle system
  132931. */
  132932. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  132933. /**
  132934. * Adds a new drag gradient
  132935. * @param gradient defines the gradient to use (between 0 and 1)
  132936. * @param factor defines the drag value to affect to the specified gradient
  132937. * @returns the current particle system
  132938. */
  132939. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  132940. /**
  132941. * Remove a specific drag gradient
  132942. * @param gradient defines the gradient to remove
  132943. * @returns the current particle system
  132944. */
  132945. removeDragGradient(gradient: number): GPUParticleSystem;
  132946. /**
  132947. * Not supported by GPUParticleSystem
  132948. * @param gradient defines the gradient to use (between 0 and 1)
  132949. * @param factor defines the emit rate value to affect to the specified gradient
  132950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  132951. * @returns the current particle system
  132952. */
  132953. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  132954. /**
  132955. * Not supported by GPUParticleSystem
  132956. * @param gradient defines the gradient to remove
  132957. * @returns the current particle system
  132958. */
  132959. removeEmitRateGradient(gradient: number): IParticleSystem;
  132960. /**
  132961. * Not supported by GPUParticleSystem
  132962. * @param gradient defines the gradient to use (between 0 and 1)
  132963. * @param factor defines the start size value to affect to the specified gradient
  132964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  132965. * @returns the current particle system
  132966. */
  132967. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  132968. /**
  132969. * Not supported by GPUParticleSystem
  132970. * @param gradient defines the gradient to remove
  132971. * @returns the current particle system
  132972. */
  132973. removeStartSizeGradient(gradient: number): IParticleSystem;
  132974. /**
  132975. * Not supported by GPUParticleSystem
  132976. * @param gradient defines the gradient to use (between 0 and 1)
  132977. * @param min defines the color remap minimal range
  132978. * @param max defines the color remap maximal range
  132979. * @returns the current particle system
  132980. */
  132981. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  132982. /**
  132983. * Not supported by GPUParticleSystem
  132984. * @param gradient defines the gradient to remove
  132985. * @returns the current particle system
  132986. */
  132987. removeColorRemapGradient(): IParticleSystem;
  132988. /**
  132989. * Not supported by GPUParticleSystem
  132990. * @param gradient defines the gradient to use (between 0 and 1)
  132991. * @param min defines the alpha remap minimal range
  132992. * @param max defines the alpha remap maximal range
  132993. * @returns the current particle system
  132994. */
  132995. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  132996. /**
  132997. * Not supported by GPUParticleSystem
  132998. * @param gradient defines the gradient to remove
  132999. * @returns the current particle system
  133000. */
  133001. removeAlphaRemapGradient(): IParticleSystem;
  133002. /**
  133003. * Not supported by GPUParticleSystem
  133004. * @param gradient defines the gradient to use (between 0 and 1)
  133005. * @param color defines the color to affect to the specified gradient
  133006. * @returns the current particle system
  133007. */
  133008. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  133009. /**
  133010. * Not supported by GPUParticleSystem
  133011. * @param gradient defines the gradient to remove
  133012. * @returns the current particle system
  133013. */
  133014. removeRampGradient(): IParticleSystem;
  133015. /**
  133016. * Not supported by GPUParticleSystem
  133017. * @returns the list of ramp gradients
  133018. */
  133019. getRampGradients(): Nullable<Array<Color3Gradient>>;
  133020. /**
  133021. * Not supported by GPUParticleSystem
  133022. * Gets or sets a boolean indicating that ramp gradients must be used
  133023. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  133024. */
  133025. get useRampGradients(): boolean;
  133026. set useRampGradients(value: boolean);
  133027. /**
  133028. * Not supported by GPUParticleSystem
  133029. * @param gradient defines the gradient to use (between 0 and 1)
  133030. * @param factor defines the life time factor to affect to the specified gradient
  133031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  133032. * @returns the current particle system
  133033. */
  133034. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  133035. /**
  133036. * Not supported by GPUParticleSystem
  133037. * @param gradient defines the gradient to remove
  133038. * @returns the current particle system
  133039. */
  133040. removeLifeTimeGradient(gradient: number): IParticleSystem;
  133041. /**
  133042. * Instantiates a GPU particle system.
  133043. * 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.
  133044. * @param name The name of the particle system
  133045. * @param options The options used to create the system
  133046. * @param scene The scene the particle system belongs to
  133047. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  133048. */
  133049. constructor(name: string, options: Partial<{
  133050. capacity: number;
  133051. randomTextureSize: number;
  133052. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  133053. protected _reset(): void;
  133054. private _createUpdateVAO;
  133055. private _createRenderVAO;
  133056. private _initialize;
  133057. /** @hidden */
  133058. _recreateUpdateEffect(): void;
  133059. /** @hidden */
  133060. _recreateRenderEffect(): void;
  133061. /**
  133062. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  133063. * @param preWarm defines if we are in the pre-warmimg phase
  133064. */
  133065. animate(preWarm?: boolean): void;
  133066. private _createFactorGradientTexture;
  133067. private _createSizeGradientTexture;
  133068. private _createAngularSpeedGradientTexture;
  133069. private _createVelocityGradientTexture;
  133070. private _createLimitVelocityGradientTexture;
  133071. private _createDragGradientTexture;
  133072. private _createColorGradientTexture;
  133073. /**
  133074. * Renders the particle system in its current state
  133075. * @param preWarm defines if the system should only update the particles but not render them
  133076. * @returns the current number of particles
  133077. */
  133078. render(preWarm?: boolean): number;
  133079. /**
  133080. * Rebuilds the particle system
  133081. */
  133082. rebuild(): void;
  133083. private _releaseBuffers;
  133084. private _releaseVAOs;
  133085. /**
  133086. * Disposes the particle system and free the associated resources
  133087. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  133088. */
  133089. dispose(disposeTexture?: boolean): void;
  133090. /**
  133091. * Clones the particle system.
  133092. * @param name The name of the cloned object
  133093. * @param newEmitter The new emitter to use
  133094. * @returns the cloned particle system
  133095. */
  133096. clone(name: string, newEmitter: any): GPUParticleSystem;
  133097. /**
  133098. * Serializes the particle system to a JSON object.
  133099. * @returns the JSON object
  133100. */
  133101. serialize(): any;
  133102. /**
  133103. * Parses a JSON object to create a GPU particle system.
  133104. * @param parsedParticleSystem The JSON object to parse
  133105. * @param scene The scene to create the particle system in
  133106. * @param rootUrl The root url to use to load external dependencies like texture
  133107. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  133108. * @returns the parsed GPU particle system
  133109. */
  133110. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  133111. }
  133112. }
  133113. declare module BABYLON {
  133114. /**
  133115. * Represents a set of particle systems working together to create a specific effect
  133116. */
  133117. export class ParticleSystemSet implements IDisposable {
  133118. /**
  133119. * Gets or sets base Assets URL
  133120. */
  133121. static BaseAssetsUrl: string;
  133122. private _emitterCreationOptions;
  133123. private _emitterNode;
  133124. /**
  133125. * Gets the particle system list
  133126. */
  133127. systems: IParticleSystem[];
  133128. /**
  133129. * Gets the emitter node used with this set
  133130. */
  133131. get emitterNode(): Nullable<TransformNode>;
  133132. /**
  133133. * Creates a new emitter mesh as a sphere
  133134. * @param options defines the options used to create the sphere
  133135. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  133136. * @param scene defines the hosting scene
  133137. */
  133138. setEmitterAsSphere(options: {
  133139. diameter: number;
  133140. segments: number;
  133141. color: Color3;
  133142. }, renderingGroupId: number, scene: Scene): void;
  133143. /**
  133144. * Starts all particle systems of the set
  133145. * @param emitter defines an optional mesh to use as emitter for the particle systems
  133146. */
  133147. start(emitter?: AbstractMesh): void;
  133148. /**
  133149. * Release all associated resources
  133150. */
  133151. dispose(): void;
  133152. /**
  133153. * Serialize the set into a JSON compatible object
  133154. * @returns a JSON compatible representation of the set
  133155. */
  133156. serialize(): any;
  133157. /**
  133158. * Parse a new ParticleSystemSet from a serialized source
  133159. * @param data defines a JSON compatible representation of the set
  133160. * @param scene defines the hosting scene
  133161. * @param gpu defines if we want GPU particles or CPU particles
  133162. * @returns a new ParticleSystemSet
  133163. */
  133164. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  133165. }
  133166. }
  133167. declare module BABYLON {
  133168. /**
  133169. * This class is made for on one-liner static method to help creating particle system set.
  133170. */
  133171. export class ParticleHelper {
  133172. /**
  133173. * Gets or sets base Assets URL
  133174. */
  133175. static BaseAssetsUrl: string;
  133176. /**
  133177. * Create a default particle system that you can tweak
  133178. * @param emitter defines the emitter to use
  133179. * @param capacity defines the system capacity (default is 500 particles)
  133180. * @param scene defines the hosting scene
  133181. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  133182. * @returns the new Particle system
  133183. */
  133184. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  133185. /**
  133186. * This is the main static method (one-liner) of this helper to create different particle systems
  133187. * @param type This string represents the type to the particle system to create
  133188. * @param scene The scene where the particle system should live
  133189. * @param gpu If the system will use gpu
  133190. * @returns the ParticleSystemSet created
  133191. */
  133192. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  133193. /**
  133194. * Static function used to export a particle system to a ParticleSystemSet variable.
  133195. * Please note that the emitter shape is not exported
  133196. * @param systems defines the particle systems to export
  133197. * @returns the created particle system set
  133198. */
  133199. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  133200. }
  133201. }
  133202. declare module BABYLON {
  133203. interface Engine {
  133204. /**
  133205. * Create an effect to use with particle systems.
  133206. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  133207. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  133208. * @param uniformsNames defines a list of attribute names
  133209. * @param samplers defines an array of string used to represent textures
  133210. * @param defines defines the string containing the defines to use to compile the shaders
  133211. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  133212. * @param onCompiled defines a function to call when the effect creation is successful
  133213. * @param onError defines a function to call when the effect creation has failed
  133214. * @returns the new Effect
  133215. */
  133216. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  133217. }
  133218. interface Mesh {
  133219. /**
  133220. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  133221. * @returns an array of IParticleSystem
  133222. */
  133223. getEmittedParticleSystems(): IParticleSystem[];
  133224. /**
  133225. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  133226. * @returns an array of IParticleSystem
  133227. */
  133228. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  133229. }
  133230. /**
  133231. * @hidden
  133232. */
  133233. export var _IDoNeedToBeInTheBuild: number;
  133234. }
  133235. declare module BABYLON {
  133236. /** Defines the 4 color options */
  133237. export enum PointColor {
  133238. /** color value */
  133239. Color = 2,
  133240. /** uv value */
  133241. UV = 1,
  133242. /** random value */
  133243. Random = 0,
  133244. /** stated value */
  133245. Stated = 3
  133246. }
  133247. /**
  133248. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  133249. * 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.
  133250. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  133251. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  133252. *
  133253. * Full documentation here : TO BE ENTERED
  133254. */
  133255. export class PointsCloudSystem implements IDisposable {
  133256. /**
  133257. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  133258. * Example : var p = SPS.particles[i];
  133259. */
  133260. particles: CloudPoint[];
  133261. /**
  133262. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  133263. */
  133264. nbParticles: number;
  133265. /**
  133266. * This a counter for your own usage. It's not set by any SPS functions.
  133267. */
  133268. counter: number;
  133269. /**
  133270. * The PCS name. This name is also given to the underlying mesh.
  133271. */
  133272. name: string;
  133273. /**
  133274. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  133275. */
  133276. mesh: Mesh;
  133277. /**
  133278. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  133279. * Please read :
  133280. */
  133281. vars: any;
  133282. /**
  133283. * @hidden
  133284. */
  133285. _size: number;
  133286. private _scene;
  133287. private _promises;
  133288. private _positions;
  133289. private _indices;
  133290. private _normals;
  133291. private _colors;
  133292. private _uvs;
  133293. private _indices32;
  133294. private _positions32;
  133295. private _colors32;
  133296. private _uvs32;
  133297. private _updatable;
  133298. private _isVisibilityBoxLocked;
  133299. private _alwaysVisible;
  133300. private _groups;
  133301. private _groupCounter;
  133302. private _computeParticleColor;
  133303. private _computeParticleTexture;
  133304. private _computeParticleRotation;
  133305. private _computeBoundingBox;
  133306. private _isReady;
  133307. /**
  133308. * Creates a PCS (Points Cloud System) object
  133309. * @param name (String) is the PCS name, this will be the underlying mesh name
  133310. * @param pointSize (number) is the size for each point
  133311. * @param scene (Scene) is the scene in which the PCS is added
  133312. * @param options defines the options of the PCS e.g.
  133313. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  133314. */
  133315. constructor(name: string, pointSize: number, scene: Scene, options?: {
  133316. updatable?: boolean;
  133317. });
  133318. /**
  133319. * Builds the PCS underlying mesh. Returns a standard Mesh.
  133320. * If no points were added to the PCS, the returned mesh is just a single point.
  133321. * @returns a promise for the created mesh
  133322. */
  133323. buildMeshAsync(): Promise<Mesh>;
  133324. /**
  133325. * @hidden
  133326. */
  133327. private _buildMesh;
  133328. private _addParticle;
  133329. private _randomUnitVector;
  133330. private _getColorIndicesForCoord;
  133331. private _setPointsColorOrUV;
  133332. private _colorFromTexture;
  133333. private _calculateDensity;
  133334. /**
  133335. * Adds points to the PCS in random positions within a unit sphere
  133336. * @param nb (positive integer) the number of particles to be created from this model
  133337. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  133338. * @returns the number of groups in the system
  133339. */
  133340. addPoints(nb: number, pointFunction?: any): number;
  133341. /**
  133342. * Adds points to the PCS from the surface of the model shape
  133343. * @param mesh is any Mesh object that will be used as a surface model for the points
  133344. * @param nb (positive integer) the number of particles to be created from this model
  133345. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  133346. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  133347. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  133348. * @returns the number of groups in the system
  133349. */
  133350. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  133351. /**
  133352. * Adds points to the PCS inside the model shape
  133353. * @param mesh is any Mesh object that will be used as a surface model for the points
  133354. * @param nb (positive integer) the number of particles to be created from this model
  133355. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  133356. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  133357. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  133358. * @returns the number of groups in the system
  133359. */
  133360. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  133361. /**
  133362. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  133363. * This method calls `updateParticle()` for each particle of the SPS.
  133364. * For an animated SPS, it is usually called within the render loop.
  133365. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  133366. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  133367. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  133368. * @returns the PCS.
  133369. */
  133370. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  133371. /**
  133372. * Disposes the PCS.
  133373. */
  133374. dispose(): void;
  133375. /**
  133376. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  133377. * doc :
  133378. * @returns the PCS.
  133379. */
  133380. refreshVisibleSize(): PointsCloudSystem;
  133381. /**
  133382. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  133383. * @param size the size (float) of the visibility box
  133384. * note : this doesn't lock the PCS mesh bounding box.
  133385. * doc :
  133386. */
  133387. setVisibilityBox(size: number): void;
  133388. /**
  133389. * Gets whether the PCS is always visible or not
  133390. * doc :
  133391. */
  133392. get isAlwaysVisible(): boolean;
  133393. /**
  133394. * Sets the PCS as always visible or not
  133395. * doc :
  133396. */
  133397. set isAlwaysVisible(val: boolean);
  133398. /**
  133399. * Tells to `setParticles()` to compute the particle rotations or not
  133400. * Default value : false. The PCS is faster when it's set to false
  133401. * Note : particle rotations are only applied to parent particles
  133402. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  133403. */
  133404. set computeParticleRotation(val: boolean);
  133405. /**
  133406. * Tells to `setParticles()` to compute the particle colors or not.
  133407. * Default value : true. The PCS is faster when it's set to false.
  133408. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  133409. */
  133410. set computeParticleColor(val: boolean);
  133411. set computeParticleTexture(val: boolean);
  133412. /**
  133413. * Gets if `setParticles()` computes the particle colors or not.
  133414. * Default value : false. The PCS is faster when it's set to false.
  133415. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  133416. */
  133417. get computeParticleColor(): boolean;
  133418. /**
  133419. * Gets if `setParticles()` computes the particle textures or not.
  133420. * Default value : false. The PCS is faster when it's set to false.
  133421. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  133422. */
  133423. get computeParticleTexture(): boolean;
  133424. /**
  133425. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  133426. */
  133427. set computeBoundingBox(val: boolean);
  133428. /**
  133429. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  133430. */
  133431. get computeBoundingBox(): boolean;
  133432. /**
  133433. * This function does nothing. It may be overwritten to set all the particle first values.
  133434. * The PCS doesn't call this function, you may have to call it by your own.
  133435. * doc :
  133436. */
  133437. initParticles(): void;
  133438. /**
  133439. * This function does nothing. It may be overwritten to recycle a particle
  133440. * The PCS doesn't call this function, you can to call it
  133441. * doc :
  133442. * @param particle The particle to recycle
  133443. * @returns the recycled particle
  133444. */
  133445. recycleParticle(particle: CloudPoint): CloudPoint;
  133446. /**
  133447. * Updates a particle : this function should be overwritten by the user.
  133448. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  133449. * doc :
  133450. * @example : just set a particle position or velocity and recycle conditions
  133451. * @param particle The particle to update
  133452. * @returns the updated particle
  133453. */
  133454. updateParticle(particle: CloudPoint): CloudPoint;
  133455. /**
  133456. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  133457. * This does nothing and may be overwritten by the user.
  133458. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  133459. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  133460. * @param update the boolean update value actually passed to setParticles()
  133461. */
  133462. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  133463. /**
  133464. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  133465. * This will be passed three parameters.
  133466. * This does nothing and may be overwritten by the user.
  133467. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  133468. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  133469. * @param update the boolean update value actually passed to setParticles()
  133470. */
  133471. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  133472. }
  133473. }
  133474. declare module BABYLON {
  133475. /**
  133476. * Represents one particle of a points cloud system.
  133477. */
  133478. export class CloudPoint {
  133479. /**
  133480. * particle global index
  133481. */
  133482. idx: number;
  133483. /**
  133484. * The color of the particle
  133485. */
  133486. color: Nullable<Color4>;
  133487. /**
  133488. * The world space position of the particle.
  133489. */
  133490. position: Vector3;
  133491. /**
  133492. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  133493. */
  133494. rotation: Vector3;
  133495. /**
  133496. * The world space rotation quaternion of the particle.
  133497. */
  133498. rotationQuaternion: Nullable<Quaternion>;
  133499. /**
  133500. * The uv of the particle.
  133501. */
  133502. uv: Nullable<Vector2>;
  133503. /**
  133504. * The current speed of the particle.
  133505. */
  133506. velocity: Vector3;
  133507. /**
  133508. * The pivot point in the particle local space.
  133509. */
  133510. pivot: Vector3;
  133511. /**
  133512. * Must the particle be translated from its pivot point in its local space ?
  133513. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  133514. * Default : false
  133515. */
  133516. translateFromPivot: boolean;
  133517. /**
  133518. * Index of this particle in the global "positions" array (Internal use)
  133519. * @hidden
  133520. */
  133521. _pos: number;
  133522. /**
  133523. * @hidden Index of this particle in the global "indices" array (Internal use)
  133524. */
  133525. _ind: number;
  133526. /**
  133527. * Group this particle belongs to
  133528. */
  133529. _group: PointsGroup;
  133530. /**
  133531. * Group id of this particle
  133532. */
  133533. groupId: number;
  133534. /**
  133535. * Index of the particle in its group id (Internal use)
  133536. */
  133537. idxInGroup: number;
  133538. /**
  133539. * @hidden Particle BoundingInfo object (Internal use)
  133540. */
  133541. _boundingInfo: BoundingInfo;
  133542. /**
  133543. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  133544. */
  133545. _pcs: PointsCloudSystem;
  133546. /**
  133547. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  133548. */
  133549. _stillInvisible: boolean;
  133550. /**
  133551. * @hidden Last computed particle rotation matrix
  133552. */
  133553. _rotationMatrix: number[];
  133554. /**
  133555. * Parent particle Id, if any.
  133556. * Default null.
  133557. */
  133558. parentId: Nullable<number>;
  133559. /**
  133560. * @hidden Internal global position in the PCS.
  133561. */
  133562. _globalPosition: Vector3;
  133563. /**
  133564. * Creates a Point Cloud object.
  133565. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  133566. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  133567. * @param group (PointsGroup) is the group the particle belongs to
  133568. * @param groupId (integer) is the group identifier in the PCS.
  133569. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  133570. * @param pcs defines the PCS it is associated to
  133571. */
  133572. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  133573. /**
  133574. * get point size
  133575. */
  133576. get size(): Vector3;
  133577. /**
  133578. * Set point size
  133579. */
  133580. set size(scale: Vector3);
  133581. /**
  133582. * Legacy support, changed quaternion to rotationQuaternion
  133583. */
  133584. get quaternion(): Nullable<Quaternion>;
  133585. /**
  133586. * Legacy support, changed quaternion to rotationQuaternion
  133587. */
  133588. set quaternion(q: Nullable<Quaternion>);
  133589. /**
  133590. * Returns a boolean. True if the particle intersects a mesh, else false
  133591. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  133592. * @param target is the object (point or mesh) what the intersection is computed against
  133593. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  133594. * @returns true if it intersects
  133595. */
  133596. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  133597. /**
  133598. * get the rotation matrix of the particle
  133599. * @hidden
  133600. */
  133601. getRotationMatrix(m: Matrix): void;
  133602. }
  133603. /**
  133604. * Represents a group of points in a points cloud system
  133605. * * PCS internal tool, don't use it manually.
  133606. */
  133607. export class PointsGroup {
  133608. /**
  133609. * The group id
  133610. * @hidden
  133611. */
  133612. groupID: number;
  133613. /**
  133614. * image data for group (internal use)
  133615. * @hidden
  133616. */
  133617. _groupImageData: Nullable<ArrayBufferView>;
  133618. /**
  133619. * Image Width (internal use)
  133620. * @hidden
  133621. */
  133622. _groupImgWidth: number;
  133623. /**
  133624. * Image Height (internal use)
  133625. * @hidden
  133626. */
  133627. _groupImgHeight: number;
  133628. /**
  133629. * Custom position function (internal use)
  133630. * @hidden
  133631. */
  133632. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  133633. /**
  133634. * density per facet for surface points
  133635. * @hidden
  133636. */
  133637. _groupDensity: number[];
  133638. /**
  133639. * Only when points are colored by texture carries pointer to texture list array
  133640. * @hidden
  133641. */
  133642. _textureNb: number;
  133643. /**
  133644. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  133645. * PCS internal tool, don't use it manually.
  133646. * @hidden
  133647. */
  133648. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  133649. }
  133650. }
  133651. declare module BABYLON {
  133652. interface Scene {
  133653. /** @hidden (Backing field) */
  133654. _physicsEngine: Nullable<IPhysicsEngine>;
  133655. /** @hidden */
  133656. _physicsTimeAccumulator: number;
  133657. /**
  133658. * Gets the current physics engine
  133659. * @returns a IPhysicsEngine or null if none attached
  133660. */
  133661. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  133662. /**
  133663. * Enables physics to the current scene
  133664. * @param gravity defines the scene's gravity for the physics engine
  133665. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  133666. * @return a boolean indicating if the physics engine was initialized
  133667. */
  133668. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  133669. /**
  133670. * Disables and disposes the physics engine associated with the scene
  133671. */
  133672. disablePhysicsEngine(): void;
  133673. /**
  133674. * Gets a boolean indicating if there is an active physics engine
  133675. * @returns a boolean indicating if there is an active physics engine
  133676. */
  133677. isPhysicsEnabled(): boolean;
  133678. /**
  133679. * Deletes a physics compound impostor
  133680. * @param compound defines the compound to delete
  133681. */
  133682. deleteCompoundImpostor(compound: any): void;
  133683. /**
  133684. * An event triggered when physic simulation is about to be run
  133685. */
  133686. onBeforePhysicsObservable: Observable<Scene>;
  133687. /**
  133688. * An event triggered when physic simulation has been done
  133689. */
  133690. onAfterPhysicsObservable: Observable<Scene>;
  133691. }
  133692. interface AbstractMesh {
  133693. /** @hidden */
  133694. _physicsImpostor: Nullable<PhysicsImpostor>;
  133695. /**
  133696. * Gets or sets impostor used for physic simulation
  133697. * @see http://doc.babylonjs.com/features/physics_engine
  133698. */
  133699. physicsImpostor: Nullable<PhysicsImpostor>;
  133700. /**
  133701. * Gets the current physics impostor
  133702. * @see http://doc.babylonjs.com/features/physics_engine
  133703. * @returns a physics impostor or null
  133704. */
  133705. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  133706. /** Apply a physic impulse to the mesh
  133707. * @param force defines the force to apply
  133708. * @param contactPoint defines where to apply the force
  133709. * @returns the current mesh
  133710. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  133711. */
  133712. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  133713. /**
  133714. * Creates a physic joint between two meshes
  133715. * @param otherMesh defines the other mesh to use
  133716. * @param pivot1 defines the pivot to use on this mesh
  133717. * @param pivot2 defines the pivot to use on the other mesh
  133718. * @param options defines additional options (can be plugin dependent)
  133719. * @returns the current mesh
  133720. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  133721. */
  133722. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  133723. /** @hidden */
  133724. _disposePhysicsObserver: Nullable<Observer<Node>>;
  133725. }
  133726. /**
  133727. * Defines the physics engine scene component responsible to manage a physics engine
  133728. */
  133729. export class PhysicsEngineSceneComponent implements ISceneComponent {
  133730. /**
  133731. * The component name helpful to identify the component in the list of scene components.
  133732. */
  133733. readonly name: string;
  133734. /**
  133735. * The scene the component belongs to.
  133736. */
  133737. scene: Scene;
  133738. /**
  133739. * Creates a new instance of the component for the given scene
  133740. * @param scene Defines the scene to register the component in
  133741. */
  133742. constructor(scene: Scene);
  133743. /**
  133744. * Registers the component in a given scene
  133745. */
  133746. register(): void;
  133747. /**
  133748. * Rebuilds the elements related to this component in case of
  133749. * context lost for instance.
  133750. */
  133751. rebuild(): void;
  133752. /**
  133753. * Disposes the component and the associated ressources
  133754. */
  133755. dispose(): void;
  133756. }
  133757. }
  133758. declare module BABYLON {
  133759. /**
  133760. * A helper for physics simulations
  133761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  133762. */
  133763. export class PhysicsHelper {
  133764. private _scene;
  133765. private _physicsEngine;
  133766. /**
  133767. * Initializes the Physics helper
  133768. * @param scene Babylon.js scene
  133769. */
  133770. constructor(scene: Scene);
  133771. /**
  133772. * Applies a radial explosion impulse
  133773. * @param origin the origin of the explosion
  133774. * @param radiusOrEventOptions the radius or the options of radial explosion
  133775. * @param strength the explosion strength
  133776. * @param falloff possible options: Constant & Linear. Defaults to Constant
  133777. * @returns A physics radial explosion event, or null
  133778. */
  133779. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  133780. /**
  133781. * Applies a radial explosion force
  133782. * @param origin the origin of the explosion
  133783. * @param radiusOrEventOptions the radius or the options of radial explosion
  133784. * @param strength the explosion strength
  133785. * @param falloff possible options: Constant & Linear. Defaults to Constant
  133786. * @returns A physics radial explosion event, or null
  133787. */
  133788. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  133789. /**
  133790. * Creates a gravitational field
  133791. * @param origin the origin of the explosion
  133792. * @param radiusOrEventOptions the radius or the options of radial explosion
  133793. * @param strength the explosion strength
  133794. * @param falloff possible options: Constant & Linear. Defaults to Constant
  133795. * @returns A physics gravitational field event, or null
  133796. */
  133797. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  133798. /**
  133799. * Creates a physics updraft event
  133800. * @param origin the origin of the updraft
  133801. * @param radiusOrEventOptions the radius or the options of the updraft
  133802. * @param strength the strength of the updraft
  133803. * @param height the height of the updraft
  133804. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  133805. * @returns A physics updraft event, or null
  133806. */
  133807. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  133808. /**
  133809. * Creates a physics vortex event
  133810. * @param origin the of the vortex
  133811. * @param radiusOrEventOptions the radius or the options of the vortex
  133812. * @param strength the strength of the vortex
  133813. * @param height the height of the vortex
  133814. * @returns a Physics vortex event, or null
  133815. * A physics vortex event or null
  133816. */
  133817. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  133818. }
  133819. /**
  133820. * Represents a physics radial explosion event
  133821. */
  133822. class PhysicsRadialExplosionEvent {
  133823. private _scene;
  133824. private _options;
  133825. private _sphere;
  133826. private _dataFetched;
  133827. /**
  133828. * Initializes a radial explosioin event
  133829. * @param _scene BabylonJS scene
  133830. * @param _options The options for the vortex event
  133831. */
  133832. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  133833. /**
  133834. * Returns the data related to the radial explosion event (sphere).
  133835. * @returns The radial explosion event data
  133836. */
  133837. getData(): PhysicsRadialExplosionEventData;
  133838. /**
  133839. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  133840. * @param impostor A physics imposter
  133841. * @param origin the origin of the explosion
  133842. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  133843. */
  133844. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  133845. /**
  133846. * Triggers affecterd impostors callbacks
  133847. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  133848. */
  133849. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  133850. /**
  133851. * Disposes the sphere.
  133852. * @param force Specifies if the sphere should be disposed by force
  133853. */
  133854. dispose(force?: boolean): void;
  133855. /*** Helpers ***/
  133856. private _prepareSphere;
  133857. private _intersectsWithSphere;
  133858. }
  133859. /**
  133860. * Represents a gravitational field event
  133861. */
  133862. class PhysicsGravitationalFieldEvent {
  133863. private _physicsHelper;
  133864. private _scene;
  133865. private _origin;
  133866. private _options;
  133867. private _tickCallback;
  133868. private _sphere;
  133869. private _dataFetched;
  133870. /**
  133871. * Initializes the physics gravitational field event
  133872. * @param _physicsHelper A physics helper
  133873. * @param _scene BabylonJS scene
  133874. * @param _origin The origin position of the gravitational field event
  133875. * @param _options The options for the vortex event
  133876. */
  133877. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  133878. /**
  133879. * Returns the data related to the gravitational field event (sphere).
  133880. * @returns A gravitational field event
  133881. */
  133882. getData(): PhysicsGravitationalFieldEventData;
  133883. /**
  133884. * Enables the gravitational field.
  133885. */
  133886. enable(): void;
  133887. /**
  133888. * Disables the gravitational field.
  133889. */
  133890. disable(): void;
  133891. /**
  133892. * Disposes the sphere.
  133893. * @param force The force to dispose from the gravitational field event
  133894. */
  133895. dispose(force?: boolean): void;
  133896. private _tick;
  133897. }
  133898. /**
  133899. * Represents a physics updraft event
  133900. */
  133901. class PhysicsUpdraftEvent {
  133902. private _scene;
  133903. private _origin;
  133904. private _options;
  133905. private _physicsEngine;
  133906. private _originTop;
  133907. private _originDirection;
  133908. private _tickCallback;
  133909. private _cylinder;
  133910. private _cylinderPosition;
  133911. private _dataFetched;
  133912. /**
  133913. * Initializes the physics updraft event
  133914. * @param _scene BabylonJS scene
  133915. * @param _origin The origin position of the updraft
  133916. * @param _options The options for the updraft event
  133917. */
  133918. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  133919. /**
  133920. * Returns the data related to the updraft event (cylinder).
  133921. * @returns A physics updraft event
  133922. */
  133923. getData(): PhysicsUpdraftEventData;
  133924. /**
  133925. * Enables the updraft.
  133926. */
  133927. enable(): void;
  133928. /**
  133929. * Disables the updraft.
  133930. */
  133931. disable(): void;
  133932. /**
  133933. * Disposes the cylinder.
  133934. * @param force Specifies if the updraft should be disposed by force
  133935. */
  133936. dispose(force?: boolean): void;
  133937. private getImpostorHitData;
  133938. private _tick;
  133939. /*** Helpers ***/
  133940. private _prepareCylinder;
  133941. private _intersectsWithCylinder;
  133942. }
  133943. /**
  133944. * Represents a physics vortex event
  133945. */
  133946. class PhysicsVortexEvent {
  133947. private _scene;
  133948. private _origin;
  133949. private _options;
  133950. private _physicsEngine;
  133951. private _originTop;
  133952. private _tickCallback;
  133953. private _cylinder;
  133954. private _cylinderPosition;
  133955. private _dataFetched;
  133956. /**
  133957. * Initializes the physics vortex event
  133958. * @param _scene The BabylonJS scene
  133959. * @param _origin The origin position of the vortex
  133960. * @param _options The options for the vortex event
  133961. */
  133962. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  133963. /**
  133964. * Returns the data related to the vortex event (cylinder).
  133965. * @returns The physics vortex event data
  133966. */
  133967. getData(): PhysicsVortexEventData;
  133968. /**
  133969. * Enables the vortex.
  133970. */
  133971. enable(): void;
  133972. /**
  133973. * Disables the cortex.
  133974. */
  133975. disable(): void;
  133976. /**
  133977. * Disposes the sphere.
  133978. * @param force
  133979. */
  133980. dispose(force?: boolean): void;
  133981. private getImpostorHitData;
  133982. private _tick;
  133983. /*** Helpers ***/
  133984. private _prepareCylinder;
  133985. private _intersectsWithCylinder;
  133986. }
  133987. /**
  133988. * Options fot the radial explosion event
  133989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  133990. */
  133991. export class PhysicsRadialExplosionEventOptions {
  133992. /**
  133993. * The radius of the sphere for the radial explosion.
  133994. */
  133995. radius: number;
  133996. /**
  133997. * The strenth of the explosion.
  133998. */
  133999. strength: number;
  134000. /**
  134001. * The strenght of the force in correspondence to the distance of the affected object
  134002. */
  134003. falloff: PhysicsRadialImpulseFalloff;
  134004. /**
  134005. * Sphere options for the radial explosion.
  134006. */
  134007. sphere: {
  134008. segments: number;
  134009. diameter: number;
  134010. };
  134011. /**
  134012. * Sphere options for the radial explosion.
  134013. */
  134014. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  134015. }
  134016. /**
  134017. * Options fot the updraft event
  134018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134019. */
  134020. export class PhysicsUpdraftEventOptions {
  134021. /**
  134022. * The radius of the cylinder for the vortex
  134023. */
  134024. radius: number;
  134025. /**
  134026. * The strenth of the updraft.
  134027. */
  134028. strength: number;
  134029. /**
  134030. * The height of the cylinder for the updraft.
  134031. */
  134032. height: number;
  134033. /**
  134034. * The mode for the the updraft.
  134035. */
  134036. updraftMode: PhysicsUpdraftMode;
  134037. }
  134038. /**
  134039. * Options fot the vortex event
  134040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134041. */
  134042. export class PhysicsVortexEventOptions {
  134043. /**
  134044. * The radius of the cylinder for the vortex
  134045. */
  134046. radius: number;
  134047. /**
  134048. * The strenth of the vortex.
  134049. */
  134050. strength: number;
  134051. /**
  134052. * The height of the cylinder for the vortex.
  134053. */
  134054. height: number;
  134055. /**
  134056. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  134057. */
  134058. centripetalForceThreshold: number;
  134059. /**
  134060. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  134061. */
  134062. centripetalForceMultiplier: number;
  134063. /**
  134064. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  134065. */
  134066. centrifugalForceMultiplier: number;
  134067. /**
  134068. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  134069. */
  134070. updraftForceMultiplier: number;
  134071. }
  134072. /**
  134073. * The strenght of the force in correspondence to the distance of the affected object
  134074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134075. */
  134076. export enum PhysicsRadialImpulseFalloff {
  134077. /** Defines that impulse is constant in strength across it's whole radius */
  134078. Constant = 0,
  134079. /** Defines that impulse gets weaker if it's further from the origin */
  134080. Linear = 1
  134081. }
  134082. /**
  134083. * The strength of the force in correspondence to the distance of the affected object
  134084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134085. */
  134086. export enum PhysicsUpdraftMode {
  134087. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  134088. Center = 0,
  134089. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  134090. Perpendicular = 1
  134091. }
  134092. /**
  134093. * Interface for a physics hit data
  134094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134095. */
  134096. export interface PhysicsHitData {
  134097. /**
  134098. * The force applied at the contact point
  134099. */
  134100. force: Vector3;
  134101. /**
  134102. * The contact point
  134103. */
  134104. contactPoint: Vector3;
  134105. /**
  134106. * The distance from the origin to the contact point
  134107. */
  134108. distanceFromOrigin: number;
  134109. }
  134110. /**
  134111. * Interface for radial explosion event data
  134112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134113. */
  134114. export interface PhysicsRadialExplosionEventData {
  134115. /**
  134116. * A sphere used for the radial explosion event
  134117. */
  134118. sphere: Mesh;
  134119. }
  134120. /**
  134121. * Interface for gravitational field event data
  134122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134123. */
  134124. export interface PhysicsGravitationalFieldEventData {
  134125. /**
  134126. * A sphere mesh used for the gravitational field event
  134127. */
  134128. sphere: Mesh;
  134129. }
  134130. /**
  134131. * Interface for updraft event data
  134132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134133. */
  134134. export interface PhysicsUpdraftEventData {
  134135. /**
  134136. * A cylinder used for the updraft event
  134137. */
  134138. cylinder: Mesh;
  134139. }
  134140. /**
  134141. * Interface for vortex event data
  134142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134143. */
  134144. export interface PhysicsVortexEventData {
  134145. /**
  134146. * A cylinder used for the vortex event
  134147. */
  134148. cylinder: Mesh;
  134149. }
  134150. /**
  134151. * Interface for an affected physics impostor
  134152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134153. */
  134154. export interface PhysicsAffectedImpostorWithData {
  134155. /**
  134156. * The impostor affected by the effect
  134157. */
  134158. impostor: PhysicsImpostor;
  134159. /**
  134160. * The data about the hit/horce from the explosion
  134161. */
  134162. hitData: PhysicsHitData;
  134163. }
  134164. }
  134165. declare module BABYLON {
  134166. /** @hidden */
  134167. export var blackAndWhitePixelShader: {
  134168. name: string;
  134169. shader: string;
  134170. };
  134171. }
  134172. declare module BABYLON {
  134173. /**
  134174. * Post process used to render in black and white
  134175. */
  134176. export class BlackAndWhitePostProcess extends PostProcess {
  134177. /**
  134178. * Linear about to convert he result to black and white (default: 1)
  134179. */
  134180. degree: number;
  134181. /**
  134182. * Creates a black and white post process
  134183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  134184. * @param name The name of the effect.
  134185. * @param options The required width/height ratio to downsize to before computing the render pass.
  134186. * @param camera The camera to apply the render pass to.
  134187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134188. * @param engine The engine which the post process will be applied. (default: current engine)
  134189. * @param reusable If the post process can be reused on the same frame. (default: false)
  134190. */
  134191. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134192. }
  134193. }
  134194. declare module BABYLON {
  134195. /**
  134196. * This represents a set of one or more post processes in Babylon.
  134197. * A post process can be used to apply a shader to a texture after it is rendered.
  134198. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  134199. */
  134200. export class PostProcessRenderEffect {
  134201. private _postProcesses;
  134202. private _getPostProcesses;
  134203. private _singleInstance;
  134204. private _cameras;
  134205. private _indicesForCamera;
  134206. /**
  134207. * Name of the effect
  134208. * @hidden
  134209. */
  134210. _name: string;
  134211. /**
  134212. * Instantiates a post process render effect.
  134213. * A post process can be used to apply a shader to a texture after it is rendered.
  134214. * @param engine The engine the effect is tied to
  134215. * @param name The name of the effect
  134216. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  134217. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  134218. */
  134219. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  134220. /**
  134221. * Checks if all the post processes in the effect are supported.
  134222. */
  134223. get isSupported(): boolean;
  134224. /**
  134225. * Updates the current state of the effect
  134226. * @hidden
  134227. */
  134228. _update(): void;
  134229. /**
  134230. * Attaches the effect on cameras
  134231. * @param cameras The camera to attach to.
  134232. * @hidden
  134233. */
  134234. _attachCameras(cameras: Camera): void;
  134235. /**
  134236. * Attaches the effect on cameras
  134237. * @param cameras The camera to attach to.
  134238. * @hidden
  134239. */
  134240. _attachCameras(cameras: Camera[]): void;
  134241. /**
  134242. * Detaches the effect on cameras
  134243. * @param cameras The camera to detatch from.
  134244. * @hidden
  134245. */
  134246. _detachCameras(cameras: Camera): void;
  134247. /**
  134248. * Detatches the effect on cameras
  134249. * @param cameras The camera to detatch from.
  134250. * @hidden
  134251. */
  134252. _detachCameras(cameras: Camera[]): void;
  134253. /**
  134254. * Enables the effect on given cameras
  134255. * @param cameras The camera to enable.
  134256. * @hidden
  134257. */
  134258. _enable(cameras: Camera): void;
  134259. /**
  134260. * Enables the effect on given cameras
  134261. * @param cameras The camera to enable.
  134262. * @hidden
  134263. */
  134264. _enable(cameras: Nullable<Camera[]>): void;
  134265. /**
  134266. * Disables the effect on the given cameras
  134267. * @param cameras The camera to disable.
  134268. * @hidden
  134269. */
  134270. _disable(cameras: Camera): void;
  134271. /**
  134272. * Disables the effect on the given cameras
  134273. * @param cameras The camera to disable.
  134274. * @hidden
  134275. */
  134276. _disable(cameras: Nullable<Camera[]>): void;
  134277. /**
  134278. * Gets a list of the post processes contained in the effect.
  134279. * @param camera The camera to get the post processes on.
  134280. * @returns The list of the post processes in the effect.
  134281. */
  134282. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  134283. }
  134284. }
  134285. declare module BABYLON {
  134286. /** @hidden */
  134287. export var extractHighlightsPixelShader: {
  134288. name: string;
  134289. shader: string;
  134290. };
  134291. }
  134292. declare module BABYLON {
  134293. /**
  134294. * 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.
  134295. */
  134296. export class ExtractHighlightsPostProcess extends PostProcess {
  134297. /**
  134298. * The luminance threshold, pixels below this value will be set to black.
  134299. */
  134300. threshold: number;
  134301. /** @hidden */
  134302. _exposure: number;
  134303. /**
  134304. * Post process which has the input texture to be used when performing highlight extraction
  134305. * @hidden
  134306. */
  134307. _inputPostProcess: Nullable<PostProcess>;
  134308. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134309. }
  134310. }
  134311. declare module BABYLON {
  134312. /** @hidden */
  134313. export var bloomMergePixelShader: {
  134314. name: string;
  134315. shader: string;
  134316. };
  134317. }
  134318. declare module BABYLON {
  134319. /**
  134320. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  134321. */
  134322. export class BloomMergePostProcess extends PostProcess {
  134323. /** Weight of the bloom to be added to the original input. */
  134324. weight: number;
  134325. /**
  134326. * Creates a new instance of @see BloomMergePostProcess
  134327. * @param name The name of the effect.
  134328. * @param originalFromInput Post process which's input will be used for the merge.
  134329. * @param blurred Blurred highlights post process which's output will be used.
  134330. * @param weight Weight of the bloom to be added to the original input.
  134331. * @param options The required width/height ratio to downsize to before computing the render pass.
  134332. * @param camera The camera to apply the render pass to.
  134333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134334. * @param engine The engine which the post process will be applied. (default: current engine)
  134335. * @param reusable If the post process can be reused on the same frame. (default: false)
  134336. * @param textureType Type of textures used when performing the post process. (default: 0)
  134337. * @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)
  134338. */
  134339. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  134340. /** Weight of the bloom to be added to the original input. */
  134341. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134342. }
  134343. }
  134344. declare module BABYLON {
  134345. /**
  134346. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  134347. */
  134348. export class BloomEffect extends PostProcessRenderEffect {
  134349. private bloomScale;
  134350. /**
  134351. * @hidden Internal
  134352. */
  134353. _effects: Array<PostProcess>;
  134354. /**
  134355. * @hidden Internal
  134356. */
  134357. _downscale: ExtractHighlightsPostProcess;
  134358. private _blurX;
  134359. private _blurY;
  134360. private _merge;
  134361. /**
  134362. * The luminance threshold to find bright areas of the image to bloom.
  134363. */
  134364. get threshold(): number;
  134365. set threshold(value: number);
  134366. /**
  134367. * The strength of the bloom.
  134368. */
  134369. get weight(): number;
  134370. set weight(value: number);
  134371. /**
  134372. * Specifies the size of the bloom blur kernel, relative to the final output size
  134373. */
  134374. get kernel(): number;
  134375. set kernel(value: number);
  134376. /**
  134377. * Creates a new instance of @see BloomEffect
  134378. * @param scene The scene the effect belongs to.
  134379. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  134380. * @param bloomKernel The size of the kernel to be used when applying the blur.
  134381. * @param bloomWeight The the strength of bloom.
  134382. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  134383. * @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)
  134384. */
  134385. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  134386. /**
  134387. * Disposes each of the internal effects for a given camera.
  134388. * @param camera The camera to dispose the effect on.
  134389. */
  134390. disposeEffects(camera: Camera): void;
  134391. /**
  134392. * @hidden Internal
  134393. */
  134394. _updateEffects(): void;
  134395. /**
  134396. * Internal
  134397. * @returns if all the contained post processes are ready.
  134398. * @hidden
  134399. */
  134400. _isReady(): boolean;
  134401. }
  134402. }
  134403. declare module BABYLON {
  134404. /** @hidden */
  134405. export var chromaticAberrationPixelShader: {
  134406. name: string;
  134407. shader: string;
  134408. };
  134409. }
  134410. declare module BABYLON {
  134411. /**
  134412. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  134413. */
  134414. export class ChromaticAberrationPostProcess extends PostProcess {
  134415. /**
  134416. * The amount of seperation of rgb channels (default: 30)
  134417. */
  134418. aberrationAmount: number;
  134419. /**
  134420. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  134421. */
  134422. radialIntensity: number;
  134423. /**
  134424. * 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))
  134425. */
  134426. direction: Vector2;
  134427. /**
  134428. * 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))
  134429. */
  134430. centerPosition: Vector2;
  134431. /**
  134432. * Creates a new instance ChromaticAberrationPostProcess
  134433. * @param name The name of the effect.
  134434. * @param screenWidth The width of the screen to apply the effect on.
  134435. * @param screenHeight The height of the screen to apply the effect on.
  134436. * @param options The required width/height ratio to downsize to before computing the render pass.
  134437. * @param camera The camera to apply the render pass to.
  134438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134439. * @param engine The engine which the post process will be applied. (default: current engine)
  134440. * @param reusable If the post process can be reused on the same frame. (default: false)
  134441. * @param textureType Type of textures used when performing the post process. (default: 0)
  134442. * @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)
  134443. */
  134444. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134445. }
  134446. }
  134447. declare module BABYLON {
  134448. /** @hidden */
  134449. export var circleOfConfusionPixelShader: {
  134450. name: string;
  134451. shader: string;
  134452. };
  134453. }
  134454. declare module BABYLON {
  134455. /**
  134456. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  134457. */
  134458. export class CircleOfConfusionPostProcess extends PostProcess {
  134459. /**
  134460. * 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.
  134461. */
  134462. lensSize: number;
  134463. /**
  134464. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  134465. */
  134466. fStop: number;
  134467. /**
  134468. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  134469. */
  134470. focusDistance: number;
  134471. /**
  134472. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  134473. */
  134474. focalLength: number;
  134475. private _depthTexture;
  134476. /**
  134477. * Creates a new instance CircleOfConfusionPostProcess
  134478. * @param name The name of the effect.
  134479. * @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.
  134480. * @param options The required width/height ratio to downsize to before computing the render pass.
  134481. * @param camera The camera to apply the render pass to.
  134482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134483. * @param engine The engine which the post process will be applied. (default: current engine)
  134484. * @param reusable If the post process can be reused on the same frame. (default: false)
  134485. * @param textureType Type of textures used when performing the post process. (default: 0)
  134486. * @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)
  134487. */
  134488. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134489. /**
  134490. * 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.
  134491. */
  134492. set depthTexture(value: RenderTargetTexture);
  134493. }
  134494. }
  134495. declare module BABYLON {
  134496. /** @hidden */
  134497. export var colorCorrectionPixelShader: {
  134498. name: string;
  134499. shader: string;
  134500. };
  134501. }
  134502. declare module BABYLON {
  134503. /**
  134504. *
  134505. * This post-process allows the modification of rendered colors by using
  134506. * a 'look-up table' (LUT). This effect is also called Color Grading.
  134507. *
  134508. * The object needs to be provided an url to a texture containing the color
  134509. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  134510. * Use an image editing software to tweak the LUT to match your needs.
  134511. *
  134512. * For an example of a color LUT, see here:
  134513. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  134514. * For explanations on color grading, see here:
  134515. * @see http://udn.epicgames.com/Three/ColorGrading.html
  134516. *
  134517. */
  134518. export class ColorCorrectionPostProcess extends PostProcess {
  134519. private _colorTableTexture;
  134520. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134521. }
  134522. }
  134523. declare module BABYLON {
  134524. /** @hidden */
  134525. export var convolutionPixelShader: {
  134526. name: string;
  134527. shader: string;
  134528. };
  134529. }
  134530. declare module BABYLON {
  134531. /**
  134532. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  134533. * input texture to perform effects such as edge detection or sharpening
  134534. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  134535. */
  134536. export class ConvolutionPostProcess extends PostProcess {
  134537. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  134538. kernel: number[];
  134539. /**
  134540. * Creates a new instance ConvolutionPostProcess
  134541. * @param name The name of the effect.
  134542. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  134543. * @param options The required width/height ratio to downsize to before computing the render pass.
  134544. * @param camera The camera to apply the render pass to.
  134545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134546. * @param engine The engine which the post process will be applied. (default: current engine)
  134547. * @param reusable If the post process can be reused on the same frame. (default: false)
  134548. * @param textureType Type of textures used when performing the post process. (default: 0)
  134549. */
  134550. constructor(name: string,
  134551. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  134552. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  134553. /**
  134554. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134555. */
  134556. static EdgeDetect0Kernel: number[];
  134557. /**
  134558. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134559. */
  134560. static EdgeDetect1Kernel: number[];
  134561. /**
  134562. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134563. */
  134564. static EdgeDetect2Kernel: number[];
  134565. /**
  134566. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134567. */
  134568. static SharpenKernel: number[];
  134569. /**
  134570. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134571. */
  134572. static EmbossKernel: number[];
  134573. /**
  134574. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134575. */
  134576. static GaussianKernel: number[];
  134577. }
  134578. }
  134579. declare module BABYLON {
  134580. /**
  134581. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  134582. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  134583. * based on samples that have a large difference in distance than the center pixel.
  134584. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  134585. */
  134586. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  134587. direction: Vector2;
  134588. /**
  134589. * Creates a new instance CircleOfConfusionPostProcess
  134590. * @param name The name of the effect.
  134591. * @param scene The scene the effect belongs to.
  134592. * @param direction The direction the blur should be applied.
  134593. * @param kernel The size of the kernel used to blur.
  134594. * @param options The required width/height ratio to downsize to before computing the render pass.
  134595. * @param camera The camera to apply the render pass to.
  134596. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  134597. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  134598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134599. * @param engine The engine which the post process will be applied. (default: current engine)
  134600. * @param reusable If the post process can be reused on the same frame. (default: false)
  134601. * @param textureType Type of textures used when performing the post process. (default: 0)
  134602. * @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)
  134603. */
  134604. 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);
  134605. }
  134606. }
  134607. declare module BABYLON {
  134608. /** @hidden */
  134609. export var depthOfFieldMergePixelShader: {
  134610. name: string;
  134611. shader: string;
  134612. };
  134613. }
  134614. declare module BABYLON {
  134615. /**
  134616. * Options to be set when merging outputs from the default pipeline.
  134617. */
  134618. export class DepthOfFieldMergePostProcessOptions {
  134619. /**
  134620. * The original image to merge on top of
  134621. */
  134622. originalFromInput: PostProcess;
  134623. /**
  134624. * Parameters to perform the merge of the depth of field effect
  134625. */
  134626. depthOfField?: {
  134627. circleOfConfusion: PostProcess;
  134628. blurSteps: Array<PostProcess>;
  134629. };
  134630. /**
  134631. * Parameters to perform the merge of bloom effect
  134632. */
  134633. bloom?: {
  134634. blurred: PostProcess;
  134635. weight: number;
  134636. };
  134637. }
  134638. /**
  134639. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  134640. */
  134641. export class DepthOfFieldMergePostProcess extends PostProcess {
  134642. private blurSteps;
  134643. /**
  134644. * Creates a new instance of DepthOfFieldMergePostProcess
  134645. * @param name The name of the effect.
  134646. * @param originalFromInput Post process which's input will be used for the merge.
  134647. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  134648. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  134649. * @param options The required width/height ratio to downsize to before computing the render pass.
  134650. * @param camera The camera to apply the render pass to.
  134651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134652. * @param engine The engine which the post process will be applied. (default: current engine)
  134653. * @param reusable If the post process can be reused on the same frame. (default: false)
  134654. * @param textureType Type of textures used when performing the post process. (default: 0)
  134655. * @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)
  134656. */
  134657. 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);
  134658. /**
  134659. * Updates the effect with the current post process compile time values and recompiles the shader.
  134660. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  134661. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  134662. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  134663. * @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
  134664. * @param onCompiled Called when the shader has been compiled.
  134665. * @param onError Called if there is an error when compiling a shader.
  134666. */
  134667. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  134668. }
  134669. }
  134670. declare module BABYLON {
  134671. /**
  134672. * Specifies the level of max blur that should be applied when using the depth of field effect
  134673. */
  134674. export enum DepthOfFieldEffectBlurLevel {
  134675. /**
  134676. * Subtle blur
  134677. */
  134678. Low = 0,
  134679. /**
  134680. * Medium blur
  134681. */
  134682. Medium = 1,
  134683. /**
  134684. * Large blur
  134685. */
  134686. High = 2
  134687. }
  134688. /**
  134689. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  134690. */
  134691. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  134692. private _circleOfConfusion;
  134693. /**
  134694. * @hidden Internal, blurs from high to low
  134695. */
  134696. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  134697. private _depthOfFieldBlurY;
  134698. private _dofMerge;
  134699. /**
  134700. * @hidden Internal post processes in depth of field effect
  134701. */
  134702. _effects: Array<PostProcess>;
  134703. /**
  134704. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  134705. */
  134706. set focalLength(value: number);
  134707. get focalLength(): number;
  134708. /**
  134709. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  134710. */
  134711. set fStop(value: number);
  134712. get fStop(): number;
  134713. /**
  134714. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  134715. */
  134716. set focusDistance(value: number);
  134717. get focusDistance(): number;
  134718. /**
  134719. * 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.
  134720. */
  134721. set lensSize(value: number);
  134722. get lensSize(): number;
  134723. /**
  134724. * Creates a new instance DepthOfFieldEffect
  134725. * @param scene The scene the effect belongs to.
  134726. * @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.
  134727. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  134728. * @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)
  134729. */
  134730. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  134731. /**
  134732. * Get the current class name of the current effet
  134733. * @returns "DepthOfFieldEffect"
  134734. */
  134735. getClassName(): string;
  134736. /**
  134737. * 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.
  134738. */
  134739. set depthTexture(value: RenderTargetTexture);
  134740. /**
  134741. * Disposes each of the internal effects for a given camera.
  134742. * @param camera The camera to dispose the effect on.
  134743. */
  134744. disposeEffects(camera: Camera): void;
  134745. /**
  134746. * @hidden Internal
  134747. */
  134748. _updateEffects(): void;
  134749. /**
  134750. * Internal
  134751. * @returns if all the contained post processes are ready.
  134752. * @hidden
  134753. */
  134754. _isReady(): boolean;
  134755. }
  134756. }
  134757. declare module BABYLON {
  134758. /** @hidden */
  134759. export var displayPassPixelShader: {
  134760. name: string;
  134761. shader: string;
  134762. };
  134763. }
  134764. declare module BABYLON {
  134765. /**
  134766. * DisplayPassPostProcess which produces an output the same as it's input
  134767. */
  134768. export class DisplayPassPostProcess extends PostProcess {
  134769. /**
  134770. * Creates the DisplayPassPostProcess
  134771. * @param name The name of the effect.
  134772. * @param options The required width/height ratio to downsize to before computing the render pass.
  134773. * @param camera The camera to apply the render pass to.
  134774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134775. * @param engine The engine which the post process will be applied. (default: current engine)
  134776. * @param reusable If the post process can be reused on the same frame. (default: false)
  134777. */
  134778. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134779. }
  134780. }
  134781. declare module BABYLON {
  134782. /** @hidden */
  134783. export var filterPixelShader: {
  134784. name: string;
  134785. shader: string;
  134786. };
  134787. }
  134788. declare module BABYLON {
  134789. /**
  134790. * Applies a kernel filter to the image
  134791. */
  134792. export class FilterPostProcess extends PostProcess {
  134793. /** The matrix to be applied to the image */
  134794. kernelMatrix: Matrix;
  134795. /**
  134796. *
  134797. * @param name The name of the effect.
  134798. * @param kernelMatrix The matrix to be applied to the image
  134799. * @param options The required width/height ratio to downsize to before computing the render pass.
  134800. * @param camera The camera to apply the render pass to.
  134801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134802. * @param engine The engine which the post process will be applied. (default: current engine)
  134803. * @param reusable If the post process can be reused on the same frame. (default: false)
  134804. */
  134805. constructor(name: string,
  134806. /** The matrix to be applied to the image */
  134807. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134808. }
  134809. }
  134810. declare module BABYLON {
  134811. /** @hidden */
  134812. export var fxaaPixelShader: {
  134813. name: string;
  134814. shader: string;
  134815. };
  134816. }
  134817. declare module BABYLON {
  134818. /** @hidden */
  134819. export var fxaaVertexShader: {
  134820. name: string;
  134821. shader: string;
  134822. };
  134823. }
  134824. declare module BABYLON {
  134825. /**
  134826. * Fxaa post process
  134827. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  134828. */
  134829. export class FxaaPostProcess extends PostProcess {
  134830. /** @hidden */
  134831. texelWidth: number;
  134832. /** @hidden */
  134833. texelHeight: number;
  134834. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  134835. private _getDefines;
  134836. }
  134837. }
  134838. declare module BABYLON {
  134839. /** @hidden */
  134840. export var grainPixelShader: {
  134841. name: string;
  134842. shader: string;
  134843. };
  134844. }
  134845. declare module BABYLON {
  134846. /**
  134847. * The GrainPostProcess adds noise to the image at mid luminance levels
  134848. */
  134849. export class GrainPostProcess extends PostProcess {
  134850. /**
  134851. * The intensity of the grain added (default: 30)
  134852. */
  134853. intensity: number;
  134854. /**
  134855. * If the grain should be randomized on every frame
  134856. */
  134857. animated: boolean;
  134858. /**
  134859. * Creates a new instance of @see GrainPostProcess
  134860. * @param name The name of the effect.
  134861. * @param options The required width/height ratio to downsize to before computing the render pass.
  134862. * @param camera The camera to apply the render pass to.
  134863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134864. * @param engine The engine which the post process will be applied. (default: current engine)
  134865. * @param reusable If the post process can be reused on the same frame. (default: false)
  134866. * @param textureType Type of textures used when performing the post process. (default: 0)
  134867. * @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)
  134868. */
  134869. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134870. }
  134871. }
  134872. declare module BABYLON {
  134873. /** @hidden */
  134874. export var highlightsPixelShader: {
  134875. name: string;
  134876. shader: string;
  134877. };
  134878. }
  134879. declare module BABYLON {
  134880. /**
  134881. * Extracts highlights from the image
  134882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  134883. */
  134884. export class HighlightsPostProcess extends PostProcess {
  134885. /**
  134886. * Extracts highlights from the image
  134887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  134888. * @param name The name of the effect.
  134889. * @param options The required width/height ratio to downsize to before computing the render pass.
  134890. * @param camera The camera to apply the render pass to.
  134891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134892. * @param engine The engine which the post process will be applied. (default: current engine)
  134893. * @param reusable If the post process can be reused on the same frame. (default: false)
  134894. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  134895. */
  134896. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  134897. }
  134898. }
  134899. declare module BABYLON {
  134900. /** @hidden */
  134901. export var mrtFragmentDeclaration: {
  134902. name: string;
  134903. shader: string;
  134904. };
  134905. }
  134906. declare module BABYLON {
  134907. /** @hidden */
  134908. export var geometryPixelShader: {
  134909. name: string;
  134910. shader: string;
  134911. };
  134912. }
  134913. declare module BABYLON {
  134914. /** @hidden */
  134915. export var geometryVertexShader: {
  134916. name: string;
  134917. shader: string;
  134918. };
  134919. }
  134920. declare module BABYLON {
  134921. /** @hidden */
  134922. interface ISavedTransformationMatrix {
  134923. world: Matrix;
  134924. viewProjection: Matrix;
  134925. }
  134926. /**
  134927. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  134928. */
  134929. export class GeometryBufferRenderer {
  134930. /**
  134931. * Constant used to retrieve the position texture index in the G-Buffer textures array
  134932. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  134933. */
  134934. static readonly POSITION_TEXTURE_TYPE: number;
  134935. /**
  134936. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  134937. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  134938. */
  134939. static readonly VELOCITY_TEXTURE_TYPE: number;
  134940. /**
  134941. * Dictionary used to store the previous transformation matrices of each rendered mesh
  134942. * in order to compute objects velocities when enableVelocity is set to "true"
  134943. * @hidden
  134944. */
  134945. _previousTransformationMatrices: {
  134946. [index: number]: ISavedTransformationMatrix;
  134947. };
  134948. /**
  134949. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  134950. * in order to compute objects velocities when enableVelocity is set to "true"
  134951. * @hidden
  134952. */
  134953. _previousBonesTransformationMatrices: {
  134954. [index: number]: Float32Array;
  134955. };
  134956. /**
  134957. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  134958. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  134959. */
  134960. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  134961. private _scene;
  134962. private _multiRenderTarget;
  134963. private _ratio;
  134964. private _enablePosition;
  134965. private _enableVelocity;
  134966. private _positionIndex;
  134967. private _velocityIndex;
  134968. protected _effect: Effect;
  134969. protected _cachedDefines: string;
  134970. /**
  134971. * Set the render list (meshes to be rendered) used in the G buffer.
  134972. */
  134973. set renderList(meshes: Mesh[]);
  134974. /**
  134975. * Gets wether or not G buffer are supported by the running hardware.
  134976. * This requires draw buffer supports
  134977. */
  134978. get isSupported(): boolean;
  134979. /**
  134980. * Returns the index of the given texture type in the G-Buffer textures array
  134981. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  134982. * @returns the index of the given texture type in the G-Buffer textures array
  134983. */
  134984. getTextureIndex(textureType: number): number;
  134985. /**
  134986. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  134987. */
  134988. get enablePosition(): boolean;
  134989. /**
  134990. * Sets whether or not objects positions are enabled for the G buffer.
  134991. */
  134992. set enablePosition(enable: boolean);
  134993. /**
  134994. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  134995. */
  134996. get enableVelocity(): boolean;
  134997. /**
  134998. * Sets wether or not objects velocities are enabled for the G buffer.
  134999. */
  135000. set enableVelocity(enable: boolean);
  135001. /**
  135002. * Gets the scene associated with the buffer.
  135003. */
  135004. get scene(): Scene;
  135005. /**
  135006. * Gets the ratio used by the buffer during its creation.
  135007. * How big is the buffer related to the main canvas.
  135008. */
  135009. get ratio(): number;
  135010. /** @hidden */
  135011. static _SceneComponentInitialization: (scene: Scene) => void;
  135012. /**
  135013. * Creates a new G Buffer for the scene
  135014. * @param scene The scene the buffer belongs to
  135015. * @param ratio How big is the buffer related to the main canvas.
  135016. */
  135017. constructor(scene: Scene, ratio?: number);
  135018. /**
  135019. * Checks wether everything is ready to render a submesh to the G buffer.
  135020. * @param subMesh the submesh to check readiness for
  135021. * @param useInstances is the mesh drawn using instance or not
  135022. * @returns true if ready otherwise false
  135023. */
  135024. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135025. /**
  135026. * Gets the current underlying G Buffer.
  135027. * @returns the buffer
  135028. */
  135029. getGBuffer(): MultiRenderTarget;
  135030. /**
  135031. * Gets the number of samples used to render the buffer (anti aliasing).
  135032. */
  135033. get samples(): number;
  135034. /**
  135035. * Sets the number of samples used to render the buffer (anti aliasing).
  135036. */
  135037. set samples(value: number);
  135038. /**
  135039. * Disposes the renderer and frees up associated resources.
  135040. */
  135041. dispose(): void;
  135042. protected _createRenderTargets(): void;
  135043. private _copyBonesTransformationMatrices;
  135044. }
  135045. }
  135046. declare module BABYLON {
  135047. interface Scene {
  135048. /** @hidden (Backing field) */
  135049. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  135050. /**
  135051. * Gets or Sets the current geometry buffer associated to the scene.
  135052. */
  135053. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  135054. /**
  135055. * Enables a GeometryBufferRender and associates it with the scene
  135056. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  135057. * @returns the GeometryBufferRenderer
  135058. */
  135059. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  135060. /**
  135061. * Disables the GeometryBufferRender associated with the scene
  135062. */
  135063. disableGeometryBufferRenderer(): void;
  135064. }
  135065. /**
  135066. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  135067. * in several rendering techniques.
  135068. */
  135069. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  135070. /**
  135071. * The component name helpful to identify the component in the list of scene components.
  135072. */
  135073. readonly name: string;
  135074. /**
  135075. * The scene the component belongs to.
  135076. */
  135077. scene: Scene;
  135078. /**
  135079. * Creates a new instance of the component for the given scene
  135080. * @param scene Defines the scene to register the component in
  135081. */
  135082. constructor(scene: Scene);
  135083. /**
  135084. * Registers the component in a given scene
  135085. */
  135086. register(): void;
  135087. /**
  135088. * Rebuilds the elements related to this component in case of
  135089. * context lost for instance.
  135090. */
  135091. rebuild(): void;
  135092. /**
  135093. * Disposes the component and the associated ressources
  135094. */
  135095. dispose(): void;
  135096. private _gatherRenderTargets;
  135097. }
  135098. }
  135099. declare module BABYLON {
  135100. /** @hidden */
  135101. export var motionBlurPixelShader: {
  135102. name: string;
  135103. shader: string;
  135104. };
  135105. }
  135106. declare module BABYLON {
  135107. /**
  135108. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  135109. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  135110. * As an example, all you have to do is to create the post-process:
  135111. * var mb = new BABYLON.MotionBlurPostProcess(
  135112. * 'mb', // The name of the effect.
  135113. * scene, // The scene containing the objects to blur according to their velocity.
  135114. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  135115. * camera // The camera to apply the render pass to.
  135116. * );
  135117. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  135118. */
  135119. export class MotionBlurPostProcess extends PostProcess {
  135120. /**
  135121. * Defines how much the image is blurred by the movement. Default value is equal to 1
  135122. */
  135123. motionStrength: number;
  135124. /**
  135125. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  135126. */
  135127. get motionBlurSamples(): number;
  135128. /**
  135129. * Sets the number of iterations to be used for motion blur quality
  135130. */
  135131. set motionBlurSamples(samples: number);
  135132. private _motionBlurSamples;
  135133. private _geometryBufferRenderer;
  135134. /**
  135135. * Creates a new instance MotionBlurPostProcess
  135136. * @param name The name of the effect.
  135137. * @param scene The scene containing the objects to blur according to their velocity.
  135138. * @param options The required width/height ratio to downsize to before computing the render pass.
  135139. * @param camera The camera to apply the render pass to.
  135140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135141. * @param engine The engine which the post process will be applied. (default: current engine)
  135142. * @param reusable If the post process can be reused on the same frame. (default: false)
  135143. * @param textureType Type of textures used when performing the post process. (default: 0)
  135144. * @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)
  135145. */
  135146. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  135147. /**
  135148. * Excludes the given skinned mesh from computing bones velocities.
  135149. * 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.
  135150. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  135151. */
  135152. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  135153. /**
  135154. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  135155. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  135156. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  135157. */
  135158. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  135159. /**
  135160. * Disposes the post process.
  135161. * @param camera The camera to dispose the post process on.
  135162. */
  135163. dispose(camera?: Camera): void;
  135164. }
  135165. }
  135166. declare module BABYLON {
  135167. /** @hidden */
  135168. export var refractionPixelShader: {
  135169. name: string;
  135170. shader: string;
  135171. };
  135172. }
  135173. declare module BABYLON {
  135174. /**
  135175. * Post process which applies a refractin texture
  135176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  135177. */
  135178. export class RefractionPostProcess extends PostProcess {
  135179. /** the base color of the refraction (used to taint the rendering) */
  135180. color: Color3;
  135181. /** simulated refraction depth */
  135182. depth: number;
  135183. /** the coefficient of the base color (0 to remove base color tainting) */
  135184. colorLevel: number;
  135185. private _refTexture;
  135186. private _ownRefractionTexture;
  135187. /**
  135188. * Gets or sets the refraction texture
  135189. * Please note that you are responsible for disposing the texture if you set it manually
  135190. */
  135191. get refractionTexture(): Texture;
  135192. set refractionTexture(value: Texture);
  135193. /**
  135194. * Initializes the RefractionPostProcess
  135195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  135196. * @param name The name of the effect.
  135197. * @param refractionTextureUrl Url of the refraction texture to use
  135198. * @param color the base color of the refraction (used to taint the rendering)
  135199. * @param depth simulated refraction depth
  135200. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  135201. * @param camera The camera to apply the render pass to.
  135202. * @param options The required width/height ratio to downsize to before computing the render pass.
  135203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135204. * @param engine The engine which the post process will be applied. (default: current engine)
  135205. * @param reusable If the post process can be reused on the same frame. (default: false)
  135206. */
  135207. constructor(name: string, refractionTextureUrl: string,
  135208. /** the base color of the refraction (used to taint the rendering) */
  135209. color: Color3,
  135210. /** simulated refraction depth */
  135211. depth: number,
  135212. /** the coefficient of the base color (0 to remove base color tainting) */
  135213. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  135214. /**
  135215. * Disposes of the post process
  135216. * @param camera Camera to dispose post process on
  135217. */
  135218. dispose(camera: Camera): void;
  135219. }
  135220. }
  135221. declare module BABYLON {
  135222. /** @hidden */
  135223. export var sharpenPixelShader: {
  135224. name: string;
  135225. shader: string;
  135226. };
  135227. }
  135228. declare module BABYLON {
  135229. /**
  135230. * The SharpenPostProcess applies a sharpen kernel to every pixel
  135231. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  135232. */
  135233. export class SharpenPostProcess extends PostProcess {
  135234. /**
  135235. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  135236. */
  135237. colorAmount: number;
  135238. /**
  135239. * How much sharpness should be applied (default: 0.3)
  135240. */
  135241. edgeAmount: number;
  135242. /**
  135243. * Creates a new instance ConvolutionPostProcess
  135244. * @param name The name of the effect.
  135245. * @param options The required width/height ratio to downsize to before computing the render pass.
  135246. * @param camera The camera to apply the render pass to.
  135247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135248. * @param engine The engine which the post process will be applied. (default: current engine)
  135249. * @param reusable If the post process can be reused on the same frame. (default: false)
  135250. * @param textureType Type of textures used when performing the post process. (default: 0)
  135251. * @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)
  135252. */
  135253. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  135254. }
  135255. }
  135256. declare module BABYLON {
  135257. /**
  135258. * PostProcessRenderPipeline
  135259. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135260. */
  135261. export class PostProcessRenderPipeline {
  135262. private engine;
  135263. private _renderEffects;
  135264. private _renderEffectsForIsolatedPass;
  135265. /**
  135266. * List of inspectable custom properties (used by the Inspector)
  135267. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  135268. */
  135269. inspectableCustomProperties: IInspectable[];
  135270. /**
  135271. * @hidden
  135272. */
  135273. protected _cameras: Camera[];
  135274. /** @hidden */
  135275. _name: string;
  135276. /**
  135277. * Gets pipeline name
  135278. */
  135279. get name(): string;
  135280. /** Gets the list of attached cameras */
  135281. get cameras(): Camera[];
  135282. /**
  135283. * Initializes a PostProcessRenderPipeline
  135284. * @param engine engine to add the pipeline to
  135285. * @param name name of the pipeline
  135286. */
  135287. constructor(engine: Engine, name: string);
  135288. /**
  135289. * Gets the class name
  135290. * @returns "PostProcessRenderPipeline"
  135291. */
  135292. getClassName(): string;
  135293. /**
  135294. * If all the render effects in the pipeline are supported
  135295. */
  135296. get isSupported(): boolean;
  135297. /**
  135298. * Adds an effect to the pipeline
  135299. * @param renderEffect the effect to add
  135300. */
  135301. addEffect(renderEffect: PostProcessRenderEffect): void;
  135302. /** @hidden */
  135303. _rebuild(): void;
  135304. /** @hidden */
  135305. _enableEffect(renderEffectName: string, cameras: Camera): void;
  135306. /** @hidden */
  135307. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  135308. /** @hidden */
  135309. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  135310. /** @hidden */
  135311. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  135312. /** @hidden */
  135313. _attachCameras(cameras: Camera, unique: boolean): void;
  135314. /** @hidden */
  135315. _attachCameras(cameras: Camera[], unique: boolean): void;
  135316. /** @hidden */
  135317. _detachCameras(cameras: Camera): void;
  135318. /** @hidden */
  135319. _detachCameras(cameras: Nullable<Camera[]>): void;
  135320. /** @hidden */
  135321. _update(): void;
  135322. /** @hidden */
  135323. _reset(): void;
  135324. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  135325. /**
  135326. * Disposes of the pipeline
  135327. */
  135328. dispose(): void;
  135329. }
  135330. }
  135331. declare module BABYLON {
  135332. /**
  135333. * PostProcessRenderPipelineManager class
  135334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135335. */
  135336. export class PostProcessRenderPipelineManager {
  135337. private _renderPipelines;
  135338. /**
  135339. * Initializes a PostProcessRenderPipelineManager
  135340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135341. */
  135342. constructor();
  135343. /**
  135344. * Gets the list of supported render pipelines
  135345. */
  135346. get supportedPipelines(): PostProcessRenderPipeline[];
  135347. /**
  135348. * Adds a pipeline to the manager
  135349. * @param renderPipeline The pipeline to add
  135350. */
  135351. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  135352. /**
  135353. * Attaches a camera to the pipeline
  135354. * @param renderPipelineName The name of the pipeline to attach to
  135355. * @param cameras the camera to attach
  135356. * @param unique if the camera can be attached multiple times to the pipeline
  135357. */
  135358. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  135359. /**
  135360. * Detaches a camera from the pipeline
  135361. * @param renderPipelineName The name of the pipeline to detach from
  135362. * @param cameras the camera to detach
  135363. */
  135364. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  135365. /**
  135366. * Enables an effect by name on a pipeline
  135367. * @param renderPipelineName the name of the pipeline to enable the effect in
  135368. * @param renderEffectName the name of the effect to enable
  135369. * @param cameras the cameras that the effect should be enabled on
  135370. */
  135371. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  135372. /**
  135373. * Disables an effect by name on a pipeline
  135374. * @param renderPipelineName the name of the pipeline to disable the effect in
  135375. * @param renderEffectName the name of the effect to disable
  135376. * @param cameras the cameras that the effect should be disabled on
  135377. */
  135378. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  135379. /**
  135380. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  135381. */
  135382. update(): void;
  135383. /** @hidden */
  135384. _rebuild(): void;
  135385. /**
  135386. * Disposes of the manager and pipelines
  135387. */
  135388. dispose(): void;
  135389. }
  135390. }
  135391. declare module BABYLON {
  135392. interface Scene {
  135393. /** @hidden (Backing field) */
  135394. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  135395. /**
  135396. * Gets the postprocess render pipeline manager
  135397. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135398. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  135399. */
  135400. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  135401. }
  135402. /**
  135403. * Defines the Render Pipeline scene component responsible to rendering pipelines
  135404. */
  135405. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  135406. /**
  135407. * The component name helpfull to identify the component in the list of scene components.
  135408. */
  135409. readonly name: string;
  135410. /**
  135411. * The scene the component belongs to.
  135412. */
  135413. scene: Scene;
  135414. /**
  135415. * Creates a new instance of the component for the given scene
  135416. * @param scene Defines the scene to register the component in
  135417. */
  135418. constructor(scene: Scene);
  135419. /**
  135420. * Registers the component in a given scene
  135421. */
  135422. register(): void;
  135423. /**
  135424. * Rebuilds the elements related to this component in case of
  135425. * context lost for instance.
  135426. */
  135427. rebuild(): void;
  135428. /**
  135429. * Disposes the component and the associated ressources
  135430. */
  135431. dispose(): void;
  135432. private _gatherRenderTargets;
  135433. }
  135434. }
  135435. declare module BABYLON {
  135436. /**
  135437. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  135438. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  135439. */
  135440. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  135441. private _scene;
  135442. private _camerasToBeAttached;
  135443. /**
  135444. * ID of the sharpen post process,
  135445. */
  135446. private readonly SharpenPostProcessId;
  135447. /**
  135448. * @ignore
  135449. * ID of the image processing post process;
  135450. */
  135451. readonly ImageProcessingPostProcessId: string;
  135452. /**
  135453. * @ignore
  135454. * ID of the Fast Approximate Anti-Aliasing post process;
  135455. */
  135456. readonly FxaaPostProcessId: string;
  135457. /**
  135458. * ID of the chromatic aberration post process,
  135459. */
  135460. private readonly ChromaticAberrationPostProcessId;
  135461. /**
  135462. * ID of the grain post process
  135463. */
  135464. private readonly GrainPostProcessId;
  135465. /**
  135466. * Sharpen post process which will apply a sharpen convolution to enhance edges
  135467. */
  135468. sharpen: SharpenPostProcess;
  135469. private _sharpenEffect;
  135470. private bloom;
  135471. /**
  135472. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  135473. */
  135474. depthOfField: DepthOfFieldEffect;
  135475. /**
  135476. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  135477. */
  135478. fxaa: FxaaPostProcess;
  135479. /**
  135480. * Image post processing pass used to perform operations such as tone mapping or color grading.
  135481. */
  135482. imageProcessing: ImageProcessingPostProcess;
  135483. /**
  135484. * Chromatic aberration post process which will shift rgb colors in the image
  135485. */
  135486. chromaticAberration: ChromaticAberrationPostProcess;
  135487. private _chromaticAberrationEffect;
  135488. /**
  135489. * Grain post process which add noise to the image
  135490. */
  135491. grain: GrainPostProcess;
  135492. private _grainEffect;
  135493. /**
  135494. * Glow post process which adds a glow to emissive areas of the image
  135495. */
  135496. private _glowLayer;
  135497. /**
  135498. * Animations which can be used to tweak settings over a period of time
  135499. */
  135500. animations: Animation[];
  135501. private _imageProcessingConfigurationObserver;
  135502. private _sharpenEnabled;
  135503. private _bloomEnabled;
  135504. private _depthOfFieldEnabled;
  135505. private _depthOfFieldBlurLevel;
  135506. private _fxaaEnabled;
  135507. private _imageProcessingEnabled;
  135508. private _defaultPipelineTextureType;
  135509. private _bloomScale;
  135510. private _chromaticAberrationEnabled;
  135511. private _grainEnabled;
  135512. private _buildAllowed;
  135513. /**
  135514. * Gets active scene
  135515. */
  135516. get scene(): Scene;
  135517. /**
  135518. * Enable or disable the sharpen process from the pipeline
  135519. */
  135520. set sharpenEnabled(enabled: boolean);
  135521. get sharpenEnabled(): boolean;
  135522. private _resizeObserver;
  135523. private _hardwareScaleLevel;
  135524. private _bloomKernel;
  135525. /**
  135526. * Specifies the size of the bloom blur kernel, relative to the final output size
  135527. */
  135528. get bloomKernel(): number;
  135529. set bloomKernel(value: number);
  135530. /**
  135531. * Specifies the weight of the bloom in the final rendering
  135532. */
  135533. private _bloomWeight;
  135534. /**
  135535. * Specifies the luma threshold for the area that will be blurred by the bloom
  135536. */
  135537. private _bloomThreshold;
  135538. private _hdr;
  135539. /**
  135540. * The strength of the bloom.
  135541. */
  135542. set bloomWeight(value: number);
  135543. get bloomWeight(): number;
  135544. /**
  135545. * The strength of the bloom.
  135546. */
  135547. set bloomThreshold(value: number);
  135548. get bloomThreshold(): number;
  135549. /**
  135550. * The scale of the bloom, lower value will provide better performance.
  135551. */
  135552. set bloomScale(value: number);
  135553. get bloomScale(): number;
  135554. /**
  135555. * Enable or disable the bloom from the pipeline
  135556. */
  135557. set bloomEnabled(enabled: boolean);
  135558. get bloomEnabled(): boolean;
  135559. private _rebuildBloom;
  135560. /**
  135561. * If the depth of field is enabled.
  135562. */
  135563. get depthOfFieldEnabled(): boolean;
  135564. set depthOfFieldEnabled(enabled: boolean);
  135565. /**
  135566. * Blur level of the depth of field effect. (Higher blur will effect performance)
  135567. */
  135568. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  135569. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  135570. /**
  135571. * If the anti aliasing is enabled.
  135572. */
  135573. set fxaaEnabled(enabled: boolean);
  135574. get fxaaEnabled(): boolean;
  135575. private _samples;
  135576. /**
  135577. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  135578. */
  135579. set samples(sampleCount: number);
  135580. get samples(): number;
  135581. /**
  135582. * If image processing is enabled.
  135583. */
  135584. set imageProcessingEnabled(enabled: boolean);
  135585. get imageProcessingEnabled(): boolean;
  135586. /**
  135587. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  135588. */
  135589. set glowLayerEnabled(enabled: boolean);
  135590. get glowLayerEnabled(): boolean;
  135591. /**
  135592. * Gets the glow layer (or null if not defined)
  135593. */
  135594. get glowLayer(): Nullable<GlowLayer>;
  135595. /**
  135596. * Enable or disable the chromaticAberration process from the pipeline
  135597. */
  135598. set chromaticAberrationEnabled(enabled: boolean);
  135599. get chromaticAberrationEnabled(): boolean;
  135600. /**
  135601. * Enable or disable the grain process from the pipeline
  135602. */
  135603. set grainEnabled(enabled: boolean);
  135604. get grainEnabled(): boolean;
  135605. /**
  135606. * @constructor
  135607. * @param name - The rendering pipeline name (default: "")
  135608. * @param hdr - If high dynamic range textures should be used (default: true)
  135609. * @param scene - The scene linked to this pipeline (default: the last created scene)
  135610. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  135611. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  135612. */
  135613. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  135614. /**
  135615. * Get the class name
  135616. * @returns "DefaultRenderingPipeline"
  135617. */
  135618. getClassName(): string;
  135619. /**
  135620. * Force the compilation of the entire pipeline.
  135621. */
  135622. prepare(): void;
  135623. private _hasCleared;
  135624. private _prevPostProcess;
  135625. private _prevPrevPostProcess;
  135626. private _setAutoClearAndTextureSharing;
  135627. private _depthOfFieldSceneObserver;
  135628. private _buildPipeline;
  135629. private _disposePostProcesses;
  135630. /**
  135631. * Adds a camera to the pipeline
  135632. * @param camera the camera to be added
  135633. */
  135634. addCamera(camera: Camera): void;
  135635. /**
  135636. * Removes a camera from the pipeline
  135637. * @param camera the camera to remove
  135638. */
  135639. removeCamera(camera: Camera): void;
  135640. /**
  135641. * Dispose of the pipeline and stop all post processes
  135642. */
  135643. dispose(): void;
  135644. /**
  135645. * Serialize the rendering pipeline (Used when exporting)
  135646. * @returns the serialized object
  135647. */
  135648. serialize(): any;
  135649. /**
  135650. * Parse the serialized pipeline
  135651. * @param source Source pipeline.
  135652. * @param scene The scene to load the pipeline to.
  135653. * @param rootUrl The URL of the serialized pipeline.
  135654. * @returns An instantiated pipeline from the serialized object.
  135655. */
  135656. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  135657. }
  135658. }
  135659. declare module BABYLON {
  135660. /** @hidden */
  135661. export var lensHighlightsPixelShader: {
  135662. name: string;
  135663. shader: string;
  135664. };
  135665. }
  135666. declare module BABYLON {
  135667. /** @hidden */
  135668. export var depthOfFieldPixelShader: {
  135669. name: string;
  135670. shader: string;
  135671. };
  135672. }
  135673. declare module BABYLON {
  135674. /**
  135675. * BABYLON.JS Chromatic Aberration GLSL Shader
  135676. * Author: Olivier Guyot
  135677. * Separates very slightly R, G and B colors on the edges of the screen
  135678. * Inspired by Francois Tarlier & Martins Upitis
  135679. */
  135680. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  135681. /**
  135682. * @ignore
  135683. * The chromatic aberration PostProcess id in the pipeline
  135684. */
  135685. LensChromaticAberrationEffect: string;
  135686. /**
  135687. * @ignore
  135688. * The highlights enhancing PostProcess id in the pipeline
  135689. */
  135690. HighlightsEnhancingEffect: string;
  135691. /**
  135692. * @ignore
  135693. * The depth-of-field PostProcess id in the pipeline
  135694. */
  135695. LensDepthOfFieldEffect: string;
  135696. private _scene;
  135697. private _depthTexture;
  135698. private _grainTexture;
  135699. private _chromaticAberrationPostProcess;
  135700. private _highlightsPostProcess;
  135701. private _depthOfFieldPostProcess;
  135702. private _edgeBlur;
  135703. private _grainAmount;
  135704. private _chromaticAberration;
  135705. private _distortion;
  135706. private _highlightsGain;
  135707. private _highlightsThreshold;
  135708. private _dofDistance;
  135709. private _dofAperture;
  135710. private _dofDarken;
  135711. private _dofPentagon;
  135712. private _blurNoise;
  135713. /**
  135714. * @constructor
  135715. *
  135716. * Effect parameters are as follow:
  135717. * {
  135718. * chromatic_aberration: number; // from 0 to x (1 for realism)
  135719. * edge_blur: number; // from 0 to x (1 for realism)
  135720. * distortion: number; // from 0 to x (1 for realism)
  135721. * grain_amount: number; // from 0 to 1
  135722. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  135723. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  135724. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  135725. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  135726. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  135727. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  135728. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  135729. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  135730. * }
  135731. * Note: if an effect parameter is unset, effect is disabled
  135732. *
  135733. * @param name The rendering pipeline name
  135734. * @param parameters - An object containing all parameters (see above)
  135735. * @param scene The scene linked to this pipeline
  135736. * @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)
  135737. * @param cameras The array of cameras that the rendering pipeline will be attached to
  135738. */
  135739. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  135740. /**
  135741. * Get the class name
  135742. * @returns "LensRenderingPipeline"
  135743. */
  135744. getClassName(): string;
  135745. /**
  135746. * Gets associated scene
  135747. */
  135748. get scene(): Scene;
  135749. /**
  135750. * Gets or sets the edge blur
  135751. */
  135752. get edgeBlur(): number;
  135753. set edgeBlur(value: number);
  135754. /**
  135755. * Gets or sets the grain amount
  135756. */
  135757. get grainAmount(): number;
  135758. set grainAmount(value: number);
  135759. /**
  135760. * Gets or sets the chromatic aberration amount
  135761. */
  135762. get chromaticAberration(): number;
  135763. set chromaticAberration(value: number);
  135764. /**
  135765. * Gets or sets the depth of field aperture
  135766. */
  135767. get dofAperture(): number;
  135768. set dofAperture(value: number);
  135769. /**
  135770. * Gets or sets the edge distortion
  135771. */
  135772. get edgeDistortion(): number;
  135773. set edgeDistortion(value: number);
  135774. /**
  135775. * Gets or sets the depth of field distortion
  135776. */
  135777. get dofDistortion(): number;
  135778. set dofDistortion(value: number);
  135779. /**
  135780. * Gets or sets the darken out of focus amount
  135781. */
  135782. get darkenOutOfFocus(): number;
  135783. set darkenOutOfFocus(value: number);
  135784. /**
  135785. * Gets or sets a boolean indicating if blur noise is enabled
  135786. */
  135787. get blurNoise(): boolean;
  135788. set blurNoise(value: boolean);
  135789. /**
  135790. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  135791. */
  135792. get pentagonBokeh(): boolean;
  135793. set pentagonBokeh(value: boolean);
  135794. /**
  135795. * Gets or sets the highlight grain amount
  135796. */
  135797. get highlightsGain(): number;
  135798. set highlightsGain(value: number);
  135799. /**
  135800. * Gets or sets the highlight threshold
  135801. */
  135802. get highlightsThreshold(): number;
  135803. set highlightsThreshold(value: number);
  135804. /**
  135805. * Sets the amount of blur at the edges
  135806. * @param amount blur amount
  135807. */
  135808. setEdgeBlur(amount: number): void;
  135809. /**
  135810. * Sets edge blur to 0
  135811. */
  135812. disableEdgeBlur(): void;
  135813. /**
  135814. * Sets the amout of grain
  135815. * @param amount Amount of grain
  135816. */
  135817. setGrainAmount(amount: number): void;
  135818. /**
  135819. * Set grain amount to 0
  135820. */
  135821. disableGrain(): void;
  135822. /**
  135823. * Sets the chromatic aberration amount
  135824. * @param amount amount of chromatic aberration
  135825. */
  135826. setChromaticAberration(amount: number): void;
  135827. /**
  135828. * Sets chromatic aberration amount to 0
  135829. */
  135830. disableChromaticAberration(): void;
  135831. /**
  135832. * Sets the EdgeDistortion amount
  135833. * @param amount amount of EdgeDistortion
  135834. */
  135835. setEdgeDistortion(amount: number): void;
  135836. /**
  135837. * Sets edge distortion to 0
  135838. */
  135839. disableEdgeDistortion(): void;
  135840. /**
  135841. * Sets the FocusDistance amount
  135842. * @param amount amount of FocusDistance
  135843. */
  135844. setFocusDistance(amount: number): void;
  135845. /**
  135846. * Disables depth of field
  135847. */
  135848. disableDepthOfField(): void;
  135849. /**
  135850. * Sets the Aperture amount
  135851. * @param amount amount of Aperture
  135852. */
  135853. setAperture(amount: number): void;
  135854. /**
  135855. * Sets the DarkenOutOfFocus amount
  135856. * @param amount amount of DarkenOutOfFocus
  135857. */
  135858. setDarkenOutOfFocus(amount: number): void;
  135859. private _pentagonBokehIsEnabled;
  135860. /**
  135861. * Creates a pentagon bokeh effect
  135862. */
  135863. enablePentagonBokeh(): void;
  135864. /**
  135865. * Disables the pentagon bokeh effect
  135866. */
  135867. disablePentagonBokeh(): void;
  135868. /**
  135869. * Enables noise blur
  135870. */
  135871. enableNoiseBlur(): void;
  135872. /**
  135873. * Disables noise blur
  135874. */
  135875. disableNoiseBlur(): void;
  135876. /**
  135877. * Sets the HighlightsGain amount
  135878. * @param amount amount of HighlightsGain
  135879. */
  135880. setHighlightsGain(amount: number): void;
  135881. /**
  135882. * Sets the HighlightsThreshold amount
  135883. * @param amount amount of HighlightsThreshold
  135884. */
  135885. setHighlightsThreshold(amount: number): void;
  135886. /**
  135887. * Disables highlights
  135888. */
  135889. disableHighlights(): void;
  135890. /**
  135891. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  135892. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  135893. */
  135894. dispose(disableDepthRender?: boolean): void;
  135895. private _createChromaticAberrationPostProcess;
  135896. private _createHighlightsPostProcess;
  135897. private _createDepthOfFieldPostProcess;
  135898. private _createGrainTexture;
  135899. }
  135900. }
  135901. declare module BABYLON {
  135902. /** @hidden */
  135903. export var ssao2PixelShader: {
  135904. name: string;
  135905. shader: string;
  135906. };
  135907. }
  135908. declare module BABYLON {
  135909. /** @hidden */
  135910. export var ssaoCombinePixelShader: {
  135911. name: string;
  135912. shader: string;
  135913. };
  135914. }
  135915. declare module BABYLON {
  135916. /**
  135917. * Render pipeline to produce ssao effect
  135918. */
  135919. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  135920. /**
  135921. * @ignore
  135922. * The PassPostProcess id in the pipeline that contains the original scene color
  135923. */
  135924. SSAOOriginalSceneColorEffect: string;
  135925. /**
  135926. * @ignore
  135927. * The SSAO PostProcess id in the pipeline
  135928. */
  135929. SSAORenderEffect: string;
  135930. /**
  135931. * @ignore
  135932. * The horizontal blur PostProcess id in the pipeline
  135933. */
  135934. SSAOBlurHRenderEffect: string;
  135935. /**
  135936. * @ignore
  135937. * The vertical blur PostProcess id in the pipeline
  135938. */
  135939. SSAOBlurVRenderEffect: string;
  135940. /**
  135941. * @ignore
  135942. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  135943. */
  135944. SSAOCombineRenderEffect: string;
  135945. /**
  135946. * The output strength of the SSAO post-process. Default value is 1.0.
  135947. */
  135948. totalStrength: number;
  135949. /**
  135950. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  135951. */
  135952. maxZ: number;
  135953. /**
  135954. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  135955. */
  135956. minZAspect: number;
  135957. private _samples;
  135958. /**
  135959. * Number of samples used for the SSAO calculations. Default value is 8
  135960. */
  135961. set samples(n: number);
  135962. get samples(): number;
  135963. private _textureSamples;
  135964. /**
  135965. * Number of samples to use for antialiasing
  135966. */
  135967. set textureSamples(n: number);
  135968. get textureSamples(): number;
  135969. /**
  135970. * Ratio object used for SSAO ratio and blur ratio
  135971. */
  135972. private _ratio;
  135973. /**
  135974. * Dynamically generated sphere sampler.
  135975. */
  135976. private _sampleSphere;
  135977. /**
  135978. * Blur filter offsets
  135979. */
  135980. private _samplerOffsets;
  135981. private _expensiveBlur;
  135982. /**
  135983. * If bilateral blur should be used
  135984. */
  135985. set expensiveBlur(b: boolean);
  135986. get expensiveBlur(): boolean;
  135987. /**
  135988. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  135989. */
  135990. radius: number;
  135991. /**
  135992. * The base color of the SSAO post-process
  135993. * The final result is "base + ssao" between [0, 1]
  135994. */
  135995. base: number;
  135996. /**
  135997. * Support test.
  135998. */
  135999. static get IsSupported(): boolean;
  136000. private _scene;
  136001. private _depthTexture;
  136002. private _normalTexture;
  136003. private _randomTexture;
  136004. private _originalColorPostProcess;
  136005. private _ssaoPostProcess;
  136006. private _blurHPostProcess;
  136007. private _blurVPostProcess;
  136008. private _ssaoCombinePostProcess;
  136009. /**
  136010. * Gets active scene
  136011. */
  136012. get scene(): Scene;
  136013. /**
  136014. * @constructor
  136015. * @param name The rendering pipeline name
  136016. * @param scene The scene linked to this pipeline
  136017. * @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 }
  136018. * @param cameras The array of cameras that the rendering pipeline will be attached to
  136019. */
  136020. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  136021. /**
  136022. * Get the class name
  136023. * @returns "SSAO2RenderingPipeline"
  136024. */
  136025. getClassName(): string;
  136026. /**
  136027. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  136028. */
  136029. dispose(disableGeometryBufferRenderer?: boolean): void;
  136030. private _createBlurPostProcess;
  136031. /** @hidden */
  136032. _rebuild(): void;
  136033. private _bits;
  136034. private _radicalInverse_VdC;
  136035. private _hammersley;
  136036. private _hemisphereSample_uniform;
  136037. private _generateHemisphere;
  136038. private _createSSAOPostProcess;
  136039. private _createSSAOCombinePostProcess;
  136040. private _createRandomTexture;
  136041. /**
  136042. * Serialize the rendering pipeline (Used when exporting)
  136043. * @returns the serialized object
  136044. */
  136045. serialize(): any;
  136046. /**
  136047. * Parse the serialized pipeline
  136048. * @param source Source pipeline.
  136049. * @param scene The scene to load the pipeline to.
  136050. * @param rootUrl The URL of the serialized pipeline.
  136051. * @returns An instantiated pipeline from the serialized object.
  136052. */
  136053. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  136054. }
  136055. }
  136056. declare module BABYLON {
  136057. /** @hidden */
  136058. export var ssaoPixelShader: {
  136059. name: string;
  136060. shader: string;
  136061. };
  136062. }
  136063. declare module BABYLON {
  136064. /**
  136065. * Render pipeline to produce ssao effect
  136066. */
  136067. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  136068. /**
  136069. * @ignore
  136070. * The PassPostProcess id in the pipeline that contains the original scene color
  136071. */
  136072. SSAOOriginalSceneColorEffect: string;
  136073. /**
  136074. * @ignore
  136075. * The SSAO PostProcess id in the pipeline
  136076. */
  136077. SSAORenderEffect: string;
  136078. /**
  136079. * @ignore
  136080. * The horizontal blur PostProcess id in the pipeline
  136081. */
  136082. SSAOBlurHRenderEffect: string;
  136083. /**
  136084. * @ignore
  136085. * The vertical blur PostProcess id in the pipeline
  136086. */
  136087. SSAOBlurVRenderEffect: string;
  136088. /**
  136089. * @ignore
  136090. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  136091. */
  136092. SSAOCombineRenderEffect: string;
  136093. /**
  136094. * The output strength of the SSAO post-process. Default value is 1.0.
  136095. */
  136096. totalStrength: number;
  136097. /**
  136098. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  136099. */
  136100. radius: number;
  136101. /**
  136102. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  136103. * Must not be equal to fallOff and superior to fallOff.
  136104. * Default value is 0.0075
  136105. */
  136106. area: number;
  136107. /**
  136108. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  136109. * Must not be equal to area and inferior to area.
  136110. * Default value is 0.000001
  136111. */
  136112. fallOff: number;
  136113. /**
  136114. * The base color of the SSAO post-process
  136115. * The final result is "base + ssao" between [0, 1]
  136116. */
  136117. base: number;
  136118. private _scene;
  136119. private _depthTexture;
  136120. private _randomTexture;
  136121. private _originalColorPostProcess;
  136122. private _ssaoPostProcess;
  136123. private _blurHPostProcess;
  136124. private _blurVPostProcess;
  136125. private _ssaoCombinePostProcess;
  136126. private _firstUpdate;
  136127. /**
  136128. * Gets active scene
  136129. */
  136130. get scene(): Scene;
  136131. /**
  136132. * @constructor
  136133. * @param name - The rendering pipeline name
  136134. * @param scene - The scene linked to this pipeline
  136135. * @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 }
  136136. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  136137. */
  136138. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  136139. /**
  136140. * Get the class name
  136141. * @returns "SSAORenderingPipeline"
  136142. */
  136143. getClassName(): string;
  136144. /**
  136145. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  136146. */
  136147. dispose(disableDepthRender?: boolean): void;
  136148. private _createBlurPostProcess;
  136149. /** @hidden */
  136150. _rebuild(): void;
  136151. private _createSSAOPostProcess;
  136152. private _createSSAOCombinePostProcess;
  136153. private _createRandomTexture;
  136154. }
  136155. }
  136156. declare module BABYLON {
  136157. /** @hidden */
  136158. export var standardPixelShader: {
  136159. name: string;
  136160. shader: string;
  136161. };
  136162. }
  136163. declare module BABYLON {
  136164. /**
  136165. * Standard rendering pipeline
  136166. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  136167. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  136168. */
  136169. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  136170. /**
  136171. * Public members
  136172. */
  136173. /**
  136174. * Post-process which contains the original scene color before the pipeline applies all the effects
  136175. */
  136176. originalPostProcess: Nullable<PostProcess>;
  136177. /**
  136178. * Post-process used to down scale an image x4
  136179. */
  136180. downSampleX4PostProcess: Nullable<PostProcess>;
  136181. /**
  136182. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  136183. */
  136184. brightPassPostProcess: Nullable<PostProcess>;
  136185. /**
  136186. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  136187. */
  136188. blurHPostProcesses: PostProcess[];
  136189. /**
  136190. * Post-process array storing all the vertical blur post-processes used by the pipeline
  136191. */
  136192. blurVPostProcesses: PostProcess[];
  136193. /**
  136194. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  136195. */
  136196. textureAdderPostProcess: Nullable<PostProcess>;
  136197. /**
  136198. * Post-process used to create volumetric lighting effect
  136199. */
  136200. volumetricLightPostProcess: Nullable<PostProcess>;
  136201. /**
  136202. * Post-process used to smooth the previous volumetric light post-process on the X axis
  136203. */
  136204. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  136205. /**
  136206. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  136207. */
  136208. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  136209. /**
  136210. * Post-process used to merge the volumetric light effect and the real scene color
  136211. */
  136212. volumetricLightMergePostProces: Nullable<PostProcess>;
  136213. /**
  136214. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  136215. */
  136216. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  136217. /**
  136218. * Base post-process used to calculate the average luminance of the final image for HDR
  136219. */
  136220. luminancePostProcess: Nullable<PostProcess>;
  136221. /**
  136222. * Post-processes used to create down sample post-processes in order to get
  136223. * the average luminance of the final image for HDR
  136224. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  136225. */
  136226. luminanceDownSamplePostProcesses: PostProcess[];
  136227. /**
  136228. * Post-process used to create a HDR effect (light adaptation)
  136229. */
  136230. hdrPostProcess: Nullable<PostProcess>;
  136231. /**
  136232. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  136233. */
  136234. textureAdderFinalPostProcess: Nullable<PostProcess>;
  136235. /**
  136236. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  136237. */
  136238. lensFlareFinalPostProcess: Nullable<PostProcess>;
  136239. /**
  136240. * Post-process used to merge the final HDR post-process and the real scene color
  136241. */
  136242. hdrFinalPostProcess: Nullable<PostProcess>;
  136243. /**
  136244. * Post-process used to create a lens flare effect
  136245. */
  136246. lensFlarePostProcess: Nullable<PostProcess>;
  136247. /**
  136248. * Post-process that merges the result of the lens flare post-process and the real scene color
  136249. */
  136250. lensFlareComposePostProcess: Nullable<PostProcess>;
  136251. /**
  136252. * Post-process used to create a motion blur effect
  136253. */
  136254. motionBlurPostProcess: Nullable<PostProcess>;
  136255. /**
  136256. * Post-process used to create a depth of field effect
  136257. */
  136258. depthOfFieldPostProcess: Nullable<PostProcess>;
  136259. /**
  136260. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  136261. */
  136262. fxaaPostProcess: Nullable<FxaaPostProcess>;
  136263. /**
  136264. * Represents the brightness threshold in order to configure the illuminated surfaces
  136265. */
  136266. brightThreshold: number;
  136267. /**
  136268. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  136269. */
  136270. blurWidth: number;
  136271. /**
  136272. * Sets if the blur for highlighted surfaces must be only horizontal
  136273. */
  136274. horizontalBlur: boolean;
  136275. /**
  136276. * Gets the overall exposure used by the pipeline
  136277. */
  136278. get exposure(): number;
  136279. /**
  136280. * Sets the overall exposure used by the pipeline
  136281. */
  136282. set exposure(value: number);
  136283. /**
  136284. * Texture used typically to simulate "dirty" on camera lens
  136285. */
  136286. lensTexture: Nullable<Texture>;
  136287. /**
  136288. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  136289. */
  136290. volumetricLightCoefficient: number;
  136291. /**
  136292. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  136293. */
  136294. volumetricLightPower: number;
  136295. /**
  136296. * Used the set the blur intensity to smooth the volumetric lights
  136297. */
  136298. volumetricLightBlurScale: number;
  136299. /**
  136300. * Light (spot or directional) used to generate the volumetric lights rays
  136301. * The source light must have a shadow generate so the pipeline can get its
  136302. * depth map
  136303. */
  136304. sourceLight: Nullable<SpotLight | DirectionalLight>;
  136305. /**
  136306. * For eye adaptation, represents the minimum luminance the eye can see
  136307. */
  136308. hdrMinimumLuminance: number;
  136309. /**
  136310. * For eye adaptation, represents the decrease luminance speed
  136311. */
  136312. hdrDecreaseRate: number;
  136313. /**
  136314. * For eye adaptation, represents the increase luminance speed
  136315. */
  136316. hdrIncreaseRate: number;
  136317. /**
  136318. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  136319. */
  136320. get hdrAutoExposure(): boolean;
  136321. /**
  136322. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  136323. */
  136324. set hdrAutoExposure(value: boolean);
  136325. /**
  136326. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  136327. */
  136328. lensColorTexture: Nullable<Texture>;
  136329. /**
  136330. * The overall strengh for the lens flare effect
  136331. */
  136332. lensFlareStrength: number;
  136333. /**
  136334. * Dispersion coefficient for lens flare ghosts
  136335. */
  136336. lensFlareGhostDispersal: number;
  136337. /**
  136338. * Main lens flare halo width
  136339. */
  136340. lensFlareHaloWidth: number;
  136341. /**
  136342. * Based on the lens distortion effect, defines how much the lens flare result
  136343. * is distorted
  136344. */
  136345. lensFlareDistortionStrength: number;
  136346. /**
  136347. * Configures the blur intensity used for for lens flare (halo)
  136348. */
  136349. lensFlareBlurWidth: number;
  136350. /**
  136351. * Lens star texture must be used to simulate rays on the flares and is available
  136352. * in the documentation
  136353. */
  136354. lensStarTexture: Nullable<Texture>;
  136355. /**
  136356. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  136357. * flare effect by taking account of the dirt texture
  136358. */
  136359. lensFlareDirtTexture: Nullable<Texture>;
  136360. /**
  136361. * Represents the focal length for the depth of field effect
  136362. */
  136363. depthOfFieldDistance: number;
  136364. /**
  136365. * Represents the blur intensity for the blurred part of the depth of field effect
  136366. */
  136367. depthOfFieldBlurWidth: number;
  136368. /**
  136369. * Gets how much the image is blurred by the movement while using the motion blur post-process
  136370. */
  136371. get motionStrength(): number;
  136372. /**
  136373. * Sets how much the image is blurred by the movement while using the motion blur post-process
  136374. */
  136375. set motionStrength(strength: number);
  136376. /**
  136377. * Gets wether or not the motion blur post-process is object based or screen based.
  136378. */
  136379. get objectBasedMotionBlur(): boolean;
  136380. /**
  136381. * Sets wether or not the motion blur post-process should be object based or screen based
  136382. */
  136383. set objectBasedMotionBlur(value: boolean);
  136384. /**
  136385. * List of animations for the pipeline (IAnimatable implementation)
  136386. */
  136387. animations: Animation[];
  136388. /**
  136389. * Private members
  136390. */
  136391. private _scene;
  136392. private _currentDepthOfFieldSource;
  136393. private _basePostProcess;
  136394. private _fixedExposure;
  136395. private _currentExposure;
  136396. private _hdrAutoExposure;
  136397. private _hdrCurrentLuminance;
  136398. private _motionStrength;
  136399. private _isObjectBasedMotionBlur;
  136400. private _floatTextureType;
  136401. private _camerasToBeAttached;
  136402. private _ratio;
  136403. private _bloomEnabled;
  136404. private _depthOfFieldEnabled;
  136405. private _vlsEnabled;
  136406. private _lensFlareEnabled;
  136407. private _hdrEnabled;
  136408. private _motionBlurEnabled;
  136409. private _fxaaEnabled;
  136410. private _motionBlurSamples;
  136411. private _volumetricLightStepsCount;
  136412. private _samples;
  136413. /**
  136414. * @ignore
  136415. * Specifies if the bloom pipeline is enabled
  136416. */
  136417. get BloomEnabled(): boolean;
  136418. set BloomEnabled(enabled: boolean);
  136419. /**
  136420. * @ignore
  136421. * Specifies if the depth of field pipeline is enabed
  136422. */
  136423. get DepthOfFieldEnabled(): boolean;
  136424. set DepthOfFieldEnabled(enabled: boolean);
  136425. /**
  136426. * @ignore
  136427. * Specifies if the lens flare pipeline is enabed
  136428. */
  136429. get LensFlareEnabled(): boolean;
  136430. set LensFlareEnabled(enabled: boolean);
  136431. /**
  136432. * @ignore
  136433. * Specifies if the HDR pipeline is enabled
  136434. */
  136435. get HDREnabled(): boolean;
  136436. set HDREnabled(enabled: boolean);
  136437. /**
  136438. * @ignore
  136439. * Specifies if the volumetric lights scattering effect is enabled
  136440. */
  136441. get VLSEnabled(): boolean;
  136442. set VLSEnabled(enabled: boolean);
  136443. /**
  136444. * @ignore
  136445. * Specifies if the motion blur effect is enabled
  136446. */
  136447. get MotionBlurEnabled(): boolean;
  136448. set MotionBlurEnabled(enabled: boolean);
  136449. /**
  136450. * Specifies if anti-aliasing is enabled
  136451. */
  136452. get fxaaEnabled(): boolean;
  136453. set fxaaEnabled(enabled: boolean);
  136454. /**
  136455. * Specifies the number of steps used to calculate the volumetric lights
  136456. * Typically in interval [50, 200]
  136457. */
  136458. get volumetricLightStepsCount(): number;
  136459. set volumetricLightStepsCount(count: number);
  136460. /**
  136461. * Specifies the number of samples used for the motion blur effect
  136462. * Typically in interval [16, 64]
  136463. */
  136464. get motionBlurSamples(): number;
  136465. set motionBlurSamples(samples: number);
  136466. /**
  136467. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  136468. */
  136469. get samples(): number;
  136470. set samples(sampleCount: number);
  136471. /**
  136472. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  136473. * @constructor
  136474. * @param name The rendering pipeline name
  136475. * @param scene The scene linked to this pipeline
  136476. * @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)
  136477. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  136478. * @param cameras The array of cameras that the rendering pipeline will be attached to
  136479. */
  136480. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  136481. private _buildPipeline;
  136482. private _createDownSampleX4PostProcess;
  136483. private _createBrightPassPostProcess;
  136484. private _createBlurPostProcesses;
  136485. private _createTextureAdderPostProcess;
  136486. private _createVolumetricLightPostProcess;
  136487. private _createLuminancePostProcesses;
  136488. private _createHdrPostProcess;
  136489. private _createLensFlarePostProcess;
  136490. private _createDepthOfFieldPostProcess;
  136491. private _createMotionBlurPostProcess;
  136492. private _getDepthTexture;
  136493. private _disposePostProcesses;
  136494. /**
  136495. * Dispose of the pipeline and stop all post processes
  136496. */
  136497. dispose(): void;
  136498. /**
  136499. * Serialize the rendering pipeline (Used when exporting)
  136500. * @returns the serialized object
  136501. */
  136502. serialize(): any;
  136503. /**
  136504. * Parse the serialized pipeline
  136505. * @param source Source pipeline.
  136506. * @param scene The scene to load the pipeline to.
  136507. * @param rootUrl The URL of the serialized pipeline.
  136508. * @returns An instantiated pipeline from the serialized object.
  136509. */
  136510. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  136511. /**
  136512. * Luminance steps
  136513. */
  136514. static LuminanceSteps: number;
  136515. }
  136516. }
  136517. declare module BABYLON {
  136518. /** @hidden */
  136519. export var tonemapPixelShader: {
  136520. name: string;
  136521. shader: string;
  136522. };
  136523. }
  136524. declare module BABYLON {
  136525. /** Defines operator used for tonemapping */
  136526. export enum TonemappingOperator {
  136527. /** Hable */
  136528. Hable = 0,
  136529. /** Reinhard */
  136530. Reinhard = 1,
  136531. /** HejiDawson */
  136532. HejiDawson = 2,
  136533. /** Photographic */
  136534. Photographic = 3
  136535. }
  136536. /**
  136537. * Defines a post process to apply tone mapping
  136538. */
  136539. export class TonemapPostProcess extends PostProcess {
  136540. private _operator;
  136541. /** Defines the required exposure adjustement */
  136542. exposureAdjustment: number;
  136543. /**
  136544. * Creates a new TonemapPostProcess
  136545. * @param name defines the name of the postprocess
  136546. * @param _operator defines the operator to use
  136547. * @param exposureAdjustment defines the required exposure adjustement
  136548. * @param camera defines the camera to use (can be null)
  136549. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  136550. * @param engine defines the hosting engine (can be ignore if camera is set)
  136551. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  136552. */
  136553. constructor(name: string, _operator: TonemappingOperator,
  136554. /** Defines the required exposure adjustement */
  136555. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  136556. }
  136557. }
  136558. declare module BABYLON {
  136559. /** @hidden */
  136560. export var depthVertexShader: {
  136561. name: string;
  136562. shader: string;
  136563. };
  136564. }
  136565. declare module BABYLON {
  136566. /** @hidden */
  136567. export var volumetricLightScatteringPixelShader: {
  136568. name: string;
  136569. shader: string;
  136570. };
  136571. }
  136572. declare module BABYLON {
  136573. /** @hidden */
  136574. export var volumetricLightScatteringPassVertexShader: {
  136575. name: string;
  136576. shader: string;
  136577. };
  136578. }
  136579. declare module BABYLON {
  136580. /** @hidden */
  136581. export var volumetricLightScatteringPassPixelShader: {
  136582. name: string;
  136583. shader: string;
  136584. };
  136585. }
  136586. declare module BABYLON {
  136587. /**
  136588. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  136589. */
  136590. export class VolumetricLightScatteringPostProcess extends PostProcess {
  136591. private _volumetricLightScatteringPass;
  136592. private _volumetricLightScatteringRTT;
  136593. private _viewPort;
  136594. private _screenCoordinates;
  136595. private _cachedDefines;
  136596. /**
  136597. * If not undefined, the mesh position is computed from the attached node position
  136598. */
  136599. attachedNode: {
  136600. position: Vector3;
  136601. };
  136602. /**
  136603. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  136604. */
  136605. customMeshPosition: Vector3;
  136606. /**
  136607. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  136608. */
  136609. useCustomMeshPosition: boolean;
  136610. /**
  136611. * If the post-process should inverse the light scattering direction
  136612. */
  136613. invert: boolean;
  136614. /**
  136615. * The internal mesh used by the post-process
  136616. */
  136617. mesh: Mesh;
  136618. /**
  136619. * @hidden
  136620. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  136621. */
  136622. get useDiffuseColor(): boolean;
  136623. set useDiffuseColor(useDiffuseColor: boolean);
  136624. /**
  136625. * Array containing the excluded meshes not rendered in the internal pass
  136626. */
  136627. excludedMeshes: AbstractMesh[];
  136628. /**
  136629. * Controls the overall intensity of the post-process
  136630. */
  136631. exposure: number;
  136632. /**
  136633. * Dissipates each sample's contribution in range [0, 1]
  136634. */
  136635. decay: number;
  136636. /**
  136637. * Controls the overall intensity of each sample
  136638. */
  136639. weight: number;
  136640. /**
  136641. * Controls the density of each sample
  136642. */
  136643. density: number;
  136644. /**
  136645. * @constructor
  136646. * @param name The post-process name
  136647. * @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)
  136648. * @param camera The camera that the post-process will be attached to
  136649. * @param mesh The mesh used to create the light scattering
  136650. * @param samples The post-process quality, default 100
  136651. * @param samplingModeThe post-process filtering mode
  136652. * @param engine The babylon engine
  136653. * @param reusable If the post-process is reusable
  136654. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  136655. */
  136656. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  136657. /**
  136658. * Returns the string "VolumetricLightScatteringPostProcess"
  136659. * @returns "VolumetricLightScatteringPostProcess"
  136660. */
  136661. getClassName(): string;
  136662. private _isReady;
  136663. /**
  136664. * Sets the new light position for light scattering effect
  136665. * @param position The new custom light position
  136666. */
  136667. setCustomMeshPosition(position: Vector3): void;
  136668. /**
  136669. * Returns the light position for light scattering effect
  136670. * @return Vector3 The custom light position
  136671. */
  136672. getCustomMeshPosition(): Vector3;
  136673. /**
  136674. * Disposes the internal assets and detaches the post-process from the camera
  136675. */
  136676. dispose(camera: Camera): void;
  136677. /**
  136678. * Returns the render target texture used by the post-process
  136679. * @return the render target texture used by the post-process
  136680. */
  136681. getPass(): RenderTargetTexture;
  136682. private _meshExcluded;
  136683. private _createPass;
  136684. private _updateMeshScreenCoordinates;
  136685. /**
  136686. * Creates a default mesh for the Volumeric Light Scattering post-process
  136687. * @param name The mesh name
  136688. * @param scene The scene where to create the mesh
  136689. * @return the default mesh
  136690. */
  136691. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  136692. }
  136693. }
  136694. declare module BABYLON {
  136695. interface Scene {
  136696. /** @hidden (Backing field) */
  136697. _boundingBoxRenderer: BoundingBoxRenderer;
  136698. /** @hidden (Backing field) */
  136699. _forceShowBoundingBoxes: boolean;
  136700. /**
  136701. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  136702. */
  136703. forceShowBoundingBoxes: boolean;
  136704. /**
  136705. * Gets the bounding box renderer associated with the scene
  136706. * @returns a BoundingBoxRenderer
  136707. */
  136708. getBoundingBoxRenderer(): BoundingBoxRenderer;
  136709. }
  136710. interface AbstractMesh {
  136711. /** @hidden (Backing field) */
  136712. _showBoundingBox: boolean;
  136713. /**
  136714. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  136715. */
  136716. showBoundingBox: boolean;
  136717. }
  136718. /**
  136719. * Component responsible of rendering the bounding box of the meshes in a scene.
  136720. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  136721. */
  136722. export class BoundingBoxRenderer implements ISceneComponent {
  136723. /**
  136724. * The component name helpfull to identify the component in the list of scene components.
  136725. */
  136726. readonly name: string;
  136727. /**
  136728. * The scene the component belongs to.
  136729. */
  136730. scene: Scene;
  136731. /**
  136732. * Color of the bounding box lines placed in front of an object
  136733. */
  136734. frontColor: Color3;
  136735. /**
  136736. * Color of the bounding box lines placed behind an object
  136737. */
  136738. backColor: Color3;
  136739. /**
  136740. * Defines if the renderer should show the back lines or not
  136741. */
  136742. showBackLines: boolean;
  136743. /**
  136744. * @hidden
  136745. */
  136746. renderList: SmartArray<BoundingBox>;
  136747. private _colorShader;
  136748. private _vertexBuffers;
  136749. private _indexBuffer;
  136750. private _fillIndexBuffer;
  136751. private _fillIndexData;
  136752. /**
  136753. * Instantiates a new bounding box renderer in a scene.
  136754. * @param scene the scene the renderer renders in
  136755. */
  136756. constructor(scene: Scene);
  136757. /**
  136758. * Registers the component in a given scene
  136759. */
  136760. register(): void;
  136761. private _evaluateSubMesh;
  136762. private _activeMesh;
  136763. private _prepareRessources;
  136764. private _createIndexBuffer;
  136765. /**
  136766. * Rebuilds the elements related to this component in case of
  136767. * context lost for instance.
  136768. */
  136769. rebuild(): void;
  136770. /**
  136771. * @hidden
  136772. */
  136773. reset(): void;
  136774. /**
  136775. * Render the bounding boxes of a specific rendering group
  136776. * @param renderingGroupId defines the rendering group to render
  136777. */
  136778. render(renderingGroupId: number): void;
  136779. /**
  136780. * In case of occlusion queries, we can render the occlusion bounding box through this method
  136781. * @param mesh Define the mesh to render the occlusion bounding box for
  136782. */
  136783. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  136784. /**
  136785. * Dispose and release the resources attached to this renderer.
  136786. */
  136787. dispose(): void;
  136788. }
  136789. }
  136790. declare module BABYLON {
  136791. /** @hidden */
  136792. export var depthPixelShader: {
  136793. name: string;
  136794. shader: string;
  136795. };
  136796. }
  136797. declare module BABYLON {
  136798. /**
  136799. * This represents a depth renderer in Babylon.
  136800. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136801. */
  136802. export class DepthRenderer {
  136803. private _scene;
  136804. private _depthMap;
  136805. private _effect;
  136806. private readonly _storeNonLinearDepth;
  136807. private readonly _clearColor;
  136808. /** Get if the depth renderer is using packed depth or not */
  136809. readonly isPacked: boolean;
  136810. private _cachedDefines;
  136811. private _camera;
  136812. /**
  136813. * Specifiess that the depth renderer will only be used within
  136814. * the camera it is created for.
  136815. * This can help forcing its rendering during the camera processing.
  136816. */
  136817. useOnlyInActiveCamera: boolean;
  136818. /** @hidden */
  136819. static _SceneComponentInitialization: (scene: Scene) => void;
  136820. /**
  136821. * Instantiates a depth renderer
  136822. * @param scene The scene the renderer belongs to
  136823. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136824. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136825. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136826. */
  136827. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136828. /**
  136829. * Creates the depth rendering effect and checks if the effect is ready.
  136830. * @param subMesh The submesh to be used to render the depth map of
  136831. * @param useInstances If multiple world instances should be used
  136832. * @returns if the depth renderer is ready to render the depth map
  136833. */
  136834. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136835. /**
  136836. * Gets the texture which the depth map will be written to.
  136837. * @returns The depth map texture
  136838. */
  136839. getDepthMap(): RenderTargetTexture;
  136840. /**
  136841. * Disposes of the depth renderer.
  136842. */
  136843. dispose(): void;
  136844. }
  136845. }
  136846. declare module BABYLON {
  136847. interface Scene {
  136848. /** @hidden (Backing field) */
  136849. _depthRenderer: {
  136850. [id: string]: DepthRenderer;
  136851. };
  136852. /**
  136853. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  136854. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  136855. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136856. * @returns the created depth renderer
  136857. */
  136858. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  136859. /**
  136860. * Disables a depth renderer for a given camera
  136861. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  136862. */
  136863. disableDepthRenderer(camera?: Nullable<Camera>): void;
  136864. }
  136865. /**
  136866. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  136867. * in several rendering techniques.
  136868. */
  136869. export class DepthRendererSceneComponent implements ISceneComponent {
  136870. /**
  136871. * The component name helpfull to identify the component in the list of scene components.
  136872. */
  136873. readonly name: string;
  136874. /**
  136875. * The scene the component belongs to.
  136876. */
  136877. scene: Scene;
  136878. /**
  136879. * Creates a new instance of the component for the given scene
  136880. * @param scene Defines the scene to register the component in
  136881. */
  136882. constructor(scene: Scene);
  136883. /**
  136884. * Registers the component in a given scene
  136885. */
  136886. register(): void;
  136887. /**
  136888. * Rebuilds the elements related to this component in case of
  136889. * context lost for instance.
  136890. */
  136891. rebuild(): void;
  136892. /**
  136893. * Disposes the component and the associated ressources
  136894. */
  136895. dispose(): void;
  136896. private _gatherRenderTargets;
  136897. private _gatherActiveCameraRenderTargets;
  136898. }
  136899. }
  136900. declare module BABYLON {
  136901. /** @hidden */
  136902. export var outlinePixelShader: {
  136903. name: string;
  136904. shader: string;
  136905. };
  136906. }
  136907. declare module BABYLON {
  136908. /** @hidden */
  136909. export var outlineVertexShader: {
  136910. name: string;
  136911. shader: string;
  136912. };
  136913. }
  136914. declare module BABYLON {
  136915. interface Scene {
  136916. /** @hidden */
  136917. _outlineRenderer: OutlineRenderer;
  136918. /**
  136919. * Gets the outline renderer associated with the scene
  136920. * @returns a OutlineRenderer
  136921. */
  136922. getOutlineRenderer(): OutlineRenderer;
  136923. }
  136924. interface AbstractMesh {
  136925. /** @hidden (Backing field) */
  136926. _renderOutline: boolean;
  136927. /**
  136928. * Gets or sets a boolean indicating if the outline must be rendered as well
  136929. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  136930. */
  136931. renderOutline: boolean;
  136932. /** @hidden (Backing field) */
  136933. _renderOverlay: boolean;
  136934. /**
  136935. * Gets or sets a boolean indicating if the overlay must be rendered as well
  136936. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  136937. */
  136938. renderOverlay: boolean;
  136939. }
  136940. /**
  136941. * This class is responsible to draw bothe outline/overlay of meshes.
  136942. * It should not be used directly but through the available method on mesh.
  136943. */
  136944. export class OutlineRenderer implements ISceneComponent {
  136945. /**
  136946. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  136947. */
  136948. private static _StencilReference;
  136949. /**
  136950. * The name of the component. Each component must have a unique name.
  136951. */
  136952. name: string;
  136953. /**
  136954. * The scene the component belongs to.
  136955. */
  136956. scene: Scene;
  136957. /**
  136958. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  136959. */
  136960. zOffset: number;
  136961. private _engine;
  136962. private _effect;
  136963. private _cachedDefines;
  136964. private _savedDepthWrite;
  136965. /**
  136966. * Instantiates a new outline renderer. (There could be only one per scene).
  136967. * @param scene Defines the scene it belongs to
  136968. */
  136969. constructor(scene: Scene);
  136970. /**
  136971. * Register the component to one instance of a scene.
  136972. */
  136973. register(): void;
  136974. /**
  136975. * Rebuilds the elements related to this component in case of
  136976. * context lost for instance.
  136977. */
  136978. rebuild(): void;
  136979. /**
  136980. * Disposes the component and the associated ressources.
  136981. */
  136982. dispose(): void;
  136983. /**
  136984. * Renders the outline in the canvas.
  136985. * @param subMesh Defines the sumesh to render
  136986. * @param batch Defines the batch of meshes in case of instances
  136987. * @param useOverlay Defines if the rendering is for the overlay or the outline
  136988. */
  136989. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  136990. /**
  136991. * Returns whether or not the outline renderer is ready for a given submesh.
  136992. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  136993. * @param subMesh Defines the submesh to check readyness for
  136994. * @param useInstances Defines wheter wee are trying to render instances or not
  136995. * @returns true if ready otherwise false
  136996. */
  136997. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136998. private _beforeRenderingMesh;
  136999. private _afterRenderingMesh;
  137000. }
  137001. }
  137002. declare module BABYLON {
  137003. /**
  137004. * Defines the basic options interface of a Sprite Frame Source Size.
  137005. */
  137006. export interface ISpriteJSONSpriteSourceSize {
  137007. /**
  137008. * number of the original width of the Frame
  137009. */
  137010. w: number;
  137011. /**
  137012. * number of the original height of the Frame
  137013. */
  137014. h: number;
  137015. }
  137016. /**
  137017. * Defines the basic options interface of a Sprite Frame Data.
  137018. */
  137019. export interface ISpriteJSONSpriteFrameData {
  137020. /**
  137021. * number of the x offset of the Frame
  137022. */
  137023. x: number;
  137024. /**
  137025. * number of the y offset of the Frame
  137026. */
  137027. y: number;
  137028. /**
  137029. * number of the width of the Frame
  137030. */
  137031. w: number;
  137032. /**
  137033. * number of the height of the Frame
  137034. */
  137035. h: number;
  137036. }
  137037. /**
  137038. * Defines the basic options interface of a JSON Sprite.
  137039. */
  137040. export interface ISpriteJSONSprite {
  137041. /**
  137042. * string name of the Frame
  137043. */
  137044. filename: string;
  137045. /**
  137046. * ISpriteJSONSpriteFrame basic object of the frame data
  137047. */
  137048. frame: ISpriteJSONSpriteFrameData;
  137049. /**
  137050. * boolean to flag is the frame was rotated.
  137051. */
  137052. rotated: boolean;
  137053. /**
  137054. * boolean to flag is the frame was trimmed.
  137055. */
  137056. trimmed: boolean;
  137057. /**
  137058. * ISpriteJSONSpriteFrame basic object of the source data
  137059. */
  137060. spriteSourceSize: ISpriteJSONSpriteFrameData;
  137061. /**
  137062. * ISpriteJSONSpriteFrame basic object of the source data
  137063. */
  137064. sourceSize: ISpriteJSONSpriteSourceSize;
  137065. }
  137066. /**
  137067. * Defines the basic options interface of a JSON atlas.
  137068. */
  137069. export interface ISpriteJSONAtlas {
  137070. /**
  137071. * Array of objects that contain the frame data.
  137072. */
  137073. frames: Array<ISpriteJSONSprite>;
  137074. /**
  137075. * object basic object containing the sprite meta data.
  137076. */
  137077. meta?: object;
  137078. }
  137079. }
  137080. declare module BABYLON {
  137081. /** @hidden */
  137082. export var spriteMapPixelShader: {
  137083. name: string;
  137084. shader: string;
  137085. };
  137086. }
  137087. declare module BABYLON {
  137088. /** @hidden */
  137089. export var spriteMapVertexShader: {
  137090. name: string;
  137091. shader: string;
  137092. };
  137093. }
  137094. declare module BABYLON {
  137095. /**
  137096. * Defines the basic options interface of a SpriteMap
  137097. */
  137098. export interface ISpriteMapOptions {
  137099. /**
  137100. * Vector2 of the number of cells in the grid.
  137101. */
  137102. stageSize?: Vector2;
  137103. /**
  137104. * Vector2 of the size of the output plane in World Units.
  137105. */
  137106. outputSize?: Vector2;
  137107. /**
  137108. * Vector3 of the position of the output plane in World Units.
  137109. */
  137110. outputPosition?: Vector3;
  137111. /**
  137112. * Vector3 of the rotation of the output plane.
  137113. */
  137114. outputRotation?: Vector3;
  137115. /**
  137116. * number of layers that the system will reserve in resources.
  137117. */
  137118. layerCount?: number;
  137119. /**
  137120. * number of max animation frames a single cell will reserve in resources.
  137121. */
  137122. maxAnimationFrames?: number;
  137123. /**
  137124. * number cell index of the base tile when the system compiles.
  137125. */
  137126. baseTile?: number;
  137127. /**
  137128. * boolean flip the sprite after its been repositioned by the framing data.
  137129. */
  137130. flipU?: boolean;
  137131. /**
  137132. * Vector3 scalar of the global RGB values of the SpriteMap.
  137133. */
  137134. colorMultiply?: Vector3;
  137135. }
  137136. /**
  137137. * Defines the IDisposable interface in order to be cleanable from resources.
  137138. */
  137139. export interface ISpriteMap extends IDisposable {
  137140. /**
  137141. * String name of the SpriteMap.
  137142. */
  137143. name: string;
  137144. /**
  137145. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  137146. */
  137147. atlasJSON: ISpriteJSONAtlas;
  137148. /**
  137149. * Texture of the SpriteMap.
  137150. */
  137151. spriteSheet: Texture;
  137152. /**
  137153. * The parameters to initialize the SpriteMap with.
  137154. */
  137155. options: ISpriteMapOptions;
  137156. }
  137157. /**
  137158. * Class used to manage a grid restricted sprite deployment on an Output plane.
  137159. */
  137160. export class SpriteMap implements ISpriteMap {
  137161. /** The Name of the spriteMap */
  137162. name: string;
  137163. /** The JSON file with the frame and meta data */
  137164. atlasJSON: ISpriteJSONAtlas;
  137165. /** The systems Sprite Sheet Texture */
  137166. spriteSheet: Texture;
  137167. /** Arguments passed with the Constructor */
  137168. options: ISpriteMapOptions;
  137169. /** Public Sprite Storage array, parsed from atlasJSON */
  137170. sprites: Array<ISpriteJSONSprite>;
  137171. /** Returns the Number of Sprites in the System */
  137172. get spriteCount(): number;
  137173. /** Returns the Position of Output Plane*/
  137174. get position(): Vector3;
  137175. /** Returns the Position of Output Plane*/
  137176. set position(v: Vector3);
  137177. /** Returns the Rotation of Output Plane*/
  137178. get rotation(): Vector3;
  137179. /** Returns the Rotation of Output Plane*/
  137180. set rotation(v: Vector3);
  137181. /** Sets the AnimationMap*/
  137182. get animationMap(): RawTexture;
  137183. /** Sets the AnimationMap*/
  137184. set animationMap(v: RawTexture);
  137185. /** Scene that the SpriteMap was created in */
  137186. private _scene;
  137187. /** Texture Buffer of Float32 that holds tile frame data*/
  137188. private _frameMap;
  137189. /** Texture Buffers of Float32 that holds tileMap data*/
  137190. private _tileMaps;
  137191. /** Texture Buffer of Float32 that holds Animation Data*/
  137192. private _animationMap;
  137193. /** Custom ShaderMaterial Central to the System*/
  137194. private _material;
  137195. /** Custom ShaderMaterial Central to the System*/
  137196. private _output;
  137197. /** Systems Time Ticker*/
  137198. private _time;
  137199. /**
  137200. * Creates a new SpriteMap
  137201. * @param name defines the SpriteMaps Name
  137202. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  137203. * @param spriteSheet is the Texture that the Sprites are on.
  137204. * @param options a basic deployment configuration
  137205. * @param scene The Scene that the map is deployed on
  137206. */
  137207. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  137208. /**
  137209. * Returns tileID location
  137210. * @returns Vector2 the cell position ID
  137211. */
  137212. getTileID(): Vector2;
  137213. /**
  137214. * Gets the UV location of the mouse over the SpriteMap.
  137215. * @returns Vector2 the UV position of the mouse interaction
  137216. */
  137217. getMousePosition(): Vector2;
  137218. /**
  137219. * Creates the "frame" texture Buffer
  137220. * -------------------------------------
  137221. * Structure of frames
  137222. * "filename": "Falling-Water-2.png",
  137223. * "frame": {"x":69,"y":103,"w":24,"h":32},
  137224. * "rotated": true,
  137225. * "trimmed": true,
  137226. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  137227. * "sourceSize": {"w":32,"h":32}
  137228. * @returns RawTexture of the frameMap
  137229. */
  137230. private _createFrameBuffer;
  137231. /**
  137232. * Creates the tileMap texture Buffer
  137233. * @param buffer normally and array of numbers, or a false to generate from scratch
  137234. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  137235. * @returns RawTexture of the tileMap
  137236. */
  137237. private _createTileBuffer;
  137238. /**
  137239. * Modifies the data of the tileMaps
  137240. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  137241. * @param pos is the iVector2 Coordinates of the Tile
  137242. * @param tile The SpriteIndex of the new Tile
  137243. */
  137244. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  137245. /**
  137246. * Creates the animationMap texture Buffer
  137247. * @param buffer normally and array of numbers, or a false to generate from scratch
  137248. * @returns RawTexture of the animationMap
  137249. */
  137250. private _createTileAnimationBuffer;
  137251. /**
  137252. * Modifies the data of the animationMap
  137253. * @param cellID is the Index of the Sprite
  137254. * @param _frame is the target Animation frame
  137255. * @param toCell is the Target Index of the next frame of the animation
  137256. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  137257. * @param speed is a global scalar of the time variable on the map.
  137258. */
  137259. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  137260. /**
  137261. * Exports the .tilemaps file
  137262. */
  137263. saveTileMaps(): void;
  137264. /**
  137265. * Imports the .tilemaps file
  137266. * @param url of the .tilemaps file
  137267. */
  137268. loadTileMaps(url: string): void;
  137269. /**
  137270. * Release associated resources
  137271. */
  137272. dispose(): void;
  137273. }
  137274. }
  137275. declare module BABYLON {
  137276. /**
  137277. * Class used to manage multiple sprites of different sizes on the same spritesheet
  137278. * @see http://doc.babylonjs.com/babylon101/sprites
  137279. */
  137280. export class SpritePackedManager extends SpriteManager {
  137281. /** defines the packed manager's name */
  137282. name: string;
  137283. /**
  137284. * Creates a new sprite manager from a packed sprite sheet
  137285. * @param name defines the manager's name
  137286. * @param imgUrl defines the sprite sheet url
  137287. * @param capacity defines the maximum allowed number of sprites
  137288. * @param scene defines the hosting scene
  137289. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  137290. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  137291. * @param samplingMode defines the smapling mode to use with spritesheet
  137292. * @param fromPacked set to true; do not alter
  137293. */
  137294. constructor(
  137295. /** defines the packed manager's name */
  137296. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  137297. }
  137298. }
  137299. declare module BABYLON {
  137300. /**
  137301. * Defines the list of states available for a task inside a AssetsManager
  137302. */
  137303. export enum AssetTaskState {
  137304. /**
  137305. * Initialization
  137306. */
  137307. INIT = 0,
  137308. /**
  137309. * Running
  137310. */
  137311. RUNNING = 1,
  137312. /**
  137313. * Done
  137314. */
  137315. DONE = 2,
  137316. /**
  137317. * Error
  137318. */
  137319. ERROR = 3
  137320. }
  137321. /**
  137322. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  137323. */
  137324. export abstract class AbstractAssetTask {
  137325. /**
  137326. * Task name
  137327. */ name: string;
  137328. /**
  137329. * Callback called when the task is successful
  137330. */
  137331. onSuccess: (task: any) => void;
  137332. /**
  137333. * Callback called when the task is not successful
  137334. */
  137335. onError: (task: any, message?: string, exception?: any) => void;
  137336. /**
  137337. * Creates a new AssetsManager
  137338. * @param name defines the name of the task
  137339. */
  137340. constructor(
  137341. /**
  137342. * Task name
  137343. */ name: string);
  137344. private _isCompleted;
  137345. private _taskState;
  137346. private _errorObject;
  137347. /**
  137348. * Get if the task is completed
  137349. */
  137350. get isCompleted(): boolean;
  137351. /**
  137352. * Gets the current state of the task
  137353. */
  137354. get taskState(): AssetTaskState;
  137355. /**
  137356. * Gets the current error object (if task is in error)
  137357. */
  137358. get errorObject(): {
  137359. message?: string;
  137360. exception?: any;
  137361. };
  137362. /**
  137363. * Internal only
  137364. * @hidden
  137365. */
  137366. _setErrorObject(message?: string, exception?: any): void;
  137367. /**
  137368. * Execute the current task
  137369. * @param scene defines the scene where you want your assets to be loaded
  137370. * @param onSuccess is a callback called when the task is successfully executed
  137371. * @param onError is a callback called if an error occurs
  137372. */
  137373. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137374. /**
  137375. * Execute the current task
  137376. * @param scene defines the scene where you want your assets to be loaded
  137377. * @param onSuccess is a callback called when the task is successfully executed
  137378. * @param onError is a callback called if an error occurs
  137379. */
  137380. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137381. /**
  137382. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  137383. * This can be used with failed tasks that have the reason for failure fixed.
  137384. */
  137385. reset(): void;
  137386. private onErrorCallback;
  137387. private onDoneCallback;
  137388. }
  137389. /**
  137390. * Define the interface used by progress events raised during assets loading
  137391. */
  137392. export interface IAssetsProgressEvent {
  137393. /**
  137394. * Defines the number of remaining tasks to process
  137395. */
  137396. remainingCount: number;
  137397. /**
  137398. * Defines the total number of tasks
  137399. */
  137400. totalCount: number;
  137401. /**
  137402. * Defines the task that was just processed
  137403. */
  137404. task: AbstractAssetTask;
  137405. }
  137406. /**
  137407. * Class used to share progress information about assets loading
  137408. */
  137409. export class AssetsProgressEvent implements IAssetsProgressEvent {
  137410. /**
  137411. * Defines the number of remaining tasks to process
  137412. */
  137413. remainingCount: number;
  137414. /**
  137415. * Defines the total number of tasks
  137416. */
  137417. totalCount: number;
  137418. /**
  137419. * Defines the task that was just processed
  137420. */
  137421. task: AbstractAssetTask;
  137422. /**
  137423. * Creates a AssetsProgressEvent
  137424. * @param remainingCount defines the number of remaining tasks to process
  137425. * @param totalCount defines the total number of tasks
  137426. * @param task defines the task that was just processed
  137427. */
  137428. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  137429. }
  137430. /**
  137431. * Define a task used by AssetsManager to load meshes
  137432. */
  137433. export class MeshAssetTask extends AbstractAssetTask {
  137434. /**
  137435. * Defines the name of the task
  137436. */
  137437. name: string;
  137438. /**
  137439. * Defines the list of mesh's names you want to load
  137440. */
  137441. meshesNames: any;
  137442. /**
  137443. * Defines the root url to use as a base to load your meshes and associated resources
  137444. */
  137445. rootUrl: string;
  137446. /**
  137447. * Defines the filename of the scene to load from
  137448. */
  137449. sceneFilename: string;
  137450. /**
  137451. * Gets the list of loaded meshes
  137452. */
  137453. loadedMeshes: Array<AbstractMesh>;
  137454. /**
  137455. * Gets the list of loaded particle systems
  137456. */
  137457. loadedParticleSystems: Array<IParticleSystem>;
  137458. /**
  137459. * Gets the list of loaded skeletons
  137460. */
  137461. loadedSkeletons: Array<Skeleton>;
  137462. /**
  137463. * Gets the list of loaded animation groups
  137464. */
  137465. loadedAnimationGroups: Array<AnimationGroup>;
  137466. /**
  137467. * Callback called when the task is successful
  137468. */
  137469. onSuccess: (task: MeshAssetTask) => void;
  137470. /**
  137471. * Callback called when the task is successful
  137472. */
  137473. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  137474. /**
  137475. * Creates a new MeshAssetTask
  137476. * @param name defines the name of the task
  137477. * @param meshesNames defines the list of mesh's names you want to load
  137478. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  137479. * @param sceneFilename defines the filename of the scene to load from
  137480. */
  137481. constructor(
  137482. /**
  137483. * Defines the name of the task
  137484. */
  137485. name: string,
  137486. /**
  137487. * Defines the list of mesh's names you want to load
  137488. */
  137489. meshesNames: any,
  137490. /**
  137491. * Defines the root url to use as a base to load your meshes and associated resources
  137492. */
  137493. rootUrl: string,
  137494. /**
  137495. * Defines the filename of the scene to load from
  137496. */
  137497. sceneFilename: string);
  137498. /**
  137499. * Execute the current task
  137500. * @param scene defines the scene where you want your assets to be loaded
  137501. * @param onSuccess is a callback called when the task is successfully executed
  137502. * @param onError is a callback called if an error occurs
  137503. */
  137504. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137505. }
  137506. /**
  137507. * Define a task used by AssetsManager to load text content
  137508. */
  137509. export class TextFileAssetTask extends AbstractAssetTask {
  137510. /**
  137511. * Defines the name of the task
  137512. */
  137513. name: string;
  137514. /**
  137515. * Defines the location of the file to load
  137516. */
  137517. url: string;
  137518. /**
  137519. * Gets the loaded text string
  137520. */
  137521. text: string;
  137522. /**
  137523. * Callback called when the task is successful
  137524. */
  137525. onSuccess: (task: TextFileAssetTask) => void;
  137526. /**
  137527. * Callback called when the task is successful
  137528. */
  137529. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  137530. /**
  137531. * Creates a new TextFileAssetTask object
  137532. * @param name defines the name of the task
  137533. * @param url defines the location of the file to load
  137534. */
  137535. constructor(
  137536. /**
  137537. * Defines the name of the task
  137538. */
  137539. name: string,
  137540. /**
  137541. * Defines the location of the file to load
  137542. */
  137543. url: string);
  137544. /**
  137545. * Execute the current task
  137546. * @param scene defines the scene where you want your assets to be loaded
  137547. * @param onSuccess is a callback called when the task is successfully executed
  137548. * @param onError is a callback called if an error occurs
  137549. */
  137550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137551. }
  137552. /**
  137553. * Define a task used by AssetsManager to load binary data
  137554. */
  137555. export class BinaryFileAssetTask extends AbstractAssetTask {
  137556. /**
  137557. * Defines the name of the task
  137558. */
  137559. name: string;
  137560. /**
  137561. * Defines the location of the file to load
  137562. */
  137563. url: string;
  137564. /**
  137565. * Gets the lodaded data (as an array buffer)
  137566. */
  137567. data: ArrayBuffer;
  137568. /**
  137569. * Callback called when the task is successful
  137570. */
  137571. onSuccess: (task: BinaryFileAssetTask) => void;
  137572. /**
  137573. * Callback called when the task is successful
  137574. */
  137575. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  137576. /**
  137577. * Creates a new BinaryFileAssetTask object
  137578. * @param name defines the name of the new task
  137579. * @param url defines the location of the file to load
  137580. */
  137581. constructor(
  137582. /**
  137583. * Defines the name of the task
  137584. */
  137585. name: string,
  137586. /**
  137587. * Defines the location of the file to load
  137588. */
  137589. url: string);
  137590. /**
  137591. * Execute the current task
  137592. * @param scene defines the scene where you want your assets to be loaded
  137593. * @param onSuccess is a callback called when the task is successfully executed
  137594. * @param onError is a callback called if an error occurs
  137595. */
  137596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137597. }
  137598. /**
  137599. * Define a task used by AssetsManager to load images
  137600. */
  137601. export class ImageAssetTask extends AbstractAssetTask {
  137602. /**
  137603. * Defines the name of the task
  137604. */
  137605. name: string;
  137606. /**
  137607. * Defines the location of the image to load
  137608. */
  137609. url: string;
  137610. /**
  137611. * Gets the loaded images
  137612. */
  137613. image: HTMLImageElement;
  137614. /**
  137615. * Callback called when the task is successful
  137616. */
  137617. onSuccess: (task: ImageAssetTask) => void;
  137618. /**
  137619. * Callback called when the task is successful
  137620. */
  137621. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  137622. /**
  137623. * Creates a new ImageAssetTask
  137624. * @param name defines the name of the task
  137625. * @param url defines the location of the image to load
  137626. */
  137627. constructor(
  137628. /**
  137629. * Defines the name of the task
  137630. */
  137631. name: string,
  137632. /**
  137633. * Defines the location of the image to load
  137634. */
  137635. url: string);
  137636. /**
  137637. * Execute the current task
  137638. * @param scene defines the scene where you want your assets to be loaded
  137639. * @param onSuccess is a callback called when the task is successfully executed
  137640. * @param onError is a callback called if an error occurs
  137641. */
  137642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137643. }
  137644. /**
  137645. * Defines the interface used by texture loading tasks
  137646. */
  137647. export interface ITextureAssetTask<TEX extends BaseTexture> {
  137648. /**
  137649. * Gets the loaded texture
  137650. */
  137651. texture: TEX;
  137652. }
  137653. /**
  137654. * Define a task used by AssetsManager to load 2D textures
  137655. */
  137656. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  137657. /**
  137658. * Defines the name of the task
  137659. */
  137660. name: string;
  137661. /**
  137662. * Defines the location of the file to load
  137663. */
  137664. url: string;
  137665. /**
  137666. * Defines if mipmap should not be generated (default is false)
  137667. */
  137668. noMipmap?: boolean | undefined;
  137669. /**
  137670. * Defines if texture must be inverted on Y axis (default is false)
  137671. */
  137672. invertY?: boolean | undefined;
  137673. /**
  137674. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137675. */
  137676. samplingMode: number;
  137677. /**
  137678. * Gets the loaded texture
  137679. */
  137680. texture: Texture;
  137681. /**
  137682. * Callback called when the task is successful
  137683. */
  137684. onSuccess: (task: TextureAssetTask) => void;
  137685. /**
  137686. * Callback called when the task is successful
  137687. */
  137688. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  137689. /**
  137690. * Creates a new TextureAssetTask object
  137691. * @param name defines the name of the task
  137692. * @param url defines the location of the file to load
  137693. * @param noMipmap defines if mipmap should not be generated (default is false)
  137694. * @param invertY defines if texture must be inverted on Y axis (default is false)
  137695. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137696. */
  137697. constructor(
  137698. /**
  137699. * Defines the name of the task
  137700. */
  137701. name: string,
  137702. /**
  137703. * Defines the location of the file to load
  137704. */
  137705. url: string,
  137706. /**
  137707. * Defines if mipmap should not be generated (default is false)
  137708. */
  137709. noMipmap?: boolean | undefined,
  137710. /**
  137711. * Defines if texture must be inverted on Y axis (default is false)
  137712. */
  137713. invertY?: boolean | undefined,
  137714. /**
  137715. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137716. */
  137717. samplingMode?: number);
  137718. /**
  137719. * Execute the current task
  137720. * @param scene defines the scene where you want your assets to be loaded
  137721. * @param onSuccess is a callback called when the task is successfully executed
  137722. * @param onError is a callback called if an error occurs
  137723. */
  137724. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137725. }
  137726. /**
  137727. * Define a task used by AssetsManager to load cube textures
  137728. */
  137729. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  137730. /**
  137731. * Defines the name of the task
  137732. */
  137733. name: string;
  137734. /**
  137735. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  137736. */
  137737. url: string;
  137738. /**
  137739. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  137740. */
  137741. extensions?: string[] | undefined;
  137742. /**
  137743. * Defines if mipmaps should not be generated (default is false)
  137744. */
  137745. noMipmap?: boolean | undefined;
  137746. /**
  137747. * Defines the explicit list of files (undefined by default)
  137748. */
  137749. files?: string[] | undefined;
  137750. /**
  137751. * Gets the loaded texture
  137752. */
  137753. texture: CubeTexture;
  137754. /**
  137755. * Callback called when the task is successful
  137756. */
  137757. onSuccess: (task: CubeTextureAssetTask) => void;
  137758. /**
  137759. * Callback called when the task is successful
  137760. */
  137761. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  137762. /**
  137763. * Creates a new CubeTextureAssetTask
  137764. * @param name defines the name of the task
  137765. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  137766. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  137767. * @param noMipmap defines if mipmaps should not be generated (default is false)
  137768. * @param files defines the explicit list of files (undefined by default)
  137769. */
  137770. constructor(
  137771. /**
  137772. * Defines the name of the task
  137773. */
  137774. name: string,
  137775. /**
  137776. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  137777. */
  137778. url: string,
  137779. /**
  137780. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  137781. */
  137782. extensions?: string[] | undefined,
  137783. /**
  137784. * Defines if mipmaps should not be generated (default is false)
  137785. */
  137786. noMipmap?: boolean | undefined,
  137787. /**
  137788. * Defines the explicit list of files (undefined by default)
  137789. */
  137790. files?: string[] | undefined);
  137791. /**
  137792. * Execute the current task
  137793. * @param scene defines the scene where you want your assets to be loaded
  137794. * @param onSuccess is a callback called when the task is successfully executed
  137795. * @param onError is a callback called if an error occurs
  137796. */
  137797. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137798. }
  137799. /**
  137800. * Define a task used by AssetsManager to load HDR cube textures
  137801. */
  137802. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  137803. /**
  137804. * Defines the name of the task
  137805. */
  137806. name: string;
  137807. /**
  137808. * Defines the location of the file to load
  137809. */
  137810. url: string;
  137811. /**
  137812. * Defines the desired size (the more it increases the longer the generation will be)
  137813. */
  137814. size: number;
  137815. /**
  137816. * Defines if mipmaps should not be generated (default is false)
  137817. */
  137818. noMipmap: boolean;
  137819. /**
  137820. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  137821. */
  137822. generateHarmonics: boolean;
  137823. /**
  137824. * 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)
  137825. */
  137826. gammaSpace: boolean;
  137827. /**
  137828. * Internal Use Only
  137829. */
  137830. reserved: boolean;
  137831. /**
  137832. * Gets the loaded texture
  137833. */
  137834. texture: HDRCubeTexture;
  137835. /**
  137836. * Callback called when the task is successful
  137837. */
  137838. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  137839. /**
  137840. * Callback called when the task is successful
  137841. */
  137842. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  137843. /**
  137844. * Creates a new HDRCubeTextureAssetTask object
  137845. * @param name defines the name of the task
  137846. * @param url defines the location of the file to load
  137847. * @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.
  137848. * @param noMipmap defines if mipmaps should not be generated (default is false)
  137849. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  137850. * @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)
  137851. * @param reserved Internal use only
  137852. */
  137853. constructor(
  137854. /**
  137855. * Defines the name of the task
  137856. */
  137857. name: string,
  137858. /**
  137859. * Defines the location of the file to load
  137860. */
  137861. url: string,
  137862. /**
  137863. * Defines the desired size (the more it increases the longer the generation will be)
  137864. */
  137865. size: number,
  137866. /**
  137867. * Defines if mipmaps should not be generated (default is false)
  137868. */
  137869. noMipmap?: boolean,
  137870. /**
  137871. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  137872. */
  137873. generateHarmonics?: boolean,
  137874. /**
  137875. * 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)
  137876. */
  137877. gammaSpace?: boolean,
  137878. /**
  137879. * Internal Use Only
  137880. */
  137881. reserved?: boolean);
  137882. /**
  137883. * Execute the current task
  137884. * @param scene defines the scene where you want your assets to be loaded
  137885. * @param onSuccess is a callback called when the task is successfully executed
  137886. * @param onError is a callback called if an error occurs
  137887. */
  137888. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137889. }
  137890. /**
  137891. * Define a task used by AssetsManager to load Equirectangular cube textures
  137892. */
  137893. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  137894. /**
  137895. * Defines the name of the task
  137896. */
  137897. name: string;
  137898. /**
  137899. * Defines the location of the file to load
  137900. */
  137901. url: string;
  137902. /**
  137903. * Defines the desired size (the more it increases the longer the generation will be)
  137904. */
  137905. size: number;
  137906. /**
  137907. * Defines if mipmaps should not be generated (default is false)
  137908. */
  137909. noMipmap: boolean;
  137910. /**
  137911. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  137912. * but the standard material would require them in Gamma space) (default is true)
  137913. */
  137914. gammaSpace: boolean;
  137915. /**
  137916. * Gets the loaded texture
  137917. */
  137918. texture: EquiRectangularCubeTexture;
  137919. /**
  137920. * Callback called when the task is successful
  137921. */
  137922. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  137923. /**
  137924. * Callback called when the task is successful
  137925. */
  137926. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  137927. /**
  137928. * Creates a new EquiRectangularCubeTextureAssetTask object
  137929. * @param name defines the name of the task
  137930. * @param url defines the location of the file to load
  137931. * @param size defines the desired size (the more it increases the longer the generation will be)
  137932. * If the size is omitted this implies you are using a preprocessed cubemap.
  137933. * @param noMipmap defines if mipmaps should not be generated (default is false)
  137934. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  137935. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  137936. * (default is true)
  137937. */
  137938. constructor(
  137939. /**
  137940. * Defines the name of the task
  137941. */
  137942. name: string,
  137943. /**
  137944. * Defines the location of the file to load
  137945. */
  137946. url: string,
  137947. /**
  137948. * Defines the desired size (the more it increases the longer the generation will be)
  137949. */
  137950. size: number,
  137951. /**
  137952. * Defines if mipmaps should not be generated (default is false)
  137953. */
  137954. noMipmap?: boolean,
  137955. /**
  137956. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  137957. * but the standard material would require them in Gamma space) (default is true)
  137958. */
  137959. gammaSpace?: boolean);
  137960. /**
  137961. * Execute the current task
  137962. * @param scene defines the scene where you want your assets to be loaded
  137963. * @param onSuccess is a callback called when the task is successfully executed
  137964. * @param onError is a callback called if an error occurs
  137965. */
  137966. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137967. }
  137968. /**
  137969. * This class can be used to easily import assets into a scene
  137970. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  137971. */
  137972. export class AssetsManager {
  137973. private _scene;
  137974. private _isLoading;
  137975. protected _tasks: AbstractAssetTask[];
  137976. protected _waitingTasksCount: number;
  137977. protected _totalTasksCount: number;
  137978. /**
  137979. * Callback called when all tasks are processed
  137980. */
  137981. onFinish: (tasks: AbstractAssetTask[]) => void;
  137982. /**
  137983. * Callback called when a task is successful
  137984. */
  137985. onTaskSuccess: (task: AbstractAssetTask) => void;
  137986. /**
  137987. * Callback called when a task had an error
  137988. */
  137989. onTaskError: (task: AbstractAssetTask) => void;
  137990. /**
  137991. * Callback called when a task is done (whatever the result is)
  137992. */
  137993. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  137994. /**
  137995. * Observable called when all tasks are processed
  137996. */
  137997. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  137998. /**
  137999. * Observable called when a task had an error
  138000. */
  138001. onTaskErrorObservable: Observable<AbstractAssetTask>;
  138002. /**
  138003. * Observable called when all tasks were executed
  138004. */
  138005. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  138006. /**
  138007. * Observable called when a task is done (whatever the result is)
  138008. */
  138009. onProgressObservable: Observable<IAssetsProgressEvent>;
  138010. /**
  138011. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  138012. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  138013. */
  138014. useDefaultLoadingScreen: boolean;
  138015. /**
  138016. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  138017. * when all assets have been downloaded.
  138018. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  138019. */
  138020. autoHideLoadingUI: boolean;
  138021. /**
  138022. * Creates a new AssetsManager
  138023. * @param scene defines the scene to work on
  138024. */
  138025. constructor(scene: Scene);
  138026. /**
  138027. * Add a MeshAssetTask to the list of active tasks
  138028. * @param taskName defines the name of the new task
  138029. * @param meshesNames defines the name of meshes to load
  138030. * @param rootUrl defines the root url to use to locate files
  138031. * @param sceneFilename defines the filename of the scene file
  138032. * @returns a new MeshAssetTask object
  138033. */
  138034. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  138035. /**
  138036. * Add a TextFileAssetTask to the list of active tasks
  138037. * @param taskName defines the name of the new task
  138038. * @param url defines the url of the file to load
  138039. * @returns a new TextFileAssetTask object
  138040. */
  138041. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  138042. /**
  138043. * Add a BinaryFileAssetTask to the list of active tasks
  138044. * @param taskName defines the name of the new task
  138045. * @param url defines the url of the file to load
  138046. * @returns a new BinaryFileAssetTask object
  138047. */
  138048. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  138049. /**
  138050. * Add a ImageAssetTask to the list of active tasks
  138051. * @param taskName defines the name of the new task
  138052. * @param url defines the url of the file to load
  138053. * @returns a new ImageAssetTask object
  138054. */
  138055. addImageTask(taskName: string, url: string): ImageAssetTask;
  138056. /**
  138057. * Add a TextureAssetTask to the list of active tasks
  138058. * @param taskName defines the name of the new task
  138059. * @param url defines the url of the file to load
  138060. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138061. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  138062. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138063. * @returns a new TextureAssetTask object
  138064. */
  138065. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  138066. /**
  138067. * Add a CubeTextureAssetTask to the list of active tasks
  138068. * @param taskName defines the name of the new task
  138069. * @param url defines the url of the file to load
  138070. * @param extensions defines the extension to use to load the cube map (can be null)
  138071. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138072. * @param files defines the list of files to load (can be null)
  138073. * @returns a new CubeTextureAssetTask object
  138074. */
  138075. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  138076. /**
  138077. *
  138078. * Add a HDRCubeTextureAssetTask to the list of active tasks
  138079. * @param taskName defines the name of the new task
  138080. * @param url defines the url of the file to load
  138081. * @param size defines the size you want for the cubemap (can be null)
  138082. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138083. * @param generateHarmonics defines if you want to automatically generate (true by default)
  138084. * @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)
  138085. * @param reserved Internal use only
  138086. * @returns a new HDRCubeTextureAssetTask object
  138087. */
  138088. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  138089. /**
  138090. *
  138091. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  138092. * @param taskName defines the name of the new task
  138093. * @param url defines the url of the file to load
  138094. * @param size defines the size you want for the cubemap (can be null)
  138095. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138096. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138097. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138098. * @returns a new EquiRectangularCubeTextureAssetTask object
  138099. */
  138100. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  138101. /**
  138102. * Remove a task from the assets manager.
  138103. * @param task the task to remove
  138104. */
  138105. removeTask(task: AbstractAssetTask): void;
  138106. private _decreaseWaitingTasksCount;
  138107. private _runTask;
  138108. /**
  138109. * Reset the AssetsManager and remove all tasks
  138110. * @return the current instance of the AssetsManager
  138111. */
  138112. reset(): AssetsManager;
  138113. /**
  138114. * Start the loading process
  138115. * @return the current instance of the AssetsManager
  138116. */
  138117. load(): AssetsManager;
  138118. /**
  138119. * Start the loading process as an async operation
  138120. * @return a promise returning the list of failed tasks
  138121. */
  138122. loadAsync(): Promise<void>;
  138123. }
  138124. }
  138125. declare module BABYLON {
  138126. /**
  138127. * Wrapper class for promise with external resolve and reject.
  138128. */
  138129. export class Deferred<T> {
  138130. /**
  138131. * The promise associated with this deferred object.
  138132. */
  138133. readonly promise: Promise<T>;
  138134. private _resolve;
  138135. private _reject;
  138136. /**
  138137. * The resolve method of the promise associated with this deferred object.
  138138. */
  138139. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  138140. /**
  138141. * The reject method of the promise associated with this deferred object.
  138142. */
  138143. get reject(): (reason?: any) => void;
  138144. /**
  138145. * Constructor for this deferred object.
  138146. */
  138147. constructor();
  138148. }
  138149. }
  138150. declare module BABYLON {
  138151. /**
  138152. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  138153. */
  138154. export class MeshExploder {
  138155. private _centerMesh;
  138156. private _meshes;
  138157. private _meshesOrigins;
  138158. private _toCenterVectors;
  138159. private _scaledDirection;
  138160. private _newPosition;
  138161. private _centerPosition;
  138162. /**
  138163. * Explodes meshes from a center mesh.
  138164. * @param meshes The meshes to explode.
  138165. * @param centerMesh The mesh to be center of explosion.
  138166. */
  138167. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  138168. private _setCenterMesh;
  138169. /**
  138170. * Get class name
  138171. * @returns "MeshExploder"
  138172. */
  138173. getClassName(): string;
  138174. /**
  138175. * "Exploded meshes"
  138176. * @returns Array of meshes with the centerMesh at index 0.
  138177. */
  138178. getMeshes(): Array<Mesh>;
  138179. /**
  138180. * Explodes meshes giving a specific direction
  138181. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  138182. */
  138183. explode(direction?: number): void;
  138184. }
  138185. }
  138186. declare module BABYLON {
  138187. /**
  138188. * Class used to help managing file picking and drag'n'drop
  138189. */
  138190. export class FilesInput {
  138191. /**
  138192. * List of files ready to be loaded
  138193. */
  138194. static get FilesToLoad(): {
  138195. [key: string]: File;
  138196. };
  138197. /**
  138198. * Callback called when a file is processed
  138199. */
  138200. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  138201. private _engine;
  138202. private _currentScene;
  138203. private _sceneLoadedCallback;
  138204. private _progressCallback;
  138205. private _additionalRenderLoopLogicCallback;
  138206. private _textureLoadingCallback;
  138207. private _startingProcessingFilesCallback;
  138208. private _onReloadCallback;
  138209. private _errorCallback;
  138210. private _elementToMonitor;
  138211. private _sceneFileToLoad;
  138212. private _filesToLoad;
  138213. /**
  138214. * Creates a new FilesInput
  138215. * @param engine defines the rendering engine
  138216. * @param scene defines the hosting scene
  138217. * @param sceneLoadedCallback callback called when scene is loaded
  138218. * @param progressCallback callback called to track progress
  138219. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  138220. * @param textureLoadingCallback callback called when a texture is loading
  138221. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  138222. * @param onReloadCallback callback called when a reload is requested
  138223. * @param errorCallback callback call if an error occurs
  138224. */
  138225. 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);
  138226. private _dragEnterHandler;
  138227. private _dragOverHandler;
  138228. private _dropHandler;
  138229. /**
  138230. * Calls this function to listen to drag'n'drop events on a specific DOM element
  138231. * @param elementToMonitor defines the DOM element to track
  138232. */
  138233. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  138234. /**
  138235. * Release all associated resources
  138236. */
  138237. dispose(): void;
  138238. private renderFunction;
  138239. private drag;
  138240. private drop;
  138241. private _traverseFolder;
  138242. private _processFiles;
  138243. /**
  138244. * Load files from a drop event
  138245. * @param event defines the drop event to use as source
  138246. */
  138247. loadFiles(event: any): void;
  138248. private _processReload;
  138249. /**
  138250. * Reload the current scene from the loaded files
  138251. */
  138252. reload(): void;
  138253. }
  138254. }
  138255. declare module BABYLON {
  138256. /**
  138257. * Defines the root class used to create scene optimization to use with SceneOptimizer
  138258. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138259. */
  138260. export class SceneOptimization {
  138261. /**
  138262. * Defines the priority of this optimization (0 by default which means first in the list)
  138263. */
  138264. priority: number;
  138265. /**
  138266. * Gets a string describing the action executed by the current optimization
  138267. * @returns description string
  138268. */
  138269. getDescription(): string;
  138270. /**
  138271. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138272. * @param scene defines the current scene where to apply this optimization
  138273. * @param optimizer defines the current optimizer
  138274. * @returns true if everything that can be done was applied
  138275. */
  138276. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138277. /**
  138278. * Creates the SceneOptimization object
  138279. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138280. * @param desc defines the description associated with the optimization
  138281. */
  138282. constructor(
  138283. /**
  138284. * Defines the priority of this optimization (0 by default which means first in the list)
  138285. */
  138286. priority?: number);
  138287. }
  138288. /**
  138289. * Defines an optimization used to reduce the size of render target textures
  138290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138291. */
  138292. export class TextureOptimization extends SceneOptimization {
  138293. /**
  138294. * Defines the priority of this optimization (0 by default which means first in the list)
  138295. */
  138296. priority: number;
  138297. /**
  138298. * 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
  138299. */
  138300. maximumSize: number;
  138301. /**
  138302. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  138303. */
  138304. step: number;
  138305. /**
  138306. * Gets a string describing the action executed by the current optimization
  138307. * @returns description string
  138308. */
  138309. getDescription(): string;
  138310. /**
  138311. * Creates the TextureOptimization object
  138312. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138313. * @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
  138314. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  138315. */
  138316. constructor(
  138317. /**
  138318. * Defines the priority of this optimization (0 by default which means first in the list)
  138319. */
  138320. priority?: number,
  138321. /**
  138322. * 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
  138323. */
  138324. maximumSize?: number,
  138325. /**
  138326. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  138327. */
  138328. step?: number);
  138329. /**
  138330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138331. * @param scene defines the current scene where to apply this optimization
  138332. * @param optimizer defines the current optimizer
  138333. * @returns true if everything that can be done was applied
  138334. */
  138335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138336. }
  138337. /**
  138338. * Defines an optimization used to increase or decrease the rendering resolution
  138339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138340. */
  138341. export class HardwareScalingOptimization extends SceneOptimization {
  138342. /**
  138343. * Defines the priority of this optimization (0 by default which means first in the list)
  138344. */
  138345. priority: number;
  138346. /**
  138347. * Defines the maximum scale to use (2 by default)
  138348. */
  138349. maximumScale: number;
  138350. /**
  138351. * Defines the step to use between two passes (0.5 by default)
  138352. */
  138353. step: number;
  138354. private _currentScale;
  138355. private _directionOffset;
  138356. /**
  138357. * Gets a string describing the action executed by the current optimization
  138358. * @return description string
  138359. */
  138360. getDescription(): string;
  138361. /**
  138362. * Creates the HardwareScalingOptimization object
  138363. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138364. * @param maximumScale defines the maximum scale to use (2 by default)
  138365. * @param step defines the step to use between two passes (0.5 by default)
  138366. */
  138367. constructor(
  138368. /**
  138369. * Defines the priority of this optimization (0 by default which means first in the list)
  138370. */
  138371. priority?: number,
  138372. /**
  138373. * Defines the maximum scale to use (2 by default)
  138374. */
  138375. maximumScale?: number,
  138376. /**
  138377. * Defines the step to use between two passes (0.5 by default)
  138378. */
  138379. step?: number);
  138380. /**
  138381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138382. * @param scene defines the current scene where to apply this optimization
  138383. * @param optimizer defines the current optimizer
  138384. * @returns true if everything that can be done was applied
  138385. */
  138386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138387. }
  138388. /**
  138389. * Defines an optimization used to remove shadows
  138390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138391. */
  138392. export class ShadowsOptimization extends SceneOptimization {
  138393. /**
  138394. * Gets a string describing the action executed by the current optimization
  138395. * @return description string
  138396. */
  138397. getDescription(): string;
  138398. /**
  138399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138400. * @param scene defines the current scene where to apply this optimization
  138401. * @param optimizer defines the current optimizer
  138402. * @returns true if everything that can be done was applied
  138403. */
  138404. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138405. }
  138406. /**
  138407. * Defines an optimization used to turn post-processes off
  138408. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138409. */
  138410. export class PostProcessesOptimization extends SceneOptimization {
  138411. /**
  138412. * Gets a string describing the action executed by the current optimization
  138413. * @return description string
  138414. */
  138415. getDescription(): string;
  138416. /**
  138417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138418. * @param scene defines the current scene where to apply this optimization
  138419. * @param optimizer defines the current optimizer
  138420. * @returns true if everything that can be done was applied
  138421. */
  138422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138423. }
  138424. /**
  138425. * Defines an optimization used to turn lens flares off
  138426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138427. */
  138428. export class LensFlaresOptimization extends SceneOptimization {
  138429. /**
  138430. * Gets a string describing the action executed by the current optimization
  138431. * @return description string
  138432. */
  138433. getDescription(): string;
  138434. /**
  138435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138436. * @param scene defines the current scene where to apply this optimization
  138437. * @param optimizer defines the current optimizer
  138438. * @returns true if everything that can be done was applied
  138439. */
  138440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138441. }
  138442. /**
  138443. * Defines an optimization based on user defined callback.
  138444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138445. */
  138446. export class CustomOptimization extends SceneOptimization {
  138447. /**
  138448. * Callback called to apply the custom optimization.
  138449. */
  138450. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  138451. /**
  138452. * Callback called to get custom description
  138453. */
  138454. onGetDescription: () => string;
  138455. /**
  138456. * Gets a string describing the action executed by the current optimization
  138457. * @returns description string
  138458. */
  138459. getDescription(): string;
  138460. /**
  138461. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138462. * @param scene defines the current scene where to apply this optimization
  138463. * @param optimizer defines the current optimizer
  138464. * @returns true if everything that can be done was applied
  138465. */
  138466. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138467. }
  138468. /**
  138469. * Defines an optimization used to turn particles off
  138470. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138471. */
  138472. export class ParticlesOptimization extends SceneOptimization {
  138473. /**
  138474. * Gets a string describing the action executed by the current optimization
  138475. * @return description string
  138476. */
  138477. getDescription(): string;
  138478. /**
  138479. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138480. * @param scene defines the current scene where to apply this optimization
  138481. * @param optimizer defines the current optimizer
  138482. * @returns true if everything that can be done was applied
  138483. */
  138484. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138485. }
  138486. /**
  138487. * Defines an optimization used to turn render targets off
  138488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138489. */
  138490. export class RenderTargetsOptimization extends SceneOptimization {
  138491. /**
  138492. * Gets a string describing the action executed by the current optimization
  138493. * @return description string
  138494. */
  138495. getDescription(): string;
  138496. /**
  138497. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138498. * @param scene defines the current scene where to apply this optimization
  138499. * @param optimizer defines the current optimizer
  138500. * @returns true if everything that can be done was applied
  138501. */
  138502. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138503. }
  138504. /**
  138505. * Defines an optimization used to merge meshes with compatible materials
  138506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138507. */
  138508. export class MergeMeshesOptimization extends SceneOptimization {
  138509. private static _UpdateSelectionTree;
  138510. /**
  138511. * Gets or sets a boolean which defines if optimization octree has to be updated
  138512. */
  138513. static get UpdateSelectionTree(): boolean;
  138514. /**
  138515. * Gets or sets a boolean which defines if optimization octree has to be updated
  138516. */
  138517. static set UpdateSelectionTree(value: boolean);
  138518. /**
  138519. * Gets a string describing the action executed by the current optimization
  138520. * @return description string
  138521. */
  138522. getDescription(): string;
  138523. private _canBeMerged;
  138524. /**
  138525. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138526. * @param scene defines the current scene where to apply this optimization
  138527. * @param optimizer defines the current optimizer
  138528. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  138529. * @returns true if everything that can be done was applied
  138530. */
  138531. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  138532. }
  138533. /**
  138534. * Defines a list of options used by SceneOptimizer
  138535. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138536. */
  138537. export class SceneOptimizerOptions {
  138538. /**
  138539. * Defines the target frame rate to reach (60 by default)
  138540. */
  138541. targetFrameRate: number;
  138542. /**
  138543. * Defines the interval between two checkes (2000ms by default)
  138544. */
  138545. trackerDuration: number;
  138546. /**
  138547. * Gets the list of optimizations to apply
  138548. */
  138549. optimizations: SceneOptimization[];
  138550. /**
  138551. * Creates a new list of options used by SceneOptimizer
  138552. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  138553. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  138554. */
  138555. constructor(
  138556. /**
  138557. * Defines the target frame rate to reach (60 by default)
  138558. */
  138559. targetFrameRate?: number,
  138560. /**
  138561. * Defines the interval between two checkes (2000ms by default)
  138562. */
  138563. trackerDuration?: number);
  138564. /**
  138565. * Add a new optimization
  138566. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  138567. * @returns the current SceneOptimizerOptions
  138568. */
  138569. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  138570. /**
  138571. * Add a new custom optimization
  138572. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  138573. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  138574. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138575. * @returns the current SceneOptimizerOptions
  138576. */
  138577. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  138578. /**
  138579. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  138580. * @param targetFrameRate defines the target frame rate (60 by default)
  138581. * @returns a SceneOptimizerOptions object
  138582. */
  138583. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  138584. /**
  138585. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  138586. * @param targetFrameRate defines the target frame rate (60 by default)
  138587. * @returns a SceneOptimizerOptions object
  138588. */
  138589. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  138590. /**
  138591. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  138592. * @param targetFrameRate defines the target frame rate (60 by default)
  138593. * @returns a SceneOptimizerOptions object
  138594. */
  138595. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  138596. }
  138597. /**
  138598. * Class used to run optimizations in order to reach a target frame rate
  138599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138600. */
  138601. export class SceneOptimizer implements IDisposable {
  138602. private _isRunning;
  138603. private _options;
  138604. private _scene;
  138605. private _currentPriorityLevel;
  138606. private _targetFrameRate;
  138607. private _trackerDuration;
  138608. private _currentFrameRate;
  138609. private _sceneDisposeObserver;
  138610. private _improvementMode;
  138611. /**
  138612. * Defines an observable called when the optimizer reaches the target frame rate
  138613. */
  138614. onSuccessObservable: Observable<SceneOptimizer>;
  138615. /**
  138616. * Defines an observable called when the optimizer enables an optimization
  138617. */
  138618. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  138619. /**
  138620. * Defines an observable called when the optimizer is not able to reach the target frame rate
  138621. */
  138622. onFailureObservable: Observable<SceneOptimizer>;
  138623. /**
  138624. * Gets a boolean indicating if the optimizer is in improvement mode
  138625. */
  138626. get isInImprovementMode(): boolean;
  138627. /**
  138628. * Gets the current priority level (0 at start)
  138629. */
  138630. get currentPriorityLevel(): number;
  138631. /**
  138632. * Gets the current frame rate checked by the SceneOptimizer
  138633. */
  138634. get currentFrameRate(): number;
  138635. /**
  138636. * Gets or sets the current target frame rate (60 by default)
  138637. */
  138638. get targetFrameRate(): number;
  138639. /**
  138640. * Gets or sets the current target frame rate (60 by default)
  138641. */
  138642. set targetFrameRate(value: number);
  138643. /**
  138644. * Gets or sets the current interval between two checks (every 2000ms by default)
  138645. */
  138646. get trackerDuration(): number;
  138647. /**
  138648. * Gets or sets the current interval between two checks (every 2000ms by default)
  138649. */
  138650. set trackerDuration(value: number);
  138651. /**
  138652. * Gets the list of active optimizations
  138653. */
  138654. get optimizations(): SceneOptimization[];
  138655. /**
  138656. * Creates a new SceneOptimizer
  138657. * @param scene defines the scene to work on
  138658. * @param options defines the options to use with the SceneOptimizer
  138659. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  138660. * @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)
  138661. */
  138662. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  138663. /**
  138664. * Stops the current optimizer
  138665. */
  138666. stop(): void;
  138667. /**
  138668. * Reset the optimizer to initial step (current priority level = 0)
  138669. */
  138670. reset(): void;
  138671. /**
  138672. * Start the optimizer. By default it will try to reach a specific framerate
  138673. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  138674. */
  138675. start(): void;
  138676. private _checkCurrentState;
  138677. /**
  138678. * Release all resources
  138679. */
  138680. dispose(): void;
  138681. /**
  138682. * Helper function to create a SceneOptimizer with one single line of code
  138683. * @param scene defines the scene to work on
  138684. * @param options defines the options to use with the SceneOptimizer
  138685. * @param onSuccess defines a callback to call on success
  138686. * @param onFailure defines a callback to call on failure
  138687. * @returns the new SceneOptimizer object
  138688. */
  138689. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  138690. }
  138691. }
  138692. declare module BABYLON {
  138693. /**
  138694. * Class used to serialize a scene into a string
  138695. */
  138696. export class SceneSerializer {
  138697. /**
  138698. * Clear cache used by a previous serialization
  138699. */
  138700. static ClearCache(): void;
  138701. /**
  138702. * Serialize a scene into a JSON compatible object
  138703. * @param scene defines the scene to serialize
  138704. * @returns a JSON compatible object
  138705. */
  138706. static Serialize(scene: Scene): any;
  138707. /**
  138708. * Serialize a mesh into a JSON compatible object
  138709. * @param toSerialize defines the mesh to serialize
  138710. * @param withParents defines if parents must be serialized as well
  138711. * @param withChildren defines if children must be serialized as well
  138712. * @returns a JSON compatible object
  138713. */
  138714. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  138715. }
  138716. }
  138717. declare module BABYLON {
  138718. /**
  138719. * Class used to host texture specific utilities
  138720. */
  138721. export class TextureTools {
  138722. /**
  138723. * Uses the GPU to create a copy texture rescaled at a given size
  138724. * @param texture Texture to copy from
  138725. * @param width defines the desired width
  138726. * @param height defines the desired height
  138727. * @param useBilinearMode defines if bilinear mode has to be used
  138728. * @return the generated texture
  138729. */
  138730. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  138731. }
  138732. }
  138733. declare module BABYLON {
  138734. /**
  138735. * This represents the different options available for the video capture.
  138736. */
  138737. export interface VideoRecorderOptions {
  138738. /** Defines the mime type of the video. */
  138739. mimeType: string;
  138740. /** Defines the FPS the video should be recorded at. */
  138741. fps: number;
  138742. /** Defines the chunk size for the recording data. */
  138743. recordChunckSize: number;
  138744. /** The audio tracks to attach to the recording. */
  138745. audioTracks?: MediaStreamTrack[];
  138746. }
  138747. /**
  138748. * This can help with recording videos from BabylonJS.
  138749. * This is based on the available WebRTC functionalities of the browser.
  138750. *
  138751. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  138752. */
  138753. export class VideoRecorder {
  138754. private static readonly _defaultOptions;
  138755. /**
  138756. * Returns whether or not the VideoRecorder is available in your browser.
  138757. * @param engine Defines the Babylon Engine.
  138758. * @returns true if supported otherwise false.
  138759. */
  138760. static IsSupported(engine: Engine): boolean;
  138761. private readonly _options;
  138762. private _canvas;
  138763. private _mediaRecorder;
  138764. private _recordedChunks;
  138765. private _fileName;
  138766. private _resolve;
  138767. private _reject;
  138768. /**
  138769. * True when a recording is already in progress.
  138770. */
  138771. get isRecording(): boolean;
  138772. /**
  138773. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  138774. * @param engine Defines the BabylonJS Engine you wish to record.
  138775. * @param options Defines options that can be used to customize the capture.
  138776. */
  138777. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  138778. /**
  138779. * Stops the current recording before the default capture timeout passed in the startRecording function.
  138780. */
  138781. stopRecording(): void;
  138782. /**
  138783. * Starts recording the canvas for a max duration specified in parameters.
  138784. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  138785. * If null no automatic download will start and you can rely on the promise to get the data back.
  138786. * @param maxDuration Defines the maximum recording time in seconds.
  138787. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  138788. * @return A promise callback at the end of the recording with the video data in Blob.
  138789. */
  138790. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  138791. /**
  138792. * Releases internal resources used during the recording.
  138793. */
  138794. dispose(): void;
  138795. private _handleDataAvailable;
  138796. private _handleError;
  138797. private _handleStop;
  138798. }
  138799. }
  138800. declare module BABYLON {
  138801. /**
  138802. * Class containing a set of static utilities functions for screenshots
  138803. */
  138804. export class ScreenshotTools {
  138805. /**
  138806. * Captures a screenshot of the current rendering
  138807. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138808. * @param engine defines the rendering engine
  138809. * @param camera defines the source camera
  138810. * @param size This parameter can be set to a single number or to an object with the
  138811. * following (optional) properties: precision, width, height. If a single number is passed,
  138812. * it will be used for both width and height. If an object is passed, the screenshot size
  138813. * will be derived from the parameters. The precision property is a multiplier allowing
  138814. * rendering at a higher or lower resolution
  138815. * @param successCallback defines the callback receives a single parameter which contains the
  138816. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  138817. * src parameter of an <img> to display it
  138818. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  138819. * Check your browser for supported MIME types
  138820. */
  138821. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  138822. /**
  138823. * Captures a screenshot of the current rendering
  138824. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138825. * @param engine defines the rendering engine
  138826. * @param camera defines the source camera
  138827. * @param size This parameter can be set to a single number or to an object with the
  138828. * following (optional) properties: precision, width, height. If a single number is passed,
  138829. * it will be used for both width and height. If an object is passed, the screenshot size
  138830. * will be derived from the parameters. The precision property is a multiplier allowing
  138831. * rendering at a higher or lower resolution
  138832. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  138833. * Check your browser for supported MIME types
  138834. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  138835. * to the src parameter of an <img> to display it
  138836. */
  138837. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  138838. /**
  138839. * Generates an image screenshot from the specified camera.
  138840. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138841. * @param engine The engine to use for rendering
  138842. * @param camera The camera to use for rendering
  138843. * @param size This parameter can be set to a single number or to an object with the
  138844. * following (optional) properties: precision, width, height. If a single number is passed,
  138845. * it will be used for both width and height. If an object is passed, the screenshot size
  138846. * will be derived from the parameters. The precision property is a multiplier allowing
  138847. * rendering at a higher or lower resolution
  138848. * @param successCallback The callback receives a single parameter which contains the
  138849. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  138850. * src parameter of an <img> to display it
  138851. * @param mimeType The MIME type of the screenshot image (default: image/png).
  138852. * Check your browser for supported MIME types
  138853. * @param samples Texture samples (default: 1)
  138854. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  138855. * @param fileName A name for for the downloaded file.
  138856. */
  138857. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  138858. /**
  138859. * Generates an image screenshot from the specified camera.
  138860. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138861. * @param engine The engine to use for rendering
  138862. * @param camera The camera to use for rendering
  138863. * @param size This parameter can be set to a single number or to an object with the
  138864. * following (optional) properties: precision, width, height. If a single number is passed,
  138865. * it will be used for both width and height. If an object is passed, the screenshot size
  138866. * will be derived from the parameters. The precision property is a multiplier allowing
  138867. * rendering at a higher or lower resolution
  138868. * @param mimeType The MIME type of the screenshot image (default: image/png).
  138869. * Check your browser for supported MIME types
  138870. * @param samples Texture samples (default: 1)
  138871. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  138872. * @param fileName A name for for the downloaded file.
  138873. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  138874. * to the src parameter of an <img> to display it
  138875. */
  138876. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  138877. /**
  138878. * Gets height and width for screenshot size
  138879. * @private
  138880. */
  138881. private static _getScreenshotSize;
  138882. }
  138883. }
  138884. declare module BABYLON {
  138885. /**
  138886. * Interface for a data buffer
  138887. */
  138888. export interface IDataBuffer {
  138889. /**
  138890. * Reads bytes from the data buffer.
  138891. * @param byteOffset The byte offset to read
  138892. * @param byteLength The byte length to read
  138893. * @returns A promise that resolves when the bytes are read
  138894. */
  138895. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  138896. /**
  138897. * The byte length of the buffer.
  138898. */
  138899. readonly byteLength: number;
  138900. }
  138901. /**
  138902. * Utility class for reading from a data buffer
  138903. */
  138904. export class DataReader {
  138905. /**
  138906. * The data buffer associated with this data reader.
  138907. */
  138908. readonly buffer: IDataBuffer;
  138909. /**
  138910. * The current byte offset from the beginning of the data buffer.
  138911. */
  138912. byteOffset: number;
  138913. private _dataView;
  138914. private _dataByteOffset;
  138915. /**
  138916. * Constructor
  138917. * @param buffer The buffer to read
  138918. */
  138919. constructor(buffer: IDataBuffer);
  138920. /**
  138921. * Loads the given byte length.
  138922. * @param byteLength The byte length to load
  138923. * @returns A promise that resolves when the load is complete
  138924. */
  138925. loadAsync(byteLength: number): Promise<void>;
  138926. /**
  138927. * Read a unsigned 32-bit integer from the currently loaded data range.
  138928. * @returns The 32-bit integer read
  138929. */
  138930. readUint32(): number;
  138931. /**
  138932. * Read a byte array from the currently loaded data range.
  138933. * @param byteLength The byte length to read
  138934. * @returns The byte array read
  138935. */
  138936. readUint8Array(byteLength: number): Uint8Array;
  138937. /**
  138938. * Read a string from the currently loaded data range.
  138939. * @param byteLength The byte length to read
  138940. * @returns The string read
  138941. */
  138942. readString(byteLength: number): string;
  138943. /**
  138944. * Skips the given byte length the currently loaded data range.
  138945. * @param byteLength The byte length to skip
  138946. */
  138947. skipBytes(byteLength: number): void;
  138948. }
  138949. }
  138950. declare module BABYLON {
  138951. /**
  138952. * A cursor which tracks a point on a path
  138953. */
  138954. export class PathCursor {
  138955. private path;
  138956. /**
  138957. * Stores path cursor callbacks for when an onchange event is triggered
  138958. */
  138959. private _onchange;
  138960. /**
  138961. * The value of the path cursor
  138962. */
  138963. value: number;
  138964. /**
  138965. * The animation array of the path cursor
  138966. */
  138967. animations: Animation[];
  138968. /**
  138969. * Initializes the path cursor
  138970. * @param path The path to track
  138971. */
  138972. constructor(path: Path2);
  138973. /**
  138974. * Gets the cursor point on the path
  138975. * @returns A point on the path cursor at the cursor location
  138976. */
  138977. getPoint(): Vector3;
  138978. /**
  138979. * Moves the cursor ahead by the step amount
  138980. * @param step The amount to move the cursor forward
  138981. * @returns This path cursor
  138982. */
  138983. moveAhead(step?: number): PathCursor;
  138984. /**
  138985. * Moves the cursor behind by the step amount
  138986. * @param step The amount to move the cursor back
  138987. * @returns This path cursor
  138988. */
  138989. moveBack(step?: number): PathCursor;
  138990. /**
  138991. * Moves the cursor by the step amount
  138992. * If the step amount is greater than one, an exception is thrown
  138993. * @param step The amount to move the cursor
  138994. * @returns This path cursor
  138995. */
  138996. move(step: number): PathCursor;
  138997. /**
  138998. * Ensures that the value is limited between zero and one
  138999. * @returns This path cursor
  139000. */
  139001. private ensureLimits;
  139002. /**
  139003. * Runs onchange callbacks on change (used by the animation engine)
  139004. * @returns This path cursor
  139005. */
  139006. private raiseOnChange;
  139007. /**
  139008. * Executes a function on change
  139009. * @param f A path cursor onchange callback
  139010. * @returns This path cursor
  139011. */
  139012. onchange(f: (cursor: PathCursor) => void): PathCursor;
  139013. }
  139014. }
  139015. declare module BABYLON {
  139016. /** @hidden */
  139017. export var blurPixelShader: {
  139018. name: string;
  139019. shader: string;
  139020. };
  139021. }
  139022. declare module BABYLON {
  139023. /** @hidden */
  139024. export var pointCloudVertexDeclaration: {
  139025. name: string;
  139026. shader: string;
  139027. };
  139028. }
  139029. // Mixins
  139030. interface Window {
  139031. mozIndexedDB: IDBFactory;
  139032. webkitIndexedDB: IDBFactory;
  139033. msIndexedDB: IDBFactory;
  139034. webkitURL: typeof URL;
  139035. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  139036. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  139037. WebGLRenderingContext: WebGLRenderingContext;
  139038. MSGesture: MSGesture;
  139039. CANNON: any;
  139040. AudioContext: AudioContext;
  139041. webkitAudioContext: AudioContext;
  139042. PointerEvent: any;
  139043. Math: Math;
  139044. Uint8Array: Uint8ArrayConstructor;
  139045. Float32Array: Float32ArrayConstructor;
  139046. mozURL: typeof URL;
  139047. msURL: typeof URL;
  139048. VRFrameData: any; // WebVR, from specs 1.1
  139049. DracoDecoderModule: any;
  139050. setImmediate(handler: (...args: any[]) => void): number;
  139051. }
  139052. interface HTMLCanvasElement {
  139053. requestPointerLock(): void;
  139054. msRequestPointerLock?(): void;
  139055. mozRequestPointerLock?(): void;
  139056. webkitRequestPointerLock?(): void;
  139057. /** Track wether a record is in progress */
  139058. isRecording: boolean;
  139059. /** Capture Stream method defined by some browsers */
  139060. captureStream(fps?: number): MediaStream;
  139061. }
  139062. interface CanvasRenderingContext2D {
  139063. msImageSmoothingEnabled: boolean;
  139064. }
  139065. interface MouseEvent {
  139066. mozMovementX: number;
  139067. mozMovementY: number;
  139068. webkitMovementX: number;
  139069. webkitMovementY: number;
  139070. msMovementX: number;
  139071. msMovementY: number;
  139072. }
  139073. interface Navigator {
  139074. mozGetVRDevices: (any: any) => any;
  139075. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  139076. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  139077. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  139078. webkitGetGamepads(): Gamepad[];
  139079. msGetGamepads(): Gamepad[];
  139080. webkitGamepads(): Gamepad[];
  139081. }
  139082. interface HTMLVideoElement {
  139083. mozSrcObject: any;
  139084. }
  139085. interface Math {
  139086. fround(x: number): number;
  139087. imul(a: number, b: number): number;
  139088. }
  139089. interface WebGLRenderingContext {
  139090. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  139091. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  139092. vertexAttribDivisor(index: number, divisor: number): void;
  139093. createVertexArray(): any;
  139094. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  139095. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  139096. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  139097. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  139098. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  139099. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  139100. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  139101. // Queries
  139102. createQuery(): WebGLQuery;
  139103. deleteQuery(query: WebGLQuery): void;
  139104. beginQuery(target: number, query: WebGLQuery): void;
  139105. endQuery(target: number): void;
  139106. getQueryParameter(query: WebGLQuery, pname: number): any;
  139107. getQuery(target: number, pname: number): any;
  139108. MAX_SAMPLES: number;
  139109. RGBA8: number;
  139110. READ_FRAMEBUFFER: number;
  139111. DRAW_FRAMEBUFFER: number;
  139112. UNIFORM_BUFFER: number;
  139113. HALF_FLOAT_OES: number;
  139114. RGBA16F: number;
  139115. RGBA32F: number;
  139116. R32F: number;
  139117. RG32F: number;
  139118. RGB32F: number;
  139119. R16F: number;
  139120. RG16F: number;
  139121. RGB16F: number;
  139122. RED: number;
  139123. RG: number;
  139124. R8: number;
  139125. RG8: number;
  139126. UNSIGNED_INT_24_8: number;
  139127. DEPTH24_STENCIL8: number;
  139128. MIN: number;
  139129. MAX: number;
  139130. /* Multiple Render Targets */
  139131. drawBuffers(buffers: number[]): void;
  139132. readBuffer(src: number): void;
  139133. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  139134. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  139135. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  139136. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  139137. // Occlusion Query
  139138. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  139139. ANY_SAMPLES_PASSED: number;
  139140. QUERY_RESULT_AVAILABLE: number;
  139141. QUERY_RESULT: number;
  139142. }
  139143. interface WebGLProgram {
  139144. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  139145. }
  139146. interface EXT_disjoint_timer_query {
  139147. QUERY_COUNTER_BITS_EXT: number;
  139148. TIME_ELAPSED_EXT: number;
  139149. TIMESTAMP_EXT: number;
  139150. GPU_DISJOINT_EXT: number;
  139151. QUERY_RESULT_EXT: number;
  139152. QUERY_RESULT_AVAILABLE_EXT: number;
  139153. queryCounterEXT(query: WebGLQuery, target: number): void;
  139154. createQueryEXT(): WebGLQuery;
  139155. beginQueryEXT(target: number, query: WebGLQuery): void;
  139156. endQueryEXT(target: number): void;
  139157. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  139158. deleteQueryEXT(query: WebGLQuery): void;
  139159. }
  139160. interface WebGLUniformLocation {
  139161. _currentState: any;
  139162. }
  139163. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  139164. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  139165. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  139166. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  139167. interface WebGLRenderingContext {
  139168. readonly RASTERIZER_DISCARD: number;
  139169. readonly DEPTH_COMPONENT24: number;
  139170. readonly TEXTURE_3D: number;
  139171. readonly TEXTURE_2D_ARRAY: number;
  139172. readonly TEXTURE_COMPARE_FUNC: number;
  139173. readonly TEXTURE_COMPARE_MODE: number;
  139174. readonly COMPARE_REF_TO_TEXTURE: number;
  139175. readonly TEXTURE_WRAP_R: number;
  139176. readonly HALF_FLOAT: number;
  139177. readonly RGB8: number;
  139178. readonly RED_INTEGER: number;
  139179. readonly RG_INTEGER: number;
  139180. readonly RGB_INTEGER: number;
  139181. readonly RGBA_INTEGER: number;
  139182. readonly R8_SNORM: number;
  139183. readonly RG8_SNORM: number;
  139184. readonly RGB8_SNORM: number;
  139185. readonly RGBA8_SNORM: number;
  139186. readonly R8I: number;
  139187. readonly RG8I: number;
  139188. readonly RGB8I: number;
  139189. readonly RGBA8I: number;
  139190. readonly R8UI: number;
  139191. readonly RG8UI: number;
  139192. readonly RGB8UI: number;
  139193. readonly RGBA8UI: number;
  139194. readonly R16I: number;
  139195. readonly RG16I: number;
  139196. readonly RGB16I: number;
  139197. readonly RGBA16I: number;
  139198. readonly R16UI: number;
  139199. readonly RG16UI: number;
  139200. readonly RGB16UI: number;
  139201. readonly RGBA16UI: number;
  139202. readonly R32I: number;
  139203. readonly RG32I: number;
  139204. readonly RGB32I: number;
  139205. readonly RGBA32I: number;
  139206. readonly R32UI: number;
  139207. readonly RG32UI: number;
  139208. readonly RGB32UI: number;
  139209. readonly RGBA32UI: number;
  139210. readonly RGB10_A2UI: number;
  139211. readonly R11F_G11F_B10F: number;
  139212. readonly RGB9_E5: number;
  139213. readonly RGB10_A2: number;
  139214. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  139215. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  139216. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  139217. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  139218. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  139219. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  139220. 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;
  139221. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  139222. readonly TRANSFORM_FEEDBACK: number;
  139223. readonly INTERLEAVED_ATTRIBS: number;
  139224. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  139225. createTransformFeedback(): WebGLTransformFeedback;
  139226. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  139227. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  139228. beginTransformFeedback(primitiveMode: number): void;
  139229. endTransformFeedback(): void;
  139230. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  139231. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  139232. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  139233. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  139234. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  139235. }
  139236. interface ImageBitmap {
  139237. readonly width: number;
  139238. readonly height: number;
  139239. close(): void;
  139240. }
  139241. interface WebGLQuery extends WebGLObject {
  139242. }
  139243. declare var WebGLQuery: {
  139244. prototype: WebGLQuery;
  139245. new(): WebGLQuery;
  139246. };
  139247. interface WebGLSampler extends WebGLObject {
  139248. }
  139249. declare var WebGLSampler: {
  139250. prototype: WebGLSampler;
  139251. new(): WebGLSampler;
  139252. };
  139253. interface WebGLSync extends WebGLObject {
  139254. }
  139255. declare var WebGLSync: {
  139256. prototype: WebGLSync;
  139257. new(): WebGLSync;
  139258. };
  139259. interface WebGLTransformFeedback extends WebGLObject {
  139260. }
  139261. declare var WebGLTransformFeedback: {
  139262. prototype: WebGLTransformFeedback;
  139263. new(): WebGLTransformFeedback;
  139264. };
  139265. interface WebGLVertexArrayObject extends WebGLObject {
  139266. }
  139267. declare var WebGLVertexArrayObject: {
  139268. prototype: WebGLVertexArrayObject;
  139269. new(): WebGLVertexArrayObject;
  139270. };
  139271. // Type definitions for WebVR API
  139272. // Project: https://w3c.github.io/webvr/
  139273. // Definitions by: six a <https://github.com/lostfictions>
  139274. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  139275. interface VRDisplay extends EventTarget {
  139276. /**
  139277. * Dictionary of capabilities describing the VRDisplay.
  139278. */
  139279. readonly capabilities: VRDisplayCapabilities;
  139280. /**
  139281. * z-depth defining the far plane of the eye view frustum
  139282. * enables mapping of values in the render target depth
  139283. * attachment to scene coordinates. Initially set to 10000.0.
  139284. */
  139285. depthFar: number;
  139286. /**
  139287. * z-depth defining the near plane of the eye view frustum
  139288. * enables mapping of values in the render target depth
  139289. * attachment to scene coordinates. Initially set to 0.01.
  139290. */
  139291. depthNear: number;
  139292. /**
  139293. * An identifier for this distinct VRDisplay. Used as an
  139294. * association point in the Gamepad API.
  139295. */
  139296. readonly displayId: number;
  139297. /**
  139298. * A display name, a user-readable name identifying it.
  139299. */
  139300. readonly displayName: string;
  139301. readonly isConnected: boolean;
  139302. readonly isPresenting: boolean;
  139303. /**
  139304. * If this VRDisplay supports room-scale experiences, the optional
  139305. * stage attribute contains details on the room-scale parameters.
  139306. */
  139307. readonly stageParameters: VRStageParameters | null;
  139308. /**
  139309. * Passing the value returned by `requestAnimationFrame` to
  139310. * `cancelAnimationFrame` will unregister the callback.
  139311. * @param handle Define the hanle of the request to cancel
  139312. */
  139313. cancelAnimationFrame(handle: number): void;
  139314. /**
  139315. * Stops presenting to the VRDisplay.
  139316. * @returns a promise to know when it stopped
  139317. */
  139318. exitPresent(): Promise<void>;
  139319. /**
  139320. * Return the current VREyeParameters for the given eye.
  139321. * @param whichEye Define the eye we want the parameter for
  139322. * @returns the eye parameters
  139323. */
  139324. getEyeParameters(whichEye: string): VREyeParameters;
  139325. /**
  139326. * Populates the passed VRFrameData with the information required to render
  139327. * the current frame.
  139328. * @param frameData Define the data structure to populate
  139329. * @returns true if ok otherwise false
  139330. */
  139331. getFrameData(frameData: VRFrameData): boolean;
  139332. /**
  139333. * Get the layers currently being presented.
  139334. * @returns the list of VR layers
  139335. */
  139336. getLayers(): VRLayer[];
  139337. /**
  139338. * Return a VRPose containing the future predicted pose of the VRDisplay
  139339. * when the current frame will be presented. The value returned will not
  139340. * change until JavaScript has returned control to the browser.
  139341. *
  139342. * The VRPose will contain the position, orientation, velocity,
  139343. * and acceleration of each of these properties.
  139344. * @returns the pose object
  139345. */
  139346. getPose(): VRPose;
  139347. /**
  139348. * Return the current instantaneous pose of the VRDisplay, with no
  139349. * prediction applied.
  139350. * @returns the current instantaneous pose
  139351. */
  139352. getImmediatePose(): VRPose;
  139353. /**
  139354. * The callback passed to `requestAnimationFrame` will be called
  139355. * any time a new frame should be rendered. When the VRDisplay is
  139356. * presenting the callback will be called at the native refresh
  139357. * rate of the HMD. When not presenting this function acts
  139358. * identically to how window.requestAnimationFrame acts. Content should
  139359. * make no assumptions of frame rate or vsync behavior as the HMD runs
  139360. * asynchronously from other displays and at differing refresh rates.
  139361. * @param callback Define the eaction to run next frame
  139362. * @returns the request handle it
  139363. */
  139364. requestAnimationFrame(callback: FrameRequestCallback): number;
  139365. /**
  139366. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  139367. * Repeat calls while already presenting will update the VRLayers being displayed.
  139368. * @param layers Define the list of layer to present
  139369. * @returns a promise to know when the request has been fulfilled
  139370. */
  139371. requestPresent(layers: VRLayer[]): Promise<void>;
  139372. /**
  139373. * Reset the pose for this display, treating its current position and
  139374. * orientation as the "origin/zero" values. VRPose.position,
  139375. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  139376. * updated when calling resetPose(). This should be called in only
  139377. * sitting-space experiences.
  139378. */
  139379. resetPose(): void;
  139380. /**
  139381. * The VRLayer provided to the VRDisplay will be captured and presented
  139382. * in the HMD. Calling this function has the same effect on the source
  139383. * canvas as any other operation that uses its source image, and canvases
  139384. * created without preserveDrawingBuffer set to true will be cleared.
  139385. * @param pose Define the pose to submit
  139386. */
  139387. submitFrame(pose?: VRPose): void;
  139388. }
  139389. declare var VRDisplay: {
  139390. prototype: VRDisplay;
  139391. new(): VRDisplay;
  139392. };
  139393. interface VRLayer {
  139394. leftBounds?: number[] | Float32Array | null;
  139395. rightBounds?: number[] | Float32Array | null;
  139396. source?: HTMLCanvasElement | null;
  139397. }
  139398. interface VRDisplayCapabilities {
  139399. readonly canPresent: boolean;
  139400. readonly hasExternalDisplay: boolean;
  139401. readonly hasOrientation: boolean;
  139402. readonly hasPosition: boolean;
  139403. readonly maxLayers: number;
  139404. }
  139405. interface VREyeParameters {
  139406. /** @deprecated */
  139407. readonly fieldOfView: VRFieldOfView;
  139408. readonly offset: Float32Array;
  139409. readonly renderHeight: number;
  139410. readonly renderWidth: number;
  139411. }
  139412. interface VRFieldOfView {
  139413. readonly downDegrees: number;
  139414. readonly leftDegrees: number;
  139415. readonly rightDegrees: number;
  139416. readonly upDegrees: number;
  139417. }
  139418. interface VRFrameData {
  139419. readonly leftProjectionMatrix: Float32Array;
  139420. readonly leftViewMatrix: Float32Array;
  139421. readonly pose: VRPose;
  139422. readonly rightProjectionMatrix: Float32Array;
  139423. readonly rightViewMatrix: Float32Array;
  139424. readonly timestamp: number;
  139425. }
  139426. interface VRPose {
  139427. readonly angularAcceleration: Float32Array | null;
  139428. readonly angularVelocity: Float32Array | null;
  139429. readonly linearAcceleration: Float32Array | null;
  139430. readonly linearVelocity: Float32Array | null;
  139431. readonly orientation: Float32Array | null;
  139432. readonly position: Float32Array | null;
  139433. readonly timestamp: number;
  139434. }
  139435. interface VRStageParameters {
  139436. sittingToStandingTransform?: Float32Array;
  139437. sizeX?: number;
  139438. sizeY?: number;
  139439. }
  139440. interface Navigator {
  139441. getVRDisplays(): Promise<VRDisplay[]>;
  139442. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  139443. }
  139444. interface Window {
  139445. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  139446. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  139447. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  139448. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  139449. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  139450. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  139451. }
  139452. interface Gamepad {
  139453. readonly displayId: number;
  139454. }
  139455. type XRSessionMode =
  139456. | "inline"
  139457. | "immersive-vr"
  139458. | "immersive-ar";
  139459. type XRReferenceSpaceType =
  139460. | "viewer"
  139461. | "local"
  139462. | "local-floor"
  139463. | "bounded-floor"
  139464. | "unbounded";
  139465. type XREnvironmentBlendMode =
  139466. | "opaque"
  139467. | "additive"
  139468. | "alpha-blend";
  139469. type XRVisibilityState =
  139470. | "visible"
  139471. | "visible-blurred"
  139472. | "hidden";
  139473. type XRHandedness =
  139474. | "none"
  139475. | "left"
  139476. | "right";
  139477. type XRTargetRayMode =
  139478. | "gaze"
  139479. | "tracked-pointer"
  139480. | "screen";
  139481. type XREye =
  139482. | "none"
  139483. | "left"
  139484. | "right";
  139485. interface XRSpace extends EventTarget {
  139486. }
  139487. interface XRRenderState {
  139488. depthNear?: number;
  139489. depthFar?: number;
  139490. inlineVerticalFieldOfView?: number;
  139491. baseLayer?: XRWebGLLayer;
  139492. }
  139493. interface XRInputSource {
  139494. handedness: XRHandedness;
  139495. targetRayMode: XRTargetRayMode;
  139496. targetRaySpace: XRSpace;
  139497. gripSpace: XRSpace | undefined;
  139498. gamepad: Gamepad | undefined;
  139499. profiles: Array<string>;
  139500. }
  139501. interface XRSession extends XRAnchorCreator {
  139502. addEventListener: Function;
  139503. removeEventListener: Function;
  139504. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  139505. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  139506. requestAnimationFrame: Function;
  139507. end(): Promise<void>;
  139508. renderState: XRRenderState;
  139509. inputSources: Array<XRInputSource>;
  139510. // AR hit test
  139511. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  139512. updateWorldTrackingState(options: {
  139513. planeDetectionState?: { enabled: boolean; }
  139514. }): void;
  139515. }
  139516. interface XRReferenceSpace extends XRSpace {
  139517. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  139518. onreset: any;
  139519. }
  139520. type XRPlaneSet = Set<XRPlane>;
  139521. type XRAnchorSet = Set<XRAnchor>;
  139522. interface XRFrame {
  139523. session: XRSession;
  139524. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  139525. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  139526. // Anchors
  139527. trackedAnchors?: XRAnchorSet;
  139528. // Planes
  139529. worldInformation: {
  139530. detectedPlanes?: XRPlaneSet;
  139531. };
  139532. }
  139533. interface XRViewerPose extends XRPose {
  139534. views: Array<XRView>;
  139535. }
  139536. interface XRPose {
  139537. transform: XRRigidTransform;
  139538. emulatedPosition: boolean;
  139539. }
  139540. interface XRWebGLLayerOptions {
  139541. antialias?: boolean;
  139542. depth?: boolean;
  139543. stencil?: boolean;
  139544. alpha?: boolean;
  139545. multiview?: boolean;
  139546. framebufferScaleFactor?: number;
  139547. }
  139548. declare var XRWebGLLayer: {
  139549. prototype: XRWebGLLayer;
  139550. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  139551. };
  139552. interface XRWebGLLayer {
  139553. framebuffer: WebGLFramebuffer;
  139554. framebufferWidth: number;
  139555. framebufferHeight: number;
  139556. getViewport: Function;
  139557. }
  139558. declare class XRRigidTransform {
  139559. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  139560. position: DOMPointReadOnly;
  139561. orientation: DOMPointReadOnly;
  139562. matrix: Float32Array;
  139563. inverse: XRRigidTransform;
  139564. }
  139565. interface XRView {
  139566. eye: XREye;
  139567. projectionMatrix: Float32Array;
  139568. transform: XRRigidTransform;
  139569. }
  139570. interface XRInputSourceChangeEvent {
  139571. session: XRSession;
  139572. removed: Array<XRInputSource>;
  139573. added: Array<XRInputSource>;
  139574. }
  139575. interface XRInputSourceEvent extends Event {
  139576. readonly frame: XRFrame;
  139577. readonly inputSource: XRInputSource;
  139578. }
  139579. // Experimental(er) features
  139580. declare class XRRay {
  139581. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  139582. origin: DOMPointReadOnly;
  139583. direction: DOMPointReadOnly;
  139584. matrix: Float32Array;
  139585. }
  139586. interface XRHitResult {
  139587. hitMatrix: Float32Array;
  139588. }
  139589. interface XRAnchor {
  139590. // remove?
  139591. id?: string;
  139592. anchorSpace: XRSpace;
  139593. lastChangedTime: number;
  139594. detach(): void;
  139595. }
  139596. interface XRPlane extends XRAnchorCreator {
  139597. orientation: "Horizontal" | "Vertical";
  139598. planeSpace: XRSpace;
  139599. polygon: Array<DOMPointReadOnly>;
  139600. lastChangedTime: number;
  139601. }
  139602. interface XRAnchorCreator {
  139603. // AR Anchors
  139604. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  139605. }